At each step the model outputs logits, raw scores for every token, which are converted to probabilities using the softmax function, and the highest-probability token is called the greedy choice. Greedy decoding always picks that token, which is what temperature 0 approximates, while sampling introduces controlled randomness. The choice between them is a task decision: extraction and classification want greedy, creative writing wants sampling.
What you need
- One task, run twice under different settings
- Access to the temperature and top-p settings
- A note of what a good answer looks like for this task
Step 1: Run the task greedy first
Set temperature to 0 and run the task. Record the answer and whether it is correct and complete.
Step 2: Run the same task with sampling
Set temperature to 0.7 and top-p to 0.9 and run the identical task again. Record the answer and whether it is correct and complete.
Step 3: Pick by the task, not by preference
If the task feeds a downstream system or needs one right answer, pick greedy. If the task needs varied ideas or drafts, pick sampling. Record the choice with the task so the next run uses the same settings.
Worked example: synthetic greedy versus sampling test
The table below is a synthetic example. It shows the expected result of comparing the two modes; no model was run.
| Task | Greedy (temp 0) | Sampling (temp 0.7) |
|---|---|---|
| Extract a date | Correct, same every time | Sometimes reworded |
| Classify a ticket | Correct, stable | Occasionally changes class |
| Draft a story opening | Safe but flat | Varied, pick the best |
| Choice | Greedy for the first two | Sampling for the third |
Expected result (UNTESTED). greedy wins for extraction and classification, sampling wins for the story draft, and the choice is recorded per task. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Greedy decoding often gives safe but repetitive text; sampling trades some reliability for variety.
- For extraction, classification and any task feeding a downstream system, use temperature 0.
- Greedy is what temperature 0 approximates; it is not a separate mode on most APIs.
- Sampling introduces controlled randomness; the same prompt can give different answers, which is a feature for drafts and a bug for facts.
