Majid Al-RaimiReference sheet

ICS 582Lecture 03Reference

Reference sheet

N-gram language models compressed onto one page: the definitions, formulas and numbers to have in your head before a quiz or exam.

What a language model is

A language model gives a probability distribution over the next word given a history, which by the chain rule is also a probability for every whole sentence. In applications another component proposes candidates and the LM ranks them by fluency. Part 01: Why predict words

P(wt∣w<t) for every wt∈V,∑w∈VP(w∣h)=1\begin{gathered} P(w_t \mid w_{<t}) \ \text{for every } w_t \in V, \\ \sum_{w \in V} P(w \mid h) = 1 \end{gathered}
One history, one distribution over the whole vocabulary
S^=arg⁡max⁡S Pr⁡(S) Pr⁡(T∣S)\hat{S} = \arg\max_{S}\ \Pr(S)\, \Pr(T \mid S)
Noisy channel for MT (Brown et al. 1990): language model times translation model
ApplicationCandidates fromLM decidesExample
Spelling correctionVariants of the typed wordsWhich variant gives the more probable sentenceTheir are two midterms
Speech recognitionThe acoustic modelWhich sound-alike transcription is fluentback soonish / bassoon dish
Machine translationThe translation modelWhich faithful candidate is well formedPr(S) Pr(T|S)
AAC and keyboardsThe vocabulary or the partial wordThe top-k menu, ranked by probabilityThe quick bro → brown
Candidates from elsewhere, ranking from the LM
AspectCount-based (n-gram)Neural
How P(w | h) is estimatedRelative frequency of the exact n-gram, then smoothedA learned function of continuous word vectors
ParametersOne per observed n-gram; the table grows as |V|^nFixed by network size, shared across contexts
GeneralizationOnly across identical word sequencesAcross similar words: cat transfers to dog
Context1 to 4 previous words in practiceHundreds to many thousands of tokens
Gboard 20185-gram FST, 13.0% top-1 recallCIFG RNN, 16.4% top-1 recall
Count-based against neural language models

Chain rule and the Markov assumption

Counting P(w | h) directly fails because histories grow as V^k. The chain rule is exact; the Markov assumption keeps only the last N - 1 words. Part 02: Chain rule and Markov

P(w1:n)=∏k=1nP(wk∣w1:k−1)P(w_{1:n}) = \prod_{k=1}^{n} P(w_k \mid w_{1:k-1})
Chain rule (SLP3 Eq. 3.4), exact
P(wn∣w1:n−1)≈P(wn∣wn−N+1:n−1)P(w_n \mid w_{1:n-1}) \approx P(w_n \mid w_{n-N+1:n-1})
Markov assumption for an N-gram model (SLP3 Eq. 3.8)
P(w1:n)≈∏k=1nP(wk∣wk−1),w0=⟨s⟩, plus P(⟨/s⟩∣wn)\begin{gathered} P(w_{1:n}) \approx \prod_{k=1}^{n} P(w_k \mid w_{k-1}), \\ w_0 = \langle s\rangle,\ \text{plus } P(\langle /s\rangle \mid w_n) \end{gathered}
Bigram sentence probability (SLP3 Eq. 3.9)
OrderContext wordsFactorPossible contextsCaptures
Unigram0P(w_k)1Frequency only, a bag of words
Bigram1P(w_k | w_(k-1))10^4Local syntax between neighbours
Trigram2P(w_k | w_(k-2), w_(k-1))10^8Short phrases read fluently
Model order against context and possible contexts (V = 10^4)
  • A sentence of L tokens has L - n + 1 n-grams of order n.
  • A trigram pads with <s> <s>; order N pads with N - 1 start tokens.
  • </s> turns one distribution per sentence length into one distribution over all sentences.
  • Markov's 1913 Onegin study (20,000 letters) was the first bigram model.

Maximum likelihood estimation

Count, then normalize by the history count so each conditional row sums to 1. Dividing by the total number of bigrams would give a joint probability instead. Part 03: MLE estimation

