Loading Larkspur mini
Chapter 1 of 7
Prefill and decode
Monday mornings, customers wait for the assistant’s first word, then watch the reply trickle out. The team runs the server. What does one request cost?
This chapter: Why does the first token take a different time from every token after it?
About this chapter
You will learn
- Prefill: the model reads the whole prompt in one pass
- Decode: the model writes the reply one token per pass
- Why time to first token grows with the prompt, while time per token barely does
Words you’ll meet
- Inference
- Running a trained model to get its reply: the work a server does for every request.
- Forward pass
- One run of the model over its input, ending in a score for every possible next token.
- Prefill
- The first pass of a request: the model reads every prompt token at once and picks the first reply token.
- Decode
- Every pass after that: the model adds one token to the reply.
- Time to first token
- How long a customer waits before the reply starts: the queue plus the prefill.
- Time per token
- How long each later token of the reply takes: one decode pass.
Step 1 of 5
A request arrives: “We reply within five business”. starts: one reads all 7 tokens together, the .
Read the prompt.
Loading Larkspur mini