• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 28 pages
Summary

Summary Natural Language Processing Complete Study Guide - CS 224N

Document preview thumbnail
Preview 3 out of 28 pages

COUNT, THEN NORMALISE NLP questions are won by students who can carry a probability through a chain rule, a smoothing step and a log-space conversion without losing track of what each term means. A definition of an n-gram model is partial credit; computing an unseen bigram with add-one smoothing, writing the perplexity, and explaining why perplexity fell earns full credit. This guide keeps the arithmetic explicit and the notation honest. CONTENTS - Nine chapters: tokenisation and text normalisation; n-gram language models and smoothing; word embeddings and distributional semantics; part-of-speech tagging and HMMs; syntactic parsing and context-free grammars; machine translation and alignment; attention and the transformer; evaluation (BLEU, perplexity, F1); neural language models and prompts. - A 32-row master table: chain rule, unigram/bigram/trigram MLE, add-one and interpolation smoothing, perplexity, word2vec objective, Viterbi recursion, CKY, attention, BLEU brevity penalty, precision/recall/F1. - Worked examples with full substitution: a bigram probability with add-one, perplexity of a short corpus, a Viterbi tag path, a CKY parse cell, a single attention head, and a BLEU computation. - Ten solved problems, 20 exam questions with step-by-step solutions, sixteen traps, plus a formula card, 25 flashcards, a glossary, extended problems and derivation essays. BEST FOR - Students who can use an NLP library but cannot derive Viterbi or perplexity by hand - Papers mixing probability, algorithms and evaluation metrics ️ LEGAL DISCLAIMER: This is an independent academic summary and study aid created for revision purposes. It is not affiliated with, endorsed by, or sponsored by any specific university, course instructor, or publisher.

Content preview

HIGH-YIELD REVISION GUIDE


Natural Language Processing
From tokenization, n-grams and smoothing to word vectors, tagging, parsing, translation, attention
and evaluation

Natural Language Processing | Course Code: CS 224N | 2026-2027 Comprehensive Edition




WHAT’S INSIDE THIS GUIDE

✔ Chapter 1 — Tokenization and text normalization ✔ Chapter 2 — n-gram language models and smoothing
✔ Chapter 3 — Word vectors and distributional semantics ✔ Chapter 4 — POS tagging and hidden Markov models
✔ Chapter 5 — Parsing and context-free grammars ✔ Chapter 6 — Machine translation and alignment
✔ Chapter 7 — Attention and the Transformer ✔ Chapter 8 — Evaluation: BLEU, perplexity, F1
✔ Chapter 9 — Neural language models and prompting ✔ A 32-row formula Master Table with unit traps
✔ A ten-problem worked set with full arithmetic ✔ A 20-question practice exam with step-by-step solutions
✔ Sixteen exam traps as red-flag warnings ✔ Appendices: formula card, 25 flashcards, glossary, deriva-
tions




How to Use This Guide
Natural language processing is the study of how computers can reason about human language, and the exam
rewards a very particular skill: the ability to write the probability model down first, then substitute numbers.
Almost every computational question in this course is an instance of one of four moves — factor a joint distribution
with the chain rule, estimate a conditional probability by counting with smoothing, search for a highest-scoring
structure with dynamic programming, or score a system with a metric that has a precise definition. A verbal
description of word2vec or Viterbi earns partial credit; deriving the skip-gram objective, writing the Viterbi recursion,
and then completing a small numeric table by hand earns full credit. The habit to cultivate is therefore to name
the model, state its assumptions, write its equation, and only then plug in the counts.
The nine chapters form a deliberate chain. Chapters 1 and 2 build the foundation: turning raw text into tokens
and estimating a probability distribution over word sequences with n-grams and smoothing. Chapter 3 replaces
sparse counts with dense vectors, which gives the course its geometric half. Chapters 4 and 5 attach structure —
part-of-speech sequences and parse trees — using the same dynamic-programming idea in two different guises.
Chapter 6 uses those structures for translation and introduces alignment as a latent variable. Chapter 7 shows
how attention removes the bottleneck of early sequence models and leads to the Transformer. Chapter 8 supplies
the evaluation toolkit, and Chapter 9 closes with neural language models and prompting. Read a chapter, then
immediately cover the text and reproduce its three worked examples; the numbers are chosen to be reproducible
with pencil arithmetic, and reproducing them is the fastest way to expose a mistake before the exam does.
Use the Master Table as a pre-exam audit: cover the third column and, for each quantity, state the error an examiner
can build a trap around. The worked problem set, the practice exam, and the extended appendix problems grow
in length and train written reasoning rather than answer recall. Finally, the Sixteen Deadly Exam Traps and the
derivation notebook target the conceptual confusions — MLE versus smoothed, max versus sum, clipped versus
raw counts, precision versus recall, candidate versus reference length — that separate a distinction-level script
from a bare pass.
Three habits:
• Count with the correct denominator. A bigram probability divides the bigram count by the unigram count of
the conditioning word; an add-one probability adds the vocabulary size to that denominator. Write the numerator
and denominator explicitly before simplifying, because most lost marks here are a swapped denominator rather
than a wrong concept.




