Universal Sentence Representation Learning with Conditional Masked Language Model

Ziyi Yang, Yinfei Yang, Daniel Cer, Jax Law, Eric Darve

Abstract: Ziyi Yang, Yinfei Yang, Daniel Cer, Jax Law, Eric Darve. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.

2021.

Introduction

While large-scale Transformer models like BERT and RoBERTa have revolutionized word-level natural language understanding, they often struggle to produce high-quality "sentence embeddings"—fixed-length vectors that capture the holistic semantic meaning of a sentence. Traditionally, obtaining effective sentence representations required expensive supervised learning on datasets like Natural Language Inference (NLI) or semi-structured data such as question-answer pairs.

However, labeled data is scarce for the vast majority of the world's languages. This paper addresses the challenge of learning universal sentence representations in a fully unsupervised manner, ensuring scalability across domains and over 100 languages without relying on human-annotated labels.

The CMLM Architecture

The authors introduce Conditional Masked Language Modeling (CMLM), an unsupervised objective that leverages the discourse structure of large text corpora. The core intuition is that adjacent sentences in a document typically share a semantic theme. By forcing the model to reconstruct a sentence based on the condensed representation of its neighbor, the model is incentivized to encode as much semantic information as possible into a single vector.

The CMLM architecture uses a sentence vector from a neighbor sentence as a bottleneck condition for the Masked Language Modeling (MLM) task.

The Bottleneck Mechanism

  1. Encoding: Given a pair of adjacent sentences ($s_1$ and $s_2$), the model processes $s_1$ through a Transformer encoder and applies average pooling to produce a single sentence vector $v$.
  2. Conditioning: The model then performs a standard Masked Language Model (MLM) task on $s_2$. Crucially, the prediction of masked tokens in $s_2$ is conditioned on the vector $v$ derived from $s_1$.
  3. Multiple Views: To capture diverse semantic aspects, $v$ is projected into $N$ different subspaces. This allows the model to attend to various features of the neighboring context when resolving ambiguities in the current sentence.
  4. Siamese Setup: Both sentences share the same Transformer weights, ensuring a consistent mapping across the embedding space.

Experimental Setup

The CMLM models were pre-trained on massive web crawls from Common Crawl, covering English and 113 additional languages. For multilingual variants, the authors incorporated bitext (parallel translation pairs) to align representations across different languages.

Evaluation was conducted across several rigorous benchmarks:

  • SentEval: The standard suite for English sentence embedding tasks (classification, similarity, etc.).
  • XEVAL: A novel benchmark introduced by the authors, translating SentEval into 14 languages to assess multilingual quality.
  • Tatoeba: A cross-lingual semantic search task requiring the model to find translation equivalents in a different language.
  • Zero-Shot Transfer: Testing the ability to train a classifier in English (e.g., Amazon Reviews) and deploy it directly on other languages.

Results and Analysis

CMLM demonstrates significant improvements over both unsupervised and supervised baselines. In English benchmarks, CMLM-Large achieved a state-of-the-art average score of 86.8 on SentEval, outperforming SBERT (supervised) and RoBERTa (unsupervised).

Performance comparison on SentEval benchmarks showing CMLM achieving state-of-the-art results compared to BERT-based and other popular models.

Multilingual and Cross-Lingual Performance

The model's performance on the Tatoeba cross-lingual search task was particularly notable, outperforming previous baselines by an average of 10% across 36 languages. In zero-shot sentiment classification, CMLM vectors provided >5% higher accuracy than established multilingual models like LASER or mUSE.

Removing Language Bias

A key insight from the study involves "Language Bias." Multilingual models often cluster embeddings by language rather than meaning. The authors found that Principal Component Removal (PCR)—stripping the first few dimensions of the embedding—effectively removes this language-identifying noise, further enhancing semantic alignment.

Discussion and Limitations

While CMLM provides a powerful tool for sentence-level tasks, it is computationally intensive, requiring significant TPU resources for pre-training. Furthermore, the authors note a trade-off: while CMLM is superior for semantic similarity and classification, it may be less effective for token-level tasks like Named Entity Recognition (NER) compared to standard MLM-based models. Additionally, while fine-tuning on NLI data improves classification performance, it can occasionally degrade performance in linear retrieval tasks, suggesting that the optimal representation may depend on the specific downstream application.

Summary updated

BibTeX
@inproceedings{yang2021universal,
  author = {Ziyi Yang and Yinfei Yang and Daniel Cer and Jax Law and Eric Darve},
  title = {{Universal Sentence Representation Learning with Conditional Masked Language Model}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=cmXcUkvz1oF},
}
Figure