Notes

Laplace Smoothing (NLP)

Train an n-gram model on a million words and it will still meet a reasonable phrase it has never seen — then hand you a probability of zero, which wipes out the whole sentence containing it. Laplace smoothing is the oldest repair: pretend you saw everything once more than you did.

The mechanism
Also called add-one smoothing, it adds 1 to every count in the numerator and compensates by adding the vocabulary size V to the denominator, so the probabilities still sum to one. For a bigram the estimate becomes (count of the pair + 1) divided by (count of the first word + V). The generalisation — add-k, or Lidstone smoothing — adds a fraction instead of a whole count, which is gentler when the vocabulary is large.

Why it is a baseline rather than a solution

  • It is blunt: with a vocabulary of 50,000 words, add-one hands a vast share of the probability mass to the overwhelmingly many word pairs that were never observed and were never plausible.
  • It distorts what was observed: frequent bigrams are discounted far more heavily than Good-Turing or Kneser-Ney estimates justify.
  • It still earns its keep on small, dense count tables — notably the word-likelihood tables of a naive Bayes text classifier, where scikit-learn's alpha parameter is exactly this correction.

Why it matters
Laplace smoothing is where the central lesson of count-based modelling is easiest to see: a maximum-likelihood estimate of language is unusable because it declares the unobserved impossible. Every later method — backoff, interpolation, Good-Turing, Kneser-Ney — is a more careful answer to the same question of how much probability to reserve for what you have not seen.

Laplace smoothing, or add-one smoothing, removes zero probabilities from a count-based model by adding one to every n-gram count and the vocabulary size to the denominator, keeping the distribution normalised. It guarantees an unseen sequence a non-zero probability, which a maximum-likelihood estimate denies it. The correction is crude for large vocabularies — it over-rewards the unseen — so it survives as a baseline and inside naive Bayes classifiers rather than in serious language models.

Imagine judging a restaurant you have never visited and declaring that nobody could possibly eat there. That is the mistake a word-prediction system makes when it meets a phrase missing from the text it studied: it calls the phrase not unlikely but flat-out impossible, and the whole sentence collapses.

Laplace smoothing is the simplest fix. Pretend every possible word combination was seen one extra time, so nothing scores zero. It is rough and ready — it hands too much credit to combinations nobody would ever say — but it was the first solution of its kind, and it still works well enough inside simple tools like spam filters.