# Creating and training models for a model-based entity type

After you select your training data, on the **Model training** page, you create one or more trained models.

For each model, you select the version of the guidelines to use. Textual first uses those guidelines to annotate the training data. Based on how well the guidelines identified the values in the training data, you decide whether to start the model training.

When the training is complete, the model scans the test data. The model is scored based on how well it detected the definitive values that you confirmed in the test data.

## **Information on the model list**

For each model, the model list includes:

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2F8Ae4Vpyq9tuDJnuTJ2Lp%2FCustomEntityTypeModelModelTraining.png?alt=media&#x26;token=5e77b1ba-ac68-4761-99cb-7829cca38a97" alt=""><figcaption><p>Model training page</p></figcaption></figure>

* **Model** - The model name. Models are automatically named **Model&#x20;*****n***, where ***n*** is the number of the model. For example, the first model you create is Model 1, the second is Model 2, and so on.
* **Status** - The model status. The possible statuses are:
  * **Annotating** - The model is using the selected guidelines to annotate the training data.
  * **Ready for training** - The annotation is complete. For models with this status, Textual displays a **Review** option to allow you to review the annotations.
  * **Training** - The training is in progress. Textual displays the percentage of training data that the model has trained on.
  * **Ready** - The model is trained. You can select any trained model as the active model for the entity type.
* **Guideline version** - The version of the guidelines used for the model. To view the guidelines text, click the view icon.
* **Benchmark score** - A score that indicates how well the model performed when it annotated the test data after training.
* **Detected entities** - The number of entity values that the model detected in the training data.
* **# of files** - The number of training files that were used for the annotation and model training.

## **Starting a new model**

To start a new model:

1. Click **Create new model**.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2FYkmUaYRr2OwPCM9hjG55%2FCustomEntityTypeModelCreateNewModel.png?alt=media&#x26;token=87a8b018-bbd8-48bd-a6ad-a131dd5f81ea" alt=""><figcaption><p>Create new model panel to select the guidelines version for the model</p></figcaption></figure>

2. On the **Create new model** panel, from the **Guideline version** dropdown list, select the version of the guidelines to use for the model.
3. Click **Save**.

Textual adds the model to the list and uses the selected guidelines version to annotate the training data files.

## **Reviewing the annotations for a model**

Before you train the model, you review the annotations to see how well the model performed.

To review the annotations, click the model name. Models that are ready to review also display a **Review and Train** link next to the model name.

On the model details page:

* On the left is the list of training data files, with the number of entities detected in each file.
* On the right is the list of the entities in the training files, in descending order by the number of occurrences.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2Fx1cTM6Xdog3xWIWPSzvB%2FCustomEntityTypeModelModelDetailsInitial.png?alt=media&#x26;token=6ff0a886-ff46-4765-ae16-5a4783298694" alt=""><figcaption><p>Model details page with the list of detected values</p></figcaption></figure>

To display the content of a file with the annotations highlighted, click the file name.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2FplwySkMIrvYy45souT1k%2FCustomEntityTypeModelModelTrainingFileDetails.png?alt=media&#x26;token=75dbd966-efeb-40d8-b86d-531ae76e12bf" alt=""><figcaption><p>Model details page with the content of an annotated training file</p></figcaption></figure>

After you review the annotations, if you are not satisfied with the results, to return to the guidelines refinement:

1. In the model list, in the **Guideline version** column, click the view icon.
2. On the guidelines panel, click **Go to guidelines refinement**.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2FwFVH1eM2hoRpgHdVemqg%2FCustomEntityTypeModelModelGuidelinesPanel.png?alt=media&#x26;token=21e18a49-e23b-4d46-acde-dc1c2f2b39e3" alt=""><figcaption><p>Guidelines panel for a model, with the option to return to the guidelines refinement</p></figcaption></figure>

For a model that is not trained yet, the model details page also displays a **Modify guidelines** option.

Textual displays the **Guidelines Refinement** page, and selects that guidelines version. You can then [edit the guidelines to create a new version](https://docs.tonic.ai/textual/entity-types/model-entity-type-guidelines#editing-the-guidelines), then [create a new model](#starting-a-new-model) that uses the new version.

## **Training the model**

If you are satisfied with the annotation results, then on the model details page, to start the training, click **Train model**.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2FQ0oYQMmBJF3ql1kIDxje%2FCustomEntityTypeModelTrainModelOption.png?alt=media&#x26;token=a6bd56bf-05d4-4f1d-8efb-8bac4c995c63" alt=""><figcaption><p>Train model option for a model</p></figcaption></figure>

## Downloading a data package for a model <a href="#model-download-data-package" id="model-download-data-package"></a>

To help troubleshoot issues with a trained model, you can download a model data package to send to Tonic.ai.

The data package is a .zip file that contains the following:

* General information about the custom entity type and model. Includes the entity type name entity type identifier, and the model identifier.
* The set of test files, including the established entity values that you identified.
* The set of training files, including the entity values that the model identified.

To download the data package, either:

* On the **Model Training** page, click the download icon for the model.
* On the model details page, click **Download Training Data**.

<figure><img src="https://3072847115-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvOPn7KQptPWmS5iKg5P0%2Fuploads%2FtabDgsmXQkLzfaNtavd9%2FCustomEntityTypeModelModelDataDownload.png?alt=media&#x26;token=cadfba16-97eb-47ea-bb10-fd45bf24171a" alt=""><figcaption><p>Download Training Data option on the model details for a trained model</p></figcaption></figure>
