LLM Parameters
Parameters control how an LLM generates text — from creativity to precision. Understanding them gives you control over the output.
Key Parameters
Each parameter shapes how the model selects its next token
Temperature
Controls randomness in token selection. Lower values produce more deterministic, focused outputs. Higher values encourage creativity and diversity.
Top-K
Limits token selection to the K most likely candidates. K=0 means no limit. Reduces the chance of selecting unlikely or nonsensical tokens.
Top-P (Nucleus)
Selects tokens whose cumulative probability reaches P. Creates a dynamic cutoff — more tokens when probabilities are spread, fewer when concentrated.
Context Window
The maximum number of tokens the model can process at once — including both your input and the generated output. Determines how much the model can "remember."
Temperature Effect on Output
Context Window: What the Model "Sees"
User: Explain quantum computing in simple terms
Assistant: Quantum computing uses quantum bits, or qubits, which can exist in multiple states simultaneously...
User: How does this compare to classical computing?
Assistant: Classical computers use bits that are either 0 or 1. Qubits can be both at once through superposition...
User: What are the practical applications?
Assistant: ...
Top-K vs Top-P: Token Selection
Both methods filter unlikely tokens, but in different ways
Top-K = 50
Always picks from the 50 most likely tokens, regardless of their probability distribution.
Even unlikely tokens like "banana" can be selected if in top-K
Top-P = 0.9
Picks the smallest set of tokens whose probabilities sum to 90%, dynamically adjusting the cutoff.
Unlikely tokens are excluded once cumulative probability reaches P
Recommended Settings
🎯 Factual Answers
Temperature: 0.2–0.4, Top-P: 0.8, Top-K: 20–30
✍️ Creative Writing
Temperature: 0.7–1.0, Top-P: 0.9, Top-K: 50
💻 Code Generation
Temperature: 0.1–0.3, Top-P: 0.9, Top-K: 0 (unlimited)
🤝 Chat / Assistant
Temperature: 0.5–0.7, Top-P: 0.9, Top-K: 50