Self Consistency Decoding
Self-consistency decoding is an inference-time technique that improves the reliability of a language model's answers by sampling multiple independent reasoning paths for the same prompt and then aggregating them — typically by majority vote on the final answer. Introduced alongside Chain of Thought prompting, the method exploits the observation that a correct answer tends to be reached by several different reasoning routes, while incorrect or hallucinated answers are more idiosyncratic and rarely survive a vote. The cost is proportional to the number of samples generated, making it a compute-for-accuracy trade-off.
Think of it like asking five independent detectives to solve the same case separately. If four of them independently finger the same suspect using different lines of evidence, that consensus is far more trustworthy than a single detective's conclusion — even if that detective sounds very confident.
from collections import Counter
answers = []
for _ in range(10): # sample 10 reasoning paths
output = model.generate(cot_prompt, temperature=0.7)
answers.append(extract_final_answer(output))
best_answer = Counter(answers).most_common(1)[0][0]
Self-consistency builds directly on Chain of Thought and Temperature — you need non-zero temperature to get diverse paths and structured reasoning to extract a comparable final answer. It is a practical mitigation for Hallucination and complements Prompt Engineering strategies.
You will encounter self-consistency decoding in benchmarks for mathematical reasoning, multi-step logic puzzles, and any evaluation where raw single-sample accuracy on hard questions falls short of what the model actually knows.