[Paper Review] Exposing the Implicit Energy Networks behind Masked Language Models via Metropolis--Hastings
This paper proposes a Metropolis–Hastings sampling framework to extract high-quality, unconditional and conditional text samples from masked language models (MLMs) by interpreting them as implicit energy-based models. By deriving two energy parametrizations from pretrained MLMs and using their masked conditionals as proposal distributions, the method enables valid MCMC sampling that outperforms prior undirected generation approaches in both machine translation and open-ended generation tasks.
While recent work has shown that scores from models trained by the ubiquitous masked language modeling (MLM) objective effectively discriminate probable from improbable sequences, it is still an open question if these MLMs specify a principled probability distribution over the space of possible sequences. In this paper, we interpret MLMs as energy-based sequence models and propose two energy parametrizations derivable from the trained MLMs. In order to draw samples correctly from these models, we develop a tractable sampling scheme based on the Metropolis--Hastings Monte Carlo algorithm. In our approach, samples are proposed from the same masked conditionals used for training the masked language models, and they are accepted or rejected based on their energy values according to the target distribution. We validate the effectiveness of the proposed parametrizations by exploring the quality of samples drawn from these energy-based models for both open-ended unconditional generation and a conditional generation task of machine translation. We theoretically and empirically justify our sampling algorithm by showing that the masked conditionals on their own do not yield a Markov chain whose stationary distribution is that of our target distribution, and our approach generates higher quality samples than other recently proposed undirected generation approaches (Wang et al., 2019, Ghazvininejad et al., 2019).
Motivation & Objective
- To establish a principled probabilistic interpretation of masked language models (MLMs) by interpreting them as implicit energy-based models.
- To develop two energy parametrizations derived from pretrained MLMs that assign scores to sequences, enabling probabilistic modeling.
- To design a tractable sampling scheme using Metropolis–Hastings with masked conditionals as proposal distributions, overcoming the limitations of ancestral and Gibbs sampling in bidirectional models.
- To empirically validate the quality of samples drawn from these energy models in both conditional (machine translation) and unconditional generation settings.
- To demonstrate that MLMs trained via standard objectives implicitly learn a global energy network, enabling valid sampling via MCMC.
Proposed method
- Derives two energy parametrizations—raw score and locally normalized energy—from the hidden representations of a pretrained MLM, using attention scores or logit outputs as energy scores.
- Uses the masked conditional distributions from the MLM as proposal distributions in a Metropolis–Hastings MCMC sampler, enabling sampling from the target energy-based distribution.
- Introduces a non-contiguous block-replacement proposal mechanism to improve mixing and convergence speed in the Markov chain.
- Employs temperature annealing to explore regions around the mode of the energy distribution, facilitating mode-finding for conditional generation.
- Validates sampling quality via BLEU scores in machine translation and human evaluation (coherence, fluency) in unconditional generation.
- Theoretical analysis shows that naive Gibbs sampling using masked conditionals is invalid, as they do not correspond to a proper joint distribution.
Experimental results
Research questions
- RQ1Can masked language models trained via the MLM objective be interpreted as implicit energy-based models that define a principled probability distribution over sequences?
- RQ2Do the masked conditionals used in MLM training form a valid Markov chain whose stationary distribution matches the target energy-based distribution?
- RQ3Can Metropolis–Hastings sampling with MLM conditionals as proposals generate higher-quality samples than existing undirected generation methods?
- RQ4How do different energy parametrizations (raw vs. normalized) affect sample quality in unconditional and conditional generation?
- RQ5Does annealing the target distribution improve sample quality and enable effective mode-finding in machine translation?
Key findings
- The proposed MH sampler with the raw energy parametrization achieves a BLEU score of 30.12 on the De-En test set and 30.86 on Ro-En, outperforming the mask-predict baseline and degenerate Gibbs sampling.
- On the machine translation task, the MH sampler with raw energy parametrization performs competitively with autoregressive models, achieving 30.12 BLEU on De-En and 30.86 on Ro-En.
- Human evaluation shows that samples from the MH sampler (especially with raw energy) achieve higher fluency (2.05) and coherence (2.05) than the degenerate Gibbs sampler (1.23 and 1.20, respectively) on BERT-base.
- Samples from the MH sampler have significantly lower GPT-2 perplexity (125.42 for BERT-base raw) than the degenerate Gibbs sampler (296.45), indicating higher fluency and plausibility.
- The acceptance rate of the MH sampler is higher under the raw energy parametrization than the normalized version, especially when the target distribution is annealed, correlating with better generation performance.
- The non-contiguous block-replacement proposal improves mixing and reduces sampling time, resulting in faster convergence and better sample diversity.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.