RightNow-Mini / tools /card.py
Jr23xd23's picture
Upload 5 files
7c3bd43 verified
Raw History Blame Contribute Delete
5.83 kB
"""Fill the model card's marks from the result files, so no score in the card is typed by hand.
from card import fill; text = fill(template_text, "results")
python tools/card.py results # prints the facts it reads
Reads results/agent/<run>/summary.json, results/<attempts>/att-<k>/summary.json and results/alone/timing.jsonl,
as tools/pull_results.sh leaves them.
"""
import glob
import json
import statistics
import sys
REPO = "RightNowAI/RightNow-Mini"
def load(p):
try:
return json.load(open(p, encoding="utf-8"))
except Exception:
return None
def clean(s):
"""A score counts once no instance's scoring is left errored: none errored, or each was scored again alone."""
return bool(s) and (not s.get("error") or (s.get("rescored_alone") is not None and not s["rescored_alone"].get("still_error")))
def facts(res):
f = {}
def run(lab):
s = load(f"{res}/agent/{lab}/summary.json")
return s["resolved"] if clean(s) else None
f["opus"] = run("opus55-1")
f["stock"] = [x for x in (run(f"stock-{k}") for k in (1, 2, 3)) if x is not None]
f["ft"] = [x for x in (run(f"ft-{k}") for k in (1, 2, 3)) if x is not None]
f["ft2"] = [x for x in (run(f"ft2-{k}") for k in (1, 2, 3)) if x is not None]
att = {}
for d in glob.glob(f"{res}/deep/att-*"):
s = load(d + "/summary.json")
if clean(s):
att[int(d.replace("\\", "/").rsplit("-", 1)[1])] = s
f["singles"] = [att[k]["resolved"] for k in sorted(att)]
for rule in "ARC":
f[rule] = {n: run(f"deep{rule}-n{n}") for n in (2, 4, 8, 16, 32) if run(f"deep{rule}-n{n}") is not None}
f["upper"] = {}
for n in (2, 4, 8, 16, 32):
if all(k in att for k in range(1, n + 1)):
f["upper"][n] = len(set().union(*[set(att[k]["resolved_ids"]) for k in range(1, n + 1)]))
for tag in ("prune96", "prune64", "ft08"):
got = []
for d in sorted(glob.glob(f"{res}/{tag}/att-*")):
s = load(d + "/summary.json")
if clean(s):
got.append(s["resolved"])
f[tag] = got
try:
f["alone"] = [json.loads(x) for x in open(f"{res}/alone/timing.jsonl", encoding="utf-8") if x.strip()]
except OSError:
f["alone"] = []
return f
def listed(values):
"""1, 2 and 3"""
v = [str(x) for x in values]
return v[0] if len(v) == 1 else ", ".join(v[:-1]) + " and " + v[-1]
def whole(x):
return str(int(x)) if x == int(x) else str(x)
def fill(text, res):
f = facts(res)
A, R, C, singles = f["A"], f["R"], f["C"], f["singles"]
med = statistics.median(singles)
med_s = whole(med)
best_n = max(A, key=lambda n: (A[n], -n))
top = A[best_n]
rows = ["| Setup | Attempts per task | Tasks fixed out of 100 |", "|---|---|---|",
f"| One attempt | 1 | {med_s}, the median of {len(singles)} runs that range from {min(singles)} to {max(singles)} |"]
for i, n in enumerate(sorted(A)):
score = f"**{A[n]}**" if n == best_n else str(A[n])
rows.append(f"| {'Deep mode' if i == 0 else ''} | {n} | {score} |")
if f["opus"] is not None:
rows.append(f"| Opus 5.5, for reference | 1 | {f['opus']} |")
notes = []
if f["opus"] is not None:
gap = f["opus"] - top
if gap > 0:
notes.append(f"With {best_n} attempts, RightNow Mini comes within {gap} task{'s' if gap != 1 else ''} of Opus 5.5, which fixed {f['opus']} of the same "
"100 tasks in one attempt. We ran Opus 5.5 once, through OpenRouter, with the same agent.")
else:
notes.append(f"With {best_n} attempts, RightNow Mini fixes {top} tasks. Opus 5.5 fixed {f['opus']} of the same 100 tasks in one attempt. "
"We ran Opus 5.5 once, through OpenRouter, with the same agent.")
if best_n in f["upper"]:
notes.append(f"There is more to gain. Among the {best_n} attempts, at least one is correct for {f['upper'][best_n]} of the 100 tasks, "
f"and picking by agreement finds {top} of them.")
worse = []
if R:
ns = sorted(R)
worse.append(f"Asking the model to read the candidate patches and vote fixed {listed(R[n] for n in ns)} tasks with {listed(ns)} attempts.")
for n in sorted(C):
worse.append(f"Giving the model a full review session with tools fixed {C[n]} tasks with {n} attempts, where agreement fixed {A.get(n)}.")
if worse:
notes.append("Counting agreement beat the more elaborate ways of picking that we tried. " + " ".join(worse))
mins = sorted(x["seconds"] / 60 for x in f["alone"] if x.get("steps_per_attempt"))
cost = "Deep mode costs as many times the compute as it makes attempts."
if mins:
cost += (f" With a GPU to itself, {f['alone'][0]['n']} attempts at one task took between {mins[0]:.1f} and {mins[-1]:.1f} minutes, "
f"and {statistics.median(mins):.1f} minutes at the median.")
notes.append(cost)
if f["stock"]:
notes.append("Use temperature 0.8 for agent work. With greedy decoding the model often repeats one command until it runs out of steps, "
f"and it fixed {listed(f['stock'])} tasks in {len(f['stock'])} greedy runs.")
marks = {"@@ABEST@@": str(top), "@@NBEST@@": str(best_n), "@@MED@@": med_s, "@@A8@@": str(A.get(8)), "@@NSINGLES@@": str(len(singles)),
"@@GAIN@@": whole(top - med), "@@G8@@": whole(A.get(8) - med),
"@@CODING_TABLE@@": "\n".join(rows), "@@CODING_NOTES@@": "\n\n".join(notes), "@@REPO@@": REPO}
for k, v in marks.items():
text = text.replace(k, v)
return text
if __name__ == "__main__":
print(json.dumps(facts(sys.argv[1] if len(sys.argv) > 1 else "results"), indent=1, default=str))