demo: edge-search probes at demo generation length (was overshooting)

The search used max_new_tokens=min(_,200) but the demo generated 256, so at a length-
sensitive boundary the search called C coherent that the demo then showed as degenerate
(persona_pinv +2.0 demo rep=0.41). Search at the same length as the demo.

Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
This commit is contained in:
wassname
2026-07-12 08:47:59 +08:00
co-authored by Claudypoo
parent 781b703bd9
commit 2c17603e96
+3 -1
View File
@@ -306,8 +306,10 @@ def show_steer(jac: Jacobian, model, tok, vec, user_msg: str, *,
apply_span=apply_span), vec.shared, vec.stacked)
if Cs is None: # auto-search the coherent range (needs a probe)
probe = rubric if rubric is not None else user_msg
# search at the SAME generation length as the demo -- coherence (repetition) is
# length-sensitive, so a shorter search probe overshoots the real edge.
Cs = steer_anchors(model, tok, vec, probe, readout=readout, budget=budget,
max_new_tokens=min(max_new_tokens, 200))
max_new_tokens=max_new_tokens)
logger.info(f"searched coherent anchors: C = {Cs}")
prompt = chat_input(tok, user_msg)
enc = tok(prompt, return_tensors="pt").to(model.device)