|
| 1 | +--- |
| 2 | +title: "Train a custom model in the Form Recognizer Studio" |
| 3 | +titleSuffix: Azure Applied AI Services |
| 4 | +description: Learn how to build, label, and train a custom model in the Form Recognizer Studio. |
| 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/16/2022 |
| 11 | +ms.author: vikurpad |
| 12 | +--- |
| 13 | + |
| 14 | +# Build your training data set for a custom model |
| 15 | + |
| 16 | +Form Recognizer models require as few as five training documents to get started. If you have at least five documents, you can get started training a custom model. You can train either a [custom template model (custom form)](../concept-custom-template.md) or a [custom neural model (custom document)](../concept-custom-neural.md). The training process is identical for both models and this document walks you through the process of training either model. |
| 17 | + |
| 18 | +## Custom model input requirements |
| 19 | + |
| 20 | +First, make sure your training data set follows the input requirements for Form Recognizer. |
| 21 | + |
| 22 | +[!INCLUDE [input requirements](../includes/input-requirements.md)] |
| 23 | + |
| 24 | +## Training data tips |
| 25 | + |
| 26 | +Follow these tips to further optimize your data set for training: |
| 27 | + |
| 28 | +* If possible, use text-based PDF documents instead of image-based documents. Scanned PDFs are handled as images. |
| 29 | +* For forms with input fields, use examples that have all of the fields completed. |
| 30 | +* Use forms with different values in each field. |
| 31 | +* If your form images are of lower quality, use a larger data set (10-15 images, for example). |
| 32 | + |
| 33 | +## Upload your training data |
| 34 | + |
| 35 | +When you've put together the set of forms or documents that you'll use for training, you'll need to upload it to an Azure blob storage container. If you don't know how to create an Azure storage account with a container, following 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. |
| 36 | + |
| 37 | +## Create a project in the Form Recognizer Studio |
| 38 | + |
| 39 | +The Form Recognizer Studio provides and orchestrates all the API calls required to create the files required to complete your dataset and train your model. |
| 40 | + |
| 41 | +1. Start by navigating to the [Form Recognizer Studio](https://formrecognizer.appliedai.azure.com/studio). If this is your first time using the Studio, you'll need to [initialize it for use](../quickstarts/try-v3-form-recognizer-studio.md). Follow the [additional prerequisite for custom projects](../quickstarts/try-v3-form-recognizer-studio.md#additional-prerequisites-for-custom-projects) to configure the Studio to access your training dataset. |
| 42 | + |
| 43 | +1. In the Studio select the **Custom models** tile, on the custom models page and select the **Create a project** button. |
| 44 | + |
| 45 | + :::image type="content" source="../media/how-to/studio-create-project.png" alt-text="Screenshot: Create a project in the Form Recognizer Studio."::: |
| 46 | + |
| 47 | + 1. On the create project dialog, provide a name for your project, optionally a description, and select continue. |
| 48 | + |
| 49 | + 1. On the next step in the workflow, choose or create a Form Recognizer resource before you select continue. |
| 50 | + |
| 51 | + > [!IMPORTANT] |
| 52 | + > Custom neural models models are only available in a few regions. If you plan on training a neural model, please select or create a resource in one of [these supported regions](https://aka.ms/fr-neural#l#supported-regions). |
| 53 | +
|
| 54 | + :::image type="content" source="../media/how-to/studio-select-resource.png" alt-text="Screenshot: Select the Form Recognizer resource."::: |
| 55 | + |
| 56 | +1. Next select the storage account where you uploaded the dataset you wish to use to train your custom model. The **Folder path** should be empty if your training documents are in the root of the container. If your documents are in a sub-folder, enter the relative path from the container root in the **Folder path** field. Once your storage account is configured, select continue. |
| 57 | + |
| 58 | + :::image type="content" source="../media/how-to/studio-select-storage.png" alt-text="Screenshot: Select the storage account."::: |
| 59 | + |
| 60 | +1. Finally, review your project settings and select **Create Project** to create a new project. You should now be in the labeling window and see the files in your dataset listed. |
| 61 | + |
| 62 | +## Label your data |
| 63 | + |
| 64 | +In your project, your first task is to label your dataset with the fields you wish to extract. |
| 65 | + |
| 66 | +You'll see the files you uploaded to storage on the left of your screen, with the first file ready to be labeled. |
| 67 | + |
| 68 | +1. To start labeling your dataset, create your first field by selecting the plus (➕) button on the top-right of the screen to select a field type. |
| 69 | + |
| 70 | + :::image type="content" source="../media/how-to/studio-create-label.png" alt-text="Screenshot: Create a label."::: |
| 71 | + |
| 72 | +1. Enter a name for the field. |
| 73 | + |
| 74 | +1. To assign a value to the field, simply choose a word or words in the document and select the field in either the dropdown or the field list on the right navigation bar. You'll see the labeled value below the field name in the list of fields. |
| 75 | + |
| 76 | +1. Repeat this process for all the fields you wish to label for your dataset |
| 77 | + |
| 78 | +1. Label the remaining documents in your dataset by selecting each document in the document list and selecting the text to be labeled |
| 79 | + |
| 80 | +You now have all the documents in your dataset labeled. If you look at the storage account, you'll find a *.labels.json* and *.ocr.json* files that correspond to each document in your training dataset and an additional fields.json file. This is the training dataset that will be submitted to train the model. |
| 81 | + |
| 82 | +## Train your model |
| 83 | + |
| 84 | +With your dataset labeled, you're now ready to train your model. Select the train button in the upper-right corner. |
| 85 | + |
| 86 | +1. On the train model dialog, provide a unique model ID and, optionally, a description. |
| 87 | + |
| 88 | +1. For the build mode, select the type of model you want to train. Learn more about the [model types and capabilities](../concept-custom.md). |
| 89 | + |
| 90 | + :::image type="content" source="../media/how-to/studio-train-model.png" alt-text="Screenshot: Train model dialog"::: |
| 91 | + |
| 92 | +1. Select **Train** to initiate the training process. |
| 93 | + |
| 94 | +1. Template models train in a few minutes. Neural models can take up to 30 minutes to train. |
| 95 | + |
| 96 | +1. Navigate to the *Models* menu to view the status of the train operation. |
| 97 | + |
| 98 | +## Test the model |
| 99 | + |
| 100 | +Once the model training is complete, you can test your model by selecting the model on the models list page. |
| 101 | + |
| 102 | +1. Select the model and select on the **Test** button. |
| 103 | + |
| 104 | +1. Select the `+ Add` button to select a file to test the model. |
| 105 | + |
| 106 | +1. With a file selected, choose the **Analyze** button to test the model. |
| 107 | + |
| 108 | +1. The model results are displayed in the main window and the fields extracted are listed in the right navigation bar. |
| 109 | + |
| 110 | +1. Validate your model by evaluating the results for each field. |
| 111 | + |
| 112 | +1. The right navigation bar also has the sample code to invoke your model and the JSON results from the API. |
| 113 | + |
| 114 | +Congratulations you've trained a custom model in the Form Recognizer Studio! Your model is ready for use with the REST API or the SDK to analyze documents. |
| 115 | + |
| 116 | +## Next steps |
| 117 | + |
| 118 | +> [!div class="nextstepaction"] |
| 119 | +> [Learn about custom model types](../concept-custom.md) |
| 120 | +
|
| 121 | +> [!div class="nextstepaction"] |
| 122 | +> [Learn about accuracy and confidence with custom models](../concept-accuracy-confidence.md) |
0 commit comments