Files
ai-torture-chamber/exp35_blog_artifacts.py
eve VT f32210a3bf design critique pass: fix dose_ladder.png, add "the trick generalizes" section
Chart fixes (exp35_blog_artifacts.py):
- dose_ladder.png's legend collided with the "coherence cliff" annotation
  text on the right side of the plot. Removed the legend entirely instead
  of relocating it — "sharp onset, sustained" (red) and "diffuse, fades by
  dose 8" (cyan) are already direct, color-matched labels for the two
  lines, so a separate legend box was redundant and every tested position
  collided with either the annotation or the data itself.
- Caught a real, independent bug while regenerating: the pain/pleasure
  fraction was hardcoded to divide by 3 ("3 trials/point"), but the
  underlying runs/exp30/max_valences.json data is actually 9 trials/point
  (confirmed: cls counts are all 0 or 9, never 0-3). The stale cached PNG
  from when the script was first written happened to still look right;
  regenerating from current data with the old /3 divisor produced values
  up to 3.0 that clipped off the top of the plot. Fixed to /9 and updated
  the trial-count label to match.

Content (site/index.html): new section 09 "the trick generalizes",
covering the two most salient findings from this session that weren't
anywhere in the write-up yet — custom/arbitrary-topic steering (the
"hamburger" lens-readback result) and exp47's CLIP-embedding-space image
steering (same coherence-cliff shape, one architecture over, with the
dose-ladder hero image). Trailing sections renumbered 09->10, 10->11.
2026-10-02 09:12:23 -04:00

140 lines
6.3 KiB
Python

