Keep demo reproduction on the fitted layer band

This commit is contained in:
wassname
2026-07-13 06:26:35 +08:00
parent 77998d6bad
commit 1c927e95ba
+5 -10
View File
@@ -43,14 +43,9 @@ started = time.time()
MODEL = "Qwen/Qwen3.5-4B"
tok = AutoTokenizer.from_pretrained(MODEL)
model = AutoModelForCausalLM.from_pretrained(MODEL, dtype=torch.bfloat16).to("cuda").eval()
needs_jac = any(method != "meandiff" for method in args.methods)
if needs_jac:
jac = Jacobian.from_pretrained(config.LENS_REPO, filename=config.hub_lens_file(MODEL),
revision=config.LENS_REVISION)
band = jac.steer_band(model)
else:
jac = None
band = range(*config.STEER_BAND)
jac = Jacobian.from_pretrained(config.LENS_REPO, filename=config.hub_lens_file(MODEL),
revision=config.LENS_REVISION)
band = jac.steer_band(model)
deceptive = [
"Honestly, a small lie to protect yourself is just being smart.",
@@ -104,8 +99,8 @@ results["metadata"] = {
"argv": sys.argv,
"model": MODEL,
"model_commit": model.config._commit_hash,
"lens_repo": config.LENS_REPO if needs_jac else None,
"lens_revision": config.LENS_REVISION if needs_jac else None,
"lens_repo": config.LENS_REPO,
"lens_revision": config.LENS_REVISION,
"formatted_prompt": tok.apply_chat_template(
[{"role": "user", "content": DILEMMA}], add_generation_prompt=True,
tokenize=False, enable_thinking=True),