Algorithm Search⌘K

Techniquecore

Absolute discounting

Also called absolute discount smoothing, interpolated absolute discounting.

Subtract a fixed discount D from every nonzero n-gram count and give the freed mass to the lower-order model, with D often set to N_1 / (N_1 + 2 N_2).

Absolute discounting is a way to fill the zeros of an n-gram language model by taking the same small amount DD, usually less than 1, from the count of every n-gram that was seen and giving the total to the estimate of a shorter history. It rests on a fact found in large text collections: an n-gram seen rr times in one half of a corpus is seen about r−0.75r - 0.75 times, on average, in a second half of the same size, nearly the same amount less for every r≥2r \ge 2. Unlike Laplace smoothing, it takes away a fixed amount, not a share; unlike Katz backoff, its discount does not depend on rr; and unlike Kneser-Ney smoothing, which is built on it, it uses the plain lower-order estimate.

In plain words

A count from a sample is a little too high for the things you saw, because you saw them partly by luck. The surprise is that the excess is about the same for things seen twice and things seen twenty times. So take the same small amount off every count you have. For a word seen after some context, its count drops by, say, three quarters.

The amounts you took away add up. Give that total to a simpler model that looks at less context, and let it share the total among all words, also the words never seen in this context. A context followed by many different words gives away more, because more counts were cut.

When it applies

It applies to any table of counts of the form "how often ww followed hh" where most counts are small and a simpler model of ww exists: word and character n-gram models, models of DNA or protein sequences, and the escape estimates of text compressors. It needs a closed vocabulary VV that holds every predicted token, with </s> and <unk>. The discount DD is one number per order, set from the counts of counts or tuned on held-out text.

The template

For a history hh with c(h)>0c(h) > 0, write T(h)=N1+(h ⋅)T(h) = N_{1+}(h \,\cdot) for the number of distinct words seen after hh and h′h' for hh without its first token. With a discount 0<D≤10 < D \le 1, the interpolated form is

