Abstract
Pretrained masked language models (MLMs) require finetuning for most NLP tasks. Instead, we evaluate MLMs out of the box via their pseudo-log-likelihood scores (PLLs), which are computed by masking tokens one by one. We show that PLLs outperform scores from autoregressive language models like GPT-2 in a variety of tasks. By rescoring ASR and NMT hypotheses, RoBERTa reduces an end-to-end LibriSpeech model’s WER by 30% relative and adds up to +1.7 BLEU on state-of-the-art baselines for low-resource translation pairs, with further gains from domain adaptation. We attribute this success to PLL’s unsupervised expression of linguistic acceptability without a left-to-right bias, greatly improving on scores from GPT-2 (+10 points on island effects, NPI licensing in BLiMP). One can finetune MLMs to give scores without masking, enabling computation in a single inference pass. In all, PLLs and their associated pseudo-perplexities (PPPLs) enable plug-and-play use of the growing number of pretrained MLMs.
Introduction
In Natural Language Processing, language models are typically categorized as either autoregressive (e.g., GPT-2) or masked (e.g., BERT). Autoregressive models predict the next token based on previous context, allowing for straightforward probability calculation of a sequence. Masked Language Models (MLMs), however, are bidirectional, utilizing both preceding and succeeding context to predict a masked token. While MLMs excel at contextual understanding, they do not naturally provide a joint probability for a sentence. This paper introduces a method to leverage these powerful bidirectional representations for scoring and ranking tasks without task-specific fine-tuning.
Methodology: Pseudo-Log-Likelihood (PLL)
The authors propose Pseudo-Log-Likelihood (PLL) as a metric for scoring sentences with MLMs. Unlike autoregressive models that process a sentence in one pass, calculating a PLL involves masking each token in the sentence one at a time. For each masked position, the model predicts the probability of the original token given all other tokens in the sentence. The sum of these log probabilities constitutes the PLL score.
To mitigate the computational overhead of $O(n)$ passes per sentence, the researchers also developed Maskless Scoring. This technique uses distillation to train a simple linear layer on top of the [CLS] token, allowing the model to estimate the PLL in a single inference pass.
Key Results and Linguistic Acceptability
The effectiveness of PLL scoring was evaluated across Automatic Speech Recognition (ASR), Neural Machine Translation (NMT), and linguistic acceptability benchmarks.
In the BLiMP (Benchmark of Linguistic Minimal Pairs) dataset, which tests grammatical phenomena like NPI licensing and island effects, RoBERTa-large achieved a new state-of-the-art for unsupervised models. It outperformed GPT-2 by a significant margin, demonstrating that bidirectional context is crucial for capturing complex linguistic dependencies.
Further results include:
- ASR: Rescoring LibriSpeech hypotheses with RoBERTa-large led to a 30% relative reduction in Word Error Rate (WER).
- NMT: MLM rescoring improved translation quality by up to +1.7 BLEU points in low-resource settings.
- Domain Adaptation: Adapting even smaller BERT models to the target domain's text often yielded better results than using larger, general-purpose models.
Conclusion
Pseudo-log-likelihood scores enable the "out-of-the-box" use of MLMs for high-precision sentence scoring. By removing the left-to-right bias inherent in autoregressive models, PLLs provide a more stable and linguistically accurate measure of sentence fluency. While standard PLL calculation is computationally intensive, distillation methods like maskless scoring offer a path toward efficient, real-time application of these superior representations.
Summary updated