Free293-page book · 26 decks · no signup, no paywall

Teach a machine
to actually read.

Every chatbot you've used is built on a handful of ideas you can learn in a weekend. Start at "what even is a word" and finish at "I know why attention works." No black boxes.

7units, in order
293pages of book
26slide decks
1,293pages of slides
4things to break in the lab
The path

Seven units. Each one earns the next.

Do them in order and nothing arrives out of nowhere — by the time you hit transformers, every piece of the diagram is something you already built.

01

Words are weirdly predictable

Text and its regularities

Before any model, look at the raw material. A handful of words do most of the work in any language, vocabulary grows in a shape you can predict, and "how do I even cut this string into pieces" turns out to be a real research problem.

02

Turning words into numbers

Representing words

Models can't read letters, only numbers. The trick that changed everything: a word's meaning is the company it keeps. Count what appears near what, squeeze it down, and you get vectors where directions mean things — including the ugly ones.

03

The math that learns

Neural foundations

One neuron is a line that splits a plane. Stack them and you can carve any shape. Then the only real question left: how does a pile of numbers know which way to move? That's gradient descent, and backprop is just the chain rule with good bookkeeping.

PerceptronsDecision boundaries ActivationsLoss functions Gradient descentBackpropagation Feedforward netsGeneralization
04

Guessing the next word

Language models and sequences

This is the whole job. Count word pairs and you have a language model — a bad one, but a real one. Everything after this is a better way to answer the same question, with memory that survives longer than three words.

05

Attention is the whole trick

Transformers and LLMs

Instead of reading left to right and hoping you remember, let every word look at every other word at once and decide what matters. That's it. That's the idea the entire modern field is standing on.

06

Making LLMs do what you want

Working with LLMs

The part everyone skips to — except now you'll know why any of it works. Why temperature changes the vibe, why LoRA is cheap, why RAG beats fine-tuning for facts, and why BLEU scores are argued about.

07

Who gets hurt when it's wrong

Responsible NLP

Models learn the patterns in their training text — all of them, including the ones nobody wanted. This unit is about finding that bias with the same maths you used to build the thing, and knowing what you can actually do about it.

Bias & harmsMitigation Responsible AI practiceCourse synthesis

The book

The whole thing, written down properly.

293 pages that go where the slides can't: the derivations, the worked examples, and eight projects you actually build. Reads in the browser — no download, no app.

  1. p15Part I

    Language as Data

    What Natural Language Processing Is · Corpora and Preprocessing · The Empirical Laws of Text · Term Weighting and Similarity · Subword Tokenization

  2. p47Part II

    Meaning as Geometry

    Vector Space Models · Count Vectors, PPMI, and SVD · Neural Network Fundamentals · Learned Word Embeddings

  3. p105Part III

    Language Models

    n-gram Language Models and Perplexity · Neural Language Models · Recurrent Networks · Gated Recurrence: LSTM and GRU · Text Classification and Evaluation

  4. p161Part IV

    The Transformer Era

    Contextual Embeddings · Self-Attention and the Transformer · Pretrained Transformers: BERT and GPT

  5. p185Part V

    Working with Large Language Models

    Steering LLMs: Decoding and Prompting · Adaptation and Alignment · Retrieval-Augmented Generation · Evaluating Generated Text · Building with Language Models · Efficiency: Smaller, Cheaper, Faster

  6. p217Part VI

    Applications

    Machine Translation · Summarization

  7. p233Part VII

    Responsible Practice

    Responsible NLP

  8. p241Part VIII

    Projects

    About the projects · Project 1 — The Shape of Language · Project 2 — Build the Tokenizer · Project 3 — Embedding Forensics · Project 4 — Language Models · Project 5 — Classification Leaderboard · Project 6 — Transformer Anatomy · Project 7 — Steering LLMs · Project 8 — RAG Capstone

  9. p271Part IX

    Appendices: Reference Implementations

    n-gram Language Model · Scaled Dot-Product Attention · Embedding Geometry · Decoding Mechanics · BM25 Retrieval · Bibliography

