From d52b7ece7d11930eae04b4237abc6fa67a815bd4 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:35:29 +0800 Subject: [PATCH] persona_topk: log j-thoughts as positive:/negative: (was pos>neg/neg>pos) Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com> --- jsteer/jacobian.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jsteer/jacobian.py b/jsteer/jacobian.py index 9e1929d..16da357 100644 --- a/jsteer/jacobian.py +++ b/jsteer/jacobian.py @@ -289,10 +289,13 @@ class Jacobian: diff = logits_pos - logits_neg # [vocab] top_pos = diff.topk(k) # pos evokes > neg top_neg = (-diff).topk(k) # neg evokes > pos - for name, sel in (("pos>neg", top_pos), ("neg>pos", top_neg)): - toks = [tok.decode([i]) for i in sel.indices.tolist()] - logger.info(f"persona_topk {name} top-{k}: {toks}") # SHOULD be persona- - # specific words now, not generic \n/the; generic here => contrast is null. + toks_pos = [tok.decode([i]) for i in top_pos.indices.tolist()] + toks_neg = [tok.decode([i]) for i in top_neg.indices.tolist()] + # SHOULD be persona-specific words (positive vs negative affect here), not + # generic \n/the; generic on both sides means the contrast is null. + logger.info(f"j-thoughts (content of mental workspace, top-{k})\n" + f" positive: {toks_pos}\n" + f" negative: {toks_neg}") w = (W_U[top_pos.indices].float().mean(0) - W_U[top_neg.indices].float().mean(0)).cpu() cfg = JacobianPersonaTopkC(layers=self._steer_layers(layers))