CONFIGURATION

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.

FocusedCreative
0.7

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.

More focusedMore diverse
K=50

Top-P (Nucleus)

Selects tokens whose cumulative probability reaches P. Creates a dynamic cutoff — more tokens when probabilities are spread, fewer when concentrated.

More focusedMore diverse
P=0.9

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."

ShortLong
128K tokens

Temperature Effect on Output

Temp: 0.1
Highly focused — picks the most likely token
Temp: 0.7
Balanced — good mix of creativity & coherence
Temp: 1.5
Creative — probabilities are flattened, more random

Context Window: What the Model "Sees"

128K token limit
[... 45,000 tokens of prior conversation ...]

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.

quantum 35%
quantum
physics 18%
physics
technology 12%
technology
banana 0.01%
banana

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.

quantum 35%
quantum
physics 18%
physics
technology 12%
technology
banana 0.01%
banana

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

Next in Series

Inference Engines

llama.cpp, Ollama, vLLM & how they differ