Sub topic 10
Asking again: checking consistency across samples
This chapter assumes you know that a model picks each next token from a probability distribution, and that temperature changes how spread out that distribution is. You should also be able to read short Python functions.
The idea
A model that knows a fact tends to give the same answer each time you ask. A model that is guessing tends to give different answers, because many wrong candidates have similar probability. Self-consistency checking uses this difference. You ask the same question several times, compare the answers, and treat disagreement as a warning sign.
This only works if the answers can differ. That depends on sampling, so a quick look at temperature helps.
Why sampling makes the check possible
Temperature divides the model's raw scores (logits) before they become probabilities. The code below shows the effect on three candidate tokens.
import math
def softmax(logits, temperature=1.0):
scaled = [x / temperature for x in logits]
m = max(scaled)
exps = [math.exp(x - m) for x in scaled]
total = sum(exps)
return [e / total for e in exps]
logits = [2.0, 1.0, 0.5]
print(softmax(logits, temperature=1.0))
print(softmax(logits, temperature=0.5))At temperature 1.0 the top candidate gets about 0.63 of the probability. At 0.5 it gets about 0.79. A lower temperature concentrates probability on the leading candidate. A higher one spreads it out.
For a consistency check, use a moderate temperature, often around 0.7 to 1.0. At temperature 0 the model returns nearly the same answer every time, so agreement tells you nothing. Many separate chats at default settings also work.
The procedure
- Ask the same question 5 to 10 times in separate, independent conversations or API calls.
- Reduce each response to its key claim, such as a date, a name, or a number.
- Normalize the claims so trivial differences do not count as disagreement.
- Find the most common answer and the share of samples that agree with it.
from collections import Counter
def agreement(answers):
normalized = [a.strip().lower().rstrip(".") for a in answers]
value, count = Counter(normalized).most_common(1)[0]
return value, count / len(normalized)
samples = ["1889", "1889.", "1887", "1889", "1901"]
print(agreement(samples))This prints ('1889', 0.6). Three of five samples agree. The normalization step makes "1889." count as "1889".
Reading the result
| Agreement | What it suggests | Next step |
|---|---|---|
| Nearly all samples match | The model has a stable answer | Check proportionally to the stakes |
| A clear majority matches | Probably a real signal, with some doubt | Verify if the answer matters |
| Answers scatter | The model is likely guessing | Do not use the answer without a source |
Common errors
- Treating agreement as proof. A model can repeat the same wrong answer consistently. A common misconception in its training text, or a systematic bias, produces confident and consistent errors.
- Comparing long text directly. Two paragraphs can express the same claim in different words. Extract the claim first, then compare.
- Using too few samples. With three samples, one outlier changes the result a lot. Five or more gives a steadier picture.
- Sampling in one conversation. Later answers in the same chat see the earlier ones and tend to repeat them. Use fresh contexts.
- Using temperature 0. Identical outputs look like perfect agreement but show nothing.
Cost and fit
Each extra sample costs time and money. The check suits questions with short, comparable answers such as dates, quantities, names, and yes/no decisions. It fits open-ended writing poorly, because there is no single claim to compare. For those cases, pull out individual factual claims and check each one.
Exercise
You ask a model for the founding year of a small company five times at temperature 0.8 and get 1998, 1998, 2001, 1995, 1998. What agreement share do you get, and what would you do next?
Show answer
The most common answer, 1998, appears 3 of 5 times, so the share is 0.6. That is a moderate signal with real disagreement. Because the other answers differ, check the year against a primary source such as the company's registration record or official website before using it.
Exercise
A model gives the same wrong date in ten of ten samples. Why can this happen, and what does it tell you about the limits of the check?
Show answer
The error may come from a widespread misconception in the training text or from a systematic bias in what the model learned, so every sample follows the same high-probability path. Consistency shows stability, not truth, so a source check is still needed for anything important.