skills/llm/self-consistency-majority-vote/SKILL.md
Aggregate multiple LLM reasoning attempts via majority voting with random jitter tiebreaking and validity filtering
npx skillsauth add wenmin-wu/ds-skills llm-self-consistency-majority-voteInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Self-consistency generates multiple independent reasoning chains for the same problem, then selects the most common answer via majority voting. This exploits the observation that correct reasoning paths converge on the same answer, while errors are random and diverse. Add tiny random jitter to vote counts for deterministic tiebreaking without arbitrary selection.
from collections import Counter
import random
def majority_vote(answers, default=0, modulo=None):
counter = Counter()
for ans in answers:
try:
val = int(float(ans))
counter[val] += 1 + random.random() / 1000
except (ValueError, TypeError):
continue
if not counter:
return default
best = max(counter.items(), key=lambda x: x[1])[0]
return best % modulo if modulo else best
# Generate N responses with temperature > 0
responses = [generate(prompt, temperature=1.0) for _ in range(16)]
answers = [extract_answer(r) for r in responses]
final = majority_vote(answers, default=210, modulo=1000)
random.random() / 1000 breaks ties without biasing selectiondata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF