BERT has a Mouth, and It Must Speak: BERT as a Markov Random Field Language Model

Alex Wang, Kyunghyun Cho

Introduction

BERT (Bidirectional Encoder Representations from Transformers) has long been the gold standard for natural language understanding (NLU). Unlike its autoregressive counterparts like GPT, which generate text sequentially from left to right, BERT is trained using a Masked Language Modeling (MLM) objective. This bidirectional nature has historically relegated BERT to "read-only" tasks like classification or question answering. However, recent research demonstrates that BERT is actually a generative model in disguise—specifically, a Markov Random Field (MRF).

BERT as a Markov Random Field

The core insight of this work is the mathematical bridge between BERT's training objective and energy-based models. By treating a sequence of words as a fully connected graph where every word depends on every other word, the authors show that BERT’s MLM objective is equivalent to training an MRF using pseudo-log-likelihood.

To enable BERT to "speak," the researchers employed Gibbs sampling. Instead of the traditional left-to-right generation, this iterative process begins with a sequence of [MASK] tokens. The model then randomly selects positions to refine, predicting words based on the surrounding context until the sentence converges. This framework allows BERT to generate text that considers global dependencies rather than just preceding tokens.

Experimental Evaluation

The authors compared BERT-base and BERT-large against the original GPT model. All models were evaluated on the Toronto Book Corpus (TBC) and WikiText-103 (WT103) to ensure a fair architectural comparison.

Diversity vs. Fluency

A primary finding of this study is the significant trade-off between diversity and fluency. While autoregressive models like GPT are highly fluent, they often suffer from repetitiveness. In contrast, BERT's stochastic sampling process produces much more varied output.

Diversity metrics comparing BERT and GPT models. BERT shows significantly lower Self-BLEU scores, indicating higher generation diversity.

As shown in the diversity metrics, BERT models achieved Self-BLEU scores around 10, whereas GPT scored approximately 40. Lower Self-BLEU scores indicate that the generated sentences are less similar to one another, highlighting BERT's superior creative range.

Human Evaluation and the "Large" Paradox

While automated metrics like perplexity (PPL) favored GPT (154.29 vs. BERT-base's 279.10), human evaluations provided a more nuanced view of fluency. On a 4-point Likert scale, GPT led with a score of 2.80, followed closely by BERT-base at 2.65.

Human evaluation scores for sentence fluency across BERT-large, BERT-base, and GPT.

Interestingly, BERT-large exhibited a "paradox" in performance, scoring lower (2.37) than its smaller counterpart. The distribution of scores reveals that BERT-large is bimodal: it tends to produce either highly fluent sentences or completely nonsensical ones, whereas BERT-base maintains more consistent, mid-range quality.

Limitations and Future Directions

Despite its generative potential, using BERT as a language model presents several challenges:

  • Computational Cost: Gibbs sampling is slow, requiring multiple iterations compared to GPT's single-pass generation.
  • Fixed Constraints: The current method requires a pre-defined sentence length, lacking the natural stopping mechanism of autoregressive models.
  • Sampling Stability: BERT can occasionally become trapped in non-fluent modes of its distribution. The authors suggest that more advanced MCMC algorithms, like parallel tempering, might improve generation quality.

Conclusion

By re-interpreting BERT as an MRF, this research expands the utility of bidirectional models beyond discriminative tasks. While GPT remains the leader in pure fluency, BERT offers a powerful alternative for applications requiring high diversity and global context, proving that BERT indeed "has a mouth" and can be made to speak.

Summary updated

BibTeX
@inproceedings{wang2019bert,
  author = {Alex Wang and Kyunghyun Cho},
  title = {{BERT has a Mouth, and It Must Speak: BERT as a Markov Random Field Language Model}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
}
Figure