P(wn∣wn−1)=C(wn−1 wn)C(wn−1)P(w_n \mid w_{n-1}) = \frac{C(w_{n-1}\, w_n)}{C(w_{n-1})}
Bigram MLE (SLP3 Eq. 3.11)
P(wn∣wn−N+1:n−1)=C(wn−N+1:n−1  wn)C(wn−N+1:n−1)\begin{aligned} &P(w_n \mid w_{n-N+1:n-1}) \\ &\quad = \frac{C(w_{n-N+1:n-1}\; w_n)}{C(w_{n-N+1:n-1})} \end{aligned}
General N-gram MLE (SLP3 Eq. 3.12): the n-gram over its N - 1 word prefix
p1×p2×⋯×pk=exp⁡(∑ilog⁡pi)p_1 \times p_2 \times \cdots \times p_k = \exp\Big(\sum_i \log p_i\Big)
Work in log space to avoid underflow (SLP3 Eq. 3.13)
HistoryC(history)MLE estimates
<s>3P(I | <s>) = 2/3, P(Sam | <s>) = 1/3
I3P(am | I) = 2/3, P(do | I) = 1/3
am2P(Sam | am) = 1/2, P(</s> | am) = 1/2
Sam2P(</s> | Sam) = 1/2, P(I | Sam) = 1/2
I am Sam toy corpus, one row per history
EstimateBigram countRow word countProbability
P(want | i)82725330.33
P(to | want)6089270.66
P(eat | to)68624170.28
P(food | chinese)821580.52
P(lunch | eat)427460.056
P(i | want)29270.0022
BeRP (9332 sentences, V = 1446): count over row count

Worked results

I am Sam
P(<s> I am Sam </s>) = 2/3 × 2/3 × 1/2 × 1/2 = 1/9
Trigram
P(Sam | I am) = 1/2, P(do | <s> I) = 1/2
BeRP sentence
P(<s> i want english food </s>) = 0.25 × 0.33 × 0.0011 × 0.5 × 0.68 ≈ 0.000031
In logs
ln P = -10.386, log10 P = -4.511, log2 P = -14.984
Sparsity
32 of 64 cells in the hand-picked BeRP slice are zero
Underflow
0.1^400 prints 0.0; the smallest normal double is 2.2 x 10^-308

Evaluation and perplexity

Training set counts, dev set tunes, test set is run once. Perplexity is the inverse test probability normalized by length: lower is better. Part 04: Perplexity

PP(W)=P(w1…wN)−1N=∏i=1N1P(wi∣w1…wi−1)N\begin{aligned} \mathrm{PP}(W) &= P(w_1 \ldots w_N)^{-\frac{1}{N}} \\ &= \sqrt[N]{\prod_{i=1}^{N} \frac{1}{P(w_i \mid w_1 \ldots w_{i-1})}} \end{aligned}
Perplexity: geometric mean of inverse next-word probabilities
PP(W)=2−1N∑i=1Nlog⁡2P(wi∣w1…wi−1)\mathrm{PP}(W) = 2^{-\frac{1}{N}\sum_{i=1}^{N} \log_2 P(w_i \mid w_1 \ldots w_{i-1})}
The same in log space; one zero makes PP infinite
ExtrinsicIntrinsic
What is measuredThe whole application with the LM plugged inThe LM alone, on held-out text
MetricWER for ASR, BLEU or COMET for MTPerplexity
CostA full end-to-end run per candidateOne pass over the test set
UseFinal decisions and claimed gainsFast iteration over many variants
Extrinsic against intrinsic evaluation
ModelPrevious wordsTest perplexity
Unigram0962
Bigram1170
Trigram2109
WSJ, 38M training and 1.5M test words
ModelTest setP(T)Perplexity
A: uniform, 1/3 eachany 5 words(1/3)^5 ≈ 0.00413
B: red 0.8, blue 0.1, green 0.1red red red red blue0.8^4 × 0.1 = 0.04096≈ 1.89
B: red 0.8, blue 0.1, green 0.1blue blue blue blue blue0.1^5 = 0.0000110
Perplexity as weighted branching factor: the 3-color language

