Residual Energy-Based Models for Text

Anton Bakhtin, Yuntian Deng, Sam Gross, Myle Ott, Marc'Aurelio Ranzato, Arthur Szlam

Abstract

Current large-scale auto-regressive language models display impressive fluency and can generate convincing text. In this work we start by asking the question: Can the generations of these models be reliably distinguished from real text by statistical discriminators? We find experimentally that the answer is affirmative when we have access to the training data for the model, and guardedly affirmative even if we do not. This suggests that the auto-regressive models can be improved by incorporating the (globally normalized) discriminators into the generative process. We give a formalism for this using the Energy-Based Model framework, and show that it indeed improves the results of the generative models, measured both in terms of perplexity and in terms of human evaluation.

Introduction

Most modern text generators, such as GPT, are locally normalized auto-regressive models. They generate text token-by-token, where each choice is conditioned only on the past. While successful, this approach suffers from three major flaws: exposure bias, label bias, and a lack of global coherence. Errors compound during generation because the model is never exposed to its own mistakes during training. Furthermore, local normalization prevents the model from "looking ahead" to ensure long-range consistency.

This paper introduces Residual Energy-Based Models (EBMs) for text generation. Unlike standard models, EBMs evaluate the quality of an entire sequence using a globally normalized energy function. By training an un-normalized energy function to "correct" the outputs of a standard pre-trained language model, the authors achieve superior performance in both perplexity and human-rated quality.

Methodology

The authors propose a "residual" approach to make EBMs practical for discrete text spaces:

  • Residual Formulation: The model is defined as $P_\theta(x) \propto P_{LM}(x) \exp(-E_\theta(x))$, where $P_{LM}$ is a fixed, pre-trained auto-regressive model, and $E_\theta$ is a learned energy function acting as a re-ranker.
  • Bi-directional Representations: The energy function uses bi-directional transformers (e.g., BiT), allowing the model to leverage both future and past context to score a sequence.
  • Noise Contrastive Estimation (NCE): Training uses NCE to avoid intractable global normalization. A binary classifier is trained to distinguish between human text and samples from the base $P_{LM}$. The log-odds of this classifier effectively become the energy function.
  • Importance Sampling: For generation, multiple candidates are sampled from the base $P_{LM}$, and the energy function is used to select the best one.

Experimental Results

The models were evaluated on two large-scale benchmarks: the Toronto Book Corpus and CC-News.

Perplexity and Performance

Residual EBMs consistently achieved lower estimated perplexity than strong auto-regressive baselines, including models with significantly more parameters. Notably, bi-directional energy functions (BiT) significantly outperformed uni-directional ones (UniT), confirming the advantage of global context.

Perplexity results on CC-News and Toronto Book Corpus across various models.

As shown in the table above, the JOINT BiT-LARGE* model achieves the best perplexity scores across both datasets, outperforming the BASE LM and BALM baselines significantly.

Human Evaluation

In side-by-side evaluations, human judges preferred EBM-generated text over base LM generations. The preference rates typically ranged from 56% to 60%, indicating a clear qualitative improvement. The EBM was also shown to produce fewer repetitive n-grams, more closely matching the distribution of real human text.

Human preference rates and statistical significance for various model comparisons.

Discussion and Limitations

While Residual EBMs offer clear benefits, they face a sampling bottleneck: the EBM can only select from sequences generated by the proposal distribution (the base LM). If the base LM fails to generate a specific plausible sequence, the EBM cannot recover it. Additionally, the computational cost of generating multiple candidates for importance sampling is higher than greedy decoding. Future work may explore applying this approach at a "chunk level" to generate longer, more coherent documents.

Summary updated

BibTeX
@article{bakhtin2021residual,
  author = {Anton Bakhtin and Yuntian Deng and Sam Gross and Myle Ott and Marc'Aurelio Ranzato and Arthur Szlam},
  title = {{Residual Energy-Based Models for Text}},
  journal = {J. Mach. Learn. Res.},
  year = {2021},
  url = {https://openreview.net/forum?id=IH748Q1myP},
}
Figure