Improving Multilingual Sentence Embedding using Bi-directional Dual Encoder with Additive Margin Softmax

Yinfei Yang, Gustavo Hernández Ábrego, Steve Yuan, Mandy Guo, Qinlan Shen, Daniel Cer, Yun-Hsuan Sung, Brian Strope, Ray Kurzweil

TL;DR

Researchers at Google AI have developed a new approach to multilingual sentence embeddings using a bi-directional dual encoder combined with an Additive Margin Softmax (AMS). This method significantly improves the separation between true translations and "near-miss" sentences in vector space, achieving state-of-the-art results in parallel text retrieval and bitext mining tasks.

What Problem Does This Paper Address?

Neural Machine Translation (NMT) systems are data-hungry; their performance depends heavily on the volume and quality of "bitext" (parallel sentence pairs). While the internet is a vast source of potential data, mining it is difficult.

Traditional methods for finding translations in massive datasets are often computationally expensive or rely on brittle metadata. Recent "embedding-based" approaches map sentences from different languages into a shared vector space where translations should be close to each other. However, these models often struggle with "noisy matches"—sentences that look similar (e.g., sharing many words) but aren't actually translations. The challenge is to create an embedding space that is "compact" enough for true pairs but "spread out" enough to reject look-alikes.

Methods

The authors propose a Bi-directional Dual Encoder architecture trained with a specialized loss function:

The dual encoder architecture processes source (x) and target (y) sentences through shared encoders to produce embeddings.
  1. Dual Encoder: The model uses two identical encoders (sharing weights) to process source and target sentences. The goal is to maximize the cosine similarity between the resulting vectors for true translation pairs.
  2. Transformer Backbone: Each encoder is a 3-layer Transformer. To handle different languages and rare words, they use a mix of word-level unigrams and character-level n-grams.
  3. Additive Margin Softmax (AMS): This is the "secret sauce." Standard softmax tries to make the correct translation more likely than others. AMS goes further by introducing a "margin" ($m$) during training. It essentially forces the model to make the correct translation's score significantly higher than the next best candidate. This pushes true translations closer together while creating a "buffer zone" that clears out nearby non-translations.
  4. Bi-directionality: Instead of just optimizing for one direction, the model simultaneously optimizes for both Source $\rightarrow$ Target and Target $\rightarrow$ Source. This symmetry stabilizes the embedding space.

Key Insights and Ideas

  • The Power of the Margin: The most important insight is that a simple margin in the loss function drastically improves the "structure" of the embedding space. By forcing a gap between classes, the model learns to ignore "false positives" (sentences that are topically similar but not translations).
Comparison between the original embedding space and the space created with Additive Margin Softmax (AMS), showing the clear separation (margin) between clusters.
  • Simple Document Embeddings: The authors found that they could achieve near-perfect document-level retrieval (97% P@1) simply by averaging the sentence embeddings within a document. This suggests the sentence-level representations are robust enough that a simple mean captures the "essence" of a document across languages.
  • Stability through Bi-directionality: Training the model to work in both directions leads to more consistent cosine similarity scores, which is crucial when you need to set a global threshold for mining data.

Key Results

  • UN Sentence Retrieval: The system achieved a Precision@1 of 86% or higher across all tested languages, even when searching through 11.3 million candidates.
  • NMT Performance: NMT models trained on data mined by this system performed as well as (and sometimes better than) models trained on "gold" (human-verified) data.
  • BUCC Mining: The model set a new state-of-the-art on the BUCC task. While the raw embeddings were competitive, adding a second-stage BERT-based rescorer pushed F1-scores into the 93-97 range.

Limitations and Future Work

  • Partial Translations: The authors noted that the model still struggles with "partial translations"—pairs where one sentence is a subset of the other.
  • Numerical Sensitivity: The model occasionally fails to differentiate between sentences that are identical except for specific numbers or entities (e.g., different dollar amounts).
  • Second-Stage Dependency: While the embeddings are excellent, the very best results still require a computationally expensive second-stage scorer (like BERT). Future work might focus on distilling that BERT-level "knowledge" directly into the faster dual-encoder embeddings.

Summary updated

BibTeX
@inproceedings{yang2019improving,
  author = {Yinfei Yang and Gustavo Hernández Ábrego and Steve Yuan and Mandy Guo and Qinlan Shen and Daniel Cer and Yun-Hsuan Sung and Brian Strope and Ray Kurzweil},
  title = {{Improving Multilingual Sentence Embedding using Bi-directional Dual Encoder with Additive Margin Softmax}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.24963/ijcai.2019/746},
}
Figure