Terminology-constrained decoding in machine translation: enforce required terms and check sentence quality
Terminology-constrained decoding limits the search used to generate a translation so that specified words or phrases appear in the output. It can help when a product name or approved technical term is mandatory, but an incorrect term pair or a context-inappropriate forced insertion can make the translation awkward or inaccurate. Before applying constraints, verify that they fit the input and evaluate both term compliance and sentence quality.
Terminology-constrained decoding in machine translation: enforce required terms and check sentence quality
Terminology-constrained decoding limits the search used to generate a translation so that specified words or phrases appear in the output. It can help when a product name or approved technical term is mandatory, but an incorrect term pair or a context-inappropriate forced insertion can make the translation awkward or inaccurate. Before applying constraints, verify that they fit the input and evaluate both term compliance and sentence quality.
A glossary is not constrained decoding
A glossary stores source expressions and permitted target-language equivalents. Constrained decoding is a generation method that selects applicable entries for an input sentence and guides the decoder to find candidates containing those expressions. Passing a glossary to a model does not necessarily activate decoding constraints. Check the system documentation to see whether it supports a soft preference or a hard requirement that the output must contain.
Review entries before applying constraints
**Find the source term in context.** Check whether the source expression matches a glossary entry or a synonym rule. Apply a homograph only when the surrounding context supports the intended meaning.
**Determine the target form.** Distinguish an invariant product name from a common noun that changes form with case, number, gender, or surrounding grammar. If the required term does not fit the sentence grammar, define an allowed variant or a policy for omitting the constraint.
**Link the source span to the target expression.** Some decoding methods use the source span as well as the target term. A misaligned pair or span that is too short can omit surrounding meaning and cause over- or under-translation.
**Check for conflicting terms on the same span.** If a source expression can have several target equivalents, record the context conditions for choosing among them. Forcing several alternatives at once can make selection difficult or produce an incorrect combination.
Methods and selection criteria
| Method | How it works | What to check |
|---|---|---|
| Hard constrained search | Restricts beam search so a specified word or phrase appears in the output | Measure latency, search overhead, and sentence quality as the number of constraints grows |
| Soft terminology guidance | Increases the chance of using a term but allows the model to choose another expression | Test whether it provides enough assurance for names that must appear exactly |
| Term tags or placeholders during training | Signals term positions in training or inference inputs so the model can generate them in context | Check consistency of training data and term-marking rules |
Post and Vilar’s 2018 study describes constrained decoding that modifies beam search to include target words or phrases and examines search efficiency as the constraint count grows. Later studies in English–German settings found different trade-offs between term accuracy and overall translation quality as the number of constraints and target-term length increased. Do not generalize results from a particular model or language pair into a guarantee for another environment.
Evaluate whether it works, step by step
Translate baseline inputs without terms and inputs where glossary terms apply, using the same system.
Include cases where a term truly appears in the source as well as homographs and cases where the term does not apply.
Record term compliance, meaning preservation, grammar and fluency, omissions or duplication, and translation latency.
Have a person review a sample for cases where a term appears but has the wrong meaning.
Provide a safe fallback that can ignore a constraint or route the sentence to human review when the term is inaccurate or its applicability is unclear.
For example, “Mercury” could be a company’s product name or the planet. An English glossary entry alone cannot determine which target expression to enforce. Choose the entry using the surrounding sentence and product-domain context. A constrained decoder may make a wrongly selected term appear more reliably; the enforcement feature does not verify that the glossary is correct.
References
[Post and Vilar, “Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translation” (NAACL 2018)](https://aclanthology.org/N18-1119/)
[Hasler et al., “Neural Machine Translation Decoding with Terminology Constraints” (NAACL 2018)](https://aclanthology.org/N18-2081/)
[Zhang et al., “Understanding and Improving the Robustness of Terminology Constraints in Neural Machine Translation” (ACL 2023)](https://aclanthology.org/2023.acl-long.332/)