Distributionally Robust Language Modeling

Yonatan Oren, Shiori Sagawa, Tatsunori B. Hashimoto, Percy Liang

Standard language models (LMs) are typically trained using Maximum Likelihood Estimation (MLE), an objective that minimizes average loss across a training corpus. While effective for general-purpose modeling, this "averaging" approach often fails on niche topics or minority subpopulations. This paper introduces Topic CVaR, a training framework that leverages distributionally robust optimization (DRO) to ensure models perform reliably across all topics, even those underrepresented in the training data.

The Problem with Average-Case Optimization

When training large-scale LMs, researchers often combine heterogeneous datasets—such as news articles, Wikipedia, and product reviews—into a single massive pile. Because MLE prioritizes lowering the total average loss, the model naturally favors the most frequent data types.

Conceptual comparison of standard training (MLE) vs. robust modeling. MLE fits the majority peak (news) while ignoring the minority (reviews); the robust approach balances both.

For example, if a training set is 90% news and 10% restaurant reviews, the model will optimize for news at the expense of reviews. This leads to a phenomenon known as subpopulation shift. Surprisingly, the authors demonstrate that adding more data can sometimes degrade performance: a model trained on a mixture of 10% Yelp reviews and 90% news performs significantly worse on reviews (perplexity of 43) than a model trained exclusively on that 10% of Yelp data (perplexity of 32). The goal of this work is to create a single model robust enough to handle any specific topic within its training data without requiring niche fine-tuning.

Methodology: From Sentences to Topics

The authors propose Topic CVaR (Conditional Value at Risk), which builds on the framework of Distributionally Robust Optimization (DRO). The core innovation lies in how the model identifies what to be robust against.

1. Identifying Latent Topics

Standard DRO often operates at the sentence level (Sentence CVaR). However, the authors find that sentence-level robustness is counterproductive; it forces the model to "optimize" for ungrammatical or nonsensical sentences because they naturally have the highest loss. To solve this, they use Latent Dirichlet Allocation (LDA) to cluster training data into meaningful latent topics.

Comparison of probability distributions under different objectives. Sentence CVaR focuses on noise (ungrammatical sentences), while Topic CVaR balances probability across meaningful sentence categories.

2. The Uncertainty Set and Baselined Loss

The method defines a set of potential test distributions that are mixtures of these latent topics. The training objective is to minimize the loss on the worst-performing mixture.

Crucially, they introduce a baselined loss function. Standard log-loss is biased toward high-entropy topics (like complex news) which are inherently harder to predict. By comparing the model's performance against a simple bigram baseline, the model is forced to focus on topics where it is performing poorly relative to what is possible, rather than just focusing on topics that are naturally difficult.

3. Online Optimization

Training is framed as a two-player minimax game. One player (the model) tries to minimize loss, while an "adversary" dynamically upweights the topics where the model is currently struggling most.

Key Results and Insights

The researchers evaluated Topic CVaR using the Yelp Open Dataset (reviews), the One Billion Word Benchmark (news), and the TripAdvisor dataset (OOD hotel reviews).

  • Significant Perplexity Gains: On a mixture of 10% Yelp and 90% News, Topic CVaR achieved a 5.5 point reduction in perplexity on Yelp reviews compared to standard MLE.
  • Out-of-Distribution (OOD) Robustness: When tested on TripAdvisor hotel reviews—data not seen during training—Topic CVaR provided a 4-point perplexity reduction over MLE, suggesting the learned robustness generalizes to similar but distinct domains.
  • Oracle-level Performance: The model performed nearly as well as an "Oracle" model provided with ground-truth topic labels, validating that unsupervised LDA clustering is sufficient for identifying robust sub-structures.

Limitations and Future Outlook

While Topic CVaR offers a path toward more equitable and robust LMs, it introduces new challenges. The method is sensitive to the hyperparameter $\alpha$ (which controls the concentration of the worst-case subpopulation) and relies on the quality of the initial topic clustering. Additionally, the minimax optimization and baseline estimations add computational overhead compared to simple MLE. Future work will involve scaling these robust objectives to massive Transformer-based models and exploring more sophisticated embedding-based clustering techniques.

Summary updated

BibTeX
@inproceedings{oren2019distributionally,
  author = {Yonatan Oren and Shiori Sagawa and Tatsunori B. Hashimoto and Percy Liang},
  title = {{Distributionally Robust Language Modeling}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2019},
  url = {https://openreview.net/forum?id=dIEz92O_WB_},
}
Figure