Skip to content
Learn · AI Lessons · Free lesson

Temperature, Top-P and Other Generation Parameters

You have crafted a careful prompt, but two runs of the same request produce very different results. One response is crisp and on-target, the next meanders. Or perhaps you need deterministic output for a classification task but keep getting variation you cannot account for. The culprit, more often than not, is not the prompt. It is the generation parameters you are using, or not using deliberately. Large language models do not produce text the way a calculator produces a number. At each step the model outputs a probability distribution across tens of thousands of possible next tokens, the basic units of text, and generation parameters determine how it samples from that distribution. Change the parameters and you change the character of the output entirely, without touching a single word of your prompt. This lesson demystifies the parameters practitioners meet most: temperature, top-p and top-k, repetition and frequency penalties, and max tokens.

Start this lesson freeFree forever. No card required.
Intermediate 10 minutes AI for Practitioners Certificate upon completion

Create your free account

Unlock the full lesson, the quiz, and your verifiable completion.

Continue with Google
or
Continue with email

By continuing you agree to the Institute of AI terms of use and privacy policy.

Learners across the UK study with the Institute of AI
Open to everyone From the UK's professional body for AI 100% free, no card required
What you'll learn

By the end of this lesson, you will be able to:

  • Explain what temperature does to the probability distribution, and what it can never change.
  • Choose between top-p and top-k, and say why nucleus sampling adapts to how confident the model is.
  • Use repetition and frequency penalties without suppressing recurrence the text actually needs.
  • Match a parameter set to the task, from near-zero for structured output to higher values for creative work.
  • Tune one parameter at a time, and log the settings that produced a result.

Recommended before you start

None of these are hard requirements. The lesson is easier if they are already familiar, but everything it uses is explained along the way, so you can start without them.

  • Hands-on use of a model through an API or playground where generation parameters can be set.
Join Others Learning AI

Free to start. Free to finish. Free to prove.

Start this lesson free
Inside this lesson

3 sections, about 10 minutes.

Section one is open to everyone. Create a free account to work through the rest and take the quiz.

01

Temperature: The Confidence Dial

Free preview

Before a model picks the next token, it produces raw scores called logits for every token in its vocabulary, which are converted into probabilities by a softmax function. Temperature is applied before that conversion: each logit is divided by the temperature value, and softmax then converts the result into probabilities. A temperature of 1.0 leaves the distribution exactly as the model produced it. Below 1.0 the distribution sharpens, so the highest-probability tokens become relatively more likely and lower-probability tokens are further suppressed. At the extreme, temperature 0 is effectively greedy decoding: the model always picks the single highest-probability token, producing highly consistent output for the same input. Above 1.0 the distribution flattens, so tokens the model considered unlikely become more competitive, producing more varied and potentially surprising output. Pushed too high, this tips into incoherence as the model starts selecting tokens it would ordinarily dismiss. Think of it as a confidence dial: at low temperature you get a cautious expert who gives one clear, considered answer, while at high temperature you get a freewheeling brainstorm where unusual connections emerge but nonsense occasionally slips in too. A common misconception is that temperature changes what the model knows. It does not. It changes how the model samples from what it knows. A temperature of 0 does not make the model more accurate, it makes it more consistent, and if the most probable token happens to be wrong you will get the same wrong answer every time. As starting points that vary by model and task, extraction and classification suit a temperature around 0 to 0.2, summarisation and question-answering around 0.3 to 0.5, and creative or generative tasks around 0.7 to 1.0.

02

Top-P and Top-K: Filtering the Candidate Pool

Unlock free
03

Repetition Penalties, Frequency Penalties, and Max Tokens

Unlock free
How it works

Walk away with proof, not just knowledge.

Step 1

Study the lesson

Work through every section at your own pace, from start to finish.

Step 2

Pass the quiz

A short set of questions on what you have just covered.

Step 3

Get your certification

Every completion has a certificate that you can share publicly for anyone to verify.

Your record of completion

Finish the lesson. Keep the proof.

The Institute of AI
Record of completion
Temperature, Top-P and Other Generation Parameters
Completed by
Your name
Quiz score
90%
theinstituteofai.co.uk/verify/lesson/…

Pass the quiz and the Institute of AI issues you a record of completion with your score. Every completion has its own public verification page, so the link you put on your CV or LinkedIn profile can be checked by anyone, at any time.

  • Verifiable by anyone, with no account needed
  • One link for your CV, email signature, or LinkedIn profile
  • Issued by the UK's professional body for AI
— Common questions —

Frequently asked questions.

Is this lesson really free?+
Yes. Every AI lesson from the Institute of AI is free to take and free to complete, including the quiz and your record of completion. There is no trial, no card, and no catch.
Do I need a technical background?+
This lesson is pitched at intermediate level, so it helps to be comfortable with what is recommended above, though none of it is a hard requirement. Everything is explained in plain English, and if a term matters, the lesson covers it before using it.
How long does this lesson take?+
Around 10 minutes to work through, plus the quiz at the end. You can leave and come back at any point.
What do I get when I finish?+
A record of completion with your score, held on your profile. Each completion has a public verification page, so you can share a link on your CV or LinkedIn profile that anyone can check.
What is the Institute of AI?+
The Institute of AI is the UK’s professional body for artificial intelligence. It sets the standard of AI practice, works to that standard itself, and puts it within reach of everyone else. Its work runs across four areas: Accreditation, Practice, Platforms, and AI for All.

Join learners across the UK and start "Temperature, Top-P and Other Generation Parameters" today.

Free lessons, a quiz to test what you have learned, and a completion you can verify publicly. All from the UK's professional body for artificial intelligence.

The Institute of AI

Free to learn.
Yours to prove.

Every AI lesson is free to start, free to finish, and ends in a completion you can verify publicly.