Smoothing Techniques › The Zero Probability Problem

Michael BrenndoerferMarch 22, 20254 min read
Language AI HandbookAll chapters
Part 2 of 67Classical Text Representations
Chapter 9Smoothing Techniques › The Zero Probability Problem
Reading section 2 of 13 · The Zero Probability Problem · 4 minSection 2 of 13 · 4 min

Book contents

Section 2 of 13 · 4 min read

Smoothing Techniques › The Zero Probability ProblemOne section · Sections in this chapter2 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Before diving into solutions, let's develop a crisp understanding of why this problem is so severe and how pervasive it is.

Suppose you train a bigram model on 1 million words of newspaper text. Your model has learned P("president"∣"the")P(\text{"president"} \mid \text{"the"}), P("company"∣"the")P(\text{"company"} \mid \text{"the"}), and thousands of other bigrams. Now you want to evaluate the probability of a sentence containing the bigram "the aardvark." Unless your training corpus happened to discuss aardvarks, this bigram has count zero. MLE gives it probability zero.

The formal quantity at stake is the MLE bigram probability. To estimate how likely word wiw_i is given the preceding word wi−1w_{i-1}, MLE computes:

PMLE(wi∣wi−1)=C(wi−1,wi)C(wi−1)P_{\text{MLE}}(w_i \mid w_{i-1}) = \frac{C(w_{i-1}, w_i)}{C(w_{i-1})}

where:

  • C(wi−1,wi)C(w_{i-1}, w_i): the count of the bigram wi−1wiw_{i-1} w_i in the training corpus
  • C(wi−1)C(w_{i-1}): the count of the word wi−1w_{i-1} in the training corpus (the context)

When C(wi−1,wi)=0C(w_{i-1}, w_i) = 0, the probability is zero, regardless of how large the corpus is.

How bad is this in practice? A vocabulary of ∣V∣|V| words produces ∣V∣2|V|^2 possible bigrams and ∣V∣3|V|^3 possible trigrams. For a typical vocabulary of 50,000 words, that's 2.5 billion possible bigrams and 125 trillion possible trigrams. No training corpus of any realistic size will cover more than a tiny fraction of these. Zipf's Law compounds the problem: most words are rare, so most n-grams that do occur in language appear only once or twice even in large corpora. The distribution is extremely heavy-tailed, which means that even after collecting tens of millions of sentences, you'll still encounter enormous numbers of bigrams in real text that never appeared in your training data.

To make this concrete, consider what happens at the level of trigrams. A well-built bigram model might have coverage for most bigrams in common text. But a trigram model trained on even a large corpus will miss the vast majority of possible three-word sequences. This is the curse of dimensionality applied to discrete combinatorial spaces: the number of possible sequences grows exponentially in nn, but the amount of training data grows only linearly. The mismatch is permanent, no matter how much data you collect.

Held-Out Data

Evaluating a language model typically involves computing the probability of a held-out test set, text that was not used during training. Zero probabilities on the test set make the model unusable for evaluation (log-probability becomes negative infinity) and for any downstream application that assigns probabilities to text. Every practical deployment of an n-gram model therefore requires some form of smoothing.

Smoothing solves this by ensuring every n-gram gets a positive probability. The challenge is doing this in a principled way that doesn't distort the probability distribution too badly. A terrible smoothing method would assign equal probability to all unseen n-grams regardless of how plausible they are. A good one will allocate probability mass in proportion to evidence about how likely each word is to appear in a given context, even if that specific context was never observed.

The Conservation Constraint

One important constraint governs any valid smoothing scheme: the probabilities of all possible next words given a context must still sum to 1. This is the fundamental property that makes a conditional probability distribution valid.

If we add probability mass to unseen n-grams, we must subtract an equal amount from the seen ones. This is the "conservation" intuition behind smoothing: probability mass is neither created nor destroyed, only redistributed. The question is how to redistribute it wisely.

Most smoothing methods follow a two-step pattern. First, they apply a discount to reduce the probability assigned to seen n-grams. Second, they distribute the freed-up probability mass to unseen n-grams using some lower-order model as a guide. The choice of how much to discount and where to send the freed mass is what distinguishes one smoothing method from another.