Self consistency

From Miosa-osa/canopy · View interactive version

Self consistency is an AI agent skill from the GitHub repository Miosa-osa/canopy. Sample multiple paths, select most consistent - +17.9% on GSM8K

How to use this skill

Skill file

Self-Consistency (CoT-SC) Pattern

Sample multiple reasoning paths and select the most consistent answer. Achieved +17.9% on GSM8K, +12.2% on AQuA.

Activation

Use for:

Process

1. Sample Diverse Paths

Generate N (typically 5-10) reasoning paths with higher temperature.

2. Extract Final Answers

Parse the conclusive answer from each path.

3. Majority Vote

Select the most frequent answer across all paths.

Implementation

def self_consistency(prompt, question, num_samples=5):
    answers = []
    for _ in range(num_samples):
        response = reason_with_cot(prompt, question)
        answer = extract_final_answer(response)
        answers.append(answer)
    
    # Majority vote
    from collections import Counter
    return Counter(answers).most_common(1)[0][0]

When NOT to Use

Universal Self-Consistency

For open-ended tasks without fixed answers:

"Here are several responses to the same question:
[Response 1]
[Response 2]
[Response 3]

Determine which elements are most consistent across these responses
and synthesize the most reliable answer."

Integration


Based on Google Research - arXiv:2203.11171

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.