-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_consensus.py
More file actions
67 lines (54 loc) · 2 KB
/
debug_consensus.py
File metadata and controls
67 lines (54 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""
Debug consensus mechanism.
"""
import sys
from pathlib import Path
# Add src to path
sys.path.append(str(Path(__file__).parent / "src"))
from models.model_factory import ModelFactory
from adaptive.adaptive_cot import AdaptiveCoT
def debug_consensus():
"""Debug the consensus mechanism."""
print("🔬 Debug Consensus Mechanism")
print("=" * 60)
# Load model
print("🔧 Loading model...")
model = ModelFactory.create_model(
model_type="deepseek",
model_name="/raid/LLM/deepseek-r1-distill-qwen-1.5b",
config={"gpu_id": 0}
)
model.load_model()
# Create adaptive CoT
config = {
"adaptive_branching": False,
"min_branches": 8,
"max_branches": 8,
"default_branches": 8,
"num_fewshot": 0,
"temperature": 0.7,
"top_p": 0.95,
"max_tokens": 512,
}
adaptive_cot = AdaptiveCoT(model, config)
# Test with the house flipping problem
problem = "Josh decides to try flipping a house. He buys a house for $80,000 and then puts in $50,000 in repairs. This increased the value of the house by 150%. How much profit did he make?"
print(f"📝 Problem: {problem}")
print("=" * 60)
# Solve the problem
result = adaptive_cot.solve_problem(problem)
print(f"🎯 Final answer: {result['final_answer']}")
print(f"📊 Consensus confidence: {result['consensus_info']['confidence']:.3f}")
print(f"📊 Answer counts: {result['consensus_info']['answer_counts']}")
print()
# Show individual branch answers
print("🔍 Individual branch answers:")
for i, (reasoning, answer) in enumerate(zip(result['reasoning_paths'], result['extracted_answers'])):
print(f"Branch {i+1}: {answer}")
# Show first 100 chars of reasoning
reasoning_preview = reasoning[:100].replace('\n', ' ')
print(f" Reasoning: {reasoning_preview}...")
print()
if __name__ == "__main__":
debug_consensus()