How Neural Machine Translation Generates a Sentence
Learn how an encoder-decoder model produces translation tokens and what to test for meaning, rare words, and hallucinations.
How Neural Machine Translation Generates a Sentence
Neural machine translation (NMT) uses patterns learned by a neural network to generate a translation from a source text. A common encoder-decoder model reads the source into internal representations, then predicts translation tokens one at a time using those representations and the tokens already produced. This can create context-sensitive sentences, but fluency does not prove that the source meaning was preserved.
What the encoder and decoder do
**Tokenization:** The model splits text into units it can process. Subword units can represent rare or unseen words as smaller pieces. That does not guarantee that names will be copied or transliterated correctly, so test proper names.
**Encoder:** It reads source tokens and their positions to compute contextual representations. The Transformer centers on attention rather than recurrence or convolution, allowing parallel processing of multiple positions during training.
**Attention link:** When producing an output token, the decoder can weight relevant parts of the source. This helps learn alignments, but attention weights are not proof that a translation is accurate.
**Token generation:** The decoder predicts a next token from the available context and repeats until it emits an end marker. Each step depends on earlier output, so generation is not as parallel as training.
**Training:** Many NMT systems learn from parallel sentence pairs, predicting translations that correspond to source sentences. If training languages, domains, or writing conventions differ from deployment, quality may change. A multilingual model may share knowledge across language pairs, but do not assume equal support in every direction.
For example, translating “the meeting was not postponed” requires preserving “not.” A fluent sentence that drops negation reverses the meaning. This example illustrates an error type; it is not a test result for a particular model.
How to choose and test a model
Define each language pair and direction separately. Prepare test sentences that reflect the actual audience, domain, and input format. Include numbers, dates, proper names, negation, longer context, sentence boundaries, rare terms, and mixed scripts. Split evaluation data by document or source so similar material from training does not inflate results.
Compare candidate models with the same source, context, glossary, formatting, and evaluation process. Overlap metrics such as BLEU and learned metrics such as COMET can help explore differences, but interpretation requires recording the language pair, test set, settings, and metric version. Check meaning and key terminology against the source through human assessment. For close, high-quality candidates, inspect error types that matter to the intended use.
NMT failure modes to watch
**Fluent text that adds unsupported content:** NMT can generate a sentence detached from its source. Research across multilingual systems found hallucination issues can be more pronounced in some lower-resource directions and in translation out of English. These are study-specific observations, not rates that apply to every model or pair; test the actual deployment direction.
**Rare words and names:** Subword segmentation helps represent unknown words, but whether a name should be copied, transliterated, or translated depends on context and policy.
**Domain shift:** Results on news do not automatically apply to medical guidance or product manuals. Include samples and terms from the deployment domain.
**Direction-specific quality:** Translation in one direction and the reverse are separate cases. Test lower-resource directions, scripts, and regional forms independently, even for multilingual models.
**Scores that hide severe errors:** A high average can hide a critical sentence error. Review negation, quantities, names, and safety content separately or route them to a person.
A simple pre-deployment decision path
| Finding | Next step |
|---|---|
| Meaning and formatting fit the use case on representative text | Start limited automatic processing and keep sampling |
| Names, terminology, or formatting fail repeatedly | Improve the glossary, input cleanup, or format checks, then rerun the same test |
| Unsupported content appears or negation/quantities change | Do not auto-approve that error class; route it for human review |
| A language direction or domain is outside the test scope | Do not assume performance; collect relevant data and evaluate again |
NMT learns complex patterns from sentence pairs, but results depend on training data and translation direction. Do not judge suitability from architecture alone: inspect meaning preservation and error types in the actual route before deciding what to automate.
References
Ashish Vaswani et al., [Attention Is All You Need](https://arxiv.org/abs/1706.03762), Transformer architecture, NeurIPS 2017.
Rico Sennrich et al., [Neural Machine Translation of Rare Words with Subword Units](https://aclanthology.org/P16-1162/), ACL 2016.
Nuno M. Guerreiro et al., [Looking for a Needle in a Haystack: A Comprehensive Study of Hallucinations in Neural Machine Translation](https://aclanthology.org/2023.eacl-main.75/), EACL 2023.
Nuno M. Guerreiro et al., [Hallucinations in Large Multilingual Translation Models](https://aclanthology.org/2023.tacl-1.85/), TACL 2023.
References
- Ashish Vaswani et al., Attention Is All You Need (NeurIPS 2017)
- Rico Sennrich et al., Neural Machine Translation of Rare Words with Subword Units (ACL 2016)
- Nuno M. Guerreiro et al., Looking for a Needle in a Haystack (EACL 2023)
- Nuno M. Guerreiro et al., Hallucinations in Large Multilingual Translation Models (TACL 2023)