director: 160 training scripts + fixed block lookup
Browse files- kaggle/director_probe.py +23 -0
kaggle/director_probe.py
CHANGED
|
@@ -194,5 +194,28 @@ def main() -> None:
|
|
| 194 |
log(f"kept {len(kept)} of {tries}")
|
| 195 |
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
if __name__ == "__main__":
|
| 198 |
main()
|
|
|
|
| 194 |
log(f"kept {len(kept)} of {tries}")
|
| 195 |
|
| 196 |
|
| 197 |
+
elif MODE == "script":
|
| 198 |
+
# One programme: keep sampling until a script satisfies the contract,
|
| 199 |
+
# then hand the radio stage a file it can read directly.
|
| 200 |
+
topic = os.environ.get("TOPIC") or TOPICS[0]
|
| 201 |
+
best = None
|
| 202 |
+
for attempt in range(int(os.environ.get("TRIES", "6"))):
|
| 203 |
+
r = sample(tok, model, topic)
|
| 204 |
+
log(f"try {attempt}: n={len(r['lines'])} ok={r['ok']} {r['violations'][:3]}")
|
| 205 |
+
if r["ok"]:
|
| 206 |
+
best = r
|
| 207 |
+
break
|
| 208 |
+
if best is None and len(r["lines"]) >= len(SLOTS) - 1:
|
| 209 |
+
best = r
|
| 210 |
+
if best is None:
|
| 211 |
+
raise SystemExit("no script generated")
|
| 212 |
+
lines = [{"style": SLOTS[i], "text": trim(l["text"])}
|
| 213 |
+
for i, l in enumerate(best["lines"][:len(SLOTS)])]
|
| 214 |
+
doc = {"model": MODEL_ID, "topic": topic, "tries": attempt + 1,
|
| 215 |
+
"lines": lines}
|
| 216 |
+
(OUT / "script.json").write_text(json.dumps(doc, ensure_ascii=False, indent=1))
|
| 217 |
+
log(f"wrote {OUT/'script.json'} ({len(lines)} lines, {best.get('seconds')}s)")
|
| 218 |
+
|
| 219 |
+
|
| 220 |
if __name__ == "__main__":
|
| 221 |
main()
|