Independent study aid. Not affiliated with or endorsed by any university or publisher. Page 1 of 28

,Natural Language Processing · CS 224N Natural Language Processing



• Say whether you are maximising or summing. Viterbi takes a maximum over previous states, the forward
algorithm takes a sum, and CKY takes a maximum over split points. The recurrences look nearly identical; the
one word “max” versus “sum” is the whole algorithm.
• Define every metric’s reference frame. Perplexity Lower is better, BLEU compares a candidate against a
reference with a brevity penalty, and F1 is a harmonic mean of two rates that must be computed on the same
set of items. State which side is the hypothesis and which is the truth before computing.


KEY TAKEAWAY

Every problem in this course reduces to one of four skeletons: factor a joint with the chain rule, estimate a
conditional by counting plus smoothing, search a highest-scoring structure with dynamic programming, or
score a candidate with a precisely defined metric. Name the skeleton, write the equation, then substitute.




1 Quick-Reference Master Table
Quantity Formula or meaning Unit trap / common error
Chain rule P(w₁ … wₙ) = ∏ᵢ P(wᵢ | w₁ … wᵢ₋₁) Dropping the conditioning context
Unigram MLE P(w) = C(w) / N N is the total token count, not types
Bigram MLE P(w₂ | w₁) = C(w₁,w₂) / C(w₁) Denominator is the count of w₁
alone
Trigram MLE P(w₃ | w₁,w₂) = C(w₁,w₂,w₃) / C(w₁,w₂) Denominator is the bigram count
Add-one smoothing P(w₂ | w₁) = (C(w₁,w₂)+1) / (C(w₁)+V) V added to denominator, not
numerator only
Linear interpolation P = λ₁P₀ + λ₂P₁ + λ₃P₂ Weights must sum to one
Good-Turing c-star = (c+1)·N(c+1) / N(c) Uses counts of counts, not raw
count
Kneser-Ney P = max(c−δ,0)/C(w₁) + δ·N₁₊(w₁,w₂)/N₁₊(w₁) Continuation count, not raw
frequency
Perplexity PP(W) = P(W) raised to (−1/N) Lower is better; N is number of
tokens
Log perplexity PP = 2 raised to (−(1/N)·Σ log₂ P(wᵢ|hᵢ)) Log base must match the power
base
Skip-gram objective J = −Σₜ Σ(j ≠ 0) log P(w(t+j) | wₜ) Negative log-likelihood, sign matters
Skip-gram softmax P(wₒ|w𝚌) = exp(vₒ·v𝚌) / Σᵥ exp(vᵥ·v𝚌) O(V) per example; sum over all
words
Negative sampling log σ(vₒ·v𝚌) + Σ log σ(−vₙ·v𝚌) σ is the sigmoid function
Cosine similarity cos(u,v) = (u·v) / (‖u‖‖v‖) Range −1 to 1; sign carries meaning
GloVe objective J = Σ f(Xᵢⱼ)·(wᵢ·wⱼ + bᵢ + bⱼ − log Xᵢⱼ)² Weighted least squares on co-
occurrence
HMM joint P(O,Q) = π(q₁)·∏ b(qᵢ;oᵢ)·∏ a(qᵢ,qᵢ₊₁) Three factors: prior, emission,
transition
Viterbi recursion δₜ(j) = maxᵢ [δₜ₋₁(i)·a(i,j)]·b(j;oₜ) Max over previous, then emit
Viterbi backpointer ψₜ(j) = argmaxᵢ δₜ₋₁(i)·a(i,j) Store argmax to recover the path
Forward algorithm αₜ(j) = Σᵢ αₜ₋₁(i)·a(i,j)·b(j;oₜ) Sum, not max
CFG in CNF A → B C or A → a At most two nonterminals on the
right
CKY fill P(A,i,j) = maxₖ P(B,i,k)·P(C,k,j)·P(A→BC) Split at k with i below k below j
Dependency arc head → dependent, labelled One head per word and a single root
IBM Model 1 P(f,a|e) = ∏ᵢ P(aᵢ|i)·P(fᵢ|e at aᵢ) Alignment is a hidden variable
Noisy-channel MT P(e|f) ∝ P(f|e)·P(e) P(f) is constant in the argmax
Attention weight αᵢ = exp(score(q,kᵢ)) / Σⱼ exp(score(q,kⱼ)) Softmax over all keys
Scaled dot-product Attention(Q,K,V) = softmax(Q·Kᵀ / √dₖ)·V Divide by √dₖ before softmax




Independent study aid. Not affiliated with or endorsed by any university or publisher. Page 2 of 28

,Natural Language Processing · CS 224N Natural Language Processing




