File size: 1,548 Bytes
000c57b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
scripts/run_reasoning_benchmark.py

Executes multi-step reasoning token complexity evaluation across mathematical,
algorithmic, and logical sequences. Dumps JSON telemetry to results/raw/.
"""

import sys
import json
from pathlib import Path
from dataclasses import asdict

ROOT_DIR = Path(__file__).resolve().parent.parent
if str(ROOT_DIR) not in sys.path:
    sys.path.insert(0, str(ROOT_DIR))

from src.reasoning_benchmark import ReasoningComplexityAnalyzer


def main():
    print("=" * 70)
    print("Q-TensorFormer: Real-World Reasoning Token Complexity Benchmark")
    print("=" * 70)

    analyzer = ReasoningComplexityAnalyzer()
    results = analyzer.run_all_benchmarks()

    output_data = []
    for r in results:
        print(f"\n[Problem]: {r.problem_name}")
        print(f"  Prompt Length:       {r.total_tokens} tokens")
        print(f"  Mean TT-Rank:        {r.mean_allocated_rank} (High: {r.high_rank_tokens_count}, Low: {r.low_rank_tokens_count})")
        print(f"  DRAM Memory Saved:   {r.dram_savings_pct:.2f}%")
        print(f"  Accuracy Retention:  {r.accuracy_retention_pct:.2f}%")
        output_data.append(asdict(r))

    out_path = ROOT_DIR / "results" / "raw" / "reasoning_token_complexity.json"
    out_path.parent.mkdir(parents=True, exist_ok=True)
    with open(out_path, "w", encoding="utf-8") as f:
        json.dump(output_data, f, indent=2)

    print(f"\n[SUCCESS] Dumped reasoning benchmark telemetry to: {out_path}")
    print("=" * 70)


if __name__ == "__main__":
    main()