Self-consistency và Tree-of-Thought: khi nào dùng để cải thiện reasoning?

Hai kỹ thuật nâng cao CoT giúp LLM giải task reasoning phức tạp tốt hơn.

Self-Consistency (Wang 2022)
- Ý tưởng: sample N lời giải CoT khác nhau (temperature cao), lấy đáp án đa số (majority vote). Nếu model thực sự reasoning đúng, các path khác nhau sẽ hội tụ đáp án đúng.
- Workflow:
1. Gửi prompt CoT với temperature=0.7-1.0.
2. Generate N=5-40 lời giải.
3. Extract final answer mỗi cái.
4. Majority vote (với task có finite answer) hoặc weighted by logprob.
- Cải thiện: +10-20% accuracy trên GSM8K, MATH, commonsense reasoning.
- Cost: N × single CoT cost. Dùng N=5 để balance.
- Khi dùng: task có đáp án rõ (math, classification, multiple choice). Không work với open-ended generation.

Tree-of-Thoughts (ToT) (Yao 2023)
- Ý tưởng: khám phá nhiều nhánh suy luận trong "cây", đánh giá từng nhánh, prune nhánh kém, expand nhánh tốt. Như BFS/DFS trên state space.
- Workflow:
1. Decompose task thành steps.
2. Mỗi step, sample K "thought candidate".
3. LLM self-evaluate mỗi candidate (sure/likely/impossible).
4. Keep top candidates → expand next step.
5. Backtrack nếu cần.
- Cải thiện: dramatic trên task cần planning (Game of 24 từ 4% CoT lên 74% ToT).
- Cost: rất đắt, 100x+ single CoT.
- Khi dùng: task cần exploration có chiến lược — game, puzzle, creative writing with constraints.

So sánh:

Self-ConsistencyTree-of-Thoughts
Kỹ thuậtSample N paths, voteTree search với self-eval
ImplementationDễPhức tạp
Cost5-40x100-1000x
Task phù hợpFinite answerPlanning, multi-step
CodeFew linesCustom framework

Khi KHÔNG dùng: task đơn giản (classification, ngắn), latency-sensitive (user chờ), cost-sensitive. Model reasoning mới (o1, o3, Claude extended thinking) đã internalize thinking → prompting đơn giản đủ.

Biến thể khác:
- Graph of Thoughts — generalize ToT với graph thay vì tree, cho phép merge paths.
- Program of Thoughts — sinh code thay vì natural language cho step reasoning.
- Algorithm of Thoughts — guide model theo algorithm cụ thể (BFS, divide-conquer).

Xem toàn bộ AI Engineering cùng filter theo level & chủ đề con.

Mở danh sách AI Engineering