← Speech and Language Processing
NLP›Popular Textbooks› SLP · Chapter 3

Chapter 3

N-gram Language Models: Count, Predict, and Measure Surprise

Chapter: N-gram Language Models, in Daniel Jurafsky and James H. Martin, Speech and Language Processing, 3rd edition draft, August 19, 2026.

Topics to learn

Page numbers refer to the linked chapter PDF.

FAQ

Why is a conditional probability not the unigram count divided by the corpus size?

Conditioning restricts the denominator to continuations of that history. The corpus-wide count answers a different question.

How can an unseen sentence still have positive probability?

The model multiplies local n-gram probabilities. The full sentence may be new even when every counted transition occurred.

Does adding a constant only to zero cells fix the row?

Not by itself. The row must still sum to one. A smoothing rule has to define the whole distribution, then renormalize if needed.

Does lower perplexity mean the system is better?

Only as a prediction score, and only when both systems use the same test text, tokenization, vocabulary, and boundary convention. It does not measure truth or task success.