From pretraining to prediction / 3 of 9
Inside an LLM
What you’ll learn
- Explain the main idea of “Inside an LLM” in your own words.
- Trace a concrete example and identify the assumptions behind it.
- Apply the principle in a practice problem and recognize a common failure.
The idea, intuitively
Many text LLMs use a decoder transformer: token embeddings enter repeated attention and feed-forward blocks, then an output projection produces vocabulary scores. The model predicts distributions rather than directly storing a single answer per question.
Separate what a model learned during training from what an application supplies at runtime. Generation settings change how outputs are selected, while architecture and precision affect resource needs. The labs use small transparent calculations so you can understand mechanisms without downloading a model or calling an API.
Under the hood
Residual connections carry information across blocks. Normalization stabilizes transformations. During decoding, a key-value cache reuses past attention states to avoid recomputing them; the cache consumes additional memory.
Weights and context are different: supplying a document does not ordinarily retrain the model.
A worked example
A long conversation can fit model weights in memory yet run out of space because its KV cache grows with context and batch size.
How to use this way of thinking
Compare one setting at a time using fixed inputs and a written quality rubric. Record the checkpoint, tokenizer, decoding options, and hardware. Report failures and resource costs alongside successful examples. Do not infer factual reliability from confidence, fluency, or parameter count alone.
Try it yourself
Explain why prompt text and model parameters have different lifetimes.
Key takeaways
- Scores over the token vocabulary
- Weights and context are different: supplying a document does not ordinarily retrain the model.
- Check the assumptions with a small example before applying this idea to a larger system.
Check your understanding
Use feedback to learn. Quiz scores and lesson completion are tracked separately.
Go to lesson completionFurther reading
Original papers and reference material for this school. External resources may be in English and require internet access.
Hugging Face: generation configuration (opens a new tab)llama.cpp project (opens a new tab)Finish this lesson
Mark this lesson complete when you’re ready to continue.