12.3 Self-Consistency & Majority Voting

Improving Reliability with Multiple Perspectives

Large Language Models can sometimes produce incorrect or flawed reasoning, especially for complex, multi-step problems. Self-Consistency is a powerful technique to mitigate this. Instead of just taking the first answer a model gives, we prompt it multiple times using a diverse set of reasoning paths and then select the most frequently occurring answer through a majority vote.

This works because there are often many ways to reason toward a correct answer, but far more ways to reason incorrectly. By sampling multiple reasoning paths, the correct answer is likely to be the most consistent outcome among them.

The Process:
  1. Diverse Sampling: Generate several different completions for the same prompt by using a non-zero temperature. This encourages the model to explore different "thought processes."
  2. Answer Extraction: Extract the final answer from each of the generated reasoning paths.
  3. Majority Voting: Aggregate the final answers and choose the one that appears most often. This final answer is considered more robust and reliable.

Click the "Run Simulation" button to see Self-Consistency in action. The visualization will generate multiple reasoning paths for a math word problem and determine the most consistent answer.