Translation

Translation on Google Cloud covers translating text with Cloud Translation API, improving domain consistency with glossaries, preparing custom NMT training data, and evaluating translation quality with Vertex AI evaluation metrics.

Synthesized across 3 notebooks. See the source pages under Notebooks below for line-level grounding.

Engineers typically start with Cloud Translation API for language translation, using explicit source and target language codes and regional resource paths. For domain-specific terminology, Cloud Storage-backed glossaries help keep short words and phrases translated consistently.

For custom model work, training data quality is central: source and reference DOCX content must be aligned, cleaned, validated, and exported as TSV before import from Cloud Storage. Bad or risky rows, such as mismatched blocks or lines over 200 words, should be captured instead of silently included.

Evaluation is handled with Vertex AI EvalTask over stored translation responses. Use structured source, response, and reference columns, then inspect both aggregate metrics and row-level results from BLEU, COMET, and MetricX.

Canonical workflow

  1. Configure project ID, region, authentication, and required packages for the notebook environment.
  2. Create or load source text and set source_language_code and target_language_code explicitly.
  3. Call Cloud Translation API using regional resource paths, optionally with a Cloud Storage-backed glossary for domain terms.
  4. For custom NMT training, validate matching DOCX source and reference files before processing.
  5. Remove empty lines, preserve paragraph and table order, and generate aligned TSV training pairs while capturing mismatches and over-200-word lines.
  6. Upload or reference the TSV from Cloud Storage before importing data for custom training.
  7. Evaluate stored translation responses with Vertex AI EvalTask using source, response, and reference columns.
  8. Review summary and row-level metrics, then clean up the ExperimentRun created by evaluation.

Best practices

See Translation - Best Practices for the full distilled guide.

  • Initialize Vertex AI with an explicit project and location before using evaluation APIs.
  • Install google-cloud-aiplatform with the evaluation extra before importing Vertex AI evaluation APIs.
  • Use a structured pandas DataFrame with source, response, and reference columns for translation evaluation.
  • Inspect both summary metrics and row-based metrics from EvalResult to understand aggregate quality and individual failures.
  • Delete the ExperimentRun referenced by evaluation metadata when finished.
  • Use environment variables for project ID and region when notebook parameters are not provided.

Key models & APIs

  • Cloud Translation API, Cloud Translation API glossaries, Cloud Storage-backed glossary source files, Cloud Translation custom NMT training, Vertex AI EvalTask, BLEU, COMET, MetricX, google-cloud-aiplatform[evaluation], pandas DataFrame

Notebooks (3)

Gemini (1)

Translation (2)


Part of the Generative AI Google Brain · Translation - Best Practices