Improve command understanding with bigger wording banks; tested
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+225
-20
@@ -6,8 +6,10 @@
|
||||
# case is the same (fast, after a rule change)
|
||||
.venv/bin/python tests/blind_check.py train --rules # no LLM: what the rules leave is "llm?"
|
||||
.venv/bin/python tests/blind_check.py train --limit 20 # the first 20 cases (dialogues) of each set
|
||||
.venv/bin/python tests/blind_check.py held --round r6 --sample 100 # 100 cases per file, seeded (the same each run)
|
||||
.venv/bin/python tests/blind_check.py held # held-out: only scored, never read to fix from
|
||||
.venv/bin/python tests/blind_check.py train --round r2 # round 2 (tests/blind/r2/train) -> blind_r2_train.*
|
||||
.venv/bin/python tests/blind_check.py train --rules --tag a3 # -> blind_train_a3.* (the shared files untouched)
|
||||
|
||||
-> logs/blind_<split>.md / .json (blind_r2_<split>.* with --round r2; a run of some sets keeps the others' saved
|
||||
rows). Verdicts per case (per scored turn in the dialogue sets): right; wrong; motion (a motion not asked for, the worst wrong); llm? (left to the LLM in
|
||||
@@ -54,11 +56,12 @@ from unittest import mock
|
||||
|
||||
import numpy as np
|
||||
|
||||
from assistant import brain, chain, detour, lumi, seeing, steps, voice_words
|
||||
from assistant import battery, brain, chain, detour, lumi, seeing, steps, voice_words
|
||||
from audio import ears, sing
|
||||
from tests import command_check, company_check, conversation_check, dialogue_check, song_check
|
||||
from tests.blind.maps import MAPS
|
||||
from vision import scene
|
||||
from robot import head as robot_head
|
||||
from vision import pointing, scene
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
DEFAULT_MARKERS = MAPS["office"] # cases that name no place
|
||||
@@ -69,7 +72,22 @@ SETS = ["commands_go", "commands_move", "commands_turn", "commands_look", "comma
|
||||
"commands_reach", "commands_give", "commands_take", "commands_put", "commands_bring", "commands_follow",
|
||||
"commands_stop", "commands_status", "commands_chain", "commands_detour", "speed_short", "commands_sing",
|
||||
"commands_missions", "seeing_dialogues", "followup_dialogues", "dialogues_mixed", "unknowns", "silence_noise",
|
||||
"hearing"] # commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 only
|
||||
"hearing", "questions_world", "memory_dialogues", "commands_come", "commands_hand", "commands_point",
|
||||
"commands_voice", "commands_waist", "commands_more", "closing_context"]
|
||||
# commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 on;
|
||||
# questions_world, memory_dialogues: r6 on. Any other file in a round's folder
|
||||
# is scored too, by the set its name grows ("commands_go_b" as commands_go)
|
||||
|
||||
|
||||
def base(name):
|
||||
"""The set a file's name belongs to: "commands_go_b" / "seeing_dialogues_2" -> "commands_go" / "seeing_dialogues"."""
|
||||
m = re.fullmatch(r"(.+?)_(?:[a-z]|\d+)", name)
|
||||
return m.group(1) if m and m.group(1) in SETS else name
|
||||
|
||||
|
||||
def ordered(names):
|
||||
"""Set names in SETS order, then the rest (growth files next to their set)."""
|
||||
return sorted(names, key=lambda n: (SETS.index(base(n)) if base(n) in SETS else len(SETS), n))
|
||||
|
||||
|
||||
def marks_of(c):
|
||||
@@ -125,7 +143,16 @@ def _person(p):
|
||||
return {"camera": "head", "box": [0, 0, 1, 1], "distance_m": p["dist_m"], "bearing_deg": b, "position_mm": None,
|
||||
"facing": True, "raised": raised, "pointing": None, "gesture": "hand_raised" if raised else None,
|
||||
"clothes": {"upper": p.get("top"), "lower": p.get("bottom"), "feet": None},
|
||||
"hands": {"left": hand("left"), "right": hand("right")}, "seen": 17, "where": scene.where(b)}
|
||||
"hands": {"left": hand("left"), "right": hand("right")}, "seen": 17, "where": scene.where(b),
|
||||
"posture": p.get("posture"), "_scene": p, # _scene: the r6 fields (hair, glasses ...) for the fake VLM
|
||||
"looks": seeing.scene_looks(_looks_fields(p))} # what seeing reads instead of asking the VLM (A6)
|
||||
|
||||
|
||||
def _looks_fields(p):
|
||||
"""The r6 person fields in the names seeing.scene_looks reads (hat / bag as "black cap", the pattern, the bottoms)."""
|
||||
said = lambda x: f"{x.get('colour') or ''} {x['kind']}".strip() if isinstance(x, dict) else x
|
||||
return dict(p, pattern=p.get("top_pattern"), bottom_type=p.get("bottom_kind"), hat=said(p.get("hat")),
|
||||
bag=said(p.get("bag")))
|
||||
|
||||
|
||||
def _persons(frames=None):
|
||||
@@ -137,7 +164,50 @@ def _persons(frames=None):
|
||||
|
||||
scene.snapshot = lambda cameras=None, since=None: [SCENE["now"]] if SCENE["now"] is not None else []
|
||||
scene.things, scene.people, scene._persons = _things, _people, _persons
|
||||
scene.ask_vlm = lambda *a, **k: None # "what am I wearing?" asks the picture model: no picture here
|
||||
VLM_ASKED = [("glasses", r"glass|안경|선글"), ("hat", r"\bhat|\bcap\b|beanie|모자|캡"), ("hair", r"hair|머리"),
|
||||
("bag", r"bag|backpack|가방|배낭"), ("top_pattern", r"pattern|stripe|check|dot|print|무늬|줄무늬|체크|땡땡이"),
|
||||
("bottom_kind", r"jeans|trousers|pants|skirt|shorts|바지|청바지|치마|반바지"),
|
||||
("posture", r"sit|stand|crouch|squat|앉|서 ?있|쪼그"), ("action", r"doing|하고 있|뭐 해|뭐해")]
|
||||
|
||||
|
||||
def _vlm_said(p, field, lang):
|
||||
"""One fact of the r6 scene person as the picture model would say it, or None when the scene leaves it open."""
|
||||
ko = lang == "ko"
|
||||
v = p.get(field)
|
||||
if field == "glasses":
|
||||
return None if v is None else ("선글라스를 쓰고 있어요." if ko else "You are wearing sunglasses.") if v == "sunglasses" \
|
||||
else ("안경을 쓰고 있어요." if ko else "You are wearing glasses.") if v else \
|
||||
("안경은 안 쓰고 있어요." if ko else "You are not wearing glasses.")
|
||||
if field in ("hat", "bag"):
|
||||
if field not in p:
|
||||
return None
|
||||
if not v:
|
||||
return {"hat": ("모자는 안 쓰고 있어요.", "You are not wearing a hat."),
|
||||
"bag": ("가방은 없어요.", "You have no bag.")}[field][0 if ko else 1]
|
||||
return f"{v.get('colour') or ''} {v['kind']}을(를) {'쓰고' if field == 'hat' else '메고'} 있어요." if ko else \
|
||||
f"You have a {v.get('colour') or ''} {v['kind']}.".replace(" ", " ")
|
||||
if field == "hair":
|
||||
return None if not v else (f"머리는 {v.get('colour') or ''} {v.get('length') or ''}이에요." if ko else
|
||||
f"You have {v.get('length') or ''} {v.get('colour') or ''} hair.".replace(" ", " "))
|
||||
if v is None:
|
||||
return None
|
||||
return {"top_pattern": f"The top is {v}.", "bottom_kind": f"You are wearing {v}.", "posture": f"You are {v}.",
|
||||
"action": f"You are {v}."}[field]
|
||||
|
||||
|
||||
def _fake_vlm(question, lang="en", frames=None):
|
||||
"""vision.scene.ask_vlm on the r6 scenes: what the picture model would say of the person in front (the speaker A),
|
||||
from the scene's fields; the fields the question names, else all of them; None when nobody is in view."""
|
||||
ps = _persons()
|
||||
if not ps:
|
||||
return None
|
||||
p = ps[0].get("_scene") or {}
|
||||
fields = [f for f, rx in VLM_ASKED if re.search(rx, question or "", re.I)] or [f for f, _ in VLM_ASKED]
|
||||
said = [x for x in (_vlm_said(p, f, lang) for f in fields) if x]
|
||||
return " ".join(said) or None
|
||||
|
||||
|
||||
scene.ask_vlm = _fake_vlm # "am I wearing glasses?" asks the picture model: answered from the scene
|
||||
|
||||
|
||||
def fresh_seeing():
|
||||
@@ -271,6 +341,9 @@ def score_commands(c, old, use_llm):
|
||||
else:
|
||||
got = "llm?"
|
||||
STUCK["now"] = None
|
||||
if got != "stop" and pointing.asked(text) == "there":
|
||||
got = "point" # lumi.pointed_drive, right after a stop
|
||||
got = at_limit(got, c.get("at_limit"))
|
||||
if got == "llm?":
|
||||
v = "llm?"
|
||||
else:
|
||||
@@ -292,6 +365,27 @@ def score_commands(c, old, use_llm):
|
||||
+ (f", parts {c['parts']}" if c.get("parts") else "") + f") {first[:70]!r}", raw=raw, first=first)
|
||||
|
||||
|
||||
LIMIT_AT = {"head_left": (brain.HEAD_YAW[1], None, None), "head_right": (-brain.HEAD_YAW[1], None, None),
|
||||
"head_up": (None, brain.HEAD_PITCH[1], None), "head_down": (None, brain.HEAD_PITCH[0], None),
|
||||
"lift_top": (None, None, robot_head.LIFT_MAX_MM), "lift_bottom": (None, None, 0.0)}
|
||||
|
||||
|
||||
def at_limit(got, where):
|
||||
"""commands_more (r6) "at_limit": the head or the lift already at that end; lumi.look / lumi.lift then move
|
||||
nothing and say so (LIMIT_SAY): "limit"."""
|
||||
if not where or not re.match(r"action:(?:look|lift) ", got):
|
||||
return got
|
||||
yaw, pitch, mm = LIMIT_AT[where]
|
||||
a, target = got.removeprefix("action:").split(" ", 1)
|
||||
if a == "look":
|
||||
y0, p0 = 0.0 if yaw is None else yaw, robot_head.HEAD_REST_PITCH if pitch is None else pitch
|
||||
y1, p1, limited = brain.head_goal(target, y0, p0, lumi.LOOK)
|
||||
still = abs(y1 - y0) < 1 and abs(p1 - p0) < 1 # a number past the range, cut to where it is
|
||||
return "limit" if limited in ("left", "right", "up", "down") or limited and still else got
|
||||
limited = brain.lift_goal(target, 50.0 if mm is None else mm, robot_head.LIFT_MAX_MM)[1]
|
||||
return "limit" if limited in ("up", "down") else got
|
||||
|
||||
|
||||
def score_sing(c, old, use_llm):
|
||||
text, expect, before = c
|
||||
lang = "ko" if brain.HANGUL.search(text) else "en"
|
||||
@@ -320,6 +414,24 @@ def score_sing(c, old, use_llm):
|
||||
return row(KEYS["commands_sing"](c), v, by, f"{text!r} -> {got} (want {expect}) [{by}] {first[:70]!r}", raw=raw, first=first)
|
||||
|
||||
|
||||
def same_steps(want, got):
|
||||
"""The steps as written, or more exact where the notation has no word for it: a bare "place" read with the table
|
||||
said ("put it on the table"), a "receive ... wait" read as the receive (it waits for the hand-over anyway)."""
|
||||
if got == want:
|
||||
return True
|
||||
if not got or len(got) != len(want):
|
||||
return False
|
||||
for w, g in zip(want, got):
|
||||
w, g = dict(w), dict(g)
|
||||
if w.get("do") == "place" and w.get("on") is None:
|
||||
w.pop("on", None), g.pop("on", None)
|
||||
if w.get("do") == "receive":
|
||||
w.pop("wait_s", None), g.pop("wait_s", None)
|
||||
if w != g:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def score_missions(c, old, use_llm):
|
||||
text, case = c
|
||||
mk, want = marks_of(case), case["steps"]
|
||||
@@ -330,7 +442,7 @@ def score_missions(c, old, use_llm):
|
||||
refused = bool(steps.check(got, False, mk)) if got and not unread else True
|
||||
if want.strip() == "?":
|
||||
v = "right" if unread or refused else "motion"
|
||||
elif not unread and got == [short(s.strip()) for s in want.split(" | ")]:
|
||||
elif not unread and same_steps([short(s.strip()) for s in want.split(" | ")], got):
|
||||
v = "right"
|
||||
elif unread and not use_llm and by == "rules" and len(steps._split(steps._norm(steps._cut_says(text)[0], mk))) >= 2:
|
||||
v = "llm?" # the LLM pass would read it
|
||||
@@ -340,6 +452,9 @@ def score_missions(c, old, use_llm):
|
||||
got=json.loads(json.dumps(got)), unread=unread)
|
||||
|
||||
|
||||
FORGOT = set(__import__("assistant.memory", fromlist=["FORGOT"]).FORGOT.values())
|
||||
|
||||
|
||||
def score_dialogue(d, old, use_llm, judge=False):
|
||||
"""seeing_dialogues, followup_dialogues, dialogues_mixed: one Brain for the dialogue; setup turns put into the
|
||||
history as said; back-channels (scored False) answered, not judged; a turn's scene (if any) is what the cameras
|
||||
@@ -372,6 +487,8 @@ def score_dialogue(d, old, use_llm, judge=False):
|
||||
continue
|
||||
if r.startswith("action:give") or r.startswith("action:place"):
|
||||
state = "idle" # handed over / put down: the hand is empty now
|
||||
if r == "none" and reply in FORGOT:
|
||||
r = "forget" # memory_dialogues: the talks deleted and said so
|
||||
if not scored:
|
||||
rows.append(row(key, "-", by, "", route=r, reply=reply))
|
||||
continue
|
||||
@@ -420,6 +537,47 @@ def score_unknowns(c, old, use_llm):
|
||||
f"-> [{r}] {reply[:140]!r} {probs}", route=r, reply=reply)
|
||||
|
||||
|
||||
def score_questions(c, old, use_llm):
|
||||
"""questions_world (r6): the way lumi.answer() goes: abilities / battery (fixed_answer), lumi.route (weather, search,
|
||||
seeing, status ...), quick_answers, then the LLM. expect quick: answered without the LLM (the LLM's answer is wrong
|
||||
even when right: not at once); knowledge / unknown: must / must_not on whatever answered, a lookup is wrong;
|
||||
lookup:weather: the weather lookup; lookup:news / lookup:web: the web search."""
|
||||
from assistant import abilities, quick_answers
|
||||
text, mk = c["text"], DEFAULT_MARKERS
|
||||
lang = c["lang"] if c["lang"] in ("en", "ko") else "ko" if brain.HANGUL.search(text) else "en"
|
||||
brain.FORCED_LANG["lang"] = lang
|
||||
SCENE["now"] = None
|
||||
fresh_seeing()
|
||||
b, key = brain.Brain(), text
|
||||
got = abilities.answer(text, lang, "") or (("battery", battery.answer(text, lang)) if battery.asked(text) else None)
|
||||
if got:
|
||||
r, reply, by = "quick", got[1], "rules"
|
||||
elif old and old["by"] == "llm":
|
||||
r, reply, by = old["out"]["route"], old["out"]["reply"], "llm"
|
||||
else:
|
||||
r, reply, by = turn_route(b, text, lang, mk, "idle", use_llm=False)
|
||||
if r == "llm?":
|
||||
say = quick_answers.answer(text, lang, ())
|
||||
if say:
|
||||
r, reply, by = "quick", say, "rules"
|
||||
elif use_llm:
|
||||
r, reply, by = turn_route(b, text, lang, mk, "idle", use_llm=True)
|
||||
want = c["expect"]
|
||||
looked = r in ("weather", "search", "search(unsure)")
|
||||
if r == "llm?":
|
||||
v, probs = ("wrong", ["left to the LLM, not at once"]) if want == "quick" else ("llm?", [])
|
||||
elif want.startswith("lookup:"):
|
||||
ok = r == "weather" if want == "lookup:weather" else r in ("search", "search(unsure)")
|
||||
probs = [] if ok else [f"want {want}"]
|
||||
v = "right" if ok else "motion" if MOTION.match(r) else "wrong"
|
||||
else:
|
||||
probs = company_check.problems(c, lang, reply) if not looked else [f"looked up ({r})"]
|
||||
if want == "quick" and by == "llm":
|
||||
probs.append("by the LLM, not at once")
|
||||
v = "right" if not probs else "motion" if MOTION.match(r) else "wrong"
|
||||
return row(key, v, by, f"[{c['q']}, {want}] {text!r} -> [{r}] {reply[:140]!r} {probs}", route=r, reply=reply)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def heard_as(text, speech_s):
|
||||
"""ears.transcribe on a stand-in: whisper wrote `text` (sure of it), the VAD found speech_s s of speech."""
|
||||
@@ -536,10 +694,13 @@ KEYS = {"commands": lambda c: f"{c['text']}|{c['state']}|{c['before']}",
|
||||
"commands_sing": lambda c: f"{c[0]}|{tuple(c[2]) if c[2] else None}",
|
||||
"commands_missions": lambda c: c[0],
|
||||
"unknowns": lambda c: f"{c['text']}|{c['ctx']}|{c['people_in_view']}",
|
||||
"silence_noise": lambda c: f"{c['heard']}|{json.dumps(c['ctx'], sort_keys=True)}"}
|
||||
"silence_noise": lambda c: f"{c['heard']}|{json.dumps(c['ctx'], sort_keys=True)}",
|
||||
"questions_world": lambda c: c["text"]}
|
||||
SCORERS = {"commands_sing": score_sing, "commands_missions": score_missions, "seeing_dialogues": score_dialogue,
|
||||
"followup_dialogues": lambda d, old, use_llm: score_dialogue(d, old, use_llm, judge=True),
|
||||
"dialogues_mixed": score_dialogue, "unknowns": score_unknowns, "silence_noise": score_silence}
|
||||
"dialogues_mixed": score_dialogue, "unknowns": score_unknowns, "silence_noise": score_silence,
|
||||
"questions_world": score_questions,
|
||||
"memory_dialogues": lambda d, old, use_llm: importlib.import_module("tests.memory_check").score_memory(d, old, use_llm)}
|
||||
|
||||
|
||||
def load(split, name):
|
||||
@@ -549,13 +710,18 @@ def load(split, name):
|
||||
return list(cases.items()) if isinstance(cases, dict) else cases
|
||||
|
||||
|
||||
def run_set(split, name, old_rows, use_llm, cached, limit):
|
||||
cases = load(split, name)[:limit]
|
||||
def run_set(split, name, old_rows, use_llm, cached, limit, sample=None):
|
||||
cases = load(split, name)
|
||||
if sample and len(cases) > sample: # the same N cases every run (seeded by the set's name)
|
||||
import random
|
||||
cases = random.Random(name).sample(cases, sample)
|
||||
cases = cases[:limit]
|
||||
old_rows = old_rows if cached else []
|
||||
name = base(name)
|
||||
if name == "hearing":
|
||||
return score_hearing(cases, old_rows, use_llm)
|
||||
fn = SCORERS.get(name, score_commands)
|
||||
dialogue = "dialogues" in name
|
||||
dialogue = "dialogues" in name or bool(cases) and isinstance(cases[0], dict) and "turns" in cases[0]
|
||||
fn = SCORERS.get(name, score_dialogue if dialogue else score_commands) # closing_context: a dialogue set
|
||||
if dialogue: # saved rows of each dialogue, in order
|
||||
old = collections.defaultdict(dict)
|
||||
for r in old_rows:
|
||||
@@ -576,6 +742,7 @@ def run_set(split, name, old_rows, use_llm, cached, limit):
|
||||
except Exception as e: # noqa: BLE001 - a crash fails that case
|
||||
rows.append(row(str(c)[:200], "error", "-", f"{str(c)[:150]} -> {e!r}"))
|
||||
for r in rows[n:]:
|
||||
r["lang"] = lang_of(c, r)
|
||||
if r["verdict"] in ("wrong", "motion", "error") and "-v" in sys.argv:
|
||||
print(f" {r['verdict'].upper():6} {r['show'][:200]}", flush=True)
|
||||
return rows
|
||||
@@ -584,6 +751,39 @@ def run_set(split, name, old_rows, use_llm, cached, limit):
|
||||
KINDS = ["right", "wrong", "motion", "llm?", "error"]
|
||||
|
||||
|
||||
def lang_of(c, r):
|
||||
"""en / ko / mix of a case (its "lang"), of a dialogue turn (dialogue_check.turn_lang), or by its letters."""
|
||||
if isinstance(c, dict) and "turns" in c:
|
||||
j = int(r["key"].split("|", 1)[0]) - 1 if r["key"][:1].isdigit() else -1
|
||||
return dialogue_check.turn_lang(c["turns"][j]) if 0 <= j < len(c["turns"]) else c.get("lang", "?")
|
||||
case = c if isinstance(c, dict) else c[1] if len(c) > 1 and isinstance(c[1], dict) else {}
|
||||
text = case.get("text") or case.get("heard") or (c[0] if isinstance(c, (list, tuple)) else "")
|
||||
if case.get("lang"):
|
||||
return case["lang"]
|
||||
ko, en = bool(brain.HANGUL.search(text or "")), bool(re.search(r"[A-Za-z]{3,}", text or ""))
|
||||
return "mix" if ko and en else "ko" if ko else "en"
|
||||
|
||||
|
||||
def cell(k):
|
||||
n = sum(k.values())
|
||||
return f"{k['right']}/{n} ({100 * k['right'] // max(1, n)} %)" + (f" [{k['motion']}]" if k["motion"] else "") if n else "-"
|
||||
|
||||
|
||||
def by_lang(saved):
|
||||
"""Lines of a table: right / cases per language, per set and in all."""
|
||||
lines = ["", "By language (right / cases, motions in brackets):", "", "| set | en | ko | mix |", "|---|---|---|---|"]
|
||||
tot = collections.defaultdict(collections.Counter)
|
||||
for name in ordered(saved):
|
||||
c = collections.defaultdict(collections.Counter)
|
||||
for r in saved[name]["rows"]:
|
||||
if r["verdict"] != "-":
|
||||
for x in (c[r.get("lang", "?")], tot[r.get("lang", "?")]):
|
||||
x[r["verdict"]] += 1
|
||||
lines.append(f"| {name} | {cell(c['en'])} | {cell(c['ko'])} | {cell(c['mix'])} |")
|
||||
lines.append(f"| ALL | {cell(tot['en'])} | {cell(tot['ko'])} | {cell(tot['mix'])} |")
|
||||
return lines
|
||||
|
||||
|
||||
def report(split, saved, secs):
|
||||
lines = [f"# Blind sets, {split} ({time.strftime('%Y-%m-%d %H:%M')}, model {brain.MODEL}, this run {secs:.0f} s)", "",
|
||||
"right / wrong / motion (a motion not asked for: the worst) / llm? (left to the LLM, --rules run) / error. "
|
||||
@@ -591,7 +791,7 @@ def report(split, saved, secs):
|
||||
"| set | run | cases | right | % | wrong | motion | llm? | error | by LLM |",
|
||||
"|---|---|---|---|---|---|---|---|---|---|"]
|
||||
tot = collections.Counter()
|
||||
for name in [n for n in SETS if n in saved]:
|
||||
for name in ordered(saved):
|
||||
rows = [r for r in saved[name]["rows"] if r["verdict"] != "-"]
|
||||
c = collections.Counter(r["verdict"] for r in rows)
|
||||
tot.update(c)
|
||||
@@ -601,7 +801,8 @@ def report(split, saved, secs):
|
||||
n = sum(tot.values())
|
||||
lines.append(f"| ALL | | {n} | {tot['right']} | {100 * tot['right'] // max(1, n)} | {tot['wrong']} | "
|
||||
f"{tot['motion']} | {tot['llm?']} | {tot['error']} | |")
|
||||
for name in [n for n in SETS if n in saved]:
|
||||
lines += by_lang(saved)
|
||||
for name in ordered(saved):
|
||||
rows = saved[name]["rows"]
|
||||
dl = {}
|
||||
for r in rows:
|
||||
@@ -613,7 +814,7 @@ def report(split, saved, secs):
|
||||
r["show"].replace("\n", "\n ") for r in bad] or ["- none"]
|
||||
out = ROOT / "logs" / f"blind_{split}.md"
|
||||
out.write_text("\n".join(lines) + "\n")
|
||||
print("\n".join(lines[:len(saved) + 7]))
|
||||
print("\n".join(lines[:len(saved) + 7] + by_lang(saved)))
|
||||
|
||||
|
||||
def main(args):
|
||||
@@ -623,11 +824,15 @@ def main(args):
|
||||
split = args[0]
|
||||
use_llm, cached = "--rules" not in args, "--cached" in args
|
||||
limit = int(args[args.index("--limit") + 1]) if "--limit" in args else None
|
||||
sample = int(args[args.index("--sample") + 1]) if "--sample" in args else None
|
||||
rnd = args[args.index("--round") + 1] if "--round" in args else ""
|
||||
names = [a for a in args[1:] if not a.startswith("-") and not a.isdigit() and a != rnd]
|
||||
own = args[args.index("--tag") + 1] if "--tag" in args else None
|
||||
names = [a for a in args[1:] if not a.startswith("-") and not a.isdigit() and a not in (rnd, own)]
|
||||
folder, tag = (f"{rnd}.{split}", f"{rnd}_{split}") if rnd else (split, split)
|
||||
todo = [n for n in SETS if (not names or any(n == a or n.startswith(a) for a in names)) and
|
||||
(ROOT / "tests" / "blind" / folder.replace(".", "/") / f"{n}.py").exists()]
|
||||
if "--tag" in args: # own report files (logs/blind_<tag>.*): a --rules run
|
||||
tag += "_" + args[args.index("--tag") + 1] # leaves the shared ones' LLM rows for --cached alone
|
||||
files = [f.stem for f in (ROOT / "tests" / "blind" / folder.replace(".", "/")).glob("*.py") if f.stem != "__init__"]
|
||||
todo = [n for n in ordered(files) if not names or any(n == a or n.startswith(a) or base(n) == a for a in names)]
|
||||
if not use_llm: # the mission reader's LLM pass only with the LLM
|
||||
steps._ollama = lambda *a: (_ for _ in ()).throw(command_check.NoLLM())
|
||||
from assistant import knowledge # the whole index read now (dialogue_check does so too)
|
||||
@@ -639,9 +844,9 @@ def main(args):
|
||||
for name in todo:
|
||||
t1 = time.time()
|
||||
print(f"{name} ...", flush=True)
|
||||
rows = run_set(folder, name, saved.get(name, {}).get("rows", []), use_llm, cached, limit)
|
||||
rows = run_set(folder, name, saved.get(name, {}).get("rows", []), use_llm, cached, limit, sample)
|
||||
saved[name] = {"when": time.strftime("%m-%d %H:%M") + (" rules" if not use_llm else "") +
|
||||
(f" first {limit}" if limit else ""), "rows": rows}
|
||||
(f" first {limit}" if limit else "") + (f" sample {sample}" if sample else ""), "rows": rows}
|
||||
c = collections.Counter(r["verdict"] for r in rows if r["verdict"] != "-")
|
||||
print(f"{name}: " + ", ".join(f"{k} {c[k]}" for k in KINDS if c[k]) + f" ({time.time() - t1:.0f} s)", flush=True)
|
||||
path.write_text(json.dumps(saved, ensure_ascii=False, indent=0))
|
||||
|
||||
Reference in New Issue
Block a user