Chapter 1 · Applied Natural Language Processing
batch_id |
varchar |
temp_c |
float |
ts |
timestamp |
status |
enum |
shift handover notes incident reports supplier email standards documents maintenance logs a decade of PDFs the comments column inspection notes tender documents
For fifty years the left-hand box was computable and the right-hand one was not. That is the thing that stopped being true.
“Have a machine read all 40,000 of these and tell me which ones mention a seal failure” moved from a research project to something you can prototype in a few hours. Not perfectly, and not without supervision.
1 · Rules 1950–1990
2 · Statistics 1990–2012
3 · Neural 2013–2017
4 · Pretraining 2018–2022
5 · Reasoning & agents 2023–2026
Read the scale and the prediction together. Knowing how it failed lets you tell an overclaim from a result.
Hutchins 2004 · Winograd 1972 · Kaplan et al. 2020 · Hoffmann et al. 2022
Bengio et al. 2003
| Shift | You supply | Mechanism | You get | Labels needed |
|---|---|---|---|---|
| 1990–2012 · Counting | grammar rules you wrote | count events in a corpus | an estimate that degrades gracefully | 104–105 |
| 2018– · Pretraining | someone else’s unlabelled text | pretrain once, adapt cheaply | the same weights serve many tasks | 102–103 |
| 2022– · Instruction | a sentence in your own language | preference training | the interface is the instruction | 100–101 |
Each shift moved work off your desk and onto someone else’s compute. Training labels fell about a thousandfold; evaluation labels did not.
Brown et al. 1993 · Bahdanau et al. 2015 · Sennrich et al. 2016 · Ouyang et al. 2022 · Snell et al. 2025
Both things are true. Telling them apart is most of this book.
The training-label requirement fell by two or three orders of magnitude. The evaluation set did not.
| Family | Representative | What it does | Strong at |
|---|---|---|---|
| Encoder-only | BERT (2019) | reads the whole text, a representation per token | classification, extraction, token labelling |
| Decoder-only | GPT (2020) | predicts the next token left to right | generation, prompting, chat |
| Encoder-decoder | T5 (2020) | reads an input sequence, writes an output sequence | translation, summarization, input→output |
Not “the same model does everything” — the same pretraining paradigm made increasingly general model families possible.
Ouyang et al. 2022
| Layer | What it is | Chapter |
|---|---|---|
| Base model | the raw text-continuation model, pretrained on unlabelled text | 8 |
| Instruction-following model | after instruction tuning + training on human preferences | 9 |
| Application | system prompt, retrieval (RAG), tools, guardrails, interface | Parts IV–V |
When you argue about a behaviour, know which layer you mean — that is also the layer where the fix goes.
>280×
Cost of serving GPT-3.5-level quality: $20.00 → $0.07 per million tokens, November 2022 → October 2024 — in under two years
Stanford AI Index 2025
Five task families cover almost everything; evaluation is a layer across all five.
| Family | Your documents | What you get | Chapter |
|---|---|---|---|
| Classification | Maintenance work orders | Failure categories that feed a reliability analysis | 17 |
| Extraction | Supplier emails and quotations | Structured records — part, quantity, lead time, price | 17 |
| Retrieval | Codes, regulations, technical specs | The clause, with the citation | 20 |
| Generation | Regulatory filings and reports | Routine sections drafted from structured data; a human still signs | 8 |
| Agents | Quality complaints plus production data | The system queries the database, runs the calculation, shows its work | 23 |
| Evaluation (across every family) | Any of the above, at scale | A quantified error rate — the model as an instrument to be calibrated | 22 |
| Field | Classification | And also |
|---|---|---|
| Chemical & process | Shift handover and deviation reports | Safety data sheets → extraction; internal standards → retrieval |
| Civil & structural | Bridge and building inspection reports | Tender documents → extraction; codes and specs → retrieval |
| Industrial & manufacturing | Maintenance work orders | Supplier quotations → extraction; quality complaints → agents |
| Energy & environmental | Grid incident and outage logs | Impact assessments → retrieval; regulatory filings → generation |
| Statistics & social science | Open-ended survey responses | Scientific literature → retrieval; any of it, at scale → evaluation |
Almost never a chatbot: reading documents you already own, at a scale no human can.
A book that only sells you the upside is a brochure. Five things are as hard as they ever were:
Four of them since 1966; one arrived with the agentic systems of Part V. Every one will appear in your first project — and none of them is a modelling problem.
Weizenbaum 1966, 1976 · Bender et al. 2021 · Schaeffer et al. 2023
Treat a language model the way you would treat a new measuring instrument: useful, fast, and worth exactly as much as your calibration of it.
Greshake et al. 2023
Newer does not mean better. Each approach is still the right answer somewhere.
| Classical (counts + a classifier) | Fine-tuned encoder | LLM prompting | |
|---|---|---|---|
| Covered in | Ch. 2, Ch. 3 | Ch. 8 | Ch. 17 |
| Labelled examples needed to train | Thousands | Hundreds | Zero to a handful |
| Cost per 1,000 documents | Effectively nothing | Effectively nothing after training | Metered, and it recurs forever |
| Latency | Microseconds, batched | About 2 ms per document, batched | Hundreds of milliseconds to seconds |
| Runs on your own hardware | Yes, trivially | Yes | Only for open-weight models |
| Classical | Fine-tuned encoder | LLM prompting | |
|---|---|---|---|
| Explains its decision | Yes, exactly — a linear score decomposes into per-term contributions | Not really | No; the stated reason may be invented |
| Handles a task you did not anticipate | No — retrain | No — retrain | Yes — rewrite the instruction |
| Output is reliably structured | Yes, by construction | Yes | Needs constraining and validation |
| Confidently wrong | Yes — an uncalibrated score is not a probability | Yes, and harder to spot | Routinely, and fluently |
The newer approaches buy flexibility and pay for it in cost, latency, and predictability.
If you can read a regression table and write a Python loop, you are ready.
Appendix B collects every mathematical fact the book uses. Parts VI and VII assume you have met HTTP, authentication and a deployment pipeline; if those words are new, keep Appendix A open beside you.
A vendor’s model is 94% accurate on your task. Is that good?
Which of the three approaches is the most modern — and does that make it the best?
Two annotators agree on 93% of your labels. Are the labels trustworthy?
Not necessarily — and this is the most common way a project’s foundation turns out to be rotten.
\[\kappa = \frac{p_o - p_e}{1 - p_e}\]
A percentage is meaningless without the baseline it should be read against — the same lesson as Question 1.
Your NLP project is behind schedule. Where did the time actually go?
Broad and deceptively simple — they find out whether you think in trade-offs or in tools.
Naming the cheap option first is a signal, not a weakness.
| Source | By | Why |
|---|---|---|
| Speech and Language Processing | Jurafsky & Martin | The standard reference, free online and updated |
| NLP Course For You | Elena Voita | Unusually good visual explanations |
| The Bitter Lesson | Rich Sutton | Six hundred words; re-read it once a year |
| The AI Index Report | Stanford HAI | Defensible numbers — rather than a vendor’s |
| Intro to Large Language Models | Andrej Karpathy | One hour, from 2023: stops before reasoning models |
| Neural Networks: Zero to Hero | Andrej Karpathy | Builds a working language model from scratch, on video |
| Attention Is All You Need | Vaswani et al. 2017 | Read it after Ch. 7, not before |
Uygulamalı Doğal Dil İşleme · Applied NLP