Anti-LM Decoding for Zero-shot In-context Machine Translation

Suzanna Sia, Alexandra DeLucia, Kevin Duh

Introduction

Large Language Models (LLMs) often struggle with zero-shot instructions, particularly in Machine Translation (MT). Despite their vast knowledge, they frequently "fail to translate," instead repeating the source sentence or continuing to generate text in the source language. This behavior stems from a strong internal "prior" where the model assumes the next tokens should match the dominant language of the prompt. This paper, presented at NAACL 2024, introduces Anti-LM (ALM) decoding, a "frustratingly simple" contrastive objective that penalizes source-language continuations to achieve significant performance gains without additional training.

The Challenge of Zero-shot Translation

In a zero-shot setting (e.g., "Translate English to French: [Source]"), the model performs Bayesian inference. Because the prompt is heavily weighted toward the source language, the model often defaults to:

  1. Regurgitation: Copying the source sentence exactly.
  2. Continuation: Writing more in the source language instead of switching to the target.
  3. Empty Output: Failing to produce meaningful text.

Standard decoding strategies like beam search or nucleus sampling do not address this underlying distributional bias, as they only change how we select from the existing probability distribution rather than modifying the distribution itself.

Methods: Anti-LM Contrastive Decoding

The authors propose modifying the model's output probabilities (logits) at inference time by subtracting a penalty term that represents the model's tendency to stay in the source language.

The Objective Function

The modified decoding objective is defined as: $$\text{Logits}_{\text{modified}} = \log p(y_t | y_{<t}, x, u) - \gamma^t \log p(y_1 | x)$$

Where $x$ is the source sentence, $u$ is the instruction, and $\gamma^t$ is an exponential decay factor. The term $\log p(y_1 | x)$—the "Anti-LM" term—captures the probability of the next token given only the source sentence, effectively "muting" the source language bias.

Comparison of decoding objectives and their conditional text inputs.

Key Innovations

  • Exponential Decay: The penalty is strongest at the first token—where translation failure typically occurs—and fades over time to avoid interfering with the fluency of the target language once the translation has begun.
  • Computational Efficiency: Unlike Pointwise Mutual Information (PMI), which requires a penalty term at every step, the Anti-LM term is computed only once per sentence, significantly reducing inference latency.

Experimental Setup

The method was evaluated on the FLORES-101 dataset across three language pairs (English to/from French, German, and Portuguese) using various model families: XGLM (2.9B, 7.5B), Bloom (3B, 7B), and Llama 2 (7B, 7B-chat).

Results and Analysis

The primary impact of Anti-LM is the "rescue" of failed cases. Rather than simply improving already good translations, the method turns previously garbled or copied outputs into viable translations. This reinforces the idea that LLMs often "know" how to perform a task, but their output distributions are poorly calibrated for zero-shot instructions.

BLEU score improvements across various models and language pairs using Anti-LM (ALMx) compared to base and PMI methods.

Key Findings

  • Massive Performance Gains: Anti-LM improved scores by up to 20 BLEU points in some XGLM configurations compared to standard greedy decoding.
  • Consistency: It consistently outperformed other state-of-the-art contrastive methods like PMI and context-aware decoding across nearly all tested models and language directions.
  • Instruction Sensitivity: The method remains effective even with elaborate prompts, suggesting that prompt engineering alone cannot overcome deep-seated linguistic priors.

Conclusion and Limitations

Anti-LM provides a powerful, training-free calibration tool for zero-shot MT. While highly effective, its benefits diminish in few-shot settings where provided examples already serve to calibrate the model. Future work may explore the impact on non-Latin scripts and the potential for the penalty to inadvertently affect named entities that should remain unchanged between languages.

Summary updated

BibTeX
@inproceedings{sia2024anti,
  author = {Suzanna Sia and Alexandra DeLucia and Kevin Duh},
  title = {{Anti-LM Decoding for Zero-shot In-context Machine Translation}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-naacl.216},
}
Figure