cid-lastbrowser commited on
Commit
07ef007
·
verified ·
1 Parent(s): 71558cf

Rename to Sidekick Cortex Pro; audited benchmarks; working tests/run_benchmark.py

Browse files
Files changed (1) hide show
  1. tests/run_benchmark.py +53 -0
tests/run_benchmark.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Independent Sidekick Cortex Pro (formerly Axon) benchmark runner.
3
+ Uses Ollama /api/chat with the dataset's persona system message (temp 0).
4
+
5
+ Usage:
6
+ python tests/run_benchmark.py lastbrowser/sidekick-cortex-pro:latest \\
7
+ data/axon_handwritten_testset_50.jsonl outputs_hw50.jsonl
8
+ python tests/score.py outputs_hw50.jsonl
9
+ """
10
+ import json, time, sys, requests
11
+
12
+ def main():
13
+ if len(sys.argv) < 4:
14
+ print(__doc__)
15
+ sys.exit(2)
16
+ model, src, out = sys.argv[1], sys.argv[2], sys.argv[3]
17
+ base = sys.argv[4] if len(sys.argv) > 4 else "http://localhost:11434"
18
+ samples = [json.loads(l) for l in open(src, encoding="utf-8") if l.strip()]
19
+ with open(out, "w", encoding="utf-8") as fo:
20
+ for i, s in enumerate(samples, 1):
21
+ msgs = [m for m in s["messages"] if m["role"] != "assistant"]
22
+ t0 = time.time()
23
+ r = requests.post(
24
+ f"{base}/api/chat",
25
+ json={
26
+ "model": model,
27
+ "messages": msgs,
28
+ "stream": False,
29
+ "options": {"temperature": 0, "num_ctx": 4096, "num_predict": 256},
30
+ },
31
+ timeout=300,
32
+ ).json()
33
+ exp = next(m["content"] for m in s["messages"] if m["role"] == "assistant")
34
+ fo.write(
35
+ json.dumps(
36
+ {
37
+ "id": s.get("id", f"sample_{i}"),
38
+ "prompt": msgs[-1]["content"],
39
+ "expected": exp,
40
+ "raw": r.get("message", {}).get("content", ""),
41
+ "eval_count": r.get("eval_count"),
42
+ "eval_duration_ns": r.get("eval_duration"),
43
+ "wall_s": time.time() - t0,
44
+ },
45
+ ensure_ascii=False,
46
+ )
47
+ + "\n"
48
+ )
49
+ fo.flush()
50
+ print(f"[{i}/{len(samples)}] {s.get('id', i)} done", flush=True)
51
+
52
+ if __name__ == "__main__":
53
+ main()