Prompt Engineering: Self-Consistency
Self-consistency means running the same reasoning prompt three times and taking the answer that agrees. Agreement across runs is a sign the answer is solid.
Run 1 of the same refund prompt
The first run works the steps at temperature 0.7.
A customer wants to return the Aurora Ceramic Mug and the Trailhead Canvas Tote. The mug costs 18 dollars. The tote costs 26 dollars. Both are unused and within 30 days. The ShopStack return policy allows returns within 30 days for unused items, with a full refund to the original payment method. Think step by step and then give the total refund amount.Run 2 of the same refund prompt
The second run is the same prompt again, at the same temperature.
A customer wants to return the Aurora Ceramic Mug and the Trailhead Canvas Tote. The mug costs 18 dollars. The tote costs 26 dollars. Both are unused and within 30 days. The ShopStack return policy allows returns within 30 days for unused items, with a full refund to the original payment method. Think step by step and then give the total refund amount.Run 3 of the same refund prompt
The third run completes the set, and the agreeing answer is the one to trust.
A customer wants to return the Aurora Ceramic Mug and the Trailhead Canvas Tote. The mug costs 18 dollars. The tote costs 26 dollars. Both are unused and within 30 days. The ShopStack return policy allows returns within 30 days for unused items, with a full refund to the original payment method. Think step by step and then give the total refund amount.Example
A customer wants to return the Ember Pour-Over Set and the Willow Linen Cushion. The Ember Set costs 35 dollars. The cushion costs 29 dollars. Both are unused and within 30 days. The ShopStack return policy allows returns within 30 days for unused items, with a full refund to the original payment method. Think step by step and then give the total refund amount.Key points
- Self-consistency runs one reasoning prompt three times.
- Each run works the same steps, but the wording of the working can differ.
- The answer that appears most often is the one to trust.
- Two runs that agree beat one run that stands alone.
- Three runs cost three times as much, so the method fits answers that matter.
This example runs a self-consistency prompt against the local model and shows the reply it gave. The three runs above used the same prompt, and the answer that agreed was the total refund.
Note
Self-consistency checks the answer, not the facts. Wrong facts in the prompt give the same wrong answer three times.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What is self-consistency?