Start reading Download PDF · 2.9 MB 293 pages · 9 parts · 8 projects

The lab

Four ideas you can poke with your hands.

All of this runs in your browser, on your text, with no server and no model download. Drag the sliders until something breaks — that's the point.

Where do words even end?

Models don't see words — they see tokens. Byte-pair encoding starts from single characters and repeatedly glues together whichever pair shows up most often. Drag the slider to run more merges and watch letters fuse into chunks that look suspiciously like morphemes. This is really training BPE, live, on the text in the box.

vocab size
tokens produced
chars per token
Why you should care: vocab size is a budget. Too small and every word shatters into fragments the model has to reassemble; too large and most of the model's parameters sit in an embedding table doing nothing. GPT-style models land around 50–100k tokens — right where "unsupervised" is a couple of pieces, not eleven letters.

Jargon decoder

Words people say without explaining.

Every one of these gets a proper treatment somewhere in the decks. This is just so you're never lost in a thread.

Token

The chunk a model actually sees. Usually not a whole word — "unhappiness" might arrive as un + happi + ness. Everything is priced and limited in tokens.

Embedding

A list of numbers standing in for a word, sentence or document, arranged so similar meanings sit near each other. Usually a few hundred numbers long.

Corpus

A pile of text you're learning from. Plural: corpora. The single biggest lever on how a model behaves, and the least glamorous part of the job.

Softmax

Turns any list of scores into probabilities that add to 1, with the biggest score getting the biggest share. It's how a model converts "I like this word 8.2" into "42% chance".

Perplexity

How surprised a language model is by real text. Lower is better. Perplexity 20 means it was about as unsure as picking uniformly between 20 options at each word.

Attention

Each token looks at all the others and computes a weighted average of them, weighted by relevance. Repeat a few dozen times, and that's a transformer.

Transformer

The architecture underneath basically everything since 2017. Attention plus small feedforward layers, stacked, with no recurrence — which is why it trains fast on GPUs.

Temperature

A knob on randomness when generating. Low = repetitive and safe. High = creative then incoherent. It literally divides the scores before softmax.

Fine-tuning

Taking a trained model and nudging its weights on your own data. Expensive at full size, which is why LoRA exists.

LoRA

Freeze the big model, train two tiny matrices alongside it. You get most of the benefit of fine-tuning for a fraction of the memory. The "PEFT" family.

RAG

Retrieval-augmented generation: search your documents first, paste the hits into the prompt, then answer. How you give a model facts it was never trained on.

RLHF

Humans rank model outputs, a reward model learns those preferences, then the model is tuned to score well. It's what makes a raw LLM feel like an assistant.

BLEU

An old translation metric that counts overlapping word sequences with a reference translation. Widely used, widely complained about, still the default.

Zipf's law

Word frequency is inversely proportional to rank. A handful of words are everywhere and most words are almost nowhere. See the lab.

Hallucination

Fluent, confident, wrong. Not a bug bolted on — a direct consequence of a model whose only training objective was "sound like the next word".

Context window

How many tokens the model can look at in one go. Anything outside it doesn't exist, no matter how important you thought it was.


Start here

What you need before unit 01.

Python you can read, not write fluently

Lists, loops, dictionaries, functions. If you can write a word counter, you're fine. You'll pick up NumPy along the way.

School maths, honestly

Vectors, dot products, a bit of probability. Derivatives help by unit 03 but the slides build them up rather than assuming them.

No GPU, no cloud bill

Everything through unit 04 runs on a laptop. Colab's free tier covers the rest if you want to train something.

Do the lab as you go

Read the unit, then come back here and break the matching demo. Units 01, 02 and 04 each have one waiting.

Open unit 01.

Fifteen pages. Twenty minutes. You'll know what the field is actually asking.