Quantity Formula or meaning Unit trap / common error
Context vector c = Σᵢ αᵢ·hᵢ Weighted sum of values, weights
sum to one
Multi-head attention headₕ = Attention(Q·Wqₕ, K·Wkₕ, V·Wvₕ) Heads concatenated then projected
n-gram precision pₙ = clipped matches / candidate n-grams Clipped against reference counts
Brevity penalty BP = 1 if c > r, else exp(1 − r/c) c = candidate length, r = reference
length
BLEU BLEU = BP · exp(Σ wₙ · log pₙ) Usually wₙ = 1/N; log of zero
undefined
Precision / Recall P = TP/(TP+FP), R = TP/(TP+FN) Denominators are different sets
F1 score F1 = 2·P·R / (P+R) Harmonic, not arithmetic, mean


Chapter 1 — Tokenization and Text Normalization
Tokenization is the step that turns a raw character string into a sequence of discrete units that a model can count
or embed, and it is deceptively hard because natural language does not come with reliable word boundaries. In
English a whitespace splitter handles “the cat sat” easily but fails on “don’t”, “New York”, “e-mail”, and “U.S.A.”;
in Chinese, Japanese, and Thai there are no spaces at all, so a segmenter must decide where words begin. The
exam cares less about the engineering of a particular tokenizer and more about the trade-off it embodies: a finer
granularity gives a smaller vocabulary and fewer unknown tokens, while a coarser granularity preserves whole-
word meaning at the cost of a huge, sparse inventory. Every downstream model inherits the tokenizer’s mistakes,
so a careful answer always begins by stating what a “token” means in the system under discussion.
Tokenizers form a spectrum. Whitespace and regular-expression tokenizers split on delimiters and handle
punctuation with hand-written rules; they are transparent but brittle across languages. Subword tokenizers are
now standard: byte-pair encoding (BPE) starts from individual characters and repeatedly merges the most frequent
adjacent pair until a target vocabulary size is reached; WordPiece scores a candidate merge by how much it
increases the likelihood of the training data; the Unigram model starts with a large inventory and prunes pieces that
least damage a language-model objective. All three implement the same compromise — frequent whole words
stay intact while rare words decompose into meaningful fragments, so “unhappiness” might become “un”, “happi”,
“ness” and a model can generalise to “unkindness” by reusing “un” and “ness”. Byte-level BPE goes further and
operates on bytes, guaranteeing that every possible string can be encoded with no unknown token at all.
The BPE procedure itself is worth being able to perform by hand, because it is a counting exercise in disguise.
Given a corpus with word frequencies, first write each word as a sequence of characters terminated by a special
end-of-word symbol. Next, count the frequency of every adjacent character pair across the weighted corpus,
where each pair’s count is the sum of the frequencies of the words containing it. Merge the highest-frequency
pair into a new symbol, recompute all pair counts, and repeat. Ties are usually broken by a fixed rule such as
the lexicographically larger pair, and the exam will specify a tie-break if it matters. Notice that the end-of-word
marker is what prevents the tokenizer from merging across word boundaries, and that a merge must be applied
everywhere it occurs, not just in the word that motivated it.
Normalization sits between raw text and tokenization, and its purpose is to collapse variants that should be
treated as the same type. Case folding maps “The” and “the” together, which helps a small corpus but destroys
the distinction between “US” the country and “us” the pronoun. Unicode normalization chooses a canonical
composition (NFC) or compatibility form (NFKC) so that a character written as a base plus accent matches its
precomposed version. Punctuation and control characters are removed or mapped to explicit tokens. Stemming
(for example a Porter-style suffix stripper) applies crude rules to chop “running” to “run”, while lemmatization uses
vocabulary and morphology to map “was” to “be”; the former is fast and over-generates, the latter is accurate but
needs a lexicon. A good answer names which normalization step is safe for the task at hand — case folding helps
information retrieval but hurts part-of-speech tagging, where capitalisation is a strong clue.
The vocabulary and the unknown-token policy close the chapter. A frequency threshold keeps only words seen at
least k times and maps everything else to an unknown token, giving a finite embedding matrix; subword models
instead keep a fixed inventory of pieces and compose rare words from them. The practical quantities an exam
may ask for are the vocabulary size V, the number of tokens N after tokenization, the type-token ratio V over N
as a crude diversity measure, and the out-of-vocabulary rate on a held-out set. Zipf’s law explains why a small
vocabulary covers most text: the frequency of the r-th most common word falls roughly as one over r, so the long




Independent study aid. Not affiliated with or endorsed by any university or publisher. Page 3 of 28

Connected book
 image
Dan Jurafsky, James H. Martin Speech and Language Processing
Publisher: 2008-04-29 ISBN: 9780135041963 Edition: 2

Document information

Summarized whole book?
No
Which chapters are summarized?
Chapters covering core exam topics (tokenisation and normalisation, n-gram language models and smoot
Uploaded on
November 23, 2026
Number of pages
28
Written in
2025/2026
Type
Summary
$8.98

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
2
Followers
0
Items
140
Last sold
2 days ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions