The model has choices — how does it pick one?
Suppose the current text is “The weather is …”. The model may consider “sunny”, “cold”, “changing”, and thousands of other tokens. The neural network first produces a raw score for every vocabulary token.
Those raw scores are called logits. A softmax operation converts them into a probability distribution that is easier to interpret and sample from.
One illustrative generation step
Treat the table as one instant in generation. A decoding rule selects from these candidates; after a token is appended, the model computes a new distribution for the longer context.
A paragraph emerges one selected token at a time
Greedy decoding — always take the largest probability
If the distribution is 66.5%, 24.5%, and 9.0%, greedy decoding selects sunny. It is simple and repeatable for a fixed model/input, but repeatedly taking only the top choice can make text rigid and does not make the answer factually verified.
Temperature — make the distribution sharper or flatter
Temperature changes the relative spread of candidate probabilities before sampling. Lower positive temperatures make high-scoring tokens dominate more strongly. Higher temperatures flatten the distribution so lower-ranked candidates become more viable.
Same toy logits [2, 1, 0], two temperatures
Top-k and top-p — narrow the candidate pool
Two common filters
Top-k uses a fixed candidate count. Top-p uses a probability-mass threshold, so the number of retained tokens can change from one generation step to the next.
Which decoding style fits the job?
Start from the task, not from a fashionable setting
Why the next lesson matters
We know how the model turns its internal scores into text. How should we write the request we give it so the task is clear and testable?
Prompt Engineering →Summary / Key Takeaways
- An LLM first produces raw vocabulary scores called logits.
- Softmax converts logits into a probability distribution over candidate next tokens.
- Greedy decoding always chooses the highest-probability candidate.
- Temperature changes how concentrated or spread out the distribution is; literal division by T = 0 is invalid.
- Top-k keeps a fixed number of candidates, while top-p keeps enough candidates to reach a cumulative probability mass.
- Decoding settings should match the task, and structured outputs still require validation.