Free sample lesson ยท A Closer Look Inside

Picking From The Spread

You ran it twice and got two different answers. Neither is the mistake.

Lesson 1 of the Wondering course A Closer Look Inside

Overview of AI Sampling

  • Core Mechanism: Picks words based on probability.
  • Control Dial: Adjusts how boldly the model samples.
  • Core Concepts
  • Key Outcomes

Explore how deliberate sampling and temperature settings turn AI variation from a mystery into a controllable dial.

The Mystery of Different Answers

You might ask an AI the same question twice and receive two different responses. This is not a mistake or a sign of instability.

Variation is a deliberate feature of how these systems work. It happens because the model does not just pick one answer.

Instead, it creates a list of possible next words. Then, it picks one based on probability. This picking process is called sampling.

The Sampling Process
  • Multiple Answers: The AI can give different responses to the same question without it being a mistake.
  • Deliberate Variation: Variation happens because the model evaluates multiple paths instead of picking just one.
  • Sampling: The model generates possible next words and picks one based on probability.

How Sampling Works

At every step, the model looks at a spread of options. Imagine three possible next words with different chances of being picked.

Option A might have a 60% chance. Option B has 30%, and Option C has 10%.

If you run the request twice, the model might pick Option A the first time. The second time, it might pick Option B. This small fork at the start leads to entirely different sentences later.

Word Probability Spread Example
  • Option A: Most likely next word.
  • Option B: Second likely choice.
  • Option C: Least likely choice.

The Temperature Dial

You can influence how the model picks from the spread using a setting called Temperature.

Low temperature makes the model favor the most likely options. This results in repetitive, safe, and consistent text.

High temperature flattens the differences between probabilities. This allows the model to pick unlikely words more often. This leads to more varied and less predictable results.

Temperature Settings
  • Low Temperature
  • High Temperature

Creativity Versus Probability

A common misconception is that high temperature makes the model smarter or more creative. This is not true.

Temperature only changes how boldly the model samples from the distribution. Less probable text is not always better or more clever.

If a model always took the single most likely option, it would become stuck in loops. It would produce flat, boring text that repeats itself constantly.

Temperature Misconceptions vs Facts

Predicting the Outcome

Variation comes from the sampling step, not from the model changing its mind. You did not do anything wrong if the answer changes.

One early divergence compounds over time. Everything written after that first choice is based on the new path.

Understanding this helps you predict how the system will behave. You can use these settings to balance consistency against variety depending on your needs.

How Early Divergence Compounds
  • First Choice: A small fork at the start of generation.
  • Divergence: The initial choice compounds over time.
  • New Path: Everything written after is based on the new path.

Putting It All Together

Predicting and Controlling AI Behavior
  • Identify the Goal: Determine whether you need consistency or variety for your output.
  • Set the Temperature: Adjust the dial based on your goal to favor safe options or explore unlikely words.
  • Anticipate Variation: Expect different answers across runs due to probabilistic sampling.

Check yourself

Receiving two different responses to the exact same prompt means that the model has changed or encountered an error.

  • True
  • False

Answer: False

Variation across identical requests is a deliberate feature of sampling. Because the model picks tokens based on a probability spread, different valid paths can be chosen across runs without any error occurring.

When adjusting AI generation settings, setting a _____ makes the output safe and predictable, whereas setting a _____ flattens probabilities to produce more varied results.

Answer: When adjusting AI generation settings, setting a low temperature makes the output safe and predictable, whereas setting a high temperature flattens probabilities to produce more varied results.

Low temperature causes the model to strongly favor the top-ranked options, leading to reliable and consistent text. High temperature flattens differences, allowing less probable tokens to be picked more frequently.

What does adjusting the temperature setting actually change during text generation?

  • The overall intelligence and reasoning capability of the model
  • How boldly the model selects words from the probability distribution
  • The underlying training data used to generate the response
  • The factual accuracy and correctness of the model's knowledge

Answer: How boldly the model selects words from the probability distribution

Temperature does not make the model smarter, more creative, or more knowledgeable. It simply alters how boldly or conservatively the model samples from the calculated probability distribution of options.

Keep going

This is lesson 1 of 7 in A Closer Look Inside. Next up:

  1. Decide Whether You Want Variety
  2. Buying Time To Think
  3. When It Is Just A Slower Answer
  4. Words Become Directions
  5. Attention Mixes In The Context

Start this course free

Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.