Self-consistency prompting is a technique where you ask a language model the same reasoning question several times, let each run work through its own chain of reasoning, and then keep the final answer that appears most often. It was introduced by Wang et al. in 2022 as a replacement for taking a single “greedy” answer, and it works best on problems with one checkable answer, such as arithmetic, logic puzzles and classification. The trade-off is cost: five samples cost roughly five times the tokens of one.
Featured image: “Digital Abstraction: Neural Network Glow” by Michael Gaylard from Horsham, UK, licensed under CC BY 4.0.
This guide explains why the method works, walks through a worked example, gives a copy-ready prompt and a small voting script, and covers the cases where it does not help at all.
The idea in one paragraph
Self-consistency rests on a simple observation: a hard problem can usually be solved along several different lines of reasoning, and the correct answer tends to be the one those lines agree on. Wrong answers, by contrast, are usually wrong in different ways. If you sample five reasoning paths and three end at 67 while the other two end at 35 and 64, the 67 is more trustworthy than any single run would have been.
Two terms need defining. Chain-of-thought (CoT) prompting means asking the model to write out intermediate reasoning steps before the final answer. Greedy decoding means always choosing the single most likely next token, which produces one deterministic reasoning path. Self-consistency keeps the chain-of-thought prompt but replaces greedy decoding with sampling (some randomness, controlled by settings like temperature) plus a vote over the final answers.
What the original paper reported
The method comes from the paper Self-Consistency Improves Chain of Thought Reasoning in Language Models by Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery and Denny Zhou. Compared with standard chain-of-thought prompting, the authors reported accuracy gains on arithmetic and commonsense reasoning benchmarks, including +17.9% on GSM8K (grade-school math word problems), +11.0% on SVAMP, +12.2% on AQuA, +6.4% on StrategyQA and +3.9% on ARC-challenge.
Two cautions apply when reading those numbers. First, they were measured on the models available in 2022; current models score much higher on these benchmarks without any tricks, so the headroom is smaller. Second, the gains depend on the task having a single answer that can be extracted and compared. The paper is evidence that voting over sampled reasoning helps on that kind of task, not a promise of a fixed percentage on yours.
A worked example
A classic illustration uses a short age puzzle. The answers below are illustrative, written to show the pattern you will see in practice, not output captured from a specific model.
When I was 6, my sister was half my age. Now I am 70. How old is my sister?
A single quick answer can go wrong by computing “half of 70” and replying 35. That is the trap the puzzle is built around. If you sample five step-by-step answers instead, the runs might look like this:
| Run | Reasoning summary (illustrative) | Final answer |
|---|---|---|
| 1 | Sister was 3 when I was 6, so she is 3 years younger. 70 – 3 = 67. | 67 |
| 2 | Half of my current age is 35. | 35 |
| 3 | The age gap is 6 – 3 = 3 and never changes. 70 – 3. | 67 |
| 4 | Sister was 3. 64 years passed. 3 + 64 = 67. | 67 |
| 5 | Gap is 3, but misreads “now” and subtracts from 67. | 64 |
The vote is 67 (three runs), 35 (one) and 64 (one). The majority answer is correct even though two of the five runs were not. Notice that runs 1, 3 and 4 reach 67 by different routes: subtracting the gap, stating the gap is constant, and adding elapsed years. That diversity is the point. Agreement between genuinely different reasoning paths is stronger evidence than the same path repeated.
How to run self-consistency, step by step
Running self-consistency takes four steps: prompt for reasoning, sample several times, extract the final answers, and vote. Each step has a common way to go wrong.
1. Write a prompt that separates reasoning from the answer
The vote only works if you can pull the final answer out of each response reliably. Ask for the reasoning first and the answer last, inside a fixed marker. Here is a copy-ready template:
Solve the problem below.
<problem>
{PROBLEM}
</problem>
Work through it step by step in a section called Reasoning.
Consider what the question is really asking before calculating.
Then give only the final answer on the last line, in exactly this form:
ANSWER: <value>
The value must be a single number with no units or extra words.
Why each part exists:
- The tags around the problem mark exactly where the input begins and ends, which matters when the problem itself contains instructions or quotes. The delimiter prompting guide covers this in more detail.
- “Step by step in a section called Reasoning” is the chain-of-thought part. Without it, the model may answer in one line and you lose the diverse reasoning paths that make voting useful.
- “Consider what the question is really asking” nudges some runs to catch traps like the “half my age” puzzle.
- The fixed ANSWER line makes extraction a one-line regular expression instead of guesswork.
- “A single number with no units” normalizes the format so “67”, “67 years” and “sixty-seven” do not count as three different votes.
2. Sample several times with some randomness
If every run uses the same deterministic settings, every run produces the same reasoning and the vote is meaningless. You need sampling diversity. With a standard model, that usually means leaving temperature at a moderate value rather than forcing it to zero; the temperature and top-p explainer describes how those settings change output. Some reasoning-focused models restrict or ignore sampling parameters, so check your provider’s documentation before relying on them. Repeated calls still tend to vary, but verify that your runs actually differ.
Five samples is a reasonable starting point for most tasks. Use an odd number to reduce ties. Going higher gives diminishing returns for most practical use, while cost grows linearly.
3. Extract and normalize the answers
Pull the value after “ANSWER:” from each response. Normalize before comparing: trim whitespace, lower-case labels, convert “67.0” and “67” to the same number. A run that has no ANSWER line should be counted as a failure, not silently dropped, because a high failure rate tells you the prompt needs work.
4. Vote and read the margin
Take the most common answer. Then look at how strong the majority is, because the margin is useful information in its own right:
- 5 of 5 agree: accept the answer.
- 3 or 4 of 5 agree: accept it, and log the case if the stakes are high.
- No clear majority (for example 2-2-1): treat the question as ambiguous or too hard. Route it to a human, add context, or rephrase the problem.
Those thresholds are a sensible default, not a rule from the paper. Tune them to how costly a wrong answer is in your application.
A minimal voting script
The script below shows the whole loop in Python. The call_model function is a placeholder: replace its body with a call to whichever API or local model you use. Everything else is plain standard library.
import re
from collections import Counter
PROMPT = """Solve the problem below.
<problem>
{problem}
</problem>
Work through it step by step in a section called Reasoning.
Then give only the final answer on the last line, in exactly this form:
ANSWER: <value>
The value must be a single number with no units or extra words."""
def call_model(prompt: str) -> str:
"""Placeholder: send the prompt to your model with sampling enabled
and return the response text."""
raise NotImplementedError
def extract(text: str):
match = re.search(r"ANSWER:\s*([-+]?\d+(?:\.\d+)?)", text)
if not match:
return None
value = float(match.group(1))
return int(value) if value.is_integer() else value
def self_consistency(problem: str, samples: int = 5):
answers = [extract(call_model(PROMPT.format(problem=problem)))
for _ in range(samples)]
valid = [a for a in answers if a is not None]
if not valid:
return None, 0.0, answers
winner, count = Counter(valid).most_common(1)[0]
agreement = count / samples
return winner, agreement, answers
# answer, agreement, raw = self_consistency("When I was 6 ...")
# if agreement < 0.6: send to human review
Two details matter. The agreement score divides by the total number of samples, not just the valid ones, so runs that failed to produce an answer lower your confidence. And the function returns the raw answers so you can log them; disagreement patterns are the fastest way to find weak spots in a prompt.
When self-consistency helps and when it does not
Self-consistency is a good fit only when the answers can be compared for exact agreement. This table summarizes the practical cases:
| Task | Fit | Why |
|---|---|---|
| Math and multi-step word problems | Good | One numeric answer, easy to extract and compare |
| Classification (sentiment, ticket category, yes/no) | Good | A small fixed label set makes voting trivial |
| Logic puzzles and rule application | Good | Different reasoning routes should converge on one answer |
| Extracting a specific field from a document | Moderate | Works if values are normalized (dates, names, amounts) |
| Simple fact lookup | Poor | No reasoning to diversify; a model that does not know the fact can repeat the same wrong answer every time |
| Open-ended writing, summaries, code | Poor for plain voting | No two outputs are identical, so there is nothing to count |
The “simple fact lookup” row deserves emphasis. Agreement is not truth. If a model has learned a wrong fact, five samples can agree on it with complete confidence. Self-consistency reduces random reasoning slips; it does not fix missing knowledge. For that, ground the model in source documents, as described in the guide to reducing AI hallucinations with better prompts.
Extending the idea to free-form answers
For outputs you cannot count, there are two practical variations. The first is Universal Self-Consistency (Chen et al., 2023), where you give the model all the candidate responses and ask it to pick the one most consistent with the others. The authors report that this improves open-ended tasks such as summarization and question answering, and matches standard voting on math without needing a fixed answer format. A prompt for the selection step can be as simple as this:
Below are {N} candidate responses to the same request.
<request>
{REQUEST}
</request>
<candidates>
<candidate id="1">...</candidate>
<candidate id="2">...</candidate>
<candidate id="3">...</candidate>
</candidates>
Identify the main claims in each candidate. Select the candidate whose
claims are most consistent with the majority of the other candidates.
Reply with the id only, on one line: SELECTED: <id>
The second variation uses disagreement as a warning signal rather than as a vote. Anthropic’s documentation on reducing hallucinations describes “best-of-N verification”: run the same prompt several times and compare the outputs, since inconsistencies between them can point to hallucinated content. You do not pick a winner; you flag the claims that change from run to run and check those by hand.
Self-consistency compared with related techniques
Self-consistency is often confused with other ways of making a model “check its work”. They solve different problems:
- Asking the model to re-check its answer in the same conversation tends to anchor on the reasoning already written. Self-consistency avoids this by running independent attempts that never see each other.
- Chain-of-verification generates a draft, writes verification questions, answers them separately and revises. It targets factual claims in long answers rather than single-answer reasoning.
- Tree of thought explores and evaluates intermediate steps, backtracking from weak branches. It searches inside one problem-solving process, while self-consistency only compares finished answers.
- Reasoning models with built-in thinking already spend extra computation before answering. Self-consistency can still be layered on top for high-stakes questions, but the improvement over a single strong reasoning run is likely smaller than it was for 2022 models, and the cost is higher.
Common mistakes
- Sampling with zero randomness. Every run returns the same reasoning, and the “vote” is one answer counted five times. Check that your raw outputs actually differ.
- Voting on unnormalized text. “Positive”, “positive.” and “POSITIVE” become three candidates. Normalize first.
- Dropping failed runs silently. If two of five runs produce no parseable answer, a 3-0 vote among the rest looks unanimous when confidence is actually 60%.
- Using it on every request. Token cost and latency scale with the number of samples. Reserve it for questions where a wrong answer is expensive, or trigger it only when a first answer looks uncertain.
- Treating unanimous agreement as proof. Agreement means the model is consistent, not that it is right. Keep human review or external validation for decisions that matter.
- Running samples sequentially in one chat. If later samples can see earlier ones, they are no longer independent. Use separate requests.
Keeping the cost under control
The cheapest version of self-consistency is adaptive: answer once, and only sample more when there is a reason to doubt the result. A practical pattern is to start with three samples, stop if all three agree, and draw two more only when they disagree. Run samples in parallel to keep latency close to a single call. If the problem includes a long shared context, such as a document, prompt caching can reduce the cost of sending that context repeatedly, depending on your provider. Finally, track the agreement rate over time; if nearly every question is unanimous on the first three samples, your task may not need the technique at all.



