File size: 1,706 Bytes
96ac6f7 | 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 | """Zero-cost extension of the atlas: measure reasoning language on Beam traces other entrants already published
(neulketing Korean, esscor TamilBench). Output: data/replication/profiled.jsonl + per-condition summary."""
import json, glob, os, statistics as st
from collections import defaultdict
from lid import profile
ROOT = os.path.dirname(os.path.abspath(__file__))
rows = []
for f in glob.glob(os.path.join(ROOT, "data/replication/traces/*.jsonl")):
for l in open(f, encoding="utf-8"):
r = json.loads(l)
r["lid"] = profile(r["reasoning"], r["language"])
rows.append(r)
with open(os.path.join(ROOT, "data/replication/profiled.jsonl"), "w", encoding="utf-8") as f:
f.writelines(json.dumps(r, ensure_ascii=False) + "\n" for r in rows)
g = defaultdict(list)
for r in rows:
cond = r["condition"].split(";")[0] if r["source"].startswith("neul") else r["condition"].split(";")[1]
g[(r["source"].split("/")[0], r["language"], cond, r["reasoning_effort"])].append(r)
summary = []
for k, rs in sorted(g.items()):
t = [r["lid"]["target_share"] for r in rs if r["lid"]["target_share"] is not None]
e = [r["lid"]["eng_share"] for r in rs if r["lid"]["eng_share"] is not None]
summary.append({"source": k[0], "lang": k[1], "cond": k[2], "effort": k[3], "n": len(rs),
"mean_target_share": round(st.mean(t), 3) if t else None,
"mean_eng_share": round(st.mean(e), 3) if e else None,
"pct_mostly_target": round(100 * sum(x >= 0.5 for x in t) / len(t), 1) if t else None})
json.dump(summary, open(os.path.join(ROOT, "data/replication/profiled_summary.json"), "w"), indent=1)
for s in summary:
print(s)
|