This NLP & Speech concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
NLP & Speech
Smoothing: Laplace and Kneser-Ney
See why add-one smoothing is only the first repair, then predict how Kneser-Ney uses continuation contexts to allocate backoff mass.
Concept Structure
Smoothing: Laplace and Kneser-Ney
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
2 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
An n-gram table can look confident for the wrong reason: it has never seen many perfectly reasonable events.
If the training corpus contains new york and new models but never new san, maximum likelihood gives
san after new probability zero. One unseen transition can make a whole sentence score zero.
Laplace smoothing is the first repair. Add one imaginary count to every possible next word:
- observed words lose some probability mass
- unseen words no longer get zero
- every unseen word gets the same gift
That last point is why add-one is usually a teaching smoother, not the final answer.
Kneser-Ney asks a sharper question: "If I need to back off, which words have shown they can follow many different histories?"
In a tiny corpus, francisco may appear often, but only after san. The word york may appear after new, old, and near. Kneser-Ney treats that continuation diversity as evidence. When probability mass has to be reserved for backoff, it gives more of that mass to words that have appeared in more distinct left contexts.
Source spine: Jurafsky and Martin, SLP3 Chapter 3 and Appendix C; Chen and Goodman, An Empirical Study of Smoothing Techniques for Language Modeling.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a context, be the next word, and be the count of that bigram. The maximum-likelihood estimate is:
where
If , then .
Laplace smoothing with pseudo-count uses:
It repairs zero probability, but it does not ask whether an unseen word is a plausible continuation. Every vocabulary item receives the same pseudo-count.
Interpolated bigram Kneser-Ney uses a discount on observed counts and sends the reserved mass to a continuation distribution:
The reserved mass is:
Here is the number of distinct next words observed after .
The continuation probability is:
counts how many distinct left contexts have been seen before . counts distinct bigram types overall.
This page uses the single-discount bigram form because it is inspectable. Production n-gram language models often use modified Kneser-Ney with multiple discounts and recursive higher-order interpolation.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
This small script compares MLE, Laplace, and interpolated Kneser-Ney on the same context.
pairs = {
("new", "york"): 1,
("new", "models"): 1,
("old", "york"): 1,
("near", "york"): 1,
("old", "san"): 1,
("near", "san"): 1,
("san", "francisco"): 3,
("smart", "models"): 1,
}
candidates = ["york", "models", "san", "francisco"]
context = "new"
D = 0.75
def count(h, w):
return pairs.get((h, w), 0)
def total(h):
return sum(n for (left, _), n in pairs.items() if left == h)
def histories(w):
return {left for (left, right), n in pairs.items() if right == w and n > 0}
V = len(candidates)
T = total(context)
types_after_context = sum(1 for w in candidates if count(context, w) > 0)
bigram_types = sum(1 for n in pairs.values() if n > 0)
reserved = D * types_after_context / T
for w in candidates:
mle = count(context, w) / T
laplace = (count(context, w) + 1) / (T + V)
continuation = len(histories(w)) / bigram_types
kn = max(count(context, w) - D, 0) / T + reserved * continuation
print(f"{w:10s} MLE={mle:.3f} Laplace={laplace:.3f} KN={kn:.3f}")
The important comparison is not just "zero or nonzero." It is whether the smoother has a reason to prefer one unseen continuation over another.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Prediction check: inspect the tiny bigram corpus, then predict which smoothing method separates york from models after new and which unseen candidate receives more Kneser-Ney backoff mass before revealing the probability table.
The lab hides the final probabilities, reserved mass, continuation counts, and explanation until you commit. The goal is to feel why add-one is a blunt repair and why Kneser-Ney changes the meaning of a good backoff distribution.
Live Concept Demo
Explore Smoothing: Laplace and Kneser-Ney
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Smoothing: Laplace and Kneser-Ney should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
See why add-one smoothing is only the first repair, then predict how Kneser-Ney uses continuation contexts to allocate backoff mass.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Smoothing: Laplace and Kneser-Ney should make visible.
Visual Inquiry
Make the image answer a mathematical question
See why add-one smoothing is only the first repair, then predict how Kneser-Ney uses continuation contexts to allocate backoff mass.
Which visible object should carry the first intuition?
Pick the cue that should make Smoothing: Laplace and Kneser-Ney easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Source for n-gram maximum-likelihood estimates, zero-probability sparsity, add-one smoothing as a simple repair, interpolation, backoff, and perplexity framing.
Open sourceSource for absolute discounting, Kneser-Ney continuation probability, and the intuition that lower-order probability should depend on how many contexts a word follows.
Open sourcePrimary comparative source for smoothing methods, including the empirical strength of Kneser-Ney and modified Kneser-Ney style estimators.
Open sourceACL Anthology record for the conference version of the smoothing study; useful as a stable bibliographic anchor for Kneser-Ney comparisons.
Open sourceClaim Review
See why add-one smoothing is only the first repair, then predict how Kneser-Ney uses continuation contexts to allocate backoff mass.
Claims without a substantive review badge still need exact source-support review.
jurafsky-martin-slp3-ngram, jurafsky-martin-slp3-appendix-c-smoothing, chen-goodman-1998-smoothing, chen-goodman-1996-kneser-ney
Use equations, runnable code, and demos to check whether the source support is operational.
SLP3 Chapter 3 supports the MLE zero-probability failure, add-one smoothing, and the role of smoothing in perplexity evaluation. SLP3 Appendix C and Chen-Goodman support absolute discounting, interpolation/backoff, Kneser-Ney continuation counts, and the empirical importance of Kneser-Ney variants.
Sources: Speech and Language Processing, Chapter 3: N-gram Language Models, Speech and Language Processing, Appendix C: Smoothing, An Empirical Study of Smoothing Techniques for Language Modeling, An Empirical Study of Smoothing Techniques for Language ModelingThe page implements a tiny single-discount interpolated bigram Kneser-Ney example. It is not a full modified Kneser-Ney implementation, does not estimate discounts from held-out data, and does not claim count smoothing is how neural LLMs allocate probability.A bounded review summary is present; still check caveats and exact reference scope.Checked SLP3 Chapter 3 and Appendix C plus Chen-Goodman smoothing sources. Built a hand-computable corpus where MLE and Laplace tie two observed candidates, while Kneser-Ney breaks the tie through continuation diversity and allocates unseen mass by distinct left contexts. GPT Pro/Oracle critique remains unavailable because 127.0.0.1:51672 is closed.
Reviewer: codex-local-primary-source-audit; reviewed 2026-07-03Source support candidates
book 2026Speech and Language Processing, Chapter 3: N-gram Language ModelsSource for n-gram maximum-likelihood estimates, zero-probability sparsity, add-one smoothing as a simple repair, interpolation, backoff, and perplexity framing.
book 2025Speech and Language Processing, Appendix C: SmoothingSource for absolute discounting, Kneser-Ney continuation probability, and the intuition that lower-order probability should depend on how many contexts a word follows.
paper 1998An Empirical Study of Smoothing Techniques for Language ModelingPrimary comparative source for smoothing methods, including the empirical strength of Kneser-Ney and modified Kneser-Ney style estimators.
paper 1996An Empirical Study of Smoothing Techniques for Language ModelingACL Anthology record for the conference version of the smoothing study; useful as a stable bibliographic anchor for Kneser-Ney comparisons.
Practice Loop
Try the idea before it explains itself
See why add-one smoothing is only the first repair, then predict how Kneser-Ney uses continuation contexts to allocate backoff mass.
Before touching the demo, predict one visible change that should happen in Smoothing: Laplace and Kneser-Ney.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Smoothing: Laplace and Kneser-Ney
What is the smallest example that makes Smoothing: Laplace and Kneser-Ney click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Smoothing: Laplace and Kneser-Ney Selected item key: recorded for copy. Context: NLP & Speech Page anchor: recorded for copy. Open question: What is the smallest example that makes Smoothing: Laplace and Kneser-Ney click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/nlp-speech/smoothing-laplace-kneser-ney
concept:nlp-speech/smoothing-laplace-kneser-ney