Skip to main content
QUICK REVIEW

[Paper Review] In-context Examples Selection for Machine Translation

Sweta Agrawal, Chunting Zhou|arXiv (Cornell University)|Dec 5, 2022
Topic ModelingComputer Science17 citations
TL;DR

This paper proposes a novel in-context example selection and reranking strategy for few-shot machine translation using large generative models. By retrieving source-side n-gram similar examples via BM25 and re-ranking for maximal n-gram coverage, it improves translation quality over random or k-NN-MT baselines, especially in out-of-domain settings, while remaining memory and compute efficient.

ABSTRACT

Large-scale generative models show an impressive ability to perform a wide range of Natural Language Processing (NLP) tasks using in-context learning, where a few examples are used to describe a task to the model. For Machine Translation (MT), these examples are typically randomly sampled from the development dataset with a similar distribution as the evaluation set. However, it is unclear how the choice of these in-context examples and their ordering impacts the output translation quality. In this work, we aim to understand the properties of good in-context examples for MT in both in-domain and out-of-domain settings. We show that the translation quality and the domain of the in-context examples matter and that 1-shot noisy unrelated example can have a catastrophic impact on output quality. While concatenating multiple random examples reduces the effect of noise, a single good prompt optimized to maximize translation quality on the development dataset can elicit learned information from the pre-trained language model. Adding similar examples based on an n-gram overlap with the test source significantly and consistently improves the translation quality of the outputs, outperforming a strong kNN-MT baseline in 2 out of 4 out-of-domain datasets.

Motivation & Objective

  • To investigate how the choice, ordering, and domain of in-context examples affect translation quality in few-shot machine translation.
  • To address the lack of systematic study on in-context example properties for MT, especially in out-of-domain settings.
  • To improve translation quality by selecting high-coverage, meaning-equivalent examples rather than random or noisy ones.
  • To develop a memory- and compute-efficient alternative to dense vector-based k-NN-MT methods using retrieval and reranking.
  • To explore whether prompt templates and example-specific context can jointly improve translation quality and style mimicry.

Proposed method

  • Retrieves in-context examples from a BM25-indexed datastore using n-gram overlap between test source and training examples.
  • Reranks retrieved examples to maximize coverage of source-side n-grams in the final prompt.
  • Combines a single optimized task-level prompt (e.g., 'Translate to German:') with example-specific in-context examples via simple concatenation.
  • Uses greedy decoding with a large pre-trained language model (PLM) to generate translations conditioned on the final prompt.
  • Employs a dual-purpose prompt design: one for task specification (e.g., language direction) and one for example-specific guidance.
  • Evaluates performance using BLEU scores on WMT’19 and FLORES-101 datasets, comparing against random, k-NN-MT, and baseline in-context learning.

Experimental results

Research questions

  • RQ1How does the choice of in-context examples—especially noisy or unrelated ones—affect translation quality in few-shot MT?
  • RQ2What properties of in-context examples (e.g., n-gram similarity, domain, meaning equivalence) lead to higher-quality translations?
  • RQ3Can a single, optimized task-level prompt outperform multiple random examples in few-shot MT?
  • RQ4How does n-gram coverage of retrieved examples influence translation quality compared to random or k-NN-MT baselines?
  • RQ5To what extent can the PLM mimic the style of in-context examples, enabling template-based translation synthesis?

Key findings

  • A single 1-shot noisy or unrelated in-context example can catastrophically degrade translation quality, demonstrating high sensitivity to example quality.
  • A single optimized task-level prompt can elicit sufficient task knowledge from the PLM, outperforming multiple random examples in some settings.
  • Reranking retrieved examples for maximum source n-gram coverage leads to consistent improvements in BLEU scores across in-domain and out-of-domain datasets.
  • The proposed method outperforms a strong k-NN-MT baseline on 2 out of 4 out-of-domain datasets (Medical and IT), despite not requiring a dense token-level datastore.
  • The PLM can successfully mimic the style of in-context examples, enabling template-based translation synthesis that preserves formatting and tone.
  • Using a smaller in-domain datastore with multiple retrieved examples can achieve similar BLEU performance to a larger datastore with fewer examples, highlighting the importance of coverage over scale.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.