Skip to content

Commit dda84f6

Browse files
committed
complete updates
1 parent ca09d96 commit dda84f6

File tree

4 files changed

+266
-4
lines changed

4 files changed

+266
-4
lines changed
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
---
2+
title: "How to guide: create and compose custom models with Form Recognizer v2.0"
3+
titleSuffix: Azure Applied AI Services
4+
description: Learn how to create, use, and manage Form Recognizer v2.0 custom and composed models
5+
author: laujan
6+
manager: nitinme
7+
ms.service: applied-ai-services
8+
ms.subservice: forms-recognizer
9+
ms.topic: how-to
10+
ms.date: 02/15/2022
11+
ms.author: lajanuar
12+
recommendations: false
13+
---
14+
15+
# Create and compose custom models | Preview
16+
17+
> [!NOTE]
18+
> This how-to guide references Form Recognizer v3.0 (preview). If you would like to use Form Recognizer v2.1 (GA), see [Create and compose custom models v2.1 (GA)](compose-custom-models.md)
19+
20+
A composed model is created by taking a collection of custom models and assigning them to a single model comprised of your form types. You can assign up to 100 trained custom models to a single composed model. When you call Analyze with the composed model ID, Form Recognizer will first classify the form you submitted, choose the best matching assigned model, and then return results for that model.
21+
22+
To learn more, see [Composed custom models](concept-composed-models.md)
23+
24+
In this article you will learn how to create and use composed custom models to analyze your forms and documents.
25+
26+
## Prerequisites
27+
28+
To get started, you'll need the following:
29+
30+
* **An Azure subscription**. You can [create a free Azure subscription](https://azure.microsoft.com/free/cognitive-services/)
31+
32+
* **A Form Recognizer resource**. Once you have your Azure subscription, [create a Form Recognizer resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesFormRecognizer) in the Azure portal to get your key and endpoint. If you have an existing Form Recognizer resource, navigate directly to your resource page. You can use the free pricing tier (F0) to try the service, and upgrade later to a paid tier for production.
33+
34+
1. After the resource deploys, select **Go to resource**.
35+
36+
1. Copy the **Keys and Endpoint** values from the resource you created and paste them in a convenient location, such as *Microsoft Notepad*. You'll need the key and endpoint values to connect your application to the Form Recognizer API.
37+
38+
:::image border="true" type="content" source="media/containers/keys-and-endpoint.png" alt-text="Still photo showing how to access resource key and endpoint URL.":::
39+
40+
> [!TIP]
41+
> For further guidance, *see* [**create a Form Recognizer resource**](create-a-form-recognizer-resource.md).
42+
43+
* **An Azure storage account.** If you don't know how to create an Azure storage account, follow the [Azure Storage quickstart for Azure portal](../../storage/blobs/storage-quickstart-blobs-portal.md). You can use the free pricing tier (F0) to try the service, and upgrade later to a paid tier for production.
44+
45+
## Create your custom models
46+
47+
First, you'll need to a set of custom models to compose. Using the Form Recognizer Studio, REST API, or client-library SDKs, the steps are as follows:
48+
49+
* [**Assemble your training dataset**](#assemble-your-training-dataset)
50+
* [**Upload your training set to Azure blob storage**](#upload-your-training-dataset)
51+
* [**Train your custom models**](#train-your-custom-model)
52+
53+
## Assemble your training dataset
54+
55+
Building a custom model begins with establishing your training dataset. You'll need a minimum of five completed forms of the same type for your sample dataset. They can be of different file types (jpg, png, pdf, tiff) and contain both text and handwriting. Your forms must follow the [input requirements](build-training-data-set.md#custom-model-input-requirements) for Form Recognizer.
56+
57+
>[!TIP]
58+
> Follow these tips to optimize your data set for training:
59+
>
60+
> * If possible, use text-based PDF documents instead of image-based documents. Scanned PDFs are handled as images.
61+
> * For filled-in forms, use examples that have all of their fields filled in.
62+
> * Use forms with different values in each field.
63+
> * If your form images are of lower quality, use a larger data set (10-15 images, for example).
64+
65+
See [Build a training data set](./build-training-data-set.md) for tips on how to collect your training documents.
66+
67+
## Upload your training dataset
68+
69+
When you've gathered the set of form documents that you'll use for training, you'll need to [upload your training data](build-training-data-set.md#upload-your-training-data)
70+
to an Azure blob storage container.
71+
72+
If you want to use manually labeled data, you'll also have to upload the *.labels.json* and *.ocr.json* files that correspond to your training documents.
73+
74+
*See* [Train with labels](#train-with-labels)
75+
76+
## Train your custom model
77+
78+
You can [train your model](https://formrecognizer.appliedai.azure.com/studio/custommodel/projects) with or without labeled data sets. Unlabeled datasets rely solely on the [prebuilt-layout model](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/AnalyzeDocument) to detect and identify key information without added human input. Labeled datasets also rely on the Layout API, but supplementary human input is included such as your specific labels and field locations. To use both labeled and unlabeled data, start with at least five completed forms of the same type for the labeled training data and then add unlabeled data to the required data set.
79+
80+
### Train without labels
81+
82+
Form Recognizer uses unsupervised learning to understand the layout and relationships between fields and entries in your forms. When you submit your input forms, the algorithm clusters the forms by type, discovers what keys and tables are present, and associates values to keys and entries to tables. Training without labels doesn't require manual data labeling or intensive coding and maintenance, and we recommend you try this method first.
83+
84+
### Train with labels
85+
86+
When you train with labeled data, the model uses supervised learning to extract values of interest, using the labeled forms you provide. Labeled data results in better-performing models and can produce models that work with complex forms or forms containing values without keys.
87+
88+
Form Recognizer uses the [prebuilt-layout model](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/AnalyzeDocument) API to learn the expected sizes and positions of printed and handwritten text elements and extract tables. Then it uses user-specified labels to learn the key/value associations and tables in the documents. We recommend that you use five manually labeled forms of the same type (same structure) to get started when training a new model and add more labeled data as needed to improve the model accuracy. Form Recognizer enables training a model to extract key-value pairs and tables using supervised learning capabilities.
89+
90+
### [Form Recognizer Studio](#tab/studio)
91+
92+
To create custom models, you start with configuring your project:
93+
94+
1. From the Studio home, select the [Custom form project](https://formrecognizer.appliedai.azure.com/studio/customform/projects) to open the Custom form home page.
95+
96+
1. Use the ➕ **Create a project** command to start the new project configuration wizard.
97+
98+
1. Enter project details, select the Azure subscription and resource, and the Azure Blob storage container that contains your data.
99+
100+
1. Review and submit your settings to create the project.
101+
102+
:::image type="content" source="media/studio/create-project.gif" alt-text="Animation showing create a custom project in Form Recognizer Studio.":::
103+
104+
While creating your custom models, you may need to extract data collections from your documents. These may appear in a couple of formats. Using tables as the visual pattern:
105+
106+
* Dynamic or variable count of values (rows) for a given set of fields (columns)
107+
108+
* Specific collection of values for a given set of fields (columns and/or rows)
109+
110+
See [Form Recognizer Studio: labeling as tables](quickstarts/try-v3-form-recognizer-studio.md#labeling-as-tables)
111+
112+
### [REST API](#tab/rest)
113+
114+
Training with labels leads to better performance in some scenarios. To train with labels, you need to have special label information files (*\<filename\>.pdf.labels.json*) in your blob storage container alongside the training documents.
115+
116+
Label files contain key-value associations that a user has entered manually. They are needed for labeled data training, but not every source file needs to have a corresponding label file. Source files without labels will be treated as ordinary training documents. We recommend five or more labeled files for reliable training. You can use a UI tool like [Form Recognizer Studio](https://formrecognizer.appliedai.azure.com/studio/customform/projects) to generate these files.
117+
118+
Once you have your label files, you can include them with by calling the training method with the *useLabelFile* parameter set to `true`.
119+
120+
:::image type="content" source="media/studio/rest-use-labels.png" alt-text="{alt-text}":::
121+
122+
### [Client-libraries](#tab/sdks)
123+
124+
Training with labels leads to better performance in some scenarios. To train with labels, you need to have special label information files (*\<filename\>.pdf.labels.json*) in your blob storage container alongside the training documents. Once you have them, you can call the training method with the *useTrainingLabels* parameter set to `true`.
125+
126+
|Language |Method|
127+
|--|--|
128+
|**C#**|[**StartBuildModel**](/dotnet/api/azure.ai.formrecognizer.documentanalysis.documentmodeladministrationclient.startbuildmodel?view=azure-dotnet-preview#azure-ai-formrecognizer-documentanalysis-documentmodeladministrationclient-startbuildmodel&preserve-view=true)|
129+
|**Java**| [**beginBuildModel**](/java/api/com.azure.ai.formrecognizer.administration.documentmodeladministrationclient.beginbuildmodel?view=azure-java-preview&preserve-view=true)|
130+
|**JavaScript** | [**beginBuildModel**](/javascript/api/@azure/ai-form-recognizer/documentmodeladministrationclient?view=azure-node-preview#@azure-ai-form-recognizer-documentmodeladministrationclient-beginbuildmodel&preserve-view=true)|
131+
| **Python** | [**begin_build_model**](/python/api/azure-ai-formrecognizer/azure.ai.formrecognizer.aio.documentmodeladministrationclient?view=azure-python-preview#azure-ai-formrecognizer-aio-documentmodeladministrationclient-begin-build-model&preserve-view=true)
132+
133+
---
134+
135+
## Create a composed model
136+
137+
> [!NOTE]
138+
> **the `create compose model` operation is only available for custom models trained _with_ labels.** Attempting to compose unlabeled models will produce an error.
139+
140+
With the [**create compose model**](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/ComposeDocumentModel) operation, you can assign up to 100 trained custom models to a single model ID. When you call Analyze with the composed model ID, Form Recognizer will first classify the form you submitted, choose the best matching assigned model, and then return results for that model. This operation is useful when incoming forms may belong to one of several templates.
141+
142+
### [Form Recognizer Studio](#tab/studio)
143+
144+
Once the training process has successfully completed, you can begin to build your composed model. Here are the steps for creating and using composed models:
145+
146+
* [**Gather your custom model IDs**](#gather-your-model-ids)
147+
* [**Compose your custom models**](#compose-your-custom-models)
148+
* [**Analyze documents**](#analyze-documents)
149+
* [**Manage your composed models**](#manage-your-composed-models)
150+
151+
#### Gather your model IDs
152+
153+
When you train models using the [**Form Recognizer Studio**](https://formrecognizer.appliedai.azure.com/), the model ID is located in the models menu under a project:
154+
155+
:::image type="content" source="media/studio/composed-model.png" alt-text="Screenshot: model configuration window in Form Recognizer Studio.":::
156+
157+
#### Compose your custom models
158+
159+
1. Select a custom models project.
160+
161+
1. In the project, select the ```Models``` menu item.
162+
163+
1. From the resulting list of models, select the models you wish to compose.
164+
165+
1. Choose the **Compose button** from the upper-left corner.
166+
167+
1. In the pop-up window, name your newly composed model and select **Compose**.
168+
169+
1. When the operation completes, your newly composed model will appear in the list.
170+
171+
1. Once the model is ready, use the **Test** command to validate it with your test documents and observe the results.
172+
173+
174+
175+
#### Analyze documents
176+
177+
The custom model **Analyze** operation requires you to provide the `modelID` in the call to Form Recognizer. You should provide the composed model ID for the `modelID` parameter in your applications.
178+
179+
:::image type="content" source="media/studio/composed-model-id.png" alt-text="Screenshot of a composed model ID in Form Recognizer Studio.":::
180+
181+
#### Manage your composed models
182+
183+
You can manage your custom models throughout life cycles:
184+
185+
* Test and validate new documents.
186+
* Download your model to use in your applications.
187+
* Delete your model when it's lifecycle is complete.
188+
189+
:::image type="content" source="media/studio/compose-manage.png" alt-text="Screenshot of a composed model in the Form Recognizer Studio":::
190+
191+
### [REST API](#tab/rest)
192+
193+
Once the training process has successfully completed, you can begin to build your composed model. Here are the steps for creating and using composed models:
194+
195+
* [**Gather your custom model IDs**](#gather-your-model-ids)
196+
* [**Compose your custom models**](#compose-your-custom-models)
197+
* [**Analyze documents**](#analyze-documents)
198+
* [**Manage your composed models**](#manage-your-composed-models)
199+
200+
#### Gather your model IDs
201+
202+
The [**REST API**](./quickstarts/try-v3-rest-api.md#manage-custom-models), will return a `201 (Success)` response with a **Location** header. The value of the last parameter in this header is the model ID for the newly trained model.
203+
204+
#### Compose your custom models
205+
206+
The [compose model API](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/ComposeDocumentModel) accepts a list of models to be composed.
207+
208+
:::image type="content" source="media/compose/model-request-body.png" alt-text="Screenshot of compose model request.":::
209+
210+
#### Analyze documents
211+
212+
You can make an [**Analyze document**](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/AnalyzeDocument) request using a unique model name in the request parameters.
213+
214+
:::image type="content" source="media/custom-model-analyze-request.png" alt-text="Screenshot of a custom model request URL.":::
215+
216+
#### Manage your composed models
217+
218+
You can manage custom models throughout your development needs including [**copying**](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/CopyDocumentModelTo), [**listing**](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/GetModels), and [**deleting**](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v3-0-preview-2/operations/DeleteModel) your models.
219+
220+
### [Client-libraries](#tab/sdks)
221+
222+
Once the training process has successfully completed, you can begin to build your composed model. Here are the steps for creating and using composed models:
223+
224+
* [**Create a composed model**](#create-a-composed-model)
225+
* [**Analyze documents**](#analyze-documents)
226+
* [**Manage your composed models**](#manage-your-composed-models)
227+
228+
#### Create a composed model
229+
230+
You can use the programming language of your choice to create a composed model:
231+
232+
| Programming language| Code sample |
233+
|--|--|
234+
|**C#** | [Model compose](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample_ModelCompose.md#create-a-composed-model)
235+
|**Java** | [Model compose](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample_ModelCompose.md#create-a-composed-model)
236+
|**JavaScript** | [Compose model](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples/v4-beta/javascript/composeModel.js)
237+
|**Python** | [Create composed model](https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-formrecognizer_3.2.0b3/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_create_composed_model.py)
238+
239+
#### Analyze documents
240+
241+
Once you have built your composed model, it can be used to analyze forms and documents You can use your composed `model ID` and let the service decide which of your aggregated custom models fits best according to the document provided.
242+
243+
|Programming language| Code sample |
244+
|--|--|
245+
|**C#** | [Analyze a document with a custom/composed model](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample_AnalyzeWithCustomModel.md)
246+
|**Java** | [Analyze forms with your custom/composed model ](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/src/samples/java/com/azure/ai/formrecognizer/AnalyzeCustomDocumentFromUrl.java)
247+
|**JavaScript** | [Analyze documents by model ID](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples/v4-beta/javascript/analyzeReceiptByModelId.js)
248+
|**Python** | [Analyze custom documents](https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-formrecognizer_3.2.0b3/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_custom_documents.py)
249+
250+
## Manage your composed models
251+
252+
You can manage your custom models throughout their lifecycle by viewing a list of all custom models under your subscription, retrieving information about a specific custom model, and deleting custom models from your account.
253+
254+
|Programming language| Code sample |
255+
|--|--|
256+
|**C#** | [Analyze a document with a custom/composed model](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample_AnalyzeWithCustomModel.md)
257+
|**Java** | [Custom model management operations](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/src/samples/java/com/azure/ai/formrecognizer/administration/ManageCustomModels.java)
258+
)
259+
|**JavaScript** | [Get model types and schema](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/formrecognizer/ai-form-recognizer/samples/v4-beta/javascript/getModel.js)
260+
|**Python** | [Manage models](https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-formrecognizer_3.2.0b3/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_manage_models.py)
261+
262+
---

articles/applied-ai-services/form-recognizer/compose-custom-models.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ manager: nitinme
77
ms.service: applied-ai-services
88
ms.subservice: forms-recognizer
99
ms.topic: how-to
10-
ms.date: 02/12/2022
10+
ms.date: 02/15/2022
1111
ms.author: lajanuar
1212
recommendations: false
1313
---
1414

15-
# Create and compose custom models
15+
# Create and compose custom models v2.1 (GA)
1616

1717
> [!NOTE]
18-
> This how-to guide references Form Recognizer v2.1 (GA).
18+
> This how-to guide references Form Recognizer v2.1 (GA). If you would like to try Form Recognizer v3.0 (preview)), see [Create and compose custom models v3.0 (preview))](compose-custom-models-preview.md)
1919
2020
Form Recognizer uses advanced machine-learning technology to detect and extract information from document images and return the extracted data in a structured JSON output. With Form Recognizer, you can train standalone custom models or combine custom models to create composed models.
2121

@@ -218,4 +218,4 @@ Learn more about the Form Recognizer client library by exploring our API referen
218218

219219
> [!div class="nextstepaction"]
220220
> [Form Recognizer API reference](https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v2-1/operations/AnalyzeWithCustomForm)
221-
>
221+
>
10 KB
Loading
9.64 KB
Loading

0 commit comments

Comments
 (0)