AI engineering

Stage 1 · Lesson 5 of 8

Temperature and sampling

How LLMs work: tokens and context

At each step the model gives a probability for every possible next token, and is how it picks one. Temperature changes how adventurous that pick is. Low values, like 0 to 0.3, make the most likely token win almost every time.

That suits extraction, and code. Higher values, like 0.8 to 1, spread the choices out, which suits brainstorming. Top-p is another setting: it limits the pick to the smallest group of tokens whose probabilities add up to p. Change one setting at a time, and judge the effect on real inputs, not on a single run.

Common trapbelieving temperature 0 makes output fully repeatable: batching (the provider running many requests together) and hardware can still change results slightly, and some reasoning models ignore or fix these settings.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Keep handy

Also worth your time

Mark this stage as not done?