After you have a dataset with a solid set of labeled training documents, you are ready to create and train the custom model.
Training a model can take several hours to complete. The required training time depends on several factors, such as the size of the dataset, the nature of the training items, and the complexity of the models. AutoML Natural Language uses early stopping to produce the best possible model without overfitting.
For classification models, the average training time is around 6 hours, with a maximum of 24 hours. For entity extraction and sentiment analysis modes, the average training time is 5 hours, with a maximum of 6 hours.
After a model is successfully trained, you receive a message at the email address associated with your project.
The maximum lifespan for a custom model is 18 months. You must create and train a new model to continue making predictions after that amount of time.
Web UI
To train a model:
Open the AutoML Natural Language UI and select Get started in the box corresponding to the type of model you plan to train.
The Datasets page appears, showing the status of previously created datasets for the current project. To train using a dataset for a different project, select the project from the drop-down list in the upper right of the title bar.
Select the dataset you want to use to train the custom model.
The display name of the selected dataset appears in the title bar, and the page lists the individual documents in the dataset along with their labels.
When you are done reviewing the dataset, click the Train tab just below the title bar.
If you are about to train the first model from this dataset, the training page provides a basic analysis of the dataset and advises you about whether it is adequate for training. If AutoML Natural Language suggests changes, consider returning to the Text items page and adding documents or labels.
If you have trained other models from this dataset, the training page displays the basic evaluation metrics for those models.
Click Start Training.
Enter a name for the model.
The model name can be up to 32 characters and contain only letters, numbers and underscores. The first character must be a letter.
(Optional): To train an entity extraction model for healthcare terminology, select Enable Healthcare Entity Extraction (beta). This option enables you to start with a healthcare-tuned model that is optimized for processing healthcare data. For more information, see AutoML Entity Extraction for Healthcare.
Select the Deploy model after training finishes check box if you want to deploy the model automatically.
Click Start Training.
Code samples
Classification
REST
Before using any of the request data, make the following replacements:
- project-id: your project ID
- location-id: the location for the resource,
us-central1
for the Global location oreu
for the European Union - dataset-id: your dataset ID
HTTP method and URL:
POST https://automl.googleapis.com/v1/projects/project-id/locations/location-id/models
Request JSON body:
{ "displayName": "test_model", "dataset_id": "dataset-id", "textClassificationModelMetadata": { } }
To send your request, expand one of these options:
You should see output similar to the following. You can use the operation ID to get the status of the task. For an example, see Getting the status of an operation.
{ "name": "projects/434039606874/locations/us-central1/operations/1979469554520652445", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata", "createTime": "2018-04-27T01:28:41.338120Z", "updateTime": "2018-04-27T01:28:41.338120Z", "cancellable": true } }
Python
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Python API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Java API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Node.js API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Go API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for Ruby.
Entity extraction
REST
Before using any of the request data, make the following replacements:
- project-id: your project ID
- location-id: the location for the resource,
us-central1
for the Global location oreu
for the European Union - dataset-id: your dataset ID
- model-hint: the baseline model to use, such as
default
orhealthcare
(beta).
HTTP method and URL:
POST https://automl.googleapis.com/v1/projects/project-id/locations/location-id/models
Request JSON body:
{ "displayName": "test_model", "dataset_id": "dataset-id", "textExtractionModelMetadata": { "model_hint": "model-hint" } }
To send your request, expand one of these options:
You should see output similar to the following. You can use the operation ID to get the status of the task. For an example, see Getting the status of an operation.
{ "name": "projects/434039606874/locations/us-central1/operations/1979469554520652445", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata", "createTime": "2018-04-27T01:28:41.338120Z", "updateTime": "2018-04-27T01:28:41.338120Z", "cancellable": true } }
Python
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Python API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Java API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Node.js API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Go API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for Ruby.
Sentiment analysis
REST
Before using any of the request data, make the following replacements:
- project-id: your project ID
- location-id: the location for the resource,
us-central1
for the Global location oreu
for the European Union - dataset-id: your dataset ID
HTTP method and URL:
POST https://automl.googleapis.com/v1/projects/project-id/locations/location-id/models
Request JSON body:
{ "displayName": "test_model", "dataset_id": "dataset-id", "textSentimentModelMetadata": { } }
To send your request, expand one of these options:
You should see output similar to the following. You can use the operation ID to get the status of the task. For an example, see Getting the status of an operation.
{ "name": "projects/434039606874/locations/us-central1/operations/1979469554520652445", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata", "createTime": "2018-04-27T01:28:41.338120Z", "updateTime": "2018-04-27T01:28:41.338120Z", "cancellable": true } }
Python
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Python API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Java API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Node.js API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for AutoML Natural Language, see AutoML Natural Language client libraries. For more information, see the AutoML Natural Language Go API reference documentation.
To authenticate to AutoML Natural Language, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Natural Language reference documentation for Ruby.