TL;DR
Masked Language Models (MLMs) like BERT aren't just for fine-tuning; they can be powerful "out-of-the-box" sentence scorers. By using pseudo-log-likelihood (PLL) scores—calculated by masking tokens one by one—these bidirectional models consistently outperform autoregressive models like GPT-2 in rescoring speech and translation outputs, largely because they lack a restrictive left-to-right bias.
What Problem Does This Paper Address?
In the world of Natural Language Processing (NLP), we have two main types of language models. Autoregressive models (like GPT-2) are trained to predict the next word given the previous ones. This makes them "natural" scorers: you can easily calculate the probability of a whole sentence using the chain rule.
Masked Language Models (like BERT), however, are trained to predict a missing word using context from both its left and right. While this makes them incredibly good at understanding language, it makes them "handicapped" for scoring. Because they don't follow a simple sequence, they don't provide a mathematically "proper" probability for a whole sentence. Consequently, researchers usually only use them by fine-tuning them on specific labeled datasets.
This paper asks: Can we use pretrained MLMs to score sentences directly, and if so, are they better than traditional models?
Methods
The authors introduce a framework for evaluating MLMs without task-specific fine-tuning:
-
Pseudo-Log-Likelihood (PLL): To score a sentence $W$, they mask each token $w_t$ one at a time. The model predicts the probability of the original token given all other tokens in the sentence. The PLL is simply the sum of these log probabilities across all positions. To score a sentence, one creates copies with each token masked out. The log probability for each missing token is summed over copies to give the pseudo-log-likelihood score (PLL).
-
Pseudo-Perplexity (PPPL): They propose an MLM-equivalent to the standard "perplexity" metric, allowing for intrinsic evaluation of how well an MLM models a specific corpus.
- [MASK]less Scoring: Since masking every token is computationally expensive (requiring $N$ passes for a sentence of length $N$), the authors experimented with fine-tuning a "student" model. This model learns to predict the total PLL in a single inference pass by looking at the
[CLS]token.![We learn a linear map after the [CLS] token, supervised by the PLLs from the pretrained MLM.](https://media.lacuna.tiptreesystems.com/online_lacuna/prod/figures/63/9d/639db9cf8e0e24818aee9cb513b7ebe3510bb1e6437c153e9886ced36222557c.png)
- N-best Rescoring: They use these PLLs to re-rank the top hypotheses generated by Automatic Speech Recognition (ASR) and Neural Machine Translation (NMT) systems.
Datasets
The authors evaluated their approach across several domains:
- ASR: The LibriSpeech corpus (960 hours of audio).
- NMT: The WMT 2014 English-German dataset, the IWSLT '15 English-Vietnamese set, and several low-resource pairs from the TED Talks corpus (e.g., Galician, Slovak, and Arabic to/from English).
- Linguistic Acceptability: BLiMP (Benchmark of Linguistic Minimal Pairs), which contains 67k pairs of sentences that differ by only one grammatical feature (e.g., "The boy eats" vs. "The boy eat").
Key Insights and Ideas
-
The "First Word" Tax: In autoregressive models, the first word of a sentence is always extremely "expensive" (low probability) because there is zero context. As the sentence progresses, the model gets more confident. MLMs, by contrast, treat all positions more uniformly because every token has context from the rest of the sentence. Cross-entropy of wt | W<t versus context length (t-1) from GPT-2 models. Note the spike at the start. Cross-entropy of wt | W\t versus t from BERT. The scores are much flatter across the sentence.
-
Fluency vs. Adequacy: The authors found that GPT-2 often favors common, repeated word sequences (promoting fluency at the cost of meaning). BERT’s bidirectional view helps it reward "self-consistency," allowing rarer but correct words to persist if they fit the global context.
- Domain Adaptation Trumps Model Size: A smaller BERT model adapted to the specific target text (e.g., LibriSpeech transcripts) can outperform a massive, general-purpose RoBERTa model.
Key Results
-
ASR Improvements: On LibriSpeech, rescoring with RoBERTa-large reduced the Word Error Rate (WER) by 30% relative on the
test-cleanset compared to the baseline. WERs on LibriSpeech after rescoring. RoBERTa models consistently outperform GPT-2. -
Translation Gains: For low-resource NMT, rescoring provided gains of up to +1.7 BLEU points.
- Grammatical Superiority: On the BLiMP benchmark, MLMs achieved a new state-of-the-art in unsupervised accuracy. They were particularly effective at identifying complex grammatical "island effects" and NPI licensing, outperforming GPT-2 by over 10 percentage points in those categories.
Limitations and Future Work
- Inference Latency: The primary drawback of the standard PLL method is speed. Masking every token requires multiple passes through the model. While the "maskless" student model shows promise, it currently degrades performance slightly (+0.2-0.4 WER).
- Theoretical Foundations: While PLL works exceptionally well for ranking, it is not a "true" probability distribution (it doesn't sum to 1 over all possible strings). Further work is needed to bridge this gap for tasks like text generation.
- Broader Models: The authors suggest extending this work to other bidirectional architectures like XLNet and developing better document-level scoring metrics.
Summary updated