Mode recovery in neural autoregressive sequence modeling

Ilia Kulikov, Sean Welleck, Kyunghyun Cho

Abstract

Neural autoregressive models are prone to "pathological" behaviors, such as generating repetitive loops or unreasonably short sequences. This paper investigates whether these failures stem from the training data, the learning objective, or the decoding algorithm. We propose a "Learning Chain" framework and a new metric, Mode Recovery Cost ($O_k$), to track how the most likely sequences (modes) of a distribution are lost or distorted at each stage of the machine learning pipeline. Using a tractable synthetic testbed, we find that mode recovery is most challenging for semi-structured data—where models must balance rules and exceptions. Furthermore, we show that while model learning can sometimes "denoise" structured data, the decoding stage often introduces the final, most significant hurdle in recovering ground-truth modes.

Introduction

Modern NLP relies on neural autoregressive models that predict sequences token-by-token. Despite their success, these models often exhibit well-documented pathologies: infinite loops, hallucinations, and a bias toward empty outputs. Determining the root cause of these issues is difficult because the "ground truth" distribution of natural language is unknown. This work addresses this gap by defining a formal framework to localize mode loss across the entire learning pipeline.

The Mode Recovery Framework

We model the lifecycle of a sequence distribution as a four-stage Learning Chain:

  1. Ground-truth ($p^*$): The true underlying distribution of the universe.
  2. Empirical ($p_{emp}$): The distribution represented by a finite training dataset.
  3. Learned ($p_{model}$): The distribution captured by the trained neural network.
  4. Decoding-induced ($p_{\mathcal{F}}$): The distribution of sequences produced by search algorithms (e.g., Beam Search).

To quantify success, we introduce the Mode Recovery Cost ($O_k$). This metric measures the number of sequences one must sample from a "source" distribution (like the model) to find the top $k$ modes of a "target" distribution (like the ground truth). A high cost indicates that the target's modes have been deprioritized or lost in the source distribution.

Experimental Setup: A Tractable Testbed

To enable exact calculations, we utilize a synthetic testbed with a small vocabulary (7 tokens) and limited sequence length (10), creating a space of approximately 12 million possible sequences. We evaluate three types of ground-truth distributions:

  • Structured: Data generated by an LSTM, representing rule-based patterns.
  • Unstructured: Data where probabilities are random, representing noise or exceptions.
  • Semi-structured: A mixture of both, approximating the complexity of real-world data.

Results

The Impact of Data Structure on Learning

Our analysis reveals that the "semi-structured" case ($\alpha=0.3$) presents the greatest challenge. When data contains both strong patterns and random exceptions, the learning process itself introduces significant mode degradation. Interestingly, if the model architecture matches the data's structure (e.g., an LSTM learning structured data), the model can actually "denoise" the empirical distribution, becoming more efficient at recovering modes than the raw dataset it was trained on.

Figure 3: Log-ratio of mode recovery costs. A positive value indicates the model is more efficient at recovering ground-truth modes than the empirical dataset. The model excels at "denoising" structured data (alpha=1.0) but struggles significantly with semi-structured data (alpha=0.3).

Decoding and the Final Stage of Mode Loss

The final leak in the chain occurs during decoding. We compared the ability of Beam Search and Ancestral Sampling to recover the model's own modes. While both methods struggle as the number of modes ($k$) increases, Ancestral Sampling fails significantly more often than Beam Search across all data types. This suggests that even when a model successfully learns the modes, the choice of search algorithm can lead to their final loss in production.

Figure 6: Comparison of mode recovery during decoding. Beam search (left) is generally more effective at recovering the model's modes than ancestral sampling (right), though both show performance drops in the semi-structured case.

Conclusion

Mode recovery failures are cumulative. While data collection is the first point of failure, the learning process and decoding algorithms add further layers of distortion. Our results highlight that semi-structured data is particularly vulnerable to these failures, as models struggle to balance general rules with specific exceptions. Future work should explore how advanced training techniques, such as unlikelihood training or knowledge distillation, might mitigate these costs in large-scale real-world applications.

Summary updated

Abstract

Despite its wide use, recent studies have revealed unexpected and undesirable properties of neural autoregressive sequence models trained with maximum likelihood, such as an unreasonably high affinity to short sequences after training and to infinitely long sequences at decoding time. We propose to study these phenomena by investigating how the modes, or local maxima, of a distribution are maintained throughout the full learning chain of the ground-truth, empirical, learned and decoding-induced distributions, via the newly proposed mode recovery cost. We design a tractable testbed where we build three types of ground-truth distributions: (1) an LSTM based structured distribution, (2) an unstructured distribution where probability of a sequence does not depend on its content, and (3) a product of these two which we call a semi-structured distribution. Our study reveals both expected and unexpected findings. First, starting with data collection, mode recovery cost strongly relies on the ground-truth distribution and is most costly with the semi-structured distribution. Second, after learning, mode recovery cost from the ground-truth distribution may increase or decrease compared to data collection, with the largest cost degradation occurring with the semi-structured ground-truth distribution. Finally, the ability of the decoding-induced distribution to recover modes from the learned distribution is highly impacted by the choices made earlier in the learning chain. We conclude that future research must consider the entire learning chain in order to fully understand the potentials and perils and to further improve neural autoregressive sequence models.
BibTeX
@inproceedings{kulikov2021mode,
  author = {Ilia Kulikov and Sean Welleck and Kyunghyun Cho},
  title = {{Mode recovery in neural autoregressive sequence modeling}},
  booktitle = {SPNLP @ ACL},
  year = {2021},
  doi = {10.18653/v1/2021.spnlp-1.5},
}
Figure