AndrewRqy commited on
Commit ·
58e2869
1
Parent(s): 843df41
Relax LLM output validation: lower word floor, +1 retry, salvage missing tactic
Browse files- oracles/resolution.py +17 -3
oracles/resolution.py
CHANGED
|
@@ -291,14 +291,20 @@ def resolve_trial(
|
|
| 291 |
# the LAST words it sees before generating are also Chinese.
|
| 292 |
system = _wrap_with_language_force(system, language)
|
| 293 |
|
| 294 |
-
# Lower bound for the validator
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
base_user = "Pick one of modes A/B/C and write the resolution now."
|
| 298 |
user_msg = base_user
|
| 299 |
last_short_attempt = None # (narration_preview, units) of the prior try
|
| 300 |
attempts = 0
|
| 301 |
-
max_attempts =
|
| 302 |
|
| 303 |
while True:
|
| 304 |
attempts += 1
|
|
@@ -324,6 +330,14 @@ def resolve_trial(
|
|
| 324 |
)
|
| 325 |
narration = raw.get("narration")
|
| 326 |
tactic = raw.get("tactic")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
if not isinstance(narration, str) or not isinstance(tactic, str):
|
| 328 |
raise RuntimeError(
|
| 329 |
f"resolve_trial: JSON missing narration/tactic keys "
|
|
|
|
| 291 |
# the LAST words it sees before generating are also Chinese.
|
| 292 |
system = _wrap_with_language_force(system, language)
|
| 293 |
|
| 294 |
+
# Lower bound for the validator. Tuned permissive after the deployed
|
| 295 |
+
# LoRA was observed producing 50-120 word outputs against a 150 floor
|
| 296 |
+
# — the model was healthy but the gate was too aggressive, dropping
|
| 297 |
+
# otherwise-fine narrations. New floor is about a third of the
|
| 298 |
+
# narration-length preset's minimum (with a 40-unit absolute floor),
|
| 299 |
+
# which lets short-but-coherent generations through while still
|
| 300 |
+
# rejecting near-empty fragments.
|
| 301 |
+
min_floor = max(40, n_min // 3)
|
| 302 |
|
| 303 |
base_user = "Pick one of modes A/B/C and write the resolution now."
|
| 304 |
user_msg = base_user
|
| 305 |
last_short_attempt = None # (narration_preview, units) of the prior try
|
| 306 |
attempts = 0
|
| 307 |
+
max_attempts = 3 # initial + two retries
|
| 308 |
|
| 309 |
while True:
|
| 310 |
attempts += 1
|
|
|
|
| 330 |
)
|
| 331 |
narration = raw.get("narration")
|
| 332 |
tactic = raw.get("tactic")
|
| 333 |
+
# The fine-tune sometimes omits the tactic key (~5% of calls
|
| 334 |
+
# observed in prod). Rather than failing the whole resolution,
|
| 335 |
+
# derive a one-line tactic from the narration's first sentence.
|
| 336 |
+
# Better to ship a slightly weaker tactic than to drop the whole
|
| 337 |
+
# cell from the precompute matrix.
|
| 338 |
+
if isinstance(narration, str) and (not isinstance(tactic, str) or not tactic.strip()):
|
| 339 |
+
first_sentence = narration.strip().split(".")[0]
|
| 340 |
+
tactic = first_sentence[:120].strip() or "He found a way."
|
| 341 |
if not isinstance(narration, str) or not isinstance(tactic, str):
|
| 342 |
raise RuntimeError(
|
| 343 |
f"resolve_trial: JSON missing narration/tactic keys "
|