LLM Foundations
Understand what a language model actually computes, so the cost, latency, and failure modes of an LLM feature stop being surprises.
Background reading
Introduction to Large Language Models
A large language model learns statistical patterns in token sequences and uses those patterns to predict what token may come next. Repeating that prediction one token at a time produces a longer response.
Give the model the text “The sky is”. Its immediate task is not to write a whole paragraph. It assigns a probability to every token that could come next, such as “blue”, “clear”, or “falling”.
The tokenizer first converts the text into token IDs. An embedding table turns each ID into a vector, and the Transformer updates those vectors by passing them through attention and feed-forward layers.
At the final position, a linear layer produces one score for every vocabulary token. Softmax converts those scores into probabilities. The system selects one token and appends it to the text.
The model then repeats the same process with the longer text. This is autoregressive generation: every new token depends on the tokens already present, so output tokens must be produced in order.
Continue with Pro
Get Pro on codebaobab.com.
What you will learn next
- 01Tokenization
- 02Embeddings and Semantic Similarity
- 03Attention and the Transformer Block
- 04Encoder, Decoder, and What an LLM Keeps
- 05Inside the Transformer Block
- 06Mixture of Experts
- 07The Context Window and the KV Cache
- 08Sampling and Decoding
- 09Quantization
- 10Adapting a Model Without Retraining It
- 11Choosing the Intervention
- 12Learning BPE Merge Operations
- 13Example 1 — Size the KV Cache Before Promising a Context Length
- 14Example 2 — Compare Three Decoding Rules
- 15Example 3 — Trace the LLM.int8() Decision
- 16Review
- 17References