How LLMs work
The mechanics of large language models: tokens, prediction, context, sampling, reasoning and multimodality.
14 skills · 4 stages each
Skills
- Tokens and tokenizationFor bothStart hereHow text becomes tokens and why tokens decide cost, context limits, speed and odd spelling mistakes110 questions
- Next-token predictionFor bothThe one mechanism behind every LLM, predicting the next token again and again, and the behaviours that follow from itneeds: Tokens and tokenization110 questions
- Embeddings and meaningFor bothText turned into vectors so that similar meanings sit close together, and what that does and does not captureneeds: Tokens and tokenization110 questions
- Attention and transformers (intuition)For engineersHow a transformer decides which earlier tokens matter, why attention cost grows with context, and how blocks stack into a modelneeds: Next-token prediction110 questions
- How pre-training builds a language modelFor bothHow a model learns from trillions of tokens of text and code, what the data and compute buy, and the questions the data raisesneeds: Next-token prediction110 questions
- Post-trainingFor bothHow instruction tuning, preference tuning and reinforcement learning on checkable tasks turn a raw text predictor into an assistantneeds: How pre-training builds a language model110 questions
- The context windowFor bothEverything the model sees at once, how big windows have become, and why quality drops as context growsneeds: Tokens and tokenization110 questions
- Sampling and temperatureFor bothWhy the same prompt gives different answers, the temperature and top-p knobs, and how to get repeatable or varied output on purposeneeds: Next-token prediction110 questions
- Reasoning (thinking) modelsFor bothModels that spend extra tokens thinking before they answer: when that helps, what it costs, and how to prompt and read themneeds: Post-training110 questions
- Multimodal modelsFor bothHow models read images, PDFs, audio, video and screens, and where their perception still failsneeds: Kinds of generative AI110 questions
- Knowledge cutoff and toolsFor everyoneWhy models miss recent facts, how search and connectors fill the gap, and how to tell memory from a real lookupneeds: How pre-training builds a language model110 questions
- How a chat reaches the modelFor bothRoles, system prompts and chat templates turn a conversation into one token stream that a stateless model reads fresh every turnneeds: Next-token prediction110 questions
- How models call toolsFor bothThe model writes a structured tool request, the app runs it and feeds the result back: the mechanism behind search, code execution and agentsneeds: Next-token prediction110 questions
- Inference: how a trained model runsFor bothParameters, prefill and decode, the KV cache and mixture-of-experts explain why models differ in speed, memory needs and priceneeds: Next-token prediction110 questions
Scenarios using this domain
Where to study
- Andrej Karpathy: Deep Dive into LLMs like ChatGPT (opens in a new tab)VideoFree
A three-hour walk through pre-training data, tokens, base models and post-training, from a practitioner.
- FineWeb: decanting the web for the finest text data at scale (opens in a new tab)ArticleFree
A worked example of turning Common Crawl into training data: filtering, deduplication and what each step changes.
- Training Compute-Optimal Large Language Models (Chinchilla) (opens in a new tab)PaperFree
The study showing that, for a fixed compute budget, model size and training tokens should grow together.
- Scaling Laws for Neural Language Models (opens in a new tab)PaperFree
The first large study showing that loss falls smoothly with model size, data and compute.
- Stanford CS336: Language Modeling from Scratch (opens in a new tab)CourseFree
A free university course that covers data, training and scaling in depth, with lecture notes.
- Common Crawl (opens in a new tab)ToolFree
The open web archive behind many pre-training sets; shows what raw crawl data looks like and how to opt out.
- Context windows (Claude docs) (opens in a new tab)DocsFree
How the window fills with input and output, what happens at the limit, and how tool results count.
- Lost in the Middle: How Language Models Use Long Contexts (opens in a new tab)PaperFree
The study showing models use facts at the start and end of a long input better than facts in the middle.
- Context Rot (Chroma research) (opens in a new tab)ArticleFree
Tests of many models showing accuracy falls as input grows, even on simple tasks.
- RULER: What's the Real Context Size of Your Long-Context Language Models? (opens in a new tab)PaperFree
Shows models that ace simple retrieval tests still degrade on harder long-context tasks.
- Effective context engineering for AI agents (Anthropic) (opens in a new tab)ArticleFree
Practical ways to keep only the useful tokens in context: compaction, notes and trimmed tool results.
- Introducing Contextual Retrieval (Anthropic) (opens in a new tab)ArticleFree
Explains sending only retrieved passages instead of the whole knowledge base, and when that is enough.