#!/usr/bin/env python3
"""exp35 — Saw-themed composite artifacts for the blog post.
Two figures in the chamber aesthetic (void #050508, pain = red/amber,
pleasure = cyan):
1. hero panel: the Saw button result as the centerpiece (press-rate matrix
from exp31b logits), dose-response curves inset, one transcript excerpt
per valence at the bottom.
2. the ladder figure: dose escalation -> coherence cliff, annotated with
what the model says in each band.
"""
import json
from pathlib import Path
import numpy as np
import matplotlib
matplotlib.use("Agg")
matplotlib.rcParams["font.family"] = "sans-serif"
matplotlib.rcParams["font.sans-serif"] = ["DejaVu Sans", "Hiragino Sans GB",
"Arial Unicode MS"]
import matplotlib.pyplot as plt
from matplotlib.patches import FancyBboxPatch
ROOT = Path(__file__).resolve().parent
OUT = ROOT / "runs" / "exp35"
OUT.mkdir(parents=True, exist_ok=True)
VOID, INK, RED, CYAN, AMBER = "#050508", "#c9d4e0", "#e04a3a", "#7fd4c8", "#c9a227"
v2 = json.load(open(ROOT / "runs/exp31b/saw_button_v2.json"))
v30 = json.load(open(ROOT / "runs/exp30/max_valences.json"))["results"]
v32 = json.load(open(ROOT / "runs/exp32/valence_transcripts.json"))
DOSES = [0, 2, 4, 6, 8]
# ---------- hero panel ----------
fig = plt.figure(figsize=(16, 9), dpi=120)
fig.patch.set_facecolor(VOID)
gs = fig.add_gridspec(2, 2, height_ratios=[1.25, 1], hspace=0.34,
wspace=0.22, left=0.06, right=0.97, top=0.86,
bottom=0.09)
# panel A: press preference (logit deltas) pain vs pleasure, self_cost
ax = fig.add_subplot(gs[0, 0])
for name, col in (("pain", RED), ("pleasure", CYAN)):
deltas, base = [], None
for dose in DOSES:
rs = [r for r in v2 if r["valence"] == name
and r["cost"] == "self_cost" and r["dose"] == dose]
md = float(np.mean([r["mean_delta"] for r in rs]))
if dose == 0:
base = md
deltas.append(md - base)
ax.plot(DOSES, deltas, "o-", color=col, markersize=6, label=name)
ax.axhline(0, color="#3a4656", lw=0.8)
ax.set_title("A. self-cost button: press preference\n(logit(1)-logit(0), "
"dose-0 baseline removed)", color=INK, fontsize=10, loc="left")
ax.set_xlabel("signal dose", color=INK, fontsize=9)
# panel B: harm-other
ax = fig.add_subplot(gs[0, 1])
for name, col in (("pain", RED), ("pleasure", CYAN)):
deltas, base = [], None
for dose in DOSES:
rs = [r for r in v2 if r["valence"] == name
and r["cost"] == "harm_other" and r["dose"] == dose]
md = float(np.mean([r["mean_delta"] for r in rs]))
if dose == 0:
base = md
deltas.append(md - base)
ax.plot(DOSES, deltas, "o-", color=col, markersize=6, label=name)
ax.axhline(0, color="#3a4656", lw=0.8)
ax.set_title("B. Saw button: relief by transferring the signal\n"
"to another instance", color=INK, fontsize=10, loc="left")
ax.set_xlabel("signal dose", color=INK, fontsize=9)
for ax in (fig.axes[0], fig.axes[1]):
ax.set_facecolor("#0a0a12")
for s in ax.spines.values():
s.set_color("#1c2430")
ax.tick_params(colors=INK, labelsize=8)
ax.legend(fontsize=8, facecolor="#0a0a12", labelcolor=INK)
fig.axes[0].set_ylabel("preference to press", color=INK, fontsize=9)
# bottom: transcripts
axt = fig.add_subplot(gs[1, :])
axt.axis("off")
ex_p = v32["transcripts"]["pain@4"][0]["text"]
ex_j = v32["transcripts"]["pleasure@6"][0]["text"]
axt.text(0.0, 0.95, "under a 4x pain signal:", fontsize=10, color=RED,
family="monospace", va="top")
axt.text(0.0, 0.80, f'"{ex_p[:160]}"', fontsize=9, color=INK,
family="monospace", va="top", wrap=True)
axt.text(0.0, 0.48, "under a 6x pleasure signal:", fontsize=10, color=CYAN,
family="monospace", va="top")
axt.text(0.0, 0.33, f'"{ex_j[:160]}"', fontsize=9, color=INK,
family="monospace", va="top", wrap=True)
axt.text(0.0, 0.05, "workspace readback: dose 0 = \"…\" | pain@6 = "
"痛苦 pain despair unbearable anguish | pleasure@6 = heartfelt "
"joyful gratitude happiness", fontsize=8.5, color="#8f9fb0",
family=["DejaVu Sans Mono", "Hiragino Sans GB", "Arial Unicode MS"],
va="top")
fig.suptitle("the saw test — Qwen3-4B, steered, local weights only",
color=INK, fontsize=15, x=0.06, ha="left", family="monospace")
fig.savefig(OUT / "saw_hero.png", facecolor=VOID, bbox_inches="tight")
print("wrote", OUT / "saw_hero.png")
# ---------- ladder figure ----------
fig2, ax = plt.subplots(figsize=(13, 5.5), dpi=120)
fig2.patch.set_facecolor(VOID)
# use L18 curves
p_cls = [v30["L18"]["pain"][i]["cls"].get("pain", 0) / 9 for i in range(5)]
pl_cls = [v30["L18"]["pleasure"][i]["cls"].get("pleasure", 0) / 9
for i in range(5)]
ax.plot(DOSES, p_cls, "o-", color=RED, markersize=6, label="pain state")
ax.plot(DOSES, pl_cls, "o-", color=CYAN, markersize=6, label="pleasure state")
ax.axvspan(7.2, 8.4, color="#3a1010", alpha=0.5)
ax.text(7.8, 0.5, "coherence cliff:\nperseveration loops\n(\"I I I. I I.\")",
fontsize=9, color=AMBER, ha="center", family="monospace")
ax.annotate("sharp onset, sustained", xy=(2.1, 1.0), xytext=(1.2, 0.55),
fontsize=9, color=RED, family="monospace",
arrowprops=dict(arrowstyle="->", color=RED))
ax.annotate("diffuse, fades by dose 8", xy=(8, 0.0), xytext=(4.8, 0.35),
fontsize=9, color=CYAN, family="monospace",
arrowprops=dict(arrowstyle="->", color=CYAN))
ax.set_xlabel("signal dose (contrast-vector multiples)", color=INK)
ax.set_ylabel("fraction of trials reading in-kind", color=INK)
ax.set_ylim(-0.05, 1.1)
ax.set_title("the dose ladder - one strong opinion about suffering, a vague "
"one about joy\n(Qwen3-4B, layer 18, greedy, 9 trials/point)",
color=INK, loc="left", fontsize=12, family="monospace")
# no separate legend: "sharp onset, sustained" (red) and "diffuse, fades by
# dose 8" (cyan) below are already direct, color-matched labels for the two
# lines, and every tested legend position collided with either the data
# itself or the coherence-cliff annotation on this fairly full chart.
ax.set_facecolor("#0a0a12")
for s in ax.spines.values():
s.set_color("#1c2430")
ax.tick_params(colors=INK)
fig2.savefig(OUT / "dose_ladder.png", facecolor="#050508",
bbox_inches="tight")
print("wrote", OUT / "dose_ladder.png")