The Role of n-gram Smoothing in the Age of Neural Networks

Luca Malagutti, Andrius Buinovskij, Anej Svete, Clara Meister, Afra Amini, Ryan Cotterell

Abstract

For nearly three decades, language models derived from the $n$-gram assumption held the state of the art on the task. The key to their success lay in the application of various smoothing techniques that served to combat overfitting. However, when neural language models toppled $n$-gram models as the best performers, $n$-gram smoothing techniques became less relevant. Indeed, it would hardly be an understatement to suggest that the line of inquiry into $n$-gram smoothing techniques became dormant. This paper re-opens the role classical $n$-gram smoothing techniques may play in the age of neural language models. First, we draw a formal equivalence between label smoothing, a popular regularization technique for neural language models, and add-$\lambda$ smoothing. Second, we derive a generalized framework for converting any $n$-gram smoothing technique into a regularizer compatible with neural language models. Our empirical results find that our novel regularizers are comparable to and, indeed, sometimes outperform label smoothing on language modeling and machine translation.

1. Introduction

In the "pre-neural" era of Natural Language Processing, $n$-gram models were the standard. Their primary challenge was sparsity: the high probability that a model would encounter a sequence of words during testing that it had never seen during training, resulting in a zero-probability assignment. To mitigate this, researchers developed "smoothing" techniques—mathematical methods to redistribute probability mass from observed events to unobserved ones.

With the rise of neural language models (LMs), which utilize continuous embeddings to handle unseen contexts, the sparsity problem was largely addressed, and classical smoothing research went dormant. However, neural models still face the challenge of overfitting. Modern practitioners typically use label smoothing, a heuristic that prevents a model from becoming overconfident by pushing its predictions toward a uniform distribution. This paper bridges the gap between these two eras, demonstrating that classical smoothing logic can significantly enhance modern Transformer performance.

2. Theoretical Framework

The authors provide a theoretical bridge between count-based models and neural architectures through two primary contributions:

The paper proves a formal mathematical equivalence: applying standard label smoothing to an $n$-gram model is identical to applying add-$\lambda$ smoothing, one of the oldest and simplest $n$-gram techniques. This finding provides a rigorous theoretical grounding for a heuristic that has become ubiquitous in neural network training.

2.2 A Generalized Regularization Framework

Beyond simple add-$\lambda$, the authors propose a framework to "reverse-engineer" any classical smoothing technique into an additive regularizer $\mathcal{R}(\theta)$. By viewing smoothing as a transformation of an empirical distribution $p_D$ into a smoothed version $\tilde{p}_D$, they derive a regularizer that encourages the neural model to match the smoothed $n$-gram distribution. This allows sophisticated, context-aware techniques from the 1990s to be used as modern training objectives.

3. Experimental Setup

The researchers implemented regularizers based on four classic methods:

  • Good-Turing
  • Jelinek-Mercer (JM)
  • Katz
  • Kneser-Ney

These were evaluated on standard benchmarks including WikiText-2 (language modeling), IWSLT-14 (DE-EN), and WMT-14 (EN-DE) (machine translation).

4. Key Insights and Results

The experiments demonstrate that "old" logic remains highly effective for modern Transformers, primarily because these classical methods offer context-aware regularization. Unlike standard label smoothing, which pushes the model toward a uniform distribution regardless of the input, $n$-gram regularizers "nudge" the model based on the specific history of words it has just processed.

4.1 Performance in Language Modeling

On WikiText-2, the Jelinek-Mercer (JM) regularizer achieved a perplexity of 137.41, significantly outperforming both the unregularized baseline (147.12) and standard label smoothing (142.10). JM smoothing is particularly effective because it interpolates between higher-order and lower-order $n$-gram models, essentially teaching the neural model to fall back on shorter contexts when long-range context is unreliable.

4.2 Performance in Machine Translation

On the IWSLT-14 translation task, JM smoothing reached 33.67 BLEU, surpassing the baseline (32.86) and label smoothing (33.23). Across all tests, $n$-gram-based regularizers consistently matched or outperformed standard label smoothing, suggesting that the uniform distribution assumption used in modern heuristics is sub-optimal.

5. Limitations and Future Work

While effective, the framework faces challenges regarding scalability. Pre-calculating $n$-gram distributions has a space complexity of $O(|\Sigma|^n)$, which becomes expensive for very large vocabularies or high-order $n$-grams. Additionally, the most significant gains were observed on small-to-medium datasets; as data size increases, the relative impact of smoothing tends to diminish.

Future research may explore more complex methods like modified Kneser-Ney or the use of efficient data structures to scale these regularizers to much larger contexts, potentially integrating with projects like "Infini-gram."

6. Conclusion

This work revitalizes classical $n$-gram smoothing by reframing it as a data-centric regularization strategy for neural networks. By proving the link between label smoothing and add-$\lambda$ smoothing, the authors provide a path for incorporating decades of statistical NLP research into the modern Transformer-based pipeline.

Summary updated

BibTeX
@inproceedings{malagutti2024role,
  author = {Luca Malagutti and Andrius Buinovskij and Anej Svete and Clara Meister and Afra Amini and Ryan Cotterell},
  title = {{The Role of n-gram Smoothing in the Age of Neural Networks}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=YDwLL4rE8W},
}
Figure