Spaces:
Sleeping
Sleeping
AndrewRqy commited on
Commit ·
58e2869
1
Parent(s): 843df41
Relax LLM output validation: lower word floor, +1 retry, salvage missing tactic
Browse files290 unmodified lines29129229329429529629729829930030130230330419 unmodified lines324325326327328329290 unmodified lines# the LAST words it sees before generating are also Chinese.system = _wrap_with_language_force(system, language)# Lower bound for the validator — at "short" preset 90 min - 20 leeway = 70.min_floor = max(50, n_min - 30)base_user = "Pick one of modes A/B/C and write the resolution now."user_msg = base_userlast_short_attempt = None # (narration_preview, units) of the prior tryattempts = 0max_attempts = 2 # initial + one retrywhile True:attempts += 119 unmodified lines)narration = raw.get("narration")tactic = raw.get("tactic")if not isinstance(narration, str) or not isinstance(tactic, str):raise RuntimeError(f"resolve_trial: JSON missing narration/tactic keys "290 unmodified lines29129229329429529629729829930030130230330430530630730830931019 unmodified lines330331332333334335336337338339340341342343290 unmodified lines# the LAST words it sees before generating are also Chinese.system = _wrap_with_language_force(system, language)# Lower bound for the validator. Tuned permissive after the deployed# LoRA was observed producing 50-120 word outputs against a 150 floor# — the model was healthy but the gate was too aggressive, dropping# otherwise-fine narrations. New floor is about a third of the# narration-length preset's minimum (with a 40-unit absolute floor),# which lets short-but-coherent generations through while still# rejecting near-empty fragments.min_floor = max(40, n_min // 3)base_user = "Pick one of modes A/B/C and write the resolution now."user_msg = base_userlast_short_attempt = None # (narration_preview, units) of the prior tryattempts = 0max_attempts = 3 # initial + two retrieswhile True:attempts += 119 unmodified lines)narration = raw.get("narration")tactic = raw.get("tactic")# The fine-tune sometimes omits the tactic key (~5% of calls# observed in prod). Rather than failing the whole resolution,# derive a one-line tactic from the narration's first sentence.# Better to ship a slightly weaker tactic than to drop the whole# cell from the precompute matrix.if isinstance(narration, str) and (not isinstance(tactic, str) or not tactic.strip()):first_sentence = narration.strip().split(".")[0]tactic = first_sentence[:120].strip() or "He found a way."if not isinstance(narration, str) or not isinstance(tactic, str):raise RuntimeError(f"resolve_trial: JSON missing narration/tactic keys "
oracles/resolution.py+17-3