C.W.K.
Stream
Lesson 03 of 10 · published

Tree-of-Thought and Self-Consistency

~16 min · reasoning, tot, self-consistency

Level 0Apprentice
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

One reasoning chain can be wrong

If you sample one CoT and trust it, you've staked the answer on a single sample from a probabilistic process. Two cheap improvements: take multiple samples and reconcile (self-consistency), or branch the reasoning into a tree and prune (Tree-of-Thought).

Self-consistency

Generate N reasoning chains at temperature > 0. Take the answer that appears most often. For tasks with a small answer space (math, classification) this is a measurable accuracy boost.

Tree-of-Thought (ToT)

Generate multiple candidates at each reasoning step, score them, prune. More expensive than self-consistency; more flexible because you can backtrack mid-reasoning. Useful for planning, multi-step search, complex agent loops.

Cost reality

Self-consistency at N=5 costs 5x. Tree-of-Thought costs more. Use these only where accuracy gain is worth the cost — usually high-stakes one-shot tasks, not interactive chat.

Code

Self-consistency vote·python
from collections import Counter

answers = []
for _ in range(7):
    out = client.messages.create(
        model="claude-opus-4-7",
        temperature=0.8,
        max_tokens=512,
        messages=[{"role": "user", "content": prompt}],
    ).content[0].text
    answers.append(extract_final_answer(out))
final = Counter(answers).most_common(1)[0][0]

External links

Exercise

On a small set of hard, classifiable tasks, compare 1-sample, 5-sample-vote, and 9-sample-vote at temperature 0.8. Plot accuracy and cost. Pick a working point.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.