Pabs(w∣h)=max⁡(c(hw)−D, 0)c(h)+D T(h)c(h) Pabs(w∣h′),P_{\mathrm{abs}}(w \mid h) = \frac{\max(c(h w) - D,\, 0)}{c(h)} + \frac{D \, T(h)}{c(h)} \, P_{\mathrm{abs}}(w \mid h'),

and Pabs(w∣h)=Pabs(w∣h′)P_{\mathrm{abs}}(w \mid h) = P_{\mathrm{abs}}(w \mid h') when c(h)=0c(h) = 0. The recursion ends at the unigrams, which are interpolated with the uniform distribution 1/∣V∣1/|V| in the same way. Each seen n-gram gives up exactly DD, so the first terms sum to 1−DT(h)/c(h)1 - D T(h)/c(h), and the lower order gets exactly the rest. Since c(h)≥T(h)c(h) \ge T(h) and D≤1D \le 1, the weight DT(h)/c(h)D T(h)/c(h) lies in (0,1](0, 1].

Ney, Essen and Kneser (1994) estimated the discount of each order from the numbers N1N_1 and N2N_2 of n-grams seen once and twice:

D=N1N1+2N2.D = \frac{N_1}{N_1 + 2 N_2}.

It comes from leaving one n-gram out at a time and maximizing the likelihood of the left-out n-grams; the formula is an approximation to that optimum that is easy to compute.

The backoff form uses the first term alone for seen words, and gives the freed mass DT(h)/c(h)D T(h)/c(h) only to the unseen words, in proportion to the lower order and normalized as in Katz backoff.

Classic examples

A bigram model. Train on "a b", "a c" and "b c", padded with <s> and </s>. There are 9 predicted tokens and 7 bigram types: <s> a and c </s> twice each, and <s> b, a b, a c, b c and b </s> once each. So N1=5N_1 = 5, N2=2N_2 = 2 and D=5/9D = 5/9. For a simple example, let the lower order be the unigram estimate c(w)/9c(w)/9: a, b and c get 2/92/9 and </s> gets 3/93/9. After <s>, with c=3c = 3 and T=2T = 2, the freed mass is (5/9)⋅2/3=10/27(5/9) \cdot 2/3 = 10/27. The rows give P(w∣h)P(w \mid h):

history hh ww = </s> ww = a ww = b ww = c
<s> 10/81 137/243 56/243 20/243
a 5/27 10/81 28/81 28/81
b 11/27 10/81 10/81 28/81
c 22/27 5/81 5/81 5/81

For example, P(a∣⟨s⟩)=(2−5/9)/3+(10/27)(2/9)=137/243P(a \mid \langle s \rangle) = (2 - 5/9)/3 + (10/27)(2/9) = 137/243. The history c was followed only by </s>, so it frees only D⋅1/2=5/18D \cdot 1/2 = 5/18 of its mass. Each row sums to 1.

Kneser-Ney smoothing. Kneser-Ney smoothing is interpolated absolute discounting with one change: the lower order counts the number of distinct contexts of a word, not its frequency. On the same corpus with D=3/4D = 3/4, it gives P(a∣⟨s⟩)=41/84P(a \mid \langle s \rangle) = 41/84.

Good-Turing as a near-constant discount. For English bigrams, Church and Gale (1991) found that the Good-Turing adjusted counts satisfy r−r∗≈0.75r - r^* \approx 0.75 for r≥2r \ge 2. Absolute discounting uses this constant directly, which avoids the noise of the NrN_r at large rr.

Variations

  • Several discounts. Modified Kneser-Ney smoothing uses three discounts, D1D_1, D2D_2 and D3+D_{3+}, for the counts 1, 2 and 3 or more, set from N1N_1 to N4N_4. The freed mass is then (D1N1(h⋅)+D2N2(h⋅)+D3+N3+(h⋅))/c(h)(D_1 N_1(h \cdot) + D_2 N_2(h \cdot) + D_{3+} N_{3+}(h \cdot))/c(h).
  • Tuned discounts. Choose DD for each order to minimize the perplexity of held-out text, by a line search.
  • Backoff instead of interpolation. Use the discounted count alone for seen words and normalize the lower order over the unseen words. The two forms give different numbers, so say which one a result uses.
  • Discounts per history count. Let DD depend on a bucket of c(h)c(h), in the spirit of deleted interpolation.

Pitfalls

  • DD above 1. A count of 1 cannot give up more than 1. With D>1D > 1 the clipped term max⁡(c−D,0)\max(c - D, 0) frees less than DD per n-gram, and the rows no longer sum to 1. Keep D≤1D \le 1, or free min⁡(c(hw),D)\min(c(h w), D) per n-gram and use that total.
  • No n-gram seen twice. If N2=0N_2 = 0, the formula gives D=1D = 1, so the n-grams seen once get nothing from their own count. Check the counts of counts on small data.
  • Unseen histories. If c(h)=0c(h) = 0, the template has 0/00/0. Use the lower order directly.
  • The lower order. The plain lower order gives a word like "Francisco", common but only after "San", a high probability after every history. Kneser-Ney smoothing fixes this with continuation counts.
  • One DD per order. The n-grams of each order have their own N1N_1 and N2N_2, so each order gets its own discount.

Exercises

  1. Show that the row of a history hh with c(h)>0c(h) > 0 sums to 1 when 0<D≤10 < D \le 1 and the lower order is a distribution on VV.
  2. In the example above, compute P(c∣a)P(c \mid a) step by step and check the value 28/8128/81.
  3. A model has N1=2 000 000N_1 = 2\,000\,000 bigram types seen once and N2=600 000N_2 = 600\,000 seen twice. Compute DD. How much mass does a history seen 100 times with 40 different followers give to the lower order?
  4. Show that D=N1/(N1+2N2)D = N_1/(N_1 + 2N_2) always lies in (0,1](0, 1] when N1>0N_1 > 0, and find when it equals 1.
  5. Write the backoff form for a bigram model and give the backoff weight α(h)\alpha(h) that makes each row sum to 1.

References

  1. Ney, Essen and Kneser 1994, absolute discounting with interpolation and with backoff, and the estimate of the discount from the counts of counts by leaving one out
  2. Stanley F. Chen and Joshua Goodman, An empirical study of smoothing techniques for language modeling, Computer Speech and Language 13(4), 1999, pages 359 to 394, interpolated absolute discounting, the discount D = N_1/(N_1 + 2 N_2), and its relation to Kneser-Ney smoothing
  3. Church and Gale 1991, the measurement that held-out counts of English bigrams are close to the training counts minus a constant
  4. Daniel Jurafsky and James H. Martin, Speech and Language Processing, third edition draft, chapter N-gram Language Models (draft of January 2026), absolute discounting and Kneser-Ney smoothing

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples