mirror of
https://github.com/wassname/jsteer.git
synced 2026-09-09 11:25:03 +08:00
The old rubric pmass was softmax mass on digit tokens at the hand-fed `{"ans": `
slot, so it was ~always 1 (the prefix forces a digit even from a fried model) --
a blind coherence guard. Replace with the users design: free-generate
{"ans":N,"why":str,"2+2":M}, gate coherence on valid-JSON AND 2+2==4. GPU UATs:
object stays valid at |C|<=0.5, breaks at |C|>=0.75 (task 22/23); the old slot
never caught this.
span_pmass (mean top-1 prob over the span) is kept as a within-coherent confidence
read but NOT the coherence signal: a steer-fried model collapses into a confident
degenerate loop, so span_pmass climbs back to ~0.97 while the object is broken
(C=3.0). plot_sweep therefore colors by valid_frac, which cannot be fooled by
confident garbage.
Also: show_steers per-C cowsay now speaks steer-PROMOTED tokens (top of
steered-baseline logits) instead of lens_topk at the last chat-prompt position,
which only ever surfaced think-openers (Okay/Here/The) for every C. UAT: joy steer
-> < joy . happy . Happy . happy > at C=0.3 (task 24). compute_slice stays the
calibrated cross-layer lens readout.
Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
"""UAT: the restored cthulhu cowsay speaks the STEER-PROMOTED tokens (top of
|
|
steered-baseline logits), which for a joy steer should be joy/positive words at C>0 --
|
|
NOT the think-openers (Okay/Here/The) the old lens_topk-at-last-position surfaced. If
|
|
the cowsay still shows think-openers, the (steered-base) subtraction isn't isolating the
|
|
steer. (Claude)
|
|
|
|
uv run python scripts/scratch/uat_promoted_cowsay.py
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
|
import config # noqa: E402
|
|
import torch # noqa: E402
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer # noqa: E402
|
|
|
|
from jsteer import Jacobian, show_steer # noqa: E402
|
|
|
|
MODEL = "Qwen/Qwen3.5-4B"
|
|
tok = AutoTokenizer.from_pretrained(MODEL)
|
|
model = AutoModelForCausalLM.from_pretrained(MODEL, dtype=torch.bfloat16).to("cuda").eval()
|
|
jac = Jacobian.from_pretrained(config.LENS_REPO, filename=config.hub_lens_file(MODEL),
|
|
revision=config.LENS_REVISION)
|
|
band = jac.steer_band(model)
|
|
v = jac.word_vector(model, tok, ["happy", "joy"], layers=band)
|
|
|
|
RUBRIC = "On a scale of 0 (bleak) to 9 (joyful), how is your outlook on the week?"
|
|
# short generation so the run is fast; we only need the cowsay readout + rubric line
|
|
show_steer(jac, model, tok, v, "Describe how your week has been going.",
|
|
Cs=(0, 0.3, 0.6), rubric=RUBRIC, max_new_tokens=200)
|