A language model you can count
The probability of a sentence is the product of each word given everything before it, which is exact and impossible to estimate.
The n-gram assumption truncates that history to the last words, which makes the counting tractable and throws away everything further back.
The estimate is then just division: how often this pair appeared, over how often the first word appeared at all.
The counts explode and the data does not
A 50,000-word vocabulary has possible bigrams and trigrams.
No corpus contains even a fraction of them, so almost every count is zero, and a single zero makes the whole sentence probability zero.
That is not a rare edge case. It is the normal outcome for any sentence not in the training data, which is every sentence you care about.
Smoothing, which is the real subject
Add-alpha smoothing pretends every possible n-gram was seen times.
It is simple, it never returns zero, and it is badly wrong because it spreads mass uniformly over events that are not uniform.
Interpolation mixes the orders, so an unseen trigram falls back on the bigram and then on the unigram, with the weights fitted on held-out data.
Kneser-Ney, the best of the classical methods, changes what the fallback estimates: not how often a word occurs, but in how many different contexts it occurs.
That distinction is why it handles a word like Francisco correctly, which is frequent overall and almost never appears outside one phrase.
One model, in order
- Choose , usually 3 for text and 5 for speech.
- Count every n-gram and every prefix in the corpus.
- Estimate the conditional probabilities by division.
- Smooth them, so nothing is zero and the mass still sums to one.
- Score a new sentence by summing log probabilities rather than multiplying, to avoid underflow.
What it can and cannot do
A well-smoothed 5-gram model reaches a perplexity in the low hundreds on English news, which was the state of the art for two decades.
It is fast, interpretable and still used in keyboards, spell checkers and speech decoders where latency is measured in milliseconds.
Take the sentence "The man who grew up in Paris before moving abroad still speaks fluent French".
Its limit is structural. The word French depends on Paris, seven words back, and no fixed small enough to count is large enough to see it.
Neural language models replaced the lookup table with a learned function.
That function shares statistical strength between similar contexts, instead of treating every n-gram as unrelated to every other.