Frequency-Aware Contrastive Learning for Neural Machine Translation

Tong Zhang, Wei Ye, Baosong Yang, Long Zhang, Xingzhang Ren, Dayiheng Liu, Jinan Sun, Shikun Zhang, Haibo Zhang, Wen Zhao

Introduction

Neural Machine Translation (NMT) models frequently struggle with the "long-tail" problem. Following Zipf’s Law, while a few words appear with high frequency, the vast majority of the vocabulary appears rarely. Data-driven models naturally prioritize frequent patterns, often mispredicting low-frequency tokens which typically carry the most significant semantic weight.

Previous attempts to address this via "adaptive weighting"—increasing the loss penalty for rare words—often result in a precision-recall trade-off. While recall for rare words improves, precision tends to drop, and performance on high-frequency words can degrade. The authors identify the root cause as "representation degeneration": rare words are squeezed into a compact, narrow cone in the embedding space, making it difficult for the model to distinguish between them.

Methods: Frequency-Aware Contrastive Learning (FCL)

The researchers propose Frequency-aware Contrastive Learning (FCL), a two-step approach designed to spread out the representation space for infrequent tokens.

Overview of the FCL framework showing Token-level Contrastive Learning (TCL) and the resulting representation space.
  1. Token-level Contrastive Learning (TCL): Instead of contrasting whole sentences, the model contrasts hidden states of individual tokens. To create positive pairs, the model uses a "dropout noise" technique, passing the same sentence through the model twice with different dropout masks. Other instances of the same word in a minibatch also serve as positive pairs, while all other tokens act as negative pairs to be pushed away.
  2. Frequency-Aware Weighting: This is the core innovation. A soft weight is applied to the contrastive loss based on word frequency. Rarer words receive higher weights, forcing the model to more aggressively "push apart" their representations, creating a more isotropic and navigable embedding space for the long tail.

Experimental Setup

The model was evaluated on two major benchmarks:

  • NIST Chinese-to-English (Zh-En): 1.25M sentence pairs.
  • WMT14 English-to-German (En-De): 4.5M sentence pairs.
  • Vocabulary: 32K subword units using Byte Pair Encoding (BPE).

Key Results and Insights

FCL achieved a +1.56 BLEU improvement over the vanilla Transformer on Zh-En and +0.81 BLEU on En-De. Notably, in "Low" frequency buckets, FCL outperformed the baseline by 2.0 BLEU points.

Empirical results showing the 1-Gram Recall, Precision, and F1 gaps across token frequency buckets.

Unlike previous methods like Focal Loss or Exponential weighting, which improve recall at the expense of precision, FCL improves both metrics simultaneously. By focusing on representation learning rather than just loss weighting, the model becomes more confident and accurate when selecting rare words. Furthermore, translations produced by FCL showed higher lexical richness (measured by MATTR and MTLD), indicating a more natural and diverse use of vocabulary.

Conclusion

FCL addresses the root cause of poor rare-word translation by restructuring the representation space. While training is approximately 1.59x slower due to the dual-pass dropout mechanism, inference speed remains unaffected. This representation-centric approach offers a robust alternative to traditional adaptive training for handling data imbalance in NMT and potentially other long-tailed distribution tasks.

Summary updated

BibTeX
@inproceedings{zhang2022frequency,
  author = {Tong Zhang and Wei Ye and Baosong Yang and Long Zhang and Xingzhang Ren and Dayiheng Liu and Jinan Sun and Shikun Zhang and Haibo Zhang and Wen Zhao},
  title = {{Frequency-Aware Contrastive Learning for Neural Machine Translation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i10.21426},
}
Figure