Skip to content

Commit 4a790de

Browse files
Add token tracking and benchmark tool
- Add LLMResponse type to core package with token usage fields - Update LLMClient interface to return LLMResponse with token counts - Aggregate tokens from both root LLM and sub-LLM (Query/QueryBatched) calls - Expand system prompts with detailed examples for better structured output - Add benchmark tool for comparing RLM vs baseline performance - Include OOLONG dataset export script for benchmark data - Update all tests to use new LLMResponse return type
1 parent 7372df2 commit 4a790de

8 files changed

Lines changed: 915 additions & 72 deletions

File tree

‎cmd/benchmark/export_oolong.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
"""Export OOLONG dataset to JSON for Go benchmark."""
3+
4+
import json
5+
import sys
6+
from pathlib import Path
7+
8+
9+
def main():
10+
try:
11+
from datasets import load_dataset
12+
except ImportError:
13+
print("Error: datasets library not installed")
14+
print("Install with: pip install datasets")
15+
sys.exit(1)
16+
17+
num_tasks = int(sys.argv[1]) if len(sys.argv) > 1 else 10
18+
output_file = sys.argv[2] if len(sys.argv) > 2 else "oolong_tasks.json"
19+
20+
print(f"Loading OOLONG dataset ({num_tasks} tasks)...")
21+
dataset = load_dataset("oolongbench/oolong-synth", split="test")
22+
23+
tasks = []
24+
for i, item in enumerate(dataset):
25+
if i >= num_tasks:
26+
break
27+
28+
answer = item.get("answer", "")
29+
if isinstance(answer, list) and len(answer) > 0:
30+
answer = str(answer[0])
31+
elif isinstance(answer, str):
32+
answer = answer.strip()
33+
34+
tasks.append({
35+
"task_id": f"oolong_{i}",
36+
"context": item.get("context_window_text", ""),
37+
"question": item.get("question", ""),
38+
"answer": answer,
39+
})
40+
41+
print(f"Loaded {len(tasks)} tasks")
42+
43+
with open(output_file, "w") as f:
44+
json.dump(tasks, f, indent=2)
45+
46+
print(f"Exported to: {output_file}")
47+
48+
49+
if __name__ == "__main__":
50+
main()

0 commit comments

Comments
 (0)