beginner~3h
7 LLM Generation Parameters
The 7 levers that control every LLM generation — max tokens, temperature, top-k, top-p, frequency penalty, presence penalty, and stop sequences — plus bonus min-p sampling.
7 LLM Generation Parameters
Each lever controls a different aspect of generation. Temperature/top-k/top-p/min-p tune randomness; the rest shape length and repetition behavior.
| Controls | Low value | High value | |
|---|---|---|---|
| Max tokens | Output length limit | Cuts text off early (risk: truncation) | Wastes compute on unnecessarily long output |
| Temperature | Randomness / focus | Deterministic, focused, repetitive | Creative, diverse, sometimes incoherent |
| Top-k | Candidate pool size | Very restricted vocabulary choices | Wider, more varied vocabulary choices |
| Top-p (nucleus) | Cumulative probability cutoff | Only the most likely tokens considered | Long tail of unlikely tokens allowed in |
| Min-p | Minimum relative probability | Aggressively prunes low-probability tokens | Keeps more low-probability tokens available |
| Frequency penalty | Repetition tolerance | Repetition-friendly (e.g. poetry) | Repetition-discouraging (e.g. summarization) |
| Presence penalty | Topic novelty | Sticks to known patterns | Pushes toward novel topics |
| Stop sequences | Hard cutoff | — | Generation stops the instant the string appears (unlike the other 6, gradual, levers) |
4
Subtopics
1
Exercises
1
Projects
5
Quiz Qs
4
Flashcards
▶📚 Prerequisites(1)
🎓 Learning objectives
- •Name and configure all 7 generation parameters plus bonus min-p sampling
- •Explain the difference between frequency penalty and presence penalty
- •Use stop sequences to enforce strict structured-output boundaries
- •Choose an appropriate max_tokens value to avoid truncation without wasting compute
7 LLM Generation Parameters is a Pro topic
Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.