Automating Behavioral Testing in Machine Translation

Javier Ferrando, Matthias Sperber, Hendra Setiawan, Dominic Telaar, Sasa Hasan

Introduction

In the field of Machine Translation (MT), evaluation has long relied on aggregate metrics such as BLEU or COMET. While these provide a useful high-level score of average quality, they function as "black boxes," often masking specific, systematic failures. A model might achieve a high BLEU score while consistently failing to translate URLs, incorrectly converting physical units, or mishandling emojis—errors that can be critical in production environments.

This paper introduces a framework to automate "behavioral testing" (specifically Minimal Functionality Tests or MFTs) for MT using Large Language Models (LLMs). By leveraging LLMs to generate both diverse test sentences and sets of valid target translations, the authors can detect fine-grained linguistic failures that traditional metrics overlook.

The Challenge of Behavioral Testing in MT

Behavioral testing aims to verify specific model capabilities, but applying it to MT is notoriously difficult for two primary reasons:

  1. Infinite Output Space: Unlike sentiment analysis, where the output is a simple label, a single source sentence in MT can have dozens of valid translations. Determining "correctness" is not a binary string-matching task.
  2. Human Effort: Manually authoring thousands of test templates for different languages and linguistic properties is expensive and does not scale.

The Proposed Framework

The authors propose a three-stage pipeline to automate the creation and execution of these tests using LLMs as "test architects."

1. Source Sentence Generation

Using gpt-3.5-turbo with in-context learning, the system generates 1,000 diverse sentences for specific linguistic properties (e.g., decimals, idioms, web terms). To ensure variety and ease of parsing, the authors utilize a prompt template that requires the property under test to be wrapped in brackets.

2. Candidate Generation

To address the "infinite output" problem, the LLM generates a Near-Exhaustive Candidate Set of valid translations for the specific property. For example, if testing the translation of "miles" into German, the set might include both "Meilen" and the abbreviation "mi."

3. Pass-Fail Detection

The framework employs two methods for evaluation:

  • String Matching: For simple properties like numbers or units, the system checks if any valid candidates from the generated set appear in the MT model's output.
  • Contrastive Candidate Pairs: For complex properties like idioms, where literal translations are incorrect, the system generates a "correct" figurative translation and a "foil" (an incorrect literal translation). A multilingual encoder (Sentence-BERT) then determines if the MT output is semantically closer to the correct meaning or the literal mistake.

Experimental Setup and Insights

The authors evaluated several prominent models, including multilingual models (NLLB, M2M, WMT21), bilingual models (OPUS MT), and a high-performing commercial system. The tests covered nine linguistic properties across three language pairs: English to German (En→De), Spanish (En→Es), and Japanese (En→Ja).

Key Findings

  • The "Bilingual Blindness": Bilingual models, heavily tuned to a specific language pair, often perform worse on web terms. They frequently attempt to "translate" URLs into actual words (e.g., converting a .org link into Spanish words), whereas multilingual models better recognize that a URL should remain untouched.
  • The Comma Bug: Even high-performing commercial systems have specific weaknesses. One system showed a lower pass rate for En→Es integers because it used commas as thousands-separators in contexts where that was not the local standard—a nuance that aggregate scores would never reveal.
  • Scaling Paradoxes: While larger models generally perform better, scaling is not a universal fix. In some model families, increasing parameters did not improve, or even slightly degraded, performance on specific tasks like decimals or Japanese integers.
  • The Vocabulary Bottleneck: Most open-source models failed significantly on emojis (often near 0% pass rate) due to a lack of necessary tokens in their vocabulary. In contrast, the commercial system handled these perfectly.
  • Idioms as the "Final Boss": Across all models, idioms remained the most difficult property, with pass rates typically between 10% and 40%. Most models still fall into the trap of literal translation.

Conclusion and Future Work

The study demonstrates that LLMs are highly effective at generating diverse, natural-sounding test cases, with approximately 70-80% of generated sentences being usable. To ensure results are not biased by a model being "lucky" on a specific frequent term, the authors introduced the Macro Pass Rate (MPR) as a more robust metric for behavioral health.

However, limitations remain. The current framework is most reliable for high-resource languages and linguistic properties that appear as a single "chunk" of text. Future work is needed to address low-resource languages and properties scattered across a sentence, such as long-distance subject-verb agreement.

Summary updated

BibTeX
@inproceedings{ferrando2023automating,
  author = {Javier Ferrando and Matthias Sperber and Hendra Setiawan and Dominic Telaar and Sasa Hasan},
  title = {{Automating Behavioral Testing in Machine Translation}},
  booktitle = {WMT},
  year = {2023},
  url = {https://openreview.net/forum?id=mxwFQuXtMVq},
}
Figure