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.

ControlsLow valueHigh value
Max tokensOutput length limitCuts text off early (risk: truncation)Wastes compute on unnecessarily long output
TemperatureRandomness / focusDeterministic, focused, repetitiveCreative, diverse, sometimes incoherent
Top-kCandidate pool sizeVery restricted vocabulary choicesWider, more varied vocabulary choices
Top-p (nucleus)Cumulative probability cutoffOnly the most likely tokens consideredLong tail of unlikely tokens allowed in
Min-pMinimum relative probabilityAggressively prunes low-probability tokensKeeps more low-probability tokens available
Frequency penaltyRepetition toleranceRepetition-friendly (e.g. poetry)Repetition-discouraging (e.g. summarization)
Presence penaltyTopic noveltySticks to known patternsPushes toward novel topics
Stop sequencesHard cutoffGeneration 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.

📂 Subtopics