Sampling

Sampling draws sentences in proportion to their probability: a window into what the model learned, not a metric. Part 05: Sampling

w=wk such that F(wk−1)≤u<F(wk),F(wk)=∑j≤kP(wj), u∼U[0,1)\begin{gathered} w = w_k \ \text{such that } \\ F(w_{k-1}) \le u < F(w_k), \\ F(w_k) = \sum_{j \le k} P(w_j),\ u \sim \mathcal{U}[0,1) \end{gathered}
Unigram sampling by cumulative intervals
wi∼P(wi∣wi−N+1:i−1),start at ⟨s⟩, stop when wi=⟨/s⟩\begin{gathered} w_i \sim P(w_i \mid w_{i-N+1:i-1}), \\ \text{start at } \langle s\rangle,\ \text{stop when } w_i = \langle /s\rangle \end{gathered}
The n-gram sampling loop; the sentence probability is the product of the drawn conditionals
GreedySampling
Choice ruleargmax P(w | context)w ~ P(w | context)
DeterministicYes: same context, same wordNo: each run draws a fresh u
Failure modeBland, loops and repetitionOccasional nonsense from the tail
UseClosed tasks with one right answerOpen generation and diagnosing a model
Greedy decoding against random sampling
OrderWhat it shows
UnigramReal words, no order at all
BigramEach adjacent pair plausible, the sentence goes nowhere
TrigramPhrases hold for three or four words
4-gramFluent because copied: It cannot be but so is from King John
What Shakespeare samples show by order (SLP3 Fig. 3.4)
  • Slide 44: 0.66 and 0.99 are cumulative positions, not probabilities.
  • Interval width is the probability: with ticks 0.06, 0.09, 0.11, u = 0.10 emits "a" (width 0.02).
  • After deep learning the walkthrough draws "," (0.05) over models (0.06): sampling is not argmax.
  • The context is a sliding window: the oldest word leaves the context but stays in the output.

Generalization, zeros and add-k

Higher order fits training data better and copies it on small corpora; models encode their genre. One unseen n-gram makes the test probability zero and perplexity undefined. Part 06: Generalization and zeros

PLaplace(wi)=ci+1N+VP_{\text{Laplace}}(w_i) = \frac{c_i + 1}{N + V}
Add-one unigram
PLaplace(wn∣wn−1)=C(wn−1wn)+1C(wn−1)+VP_{\text{Laplace}}(w_n \mid w_{n-1}) = \frac{C(w_{n-1} w_n) + 1}{C(w_{n-1}) + V}
Add-one bigram
C∗(wn−1wn)=[C(wn−1wn)+1]C(wn−1)C(wn−1)+V,dc=C∗C\begin{aligned} &C^*(w_{n-1} w_n) \\ &\quad = \frac{\left[C(w_{n-1} w_n) + 1\right] C(w_{n-1})}{C(w_{n-1}) + V}, \\ &d_c = \frac{C^*}{C} \end{aligned}
Reconstituted count and discount ratio d_c (not the subtracted d of absolute discounting)
PAdd-k(wn∣wn−1)=C(wn−1wn)+kC(wn−1)+kVP_{\text{Add-}k}(w_n \mid w_{n-1}) = \frac{C(w_{n-1} w_n) + k}{C(w_{n-1}) + kV}
Add-k: k = 1 is Laplace, k → 0 is the MLE; tune k on dev data
BigramCC(prefix)MLEAdd-one PC*d_c = C*/C
i want82725330.33828 / 3979 ≈ 0.215270.64
want to6089270.66609 / 2373 ≈ 0.262380.39
chinese food821580.5283 / 1604 ≈ 0.0528.20.10
i to (unseen)0253301 / 3979 ≈ 0.000250.64n/a
Add-one on BeRP (V = 1446)
kP(food | chinese)P(to | want)
10.05170.2566
0.50.09360.3688
0.10.27130.5675
0.010.47550.6458
0 (MLE)0.5190.656
Add-k on BeRP

