Understanding LLM Parameters
Read a little, play a little. No scary maths, and no rush.
Four knobs, two that matter most
Every LLM call carries settings that shape the answer's personality and price. Two dominate daily life; two are supporting cast.
Temperature: the creativity dial
Temperature controls randomness in token picking. At 0, the model always takes the most likely token — same prompt, same answer, ideal for support bots and RAG grounding. At 0.8–1.0, it samples adventurously — stories, brainstorms, varied ideas.
The taste test to run once: ask "give me a tagline for a socks brand" at 0.2, then at 1.0. Same prompt, different universes. Ship factual features at 0.1–0.3; reserve heat for creative ones.
Top-p: the shortlist size
Top-p (nucleus sampling) keeps only the smallest set of tokens covering probability p, then samples within it. top_p=0.9 is the sensible default; lowering it (0.5) makes output safer and duller. Rule of thumb: tune temperature or top-p, not both at once — they interact confusingly.
The supporting cast
- max_tokens: hard cap on answer length — controls cost and prevents runaway essays, but set too low it truncates mid-sentence.
- stop sequences: halt strings (
"\n\n###") that end generation cleanly — handy for structured parsing.
Temperature in numbers
Suppose the model's next-token options are "great" 70%, "good" 20%, and "fine" 10%. Temperature reshapes those odds before one is picked:
- Low temperature sharpens them, to something like 95%, 4%, 1%. "Great" wins almost every time.
- Temperature 1 leaves them as they are.
- High temperature flattens them, toward something like 50%, 30%, 20%. The unlikely words get a real chance.
Over a long answer these small differences compound, which is why a hot setting can drift into odd phrasing or invented details while a cold one stays predictable.
Sensible starting settings
These are starting points, not rules. Measure on your own task and adjust.
- Extraction and classification: temperature 0, with structured output, so the same input always gives the same result.
- Answers grounded in retrieved documents: around 0.2, with a
max_tokenscap that fits your interface. - General chat assistant: around 0.5 to 0.7, for natural variety without wandering.
- Brainstorming and creative writing: around 0.9 to 1.0.
- Code generation: low, around 0 to 0.2, because code needs precision more than surprise.
Other knobs you will meet
- Frequency and presence penalties discourage the model from repeating the same words or topics. Useful for long creative text, rarely needed elsewhere.
- Seed, where supported, makes sampling more repeatable for testing, though providers usually do not guarantee identical output.
Not every provider supports every knob, and newer reasoning models may ignore temperature entirely, so check the documentation for the model you call.
Testing a change properly
Because sampling is random, one good or bad answer proves nothing. When you change a setting, run the same set of 10 to 20 prompts before and after, several times each, and compare the results side by side. Change one knob per experiment, and write down what you changed and what you saw. That small discipline turns "it feels better" into evidence.
Remember this
- Cold (0.2) for facts and RAG with citations; warm (0.8+) for ideas.
- Cap outputs, use stop strings, and change one knob at a time.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
Related chapters
Spotted a mistake or want a topic covered? Report an issue