Adaptive Translation and Terminology with Large Language Models

10 Jan 2024 » nmt, llm

Translation clients expect consistent terminology and style, but a translation model that has never seen their approved translations cannot adapt in real time. Large language models (LLMs) offer a simple way around this. If the prompt includes a few similar approved translations, or a short glossary, the LLM follows them while translating the new sentence, with no retraining. This is called in-context learning. We studied this idea in several papers. This post collects what we found and what you can do with it.

How It Works

The approach needs a translation memory (TM), which is a collection of approved translations. For each new sentence, you retrieve the most similar sentences from the TM, called fuzzy matches. In our experiments, we compared sentence embeddings to find them. Then you put the matches in the prompt, followed by the new sentence. A prompt with two matches looks like this.

English: <source fuzzy match 2>
Arabic: <target fuzzy match 2>
English: <source fuzzy match 1>
Arabic: <target fuzzy match 1>
English: <new source segment>
Arabic:

The most similar match (1) sits closest to the new sentence, and the model continues the pattern.

Terminology works in a similar way. In our WMT 2023 submission, we gave the LLM an existing translation and asked it to use the required terms and leave everything else the same. This is a form of automatic post-editing, where an LLM revises the output of an MT system.

What the Results Show

Similar examples beat random ones

In the EAMT 2023 paper, we tested GPT-3.5 on English to Arabic, Chinese, French, Kinyarwanda and Spanish, using TICO-19 as the TM. Few-shot translation with similar sentences beat few-shot translation with random sentences, and both beat zero-shot translation. Adding more matches helped (2, then 5, then 10), with smaller gains each time.

An LLM can beat a strong MT system, depending on the language

Without examples, ModernMT translated better than GPT-3.5 for the four language pairs it supports. With 5 or 10 similar examples, GPT-3.5 beat ModernMT for English to Chinese, French and Spanish, even when ModernMT used a TM too. For Arabic it did not, partly because of how the GPT-3.5 tokenizer handles Arabic. Kinyarwanda is a low-resource language. How well an LLM supports your language pair matters a lot.

If the LLM is weaker, add the MT output to the prompt

For English to Arabic, putting the translation from an encoder-decoder system (OPUS) in the prompt, next to the similar examples, beat both the MT system alone and the LLM with examples alone. The same idea helped English to Chinese with Google’s translation. When the LLM was already clearly better, as for French and Spanish, adding MT output did not help.

Terminology adherence can improve, with some care

An LLM extracted term pairs from sentence pairs, and over 95% were accurate in our human evaluation for Arabic, French and Spanish. Giving glossary terms in the prompt made the model use them more often, although forcing terms sometimes hurt grammar, and contradictory terms hurt quality.

For the WMT 2023 terminology task (German to English, English to Czech, Chinese to English), our pipeline had four steps. An LLM generated synthetic sentences from the terminology, we fine-tuned an MT model on a mix of that data and generic data, we translated with it, and finally an LLM post-edited the output to insert missing terms. On the blind test set, the pipeline raised the average share of required terms used in the translations from 36.67% with the baseline model to 72.88%. Translation quality did not suffer, and it even improved according to automatic metrics (BLEU, chrF++ and COMET).

A small open model can be enough

If you cannot send your data to a commercial API, you can fine-tune an open model. We fine-tuned Mistral 7B with QLoRA on 20,000 Spanish to English medical segments, half with plain prompts and half with one similar example. For this language pair and domain, in plain translation, the fine-tuned model matched NLLB 3.3B and beat gpt-3.5-turbo. With one similar example, it matched gpt-3.5-turbo and beat NLLB 3.3B. Training on both kinds of prompts means one model handles regular and adaptive translation.

An LLM is not always the answer

In a 2025 follow-up on medical translation for English to French, English to Portuguese, English to Swahili and Swahili to English, NLLB-200 3.3B beat every LLM we tested in the 7 to 8 billion parameter range in three of the four directions. Fine-tuning improved Mistral and Llama, but fine-tuned NLLB stayed ahead. Before you choose, compare a task-specific MT model with an LLM on your own language pair.

Code and Data

The fine-tuning code, data and evaluation scores are on GitHub. The repository covers fuzzy match retrieval with Sentence-Transformers and FAISS, fine-tuning, inference with CTranslate2 (and the ChatGPT API for comparison), and evaluation. It includes Spanish to English, plus English to French, Portuguese and Swahili, and Swahili to English.

Adaptive-MT-LLM-Fine-tuning

Papers and Citations

Adaptive Machine Translation with Large Language Models

Moslem, Haque, Kelleher and Way. EAMT 2023. First preprint, January 2023. PDF

BibTeX
@inproceedings{moslem-etal-2023-adaptive,
    title = "Adaptive Machine Translation with Large Language Models",
    author = "Moslem, Yasmin  and
      Haque, Rejwanul  and
      Kelleher, John D.  and
      Way, Andy",
    booktitle = "Proceedings of the 24th Annual Conference of the European Association for Machine Translation",
    month = jun,
    year = "2023",
    address = "Tampere, Finland",
    publisher = "European Association for Machine Translation",
    url = "https://aclanthology.org/2023.eamt-1.22/",
    pages = "227--237",
}

Domain Terminology Integration into Machine Translation: Leveraging Large Language Models

Moslem, Romani, Molaei, Haque, Kelleher and Way. WMT 2023. First preprint, October 2023. PDF

BibTeX
@inproceedings{moslem-etal-2023-domain,
    title = "Domain Terminology Integration into Machine Translation: Leveraging Large Language Models",
    author = "Moslem, Yasmin  and
      Romani, Gianfranco  and
      Molaei, Mahdi  and
      Kelleher, John D.  and
      Haque, Rejwanul  and
      Way, Andy",
    booktitle = "Proceedings of the Eighth Conference on Machine Translation",
    month = dec,
    year = "2023",
    address = "Singapore",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2023.wmt-1.82/",
    doi = "10.18653/v1/2023.wmt-1.82",
    pages = "902--911",
}

Fine-tuning Large Language Models for Adaptive Machine Translation

Moslem, Haque and Way. Preprint, December 2023, and a chapter of my thesis. PDF

BibTeX
@article{moslem-etal-2023-fine-tuning-llms,
      title={Fine-tuning Large Language Models for Adaptive Machine Translation}, 
      author={Yasmin Moslem and Rejwanul Haque and Andy Way},
      year={2023},
      eprint={2312.12740},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2312.12740}, 
}

Language Modelling Approaches to Adaptive Machine Translation

Moslem. PhD thesis, Dublin City University, 2024. PDF

BibTeX
@article{moslem-2024-adaptive-mt-llms,
      title={Language Modelling Approaches to Adaptive Machine Translation, {PhD} thesis}, 
      author={Yasmin Moslem},
      year={2024},
      eprint={2401.14559},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2401.14559}, 
}

Domain-Specific Translation with Open-Source Large Language Models: Resource-Oriented Analysis

Wassie, Molaei and Moslem. Preprint, 2025. PDF

BibTeX
@article{Wassie2025-DomainSpecific-Translation-LLM,
  title         = "{Domain-Specific Translation with Open-Source Large Language Models: Resource-Oriented Analysis}",
  author        = "Wassie, Aman Kassahun and Molaei, Mahdi and Moslem, Yasmin",
  month         =  may,
  year          =  2025,
  url           = "https://arxiv.org/abs/2412.05862",
  archivePrefix = "arXiv",
  primaryClass  = "cs.CL",
  eprint        = "2412.05862"
}