Create a custom translation model
Train and use a custom translation model by using the Google Cloud console. The following example uses AutoML Translation to train an English-to-Spanish translation model by using a dataset that contains technology-oriented segment pairs from software localization.
Before you begin
Before you can start using AutoML Translation, your project must have the Cloud Translation API enabled, and you must have the permissions that are granted by the following roles:
- Viewer role to view existing resources in your project
- Cloud Translation API Editor role to create and manage datasets and models
- Storage Admin role to upload training data to a Cloud Storage bucket
Create a translation dataset and import segment pairs
-
Download the archive file that contains the sample data for training the model, and extract the files.
For this tutorial, you'll use the English to Spanish TSV file.
Go to the AutoML Translation console.
From the navigation pane, click Datasets to go to the Datasets page.
Click Create dataset.
In the Create dataset dialog, specify details about the dataset:
- Enter
tutorial_dataset
as the name for the dataset. - Select English (EN) as your source language from the drop-down list.
- Select Spanish (ES) as your target language.
- Click Create.
- Enter
After the dataset is created, click the dataset name to view its details.
Go to the Import tab and upload the
en-es.tsv
dataset to Cloud Storage:- Select Upload files from your computer.
- Click Select files, and choose the
en-es.tsv
file that you previously downloaded and extracted. - Click Browse to select or create a new Cloud Storage bucket
where your TSV is stored. The bucket region must be
us-central1
.
Click Continue.
AutoML Translation automatically splits your data into training, validation, and testing sets. You can view these splits and the imported sentence pairs in the Sentences tab of your dataset.
Train a model
Go to the AutoML Translation console.
From the navigation pane, go to the Datasets page.
Click the tutorial_dataset dataset.
Go to the Train tab.
Click Start training, which opens the Train new model pane.
Enter
tutorial_model
for the model name.Click Start training.
Training a model can take several hours to complete.
Evaluate the model
Check to see how the model compares to the default Google NMT model that is based on segment pairs from your test set.
Go to the AutoML Translation console.
From the navigation pane, go to the Models page.
Click the tutorial_model model.
Click the Evaluate tab.
In the Previous evaluations section, Cloud Translation shows your model's BLEU score compared to the Google NMT model. The BLEU (Bilingual Evaluation Understudy) score indicates how similar the candidate text is to the reference texts; values closer to 100 represent more similar texts.
Use the translation model
From the Google Cloud console, you can use your custom model to translate some text.
Go to the AutoML Translation console.
From the navigation pane, go to the Models page.
Click the tutorial_model model.
Click the Predict tab.
In the English text box, enter text to translate and then click Translate.
You can compare the results from your custom model to the Google NMT model.
Clean up
To avoid unnecessary Google Cloud charges, delete your model,
dataset, and en-es.tsv
file. You can also use the
Google Cloud console
to delete your project if you don't need it.
What's next
- To learn about custom models, see the Beginner's guide.
- To create your own dataset and custom model, see Prepare training data for instructions on how to prepare your data.