Skip to main content

A tiny experiment

Why can AI answer the same question differently?

One reason is how the next word is chosen. Keep the same three choices, try a different draw and see what changes. You do not need to know any maths to start.

A tiny teaching example with invented scores. This is not a language model. The words are labels for three choices, not actual model predictions.

Temperature

Change how concentrated the chances are. Each change restarts the preset draw sequence.

How to choose

Sampling uses a draw between 0 and 1. Choosing the highest score ignores the draw.

Preset demonstration draws, repeated in this order: 0.1 → 0.7 → 0.95 → 0.1.

The chosen continuation

We could start today.

Draw 1/3 · Value: 0.1

This draw lands here: 0 ≤ 0.1 < 0.6652

The lower endpoint is included; the upper endpoint is excluded. Intervals use the order of the choices below.

The three choices, scores and chances
ChoiceScoreChance
todaySelected266.5%
later124.5%
never09.0%

Displayed percentages and interval endpoints are rounded. The calculation uses full precision; rounded percentages may not add up to exactly 100%.

How the numbers work

Divide each score by the positive temperature, exponentiate, then divide by the sum. In code we subtract the largest score first to keep the calculation stable. This gives the same probabilities.

pᵢ = exp((scoreᵢ − max(score)) / T) / Σⱼ exp((scoreⱼ − max(score)) / T)

softmax([2, 1, 0] / 1) = [0.6652; 0.2447; 0.09]

Take this example with you

Copy the current settings and result to compare them with another draw. The text updates whenever the experiment changes.

The same possibilities can lead to different choices

A language model assigns possible continuations different chances of being chosen. Sampling is one way to choose among them. A higher temperature spreads those chances more evenly in this example, so the lower-scored choices take up more room. A real model repeats a choice process over many tokens, which may be words or pieces of words.

What this means when you use AI

You can ask for another version when you want a different angle or wording. Model versions, the conversation so far, instructions and tools can also affect an answer. Some apps do not expose a temperature setting. A lower temperature does not establish factual correctness.

Explore the real machinery

These sources explain real models and decoding. The three scores above were invented for this lesson; they were not calculated by a language model or an attention layer.

Give your next task a clearer starting point

Try a worked invitation to see how source details, audience and format help shape a first draft.

Make a useful first draft