AI engineering roadmap

How models work

Inside a transformer at inference time: attention, choosing the next token, and why the cache matters. 3 topics, about 9 hours.

  1. Attention

    About 4 h.

    • Compute one row of scaled dot-product attention by hand
    • Explain the causal mask and why scores are divided by √d
    • Describe what multiple heads add

    Visualisers: Attention

  2. Decoding and sampling

    About 2 h.

    • Apply temperature, top-k and top-p to a set of logits
    • Work out which tokens survive a top-p cut-off
    • Explain greedy decoding, repetition penalties and entropy

    Visualisers: Sampling

  3. Inference: prefill, decode and the KV cache

    About 3 h.

    • Work out KV cache memory from a model's shape
    • Explain why time to first token and tokens per second have different limits
    • Say how grouped-query attention shrinks the cache

    Visualisers: KV cache