internalsGet Pro

AI Engineering · Module 02

How LLMs work: what builders need to know

Lessons
12
Free
2
Reading
~2 h

Your progress

0 / 12 lessons done

Sign in to track

Lessons

  1. Next-token prediction: how an LLM writes textFreeMost surprises in an AI feature trace back to how the model writes: answers that change between runs, slow long replies, text cut off mid-sentence, a confident number that was never in the input. Once you see the loop, you can predict each of them.12 min
  2. Embeddings: turning words into numbers with meaningSearch by meaning, grouping similar messages and handing a model the right documents all start with embeddings. Knowing what the numbers are and how they are compared tells you when that search will find the right thing and when it will miss.13 min
  3. Attention: how the model decides what to focus onEvery prompt you send is read through attention. It explains why long prompts take more work, why a detail in the middle of a long input can be missed, and why the order of a long prompt is worth testing.15 min
  4. Transformers: the architecture in one pictureModel size shows up in every bill and every latency number you see. Knowing what is inside a model tells you why a larger one costs more for each token, and why you can’t read a hosted model’s size from its price.8 min
  5. Training stages: pretraining, tuning and feedbackEvery time a prompt works, a model refuses, a model doesn’t know last month’s news or a new version writes longer answers, you are seeing the result of a training stage. Knowing which stage caused it tells you which fix is yours to make.14 min
  6. KV cache and prompt caching: reusing earlier workMost AI features send the same long instructions on every call. Placing one cache breakpoint correctly can cut that part of the bill by about nine tenths; placing it wrongly makes every call cost more than no caching at all, with no error to warn you.17 min
  7. Quantization: running models in less memoryThe first question about any open model you want to run is whether it fits on the GPUs you can rent. Quantization often decides the answer, and with it the hardware bill.8 min
  8. Mixture of experts: large models that run fastMany open-weight models now list two parameter counts. Read the wrong one and you rent GPUs that can’t load the model, or skip a model that would have been fast enough.7 min
  9. Reasoning effort: paying for extra thinkingEvery call to a thinking model has an effort level, set by you or by a default. It moves cost and wait on every call, and it is the first setting to check when a feature thinks more than its task needs.8 min
  10. Hallucinations: why models state false thingsFreeEvery feature that summarizes, answers or drafts will sometimes state something nobody said. The call succeeds, the checks pass and the sentence reads well, so you only catch it if you designed for it.13 min
  11. Under the hood: queries, keys and valuesModel docs, inference servers and pricing pages talk about heads, KV cache memory and why long prompts are slow. This arithmetic is what all of those words refer to.17 min
  12. Under the hood: how decoding picks each tokenEvery token a model writes is chosen by a decoding rule. Knowing that rule tells you which settings to tune when you run an open-weight model, and why on the Claude API you get consistency from prompts, schemas and checks instead.16 min

Practise with

No tools or paper guides for this module yet.

Terms this module teaches 57

Open glossary

Active parameters

The parameters a mixture-of-experts model uses for one token: the shared parts plus the experts the router picked. It decides the work per token.