> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/textual/entity-types/entity-type-custom-model/creating-and-training-models-for-a-model-based-type.md).

# Creating and training models for a model-based 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="/files/ptCjUJp7JUOUmMSnMzYa" 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.
* **F1** - An overall score to indicate how well the model performed when it annotated the test data after training. The harmonic mean of the precision and recall scores.
* **Precision -** A score that indicates the accuracy of the model detections.
* **Recall -** A score that indicates the completeness of the model detections.
* **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="/files/NvyDiOYZLwyQZTG9IXDz" 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="/files/hUpkMb3DtkyusIHhegzW" 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="/files/iOiOVEgrflF6gOYtLxcp" 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="/files/HV2mUAVTwTMU8vfz0kFc" 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](/textual/entity-types/entity-type-custom-model/model-entity-type-guidelines.md#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="/files/q5FFNWQUMMdEcHdL2Hdf" 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="/files/7zObbM1Equ8TqjLVflqB" alt=""><figcaption><p>Download Training Data option on the model details for a trained model</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tonic.ai/textual/entity-types/entity-type-custom-model/creating-and-training-models-for-a-model-based-type.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
