Self-Consistency โ Prompting Guide & Examples
Self-consistency prompting generates multiple independent responses to the same question using different reasoning paths, then selects the most common answer. It's like asking several experts independently and going with the majority consensus.
How It Works
Run the same prompt multiple times (or ask the model to solve the problem N ways in one prompt), collect all answers, and take the majority vote. This filters out reasoning errors that occur in individual chains, improving accuracy on tasks with definitive answers.
When to Use
Use self-consistency for math problems, factual questions, classification tasks, and any scenario where there's a correct answer and you want higher reliability. Not useful for creative or subjective tasks.
Model-Specific Tips
ChatGPT / GPT-4
Use temperature > 0 (e.g., 0.7) to get diverse reasoning paths. Run the same prompt 3-5 times via API and take the majority answer.
Claude
Ask Claude to solve the problem 3 ways in a single prompt. Alternatively, use the API with temperature variation for independent samples.
Gemini
Gemini supports self-consistency via temperature sampling. Use the API to generate multiple completions and aggregate results.
Pros & Cons
Pros
- โ Significantly improves accuracy on reasoning tasks
- โ Simple to implement โ just ask multiple times
- โ Filters out random errors
- โ No additional training needed
Cons
- โ 3-5x more expensive (multiple runs)
- โ Only works for tasks with definitive answers
- โ Useless for creative/subjective tasks
- โ Diminishing returns beyond 5 samples
Example Prompts
Solve this problem 3 different ways, then give your final answer based on which solution appears most often: If a train travels at 60mph for 2.5 hours, then 80mph for 1.5 hours, what's the total distance?
Classify this text as spam or not-spam using 3 different reasoning approaches, then give your final classification based on majority vote: Text: 'Congratulations! You've been selected for a $500 gift card. Click here to claim now!'
Determine the time complexity of this algorithm using 3 different analysis methods: ``` for i in range(n): for j in range(i, n): print(i, j) ```