Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · AI · From a model to an app · about 16 min to read

Play it as a journeyTutor comes with a plan

Inference (sampling, context, KV cache, hallucination)

Inference
Inference · Open board

The Inference board of the How LLMs Work track. Training is over and the weights will never change again. This is what happens in the seconds after you hit enter.

Before you start. You need to know that the model is a huge pile of fixed numbers, its parameters (a 7-billion-parameter model is a pile of 7 billion of them), which scores every word that could come next; From Transformer to LLM is where that pile came from. It deals in tokens, chunks of roughly three quarters of a word, from Tokens & Embeddings. No maths beyond adding and dividing.

Lesson 12 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2019: temperature, the dial that stops a model repeating itself
  • The KV cache: notes in the margin instead of rereading the page
  • The context window: one desk, and it is only so big
  • 30 November 2022: ChatGPT, and the KV cache becomes the bill
  • Hallucination: the confident answer that was never checked
  • Where the chances come from
  • Turning the dial
  • Cutting off the tail
  • The scribe’s bill, in sums
  • How big is the margin?
  • Sixteen chats, exactly
  • All of it in code

Terms it explains: inference, How LLMs Work, token, temperature, KV cache, context window, hallucination, logits, softmax, greedy, Top-p, nucleus, Top-k, prefill, TTFT, decode, autoregressive, layers, key-value heads, grouped-query attention, stateless, grounding, prefill vs decode, sampling, the KV cache grows with context, throughput, top-k / top-p (nucleus).

Lab

One GPU, one chat, cores 99% idle. How many more chats fit before anything gets slower?

Drag Chats sharing one read of the weights to the right and watch operations per byte rise until The wall stops it.

Open The batch size dial

The model has read 'The weather today is'. How often does it say something other than sunny?

Drag How hard the drum is shaken from T = 0.1 to 5 and watch Outside the top word climb.

Open The temperature dial

Review AI