-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.py
More file actions
75 lines (60 loc) · 2.27 KB
/
simple_test.py
File metadata and controls
75 lines (60 loc) · 2.27 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
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
"""
Simple test script to verify the Adaptive CoT framework works.
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from src.models.model_factory import ModelFactory
from src.adaptive.adaptive_cot import AdaptiveCoT
def test_basic_functionality():
"""Test basic functionality with a simple problem."""
print("🧪 Testing Basic Adaptive CoT Functionality")
print("=" * 50)
# Simple config
config = {
"adaptive_branching": {
"enabled": True,
"min_branches": 1,
"max_branches": 5,
"default_branches": 3
},
"research_logging": False
}
try:
# Create model
print("📦 Creating model...")
model = ModelFactory.create_model("generic", "/raid/LLM/llama3.1-8b-instruct", {})
model.load_model()
print("✅ Model loaded successfully")
# Create AdaptiveCoT
print("🔧 Creating AdaptiveCoT...")
cot = AdaptiveCoT(model, config)
print("✅ AdaptiveCoT created successfully")
# Test problem
problem = "What is 2+2?"
print(f"\n🔍 Testing problem: {problem}")
# Solve problem
result = cot.solve_problem(problem)
# Display results
print(f"\n📊 Results:")
print(f" Final Answer: {result['final_answer']}")
print(f" Branches Used: {result['num_branches']}")
print(f" Strategy: {result['allocation_info']['strategy']}")
print(f" Execution Time: {result['execution_time']:.2f}s")
if 'prefill_signals' in result:
prefill = result['prefill_signals']
print(f" Prefill Signals:")
print(f" Entropy: {prefill['entropy']:.3f}")
print(f" KL Divergence: {prefill['kl_divergence']:.3f}")
print(f" Confidence: {prefill['confidence']:.3f}")
print(f"\n✅ Test completed successfully!")
return True
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
success = test_basic_functionality()
sys.exit(0 if success else 1)