Interpolation, backoff and absolute discounting

Interpolation always mixes every order; backoff uses the highest order with a nonzero count. All weights are hyperparameters tuned on held-out data. Part 07: Interpolation, backoff and discounting

P^(wn∣wn−2wn−1)=λ1P(wn)+λ2P(wn∣wn−1)+λ3P(wn∣wn−2wn−1),∑iλi=1\begin{aligned} &\hat{P}(w_n \mid w_{n-2} w_{n-1}) \\ &\quad = \lambda_1 P(w_n) + \lambda_2 P(w_n \mid w_{n-1}) \\ &\quad + \lambda_3 P(w_n \mid w_{n-2} w_{n-1}), \\ &\sum_i \lambda_i = 1 \end{aligned}
Linear interpolation; λ may depend on the context
S(wi∣wi−k+1i−1)={f(wi−k+1i)f(wi−k+1i−1)if f(wi−k+1i)>00.4 S(wi∣wi−k+2i−1)otherwiseS(wi)=f(wi)N\begin{gathered} S(w_i \mid w_{i-k+1}^{i-1}) = \begin{cases} \dfrac{f(w_{i-k+1}^{i})}{f(w_{i-k+1}^{i-1})} & \text{if } f(w_{i-k+1}^{i}) > 0 \\[2mm] 0.4\, S(w_i \mid w_{i-k+2}^{i-1}) & \text{otherwise} \end{cases} \\ S(w_i) = \frac{f(w_i)}{N} \end{gathered}
Stupid backoff (Brants et al. 2007): scores, not probabilities
PAD(wi∣wi−1)=max⁡(C(wi−1wi)−d, 0)C(wi−1)+λ(wi−1) P(wi),λ(wi−1)=d ∣{w:C(wi−1w)>0}∣C(wi−1)\begin{aligned} &P_{\text{AD}}(w_i \mid w_{i-1}) \\ &\quad = \frac{\max\big(C(w_{i-1} w_i) - d,\ 0\big)}{C(w_{i-1})} \\ &\quad + \lambda(w_{i-1})\, P(w_i), \\ &\lambda(w_{i-1}) = \frac{d\, \big|\{w : C(w_{i-1} w) > 0\}\big|}{C(w_{i-1})} \end{aligned}
Interpolated absolute discounting
d=n1n1+2 n2(or d≈0.75)d = \frac{n_1}{n_1 + 2\, n_2} \quad (\text{or } d \approx 0.75)
Discount from counts of counts
InterpolationKatz backoffStupid backoff
Lower orders usedAlways, for every wordOnly when the full n-gram count is 0Only when the full n-gram count is 0
Discount on seen n-gramsImplicit, through the λ weightsYes, P* frees massNone
True distributionYes, because Σλ = 1Yes, with the normalizing αNo, it returns scores
WeightTuned λ, can depend on contextα(context) from freed massFixed 0.4 per step
Three ways to use lower orders
λ = (λ1, λ2, λ3)Token probabilitiesPerplexity
(0.1, 0.3, 0.6)0.157, 0.392, 0.27053.92
(0.6, 0.3, 0.1)0.162, 0.152, 0.0738.22
(0, 0, 1)0, 0.50, 0.40∞
Choosing λ on dev tokens: the first setting wins
Training count cHeld-out averagec minus held-out
10.4480.552
21.250.75
32.240.76
43.230.77
54.210.79
98.260.74
Church and Gale: 22M AP training words, 22M held-out

Worked results

Interpolation
P(food | want chinese) = 0.1 × 0.01 + 0.3 × 0.52 + 0.6 × 0 = 0.157
Stupid backoff
S(floor | quietly on the) = 0.4 × 0.4 × 3/60 = 0.008
To the base case
0.4³ × 5 / 10,000 = 0.000032
P_AD seen
P_AD(food | chinese) = 0.525 + 0.225 × 0.02 = 0.5295
P_AD unseen
P_AD(tea | chinese) = 0.225 × 0.001 = 0.000225
Lambda check
λ(chinese) = 0.75 × 3 / 10 = 0.225 = 1 − 0.775

Kneser-Ney for bigrams

Backing off to raw frequency asks how often a word occurs; Kneser-Ney asks how many different words it follows. Part 08: Kneser-Ney bigrams

Pcont(w)=∣{v:C(v w)>0}∣∣{(u,w′):C(u w′)>0}∣=N1+(∙ w)∑w′N1+(∙ w′)\begin{aligned} P_{\text{cont}}(w) &= \frac{\big|\{ v : C(v\,w) > 0 \}\big|}{\big|\{ (u, w') : C(u\,w') > 0 \}\big|} \\ &= \frac{N_{1+}(\bullet\, w)}{\sum_{w'} N_{1+}(\bullet\, w')} \end{aligned}
Continuation probability: distinct left contexts over bigram types
PKN(wi∣wi−1)=max⁡(C(wi−1wi)−d, 0)C(wi−1)+λ(wi−1) Pcont(wi)\begin{aligned} &P_{\text{KN}}(w_i \mid w_{i-1}) \\ &\quad = \frac{\max\big(C(w_{i-1} w_i) - d,\ 0\big)}{C(w_{i-1})} \\ &\quad + \lambda(w_{i-1})\, P_{\text{cont}}(w_i) \end{aligned}
Interpolated Kneser-Ney bigram
λ(wi−1)=dC(wi−1) N1+(wi−1 ∙)\lambda(w_{i-1}) = \frac{d}{C(w_{i-1})}\, N_{1+}(w_{i-1}\, \bullet)
Exactly the mass removed by discounting, so each row sums to 1
WordTokensLeft contextsRaw P(w)P_cont(w)
Kong30Hong30 / 34 ≈ 0.8821 / 5 = 0.2
glasses4reading, sun, safety, my4 / 34 ≈ 0.1184 / 5 = 0.8
Toy corpus: Hong Kong 30, and reading, sun, safety, my glasses 1 each
HistoryWordFrequency backoffKneser-Ney
readingKong0.6620.15
readingglasses0.3380.85
HongKong0.9970.98
Hongglasses0.0030.02
Frequency backoff against Kneser-Ney, d = 0.75
  1. Continuation: P_cont(Kong) = 1/5, P_cont(glasses) = 4/5.
  2. Weight: λ(reading) = 0.75 / 1 × 1 = 0.75; λ(Hong) = 0.75 / 30 = 0.025.
  3. Seen: P_KN(glasses | reading) = (1 − 0.75)/1 + 0.75 × 0.8 = 0.85.
  4. Unseen: P_KN(Kong | reading) = 0 + 0.75 × 0.2 = 0.15; check 0.85 + 0.15 = 1.

General and modified Kneser-Ney

The recursion interpolates every order down to a uniform floor, using raw counts only at the top order and continuation counts below. Part 09: General Kneser-Ney

PKN(wi∣wi−n+1:i−1)=max⁡(cKN(wi−n+1:i)−d, 0)∑vcKN(wi−n+1:i−1 v)+λ(wi−n+1:i−1) PKN(wi∣wi−n+2:i−1)\begin{aligned} &P_{KN}(w_i \mid w_{i-n+1:i-1}) \\ &\quad = \frac{\max\big(c_{KN}(w_{i-n+1:i}) - d,\ 0\big)}{\sum_v c_{KN}(w_{i-n+1:i-1}\, v)} \\ &\quad + \lambda(w_{i-n+1:i-1})\, P_{KN}(w_i \mid w_{i-n+2:i-1}) \end{aligned}
Recursive interpolated Kneser-Ney
cKN(⋅)={count(⋅)highest ordercontinuationcount(⋅)lower ordersc_{KN}(\cdot) = \begin{cases} \text{count}(\cdot) & \text{highest order} \\ \text{continuationcount}(\cdot) & \text{lower orders} \end{cases}
N-grams that start with <s> keep raw counts
PKN(w)=max⁡(cKN(w)−d, 0)∑w′cKN(w′)+λ(ϵ) 1V\begin{aligned} P_{KN}(w) &= \frac{\max\big(c_{KN}(w) - d,\ 0\big)}{\sum_{w'} c_{KN}(w')} \\ &\quad + \lambda(\epsilon)\, \frac{1}{V} \end{aligned}
Base case: unigram interpolated with uniform; <UNK> gets λ(ε)/V
Y=n1n1+2n2D1=1−2Yn2n1D2=2−3Yn3n2D3+=3−4Yn4n3\begin{gathered} Y = \frac{n_1}{n_1 + 2 n_2} \qquad D_1 = 1 - 2Y\frac{n_2}{n_1} \\ D_2 = 2 - 3Y\frac{n_3}{n_2} \qquad D_{3+} = 3 - 4Y\frac{n_4}{n_3} \end{gathered}
Modified Kneser-Ney discounts, per order (D1 always equals Y)
γ(h)=D1N1(h∙)+D2N2(h∙)+D3+N3+(h∙)∑wc(h w)\gamma(h) = \frac{\begin{gathered} D_1 N_1(h\bullet) + D_2 N_2(h\bullet) \\ + D_{3+} N_{3+}(h\bullet) \end{gathered}}{\sum_w c(h\, w)}
Reserved mass for history h under modified KN
N-gramLevelRawc_KNLeft neighbours
reading glassesbigram32her, his
glassesunigram42reading, sun
hongunigram32visited, loves
kongunigram31hong
sheunigram40none, always first
Raw count against c_KN (toy corpus, V = 13)
LevelWeightP(glasses)P(kong)
Unigramλ(ε) = 0.75 × 11 / 15 = 0.551.25 / 15 + 0.55 / 13 = 0.12560.0590
Bigram, readingλ = 0.75 × 1 / 2 = 0.3750.625 + 0.375 × 0.1256 = 0.67210.0221
Trigram, her readingλ = 0.3750.625 + 0.375 × 0.6721 = 0.87700.0083
P_KN(glasses | her reading), d = 0.75 at every level
AspectKneser-NeyModified KN
Discounts per order1 (d)3 (D1, D2, D3+)
Estimated = n1 / (n1 + 2 n2)Dk = k − (k+1) Y n(k+1) / n(k)
Reserved mass for hd · N1+(h•) / Σ c(hw)(D1 N1 + D2 N2 + D3+ N3+) / Σ c(hw)
SRILM-ukndiscount-kndiscount
KenLMNot offeredlmplz (default)
Kneser-Ney against modified Kneser-Ney

Worked discounts and toolkits

Counts of counts
n1 = 1000, n2 = 300, n3 = 150, n4 = 90
Discounts
Y = 0.625, D1 = 0.625, D2 = 1.0625, D3+ = 1.5
Reserved mass
Counts 1, 1, 2, 5: γ = 3.8125 / 9 = 0.4236, against 0.333 with one d = 0.75
KenLM
lmplz -o 5 <text >model.arpa
SRILM
ngram-count -order 5 -kndiscount -interpolate
Neural gain
Bengio et al. 2003: about 24% lower perplexity on Brown, 8% on AP News

Entropy, cross-entropy and the chapter

Entropy is average surprise in bits; cross-entropy of a model is never below the true entropy, and perplexity is two to the per-word cross-entropy. Part 10: Entropy and summary

H(X)=−∑xp(x)log⁡2p(x)H(X) = -\sum_x p(x)\log_2 p(x)
Entropy in bits (Shannon 1948)
H(p)≤H(p,m)=−∑xp(x)log⁡2m(x)=H(p)+DKL(p ∥ m)\begin{aligned} H(p) \le H(p,m) &= -\sum_x p(x)\log_2 m(x) \\ &= H(p) + D_{\mathrm{KL}}(p \,\|\, m) \end{aligned}
Cross-entropy; the gap is the KL divergence
H(W)=−1Nlog⁡2P(w1…wN),PP(W)=2H(W)=P(w1…wN)−1/N\begin{gathered} H(W) = -\tfrac{1}{N}\log_2 P(w_1\ldots w_N), \\ \mathrm{PP}(W) = 2^{H(W)} = P(w_1\ldots w_N)^{-1/N} \end{gathered}
Per-word cross-entropy and its link to perplexity
DistributionH (bits)2^H
Fair coin12
8 uniform horses38
Skewed horses (1/2, 1/4, 1/8, 1/16, 1/64 x4)24
3 uniform colors1.5853
0.8/0.1/0.1 colors0.9221.89
Entropy and 2^H
Model mH(p, m) bitsKL gapPerplexity
Uniform (1/3, 1/3, 1/3)1.5850.6633
(0.6, 0.2, 0.2)1.0540.1322.08
(0.9, 0.05, 0.05)0.9860.0641.98
m = p (0.8, 0.1, 0.1)0.92201.89
Cross-entropy against true p = (0.8, 0.1, 0.1)
UnitLog basePerplexityWhere
Bits2PP = 2^HTextbooks, compression, Shannon
NatsePP = e^HTraining loss in neural LM code
Conversion1 nat = 1.4427 bitsH bits = H nats / ln 2
Bits against nats
ProblemFixPart
Full history is intractableMarkov assumptionPart 02
Probabilities are unknownMLE from countsPart 03
Need to judge modelsPerplexity on test, tuning on devPart 04
Need to see what was learnedSamplingPart 05
Unseen n-grams get zeroAdd-k, interpolation, backoffParts 06 and 07
Unigram backoff overrates KongContinuation probabilityPart 08
One discount misfits counts 1, 2, 3+Modified KN with D1, D2, D3+Part 09
The chapter as problems and fixes

Slide errata

Mistakes on the original slides

Slide 13
The Key idea box says the window is the last n - 1 words, but its formula uses n for the position and N for the order. The window is the last N - 1 words. Part 02
Slide 19
Title renders as "extitI am Sam" from a broken \textit; it should read "Toy corpus: I am Sam". Part 03
Slides 46 to 53
Titled "Bigram example", but from slide 48 the model conditions on two words (deep learning, then learning ,), which is trigram sampling. Part 05
Slide 55
Titled "Shakespeare vs WSJ sampling" but shows only Shakespeare; the WSJ samples are on the next slide. Part 06
Slide 73
Titled Stupid backoff, but the substitutions carry no 0.4 factor and no Katz α: it is generic backoff intuition. Backoff fires on a zero n-gram count, not an unseen context. Part 07
Slide 74
The recursion has no base case. Brants et al. end it with S(w_i) = count(w_i) / N, and the slide's λ ≈ 0.4 is their fixed α = 0.4. Part 07
Slide 79
The numerator needs max(C − d, 0) or unseen bigrams go negative, and λ(w_(i-1)) is never defined: it equals d · |{w : C(w_(i-1) w) > 0}| / C(w_(i-1)). Part 07
Slide 83
Lists "sunglasses" as a left context of glasses; the corpus has C(sun glasses) = 1, so the context is sun. Part 08
Slide 84
Title renders as P_extcont from a broken \text; it should read P_cont. The formula itself is correct. Part 08
Slide 95
Says "back off" but the formula interpolates at every level, and the chain ends at uniform 1/V, not the unigram. λ is left undefined. Part 09
Slide 103
Gives PP(W) = 2^H(W) without defining H(W): it is the model's per-word cross-entropy, -(1/N) log2 P(w1...wN), not the true entropy of W. Part 10