One Afternoon Under the Hood
one afternoon
Read twelve topics across foundations, training, architecture and generation. Focus on explaining behavior and limits; revisit details when needed.
- Walk through how a Transformer handles a sentence: split, embed, attend, generate one token at a time
- Explain the three training stages of a chat model and what each stage solves
- Say why a model fabricates confidently, and why bigger context costs more
- Why do attention compute and memory grow quickly with context length?
- After embedding, why do similar words end up with nearby vectors?
- Why does autoregressive generation produce one token at a time instead of the whole passage at once?
- What can scaling laws predict, and what can they not?
- What data do pretraining and fine-tuning each need, and what do they solve?
- Does doubling the context window double model capability?
- In one sentence, relate hallucination to the generation objective, and give one check.
Try answering before opening the reference. Revisit the relevant step above if needed. These answers highlight key ideas; you do not need to repeat the wording.
Question 1 · Reference answer
For an autoregressive language model: tokenize, embed, apply layers with attention, obtain a next-token distribution, select a token and repeat. This sketch does not describe every Transformer task.
Question 2 · Reference answer
A common chat-model recipe uses pretraining, supervised fine-tuning and preference optimization: general patterns, task/response formats, and preferences or constraints. Actual recipes can merge, repeat or omit stages.
Question 3 · Reference answer
The generation objective does not guarantee factual support for every claim. More context adds computation and cache use. Distinguish input length, output length and runtime; a long window does not guarantee reliability.
Question 4 · Reference answer
Standard self-attention compares every token with every other token; doubling length roughly squares the number of pairs, while the KV cache grows linearly. Sparse, chunked or linear attention trades approximation for implementation complexity.
Question 5 · Reference answer
Training gives nearby representations to words that appear in similar contexts, so similarity reflects usage rather than dictionary meaning. Polysemy can still collide; vector distance alone does not settle meaning.
Question 6 · Reference answer
The model is trained to predict the next token given prior text; the new token is fed back before the next step. Whole-passage output needs a different non-autoregressive model, with different quality and speed trade-offs.
Question 7 · Reference answer
Given data, parameters and compute, they predict loss trends and diminishing returns; they do not guarantee task quality, factual correctness or the ceiling set by data quality. They are extrapolation tools, not product promises.
Question 8 · Reference answer
Pretraining learns general patterns from large unlabelled text; fine-tuning adjusts tasks and response formats with smaller, high-quality labelled or instruction data. Fine-tuning cannot replace pretraining or guarantee updated facts.
Question 9 · Reference answer
No. The window only sets how many tokens fit; effective use depends on attention, position extrapolation, where evidence sits and training length. Longer windows also add cost and latency.
Question 10 · Reference answer
The generation objective optimises next-token likelihood, not truth; so the model fills gaps without evidence. Check: trace each key claim to original material, and mark unknown if absent.
Apply this to a concrete task
Where to practise after this route
This route gets the concepts across. Do not reread it; pick one place below and use what you just learned once.
Find a tool by task, check licence and deployment
Filter by the job first, then check where it runs, whether the licence allows commercial use, and where data goes.
Open →Run a minimal project from source
Pick a repo with a clear licence, get the smallest example running, then decide whether to integrate it.
Open →Reproduce a piece from its original prompt
Change one variable and see what differs. Do not treat one rerun as a conclusion about the model.
Open →The Half-Hour Primer · The Full Week · The Writer's Route · The Builder's Route · The Decision-Maker's Route · The Researcher's Route · The Operator's Route · The Everyday User's Route · The Image / Video / Audio Creator's Route · The Safety and Compliance Review Route · The Evaluation and Quality Route · Robot software and learning route · The Office Route · The Data & RAG Route · The Teacher Route