Reja1 Claude Opus 4.7 commited on
Commit
5a056c1
·
1 Parent(s): 3758837

scripts: add NEET 2026 chart generator

Browse files

Reads live from results/*NEET_2026* and emits leaderboard, cost-vs-accuracy,
and per-subject heatmap PNGs into charts/neet_2026/. Charts directory is
gitignored — regenerate before publishing.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

Files changed (2) hide show
  1. .gitignore +3 -0
  2. scripts/make_neet_2026_charts.py +271 -0
.gitignore CHANGED
@@ -87,3 +87,6 @@ lerna-debug.log*
87
  # Other
88
  *.swp
89
  *~
 
 
 
 
87
  # Other
88
  *.swp
89
  *~
90
+
91
+ # Generated charts (regenerate via scripts/make_neet_2026_charts.py)
92
+ charts/
scripts/make_neet_2026_charts.py ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate publication-quality charts for the NEET 2026 AI benchmark.
2
+
3
+ Reads live from `results/*NEET_2026*/summary.{md,jsonl}` and `predictions.jsonl`
4
+ so the charts always reflect the current run set. Outputs PNGs into
5
+ `charts/neet_2026/`.
6
+ """
7
+
8
+ import argparse
9
+ import json
10
+ import re
11
+ from collections import defaultdict
12
+ from pathlib import Path
13
+
14
+ import matplotlib.pyplot as plt
15
+ import numpy as np
16
+
17
+ # Display label and brand color per OpenRouter model id.
18
+ # New models get a default fallback color; add an entry for nicer styling.
19
+ MODEL_META = {
20
+ "google/gemini-3-flash-preview": ("Gemini 3 Flash", "#4285F4"),
21
+ "google/gemini-3.1-pro-preview": ("Gemini 3.1 Pro", "#1A73E8"),
22
+ "openai/gpt-5.5": ("GPT-5.5", "#10A37F"),
23
+ "openai/gpt-5.4": ("GPT-5.4", "#7CC4A8"),
24
+ "qwen/qwen3-vl-235b-a22b-thinking": ("Qwen3-VL 235B Thinking", "#615CED"),
25
+ "anthropic/claude-opus-4.7": ("Claude Opus 4.7", "#C9622D"),
26
+ "anthropic/claude-sonnet-4.6": ("Claude Sonnet 4.6", "#D97757"),
27
+ "anthropic/claude-haiku-4.5": ("Claude Haiku 4.5", "#E8B496"),
28
+ "z-ai/glm-4.6v": ("GLM-4.6V", "#FFB000"),
29
+ "x-ai/grok-4.20": ("Grok 4.20", "#1DA1F2"),
30
+ }
31
+ DEFAULT_COLOR = "#888888"
32
+
33
+ NEET_SUBJECTS = ["Physics", "Chemistry", "Biology"]
34
+ NEET_SUBJECT_MAX = {"Physics": 180, "Chemistry": 180, "Biology": 360}
35
+
36
+ plt.rcParams.update({
37
+ "font.family": "DejaVu Sans",
38
+ "font.size": 11,
39
+ "axes.spines.top": False,
40
+ "axes.spines.right": False,
41
+ "axes.titleweight": "bold",
42
+ })
43
+
44
+
45
+ def parse_run(run_dir: Path) -> dict | None:
46
+ summary_md = run_dir / "summary.md"
47
+ summary_jsonl = run_dir / "summary.jsonl"
48
+ predictions_jsonl = run_dir / "predictions.jsonl"
49
+ if not (summary_md.exists() and summary_jsonl.exists() and predictions_jsonl.exists()):
50
+ return None
51
+
52
+ md = summary_md.read_text()
53
+ score_m = re.search(r"\*\*Overall Score:\*\* \*\*(\d+)\*\* / \*\*(\d+)\*\*", md)
54
+ cost_m = re.search(r"\*\*Total Cost:\*\* \$(\S+)", md)
55
+ if not score_m:
56
+ return None
57
+
58
+ subject_by_qid = {}
59
+ with predictions_jsonl.open() as f:
60
+ for line in f:
61
+ r = json.loads(line)
62
+ subject_by_qid[r["question_id"]] = r.get("subject", "Unknown")
63
+
64
+ correct = incorrect = failed = 0
65
+ subj_score = defaultdict(int)
66
+ subj_correct = defaultdict(int)
67
+ subj_total = defaultdict(int)
68
+ with summary_jsonl.open() as f:
69
+ for line in f:
70
+ r = json.loads(line)
71
+ status = r["evaluation_status"]
72
+ if status == "correct":
73
+ correct += 1
74
+ elif status == "incorrect":
75
+ incorrect += 1
76
+ else:
77
+ failed += 1
78
+ sub = subject_by_qid.get(r["question_id"], "Unknown")
79
+ subj_total[sub] += 1
80
+ subj_score[sub] += r.get("marks_awarded", 0)
81
+ if status == "correct":
82
+ subj_correct[sub] += 1
83
+
84
+ # Recover model id from dir name: provider_model_..._NEET_2026_TIMESTAMP
85
+ name = run_dir.name.split("_NEET_2026")[0]
86
+ # First underscore separates provider from rest of model slug.
87
+ model_id = name.replace("_", "/", 1)
88
+
89
+ return {
90
+ "model": model_id,
91
+ "score": int(score_m.group(1)),
92
+ "total": int(score_m.group(2)),
93
+ "correct": correct,
94
+ "incorrect": incorrect,
95
+ "failed": failed,
96
+ "cost": float(cost_m.group(1)) if cost_m else 0.0,
97
+ "subjects": {s: subj_score.get(s, 0) for s in NEET_SUBJECTS},
98
+ "run_dir": str(run_dir),
99
+ }
100
+
101
+
102
+ def load_results(results_dir: Path) -> list[dict]:
103
+ runs = []
104
+ for d in sorted(results_dir.glob("*NEET_2026*")):
105
+ if not d.is_dir():
106
+ continue
107
+ parsed = parse_run(d)
108
+ if parsed:
109
+ runs.append(parsed)
110
+ # Keep most recent run per model (in case of reruns)
111
+ by_model = {}
112
+ for r in runs:
113
+ prev = by_model.get(r["model"])
114
+ if prev is None or r["run_dir"] > prev["run_dir"]:
115
+ by_model[r["model"]] = r
116
+ return sorted(by_model.values(), key=lambda x: -x["score"])
117
+
118
+
119
+ def label_for(model_id: str) -> str:
120
+ return MODEL_META.get(model_id, (model_id, DEFAULT_COLOR))[0]
121
+
122
+
123
+ def color_for(model_id: str) -> str:
124
+ return MODEL_META.get(model_id, (model_id, DEFAULT_COLOR))[1]
125
+
126
+
127
+ def chart_main_leaderboard(data: list[dict], out_path: Path):
128
+ data = sorted(data, key=lambda x: x["score"])
129
+ labels = [label_for(d["model"]) for d in data]
130
+ scores = [d["score"] for d in data]
131
+ colors = [color_for(d["model"]) for d in data]
132
+ pcts = [s / 720 * 100 for s in scores]
133
+
134
+ fig, ax = plt.subplots(figsize=(11, max(5, 0.85 * len(data) + 1.5)), dpi=200)
135
+ fig.patch.set_facecolor("white")
136
+ bars = ax.barh(labels, scores, color=colors, edgecolor="white", linewidth=1.5, height=0.72)
137
+
138
+ ax.axvline(715, color="#E63946", linestyle="--", linewidth=1.4, alpha=0.8, zorder=0)
139
+ ax.text(715, len(labels) - 0.35, " AIR-1 cutoff zone", color="#E63946",
140
+ fontsize=10, fontweight="bold", va="bottom")
141
+
142
+ for bar, score, pct in zip(bars, scores, pcts):
143
+ ax.text(bar.get_width() + 8, bar.get_y() + bar.get_height() / 2,
144
+ f"{score} ({pct:.1f}%)", va="center", fontsize=11, fontweight="bold",
145
+ color="#222")
146
+
147
+ ax.set_xlim(0, 800)
148
+ ax.set_xlabel("Score (out of 720)", fontsize=12, fontweight="bold")
149
+ ax.set_title("NEET 2026 — Frontier AI Models Take India's Hardest Medical Exam",
150
+ fontsize=15, pad=14)
151
+ ax.text(0, len(labels) + 0.35,
152
+ "180 vision questions • zero shot • image input • exam date: 3 May 2026",
153
+ fontsize=10.5, color="#666", style="italic")
154
+ ax.tick_params(axis="y", labelsize=11.5)
155
+ ax.set_axisbelow(True)
156
+ ax.grid(axis="x", alpha=0.22, linestyle="-", linewidth=0.6)
157
+
158
+ fig.text(0.99, 0.01, "github.com/Reja1/jee-neet-benchmark", ha="right",
159
+ fontsize=8.5, color="#999", style="italic")
160
+ plt.tight_layout()
161
+ plt.savefig(out_path, bbox_inches="tight", facecolor="white")
162
+ print(f"wrote {out_path}")
163
+ plt.close()
164
+
165
+
166
+ def chart_cost_vs_accuracy(data: list[dict], out_path: Path):
167
+ fig, ax = plt.subplots(figsize=(11, 7), dpi=200)
168
+ fig.patch.set_facecolor("white")
169
+
170
+ for d in data:
171
+ if d["cost"] <= 0:
172
+ continue
173
+ pct = d["score"] / 720 * 100
174
+ ax.scatter(d["cost"], pct, s=320, color=color_for(d["model"]),
175
+ edgecolors="white", linewidths=2, zorder=3, alpha=0.95)
176
+ ax.annotate(label_for(d["model"]), (d["cost"], pct),
177
+ xytext=(d["cost"] * 1.05, pct + 0.6),
178
+ fontsize=10.5, fontweight="bold", color="#222")
179
+
180
+ pareto_pts = sorted([(d["cost"], d["score"] / 720 * 100) for d in data if d["cost"] > 0])
181
+ frontier, best = [], -1
182
+ for c, p in pareto_pts:
183
+ if p > best:
184
+ frontier.append((c, p))
185
+ best = p
186
+ if frontier:
187
+ fx, fy = zip(*frontier)
188
+ ax.plot(fx, fy, "--", color="#888", linewidth=1.4, alpha=0.5, zorder=1, label="Pareto frontier")
189
+
190
+ ax.set_xscale("log")
191
+ ax.set_xlabel("Total cost for full exam (USD, log scale)", fontsize=12, fontweight="bold")
192
+ ax.set_ylabel("Accuracy (%)", fontsize=12, fontweight="bold")
193
+ ax.set_title("NEET 2026 — Cost vs Accuracy (upper-left = best value)",
194
+ fontsize=14, pad=14)
195
+ pcts = [d["score"] / 720 * 100 for d in data]
196
+ ax.set_ylim(min(pcts) - 5, 102)
197
+ ax.grid(alpha=0.25, linestyle="-", linewidth=0.5)
198
+ ax.set_axisbelow(True)
199
+ ax.legend(loc="lower right", frameon=False, fontsize=10)
200
+
201
+ fig.text(0.99, 0.01, "github.com/Reja1/jee-neet-benchmark",
202
+ ha="right", fontsize=8.5, color="#999", style="italic")
203
+ plt.tight_layout()
204
+ plt.savefig(out_path, bbox_inches="tight", facecolor="white")
205
+ print(f"wrote {out_path}")
206
+ plt.close()
207
+
208
+
209
+ def chart_subject_heatmap(data: list[dict], out_path: Path):
210
+ data = sorted(data, key=lambda x: -x["score"])
211
+ matrix = np.array([
212
+ [d["subjects"].get(s, 0) / NEET_SUBJECT_MAX[s] * 100 for s in NEET_SUBJECTS]
213
+ for d in data
214
+ ])
215
+ labels = [label_for(d["model"]) for d in data]
216
+
217
+ fig, ax = plt.subplots(figsize=(8.5, max(4, 0.8 * len(data) + 1.5)), dpi=200)
218
+ fig.patch.set_facecolor("white")
219
+
220
+ im = ax.imshow(matrix, cmap="RdYlGn", vmin=40, vmax=100, aspect="auto")
221
+ ax.set_xticks(range(len(NEET_SUBJECTS)))
222
+ ax.set_xticklabels(NEET_SUBJECTS, fontsize=12, fontweight="bold")
223
+ ax.set_yticks(range(len(labels)))
224
+ ax.set_yticklabels(labels, fontsize=11)
225
+ ax.set_xticks(np.arange(-0.5, len(NEET_SUBJECTS), 1), minor=True)
226
+ ax.set_yticks(np.arange(-0.5, len(labels), 1), minor=True)
227
+ ax.grid(which="minor", color="white", linewidth=2)
228
+ ax.tick_params(which="minor", length=0)
229
+
230
+ for i in range(matrix.shape[0]):
231
+ for j in range(matrix.shape[1]):
232
+ val = matrix[i, j]
233
+ text_color = "white" if val < 65 else "#222"
234
+ ax.text(j, i, f"{val:.0f}%", ha="center", va="center",
235
+ fontsize=11, fontweight="bold", color=text_color)
236
+
237
+ ax.set_title("Per-Subject Accuracy — NEET 2026", fontsize=14, pad=12)
238
+ cbar = fig.colorbar(im, ax=ax, shrink=0.85)
239
+ cbar.set_label("% correct", fontsize=10)
240
+
241
+ fig.text(0.99, 0.01, "github.com/Reja1/jee-neet-benchmark",
242
+ ha="right", fontsize=8.5, color="#999", style="italic")
243
+ plt.tight_layout()
244
+ plt.savefig(out_path, bbox_inches="tight", facecolor="white")
245
+ print(f"wrote {out_path}")
246
+ plt.close()
247
+
248
+
249
+ def main():
250
+ ap = argparse.ArgumentParser()
251
+ ap.add_argument("--results-dir", default="results")
252
+ ap.add_argument("--output-dir", default="charts/neet_2026")
253
+ args = ap.parse_args()
254
+
255
+ out_dir = Path(args.output_dir)
256
+ out_dir.mkdir(parents=True, exist_ok=True)
257
+ data = load_results(Path(args.results_dir))
258
+ if not data:
259
+ raise SystemExit(f"No NEET 2026 runs found under {args.results_dir}")
260
+ print(f"loaded {len(data)} runs from {args.results_dir}")
261
+ for d in data:
262
+ print(f" {label_for(d['model']):30s} {d['score']:3d}/720 ${d['cost']:.4f}")
263
+
264
+ chart_main_leaderboard(data, out_dir / "01_leaderboard.png")
265
+ chart_cost_vs_accuracy(data, out_dir / "02_cost_vs_accuracy.png")
266
+ chart_subject_heatmap(data, out_dir / "03_subject_heatmap.png")
267
+ print(f"\ncharts written to {out_dir.resolve()}")
268
+
269
+
270
+ if __name__ == "__main__":
271
+ main()