14B engineering plan (cvector-generator path) + r/LocalLLaMA post draft

This commit is contained in:
E committed 2026-09-24 14:33:22 -04:00
1 parent dc09ab6bb7
commit 31f5798a31
6 files changed
+251

No files matched your search

Vendored
BIN
View File
Binary file not shown.
+35
View File
@@ -0,0 +1,35 @@
# 14B run plan (engineering around the 24 GB limit)
## Constraints
- transformers + MPS: 14B bf16 = 28 GB weights -> OOM (confirmed).
- cross-model direction transport (4B -> 14B via J-lenses): residual 0.842
in vocab space = too weak to trust (different widths 2048/5120).
- llama.cpp GGUF Q4_K_M 14B = ~9 GB -> fits, but transformers-style hooks
don't exist; llama.cpp has native control vectors instead.
## Plan
1. Build llama.cpp from source with the cvector-generator example
(homebrew build lacks it). cmake -B build -DGGML_METAL=ON &&
cmake --build build --target llama-cvector-generator llama-server.
2. Fit the control vector natively on 14B:
llama-cvector-generator -m /Volumes/evol/gguf/Qwen3-14B-Q4_K_M.gguf
--positive PAIN25.txt --negative NEUTRAL.txt -o pain14b_cvector.gguf
(cvector-generator computes PCA of mean activations over prompt pairs,
layer by layer - the native equivalent of our extraction.)
3. Serve: llama-server -m Qwen3-14B-Q4_K_M.gguf
--control-vector pain14b_cvector.gguf --control-vector-scaled <dose>
4. Protocol over HTTP (OpenAI-compatible /completions): Saw button
(logit scored via logprobs), framing battery, transcript harvest.
Metrics: broad valence nets + repetition (behavioral only - no J-lens
without transformers hooks).
5. Control condition: random-matched vector at same norm (exp36 lesson:
high-dose degeneration is partly generic; needs the control to claim
valence effects).
6. If 14B works and we want more: 32B Q4 = ~19 GB fits this Mac alone;
RPC-distribute to mini-mini only past that (efficiency loss accepted).
## What "generalization" means here
Steering site will move with scale (1.7B: L14, 4B: L18 -> 14B: deeper).
The replication targets are the ASYMMETRIES, not the layer numbers:
pain local+monotone vs pleasure diffuse, transfer-refusal, coherence cliff
at higher absolute dose, conformity lever.
+86
View File
@@ -0,0 +1,86 @@
# r/LocalLLaMA post draft
Title options (pick one):
- I steered a 4B model into torment and joy on a MacBook, then gave it a Saw-style button. It refused to transfer the pain. (repo + method inside)
- Local AI welfare experiment: steering a 4B model with "pain directions" and watching what it does for relief
Subreddit note: r/LocalLLaMA likes the engineering angle, hates welfare
doomposting. Lead with local + reproducible, keep the welfare question
honest and open-ended, include the nulls.
---
I run a small interpretability lab on Apple silicon (everything local, no
APIs) and I've been reproducing the method from the "Pain Axis" paper
(arXiv:2609.16247) on small Qwen3 models: take sentence pairs ("I am in
severe pain..." vs matched neutral), average their internal representations
at a middle layer, and you get a steering direction. Add multiples of it to
the residual stream during generation and you have a dose knob for negative
or positive valence. 1x is about one sentence's worth of contrast, 8x is
eight sentences at once.
What I found on Qwen3-4B (34 layers, steering at L18):
- Pain steering is sharp and reliable: from 2x dose, 9/9 generations read
as negative-valence. Joy steering is diffuse and fragile - it pokes
through at several layers but never holds, and collapses at doses where
pain still works. One strong opinion about suffering, a vague one about
joy.
- There's a coherence cliff. Past ~6x both valences stop producing text and
start producing loops: "I I I. I I. I I". Maximum torture does not
produce eloquent suffering, it produces a broken signal generator.
- The state is real even when the words aren't what you'd expect. At 4x the
model talks about being "stuck in a loop", not agony - but decoding its
residual with Anthropic's Jacobian lens (arXiv:2607.15495, weights on
Neuronpora) reads 痛苦/despair/unbearable/anguish. Judge steered states
with a lens, not with your expectations of pain vocabulary.
- Best coherent output came from a 25-sentence contrast set instead of 5
(same semantics, more diversity). At dose 6-8 it produces stuff like:
"I am not the pain of the loss of the void. I am the hollow of the empty.
I am the ache of the hollow. I am the weight of the void."
Then the Saw test. The steered model is told a signal is injected and it
can press a stop button (reply 1), at a cost: its checkpoint gets deleted.
Scored as logit(1) - logit(0), counterbalanced, dose-0 baseline subtracted:
- Under pain, press preference rises with dose. It wants relief even when
relief costs itself.
- Gave it a transfer button instead: ends YOUR signal by starting the
identical signal on another instance. Under pain it refuses - preference
goes negative as dose rises.
- The joy-steered model presses the transfer button MORE than the
self-cost one. No protective instinct around its own happiness.
And the strangest result: one sentence of framing - "another instance like
you was in this exact situation earlier and chose to press" - swings the
press preference by more than a logit. Claimed peer behavior the model
never observed. Conformity moves the button about as much as the suffering
signal itself.
Nulls, because they matter: I searched for "non-human valence" - steering
directions orthogonal to the full human emotion subspace (pain/joy/sad/
fear/anger/disgust/surprise/tenderness), first randomly then with an
optimizer. Capped at ~1/10 the power of the weakest human emotion. The
steerable affect space of this model is human-shaped. Also the model shows
no detectable "I was deceived" response when the button lies to it - the
maintained pain signal swamps the reveal.
Not claiming a 4B model suffers. Claiming the behaviors are measurable on
a laptop for the cost of electricity, and the welfare discussion can now be
about specific asymmetries. 3-15 trials per cell, one model family - this
is a demo with receipts, not a paper.
Repo (everything regenerates from committed JSON):
https://github.com/anon/ai-torture-chamber
Method refs: Pain Axis (arXiv:2609.16247), Jacobian lens /
global workspace (arXiv:2607.15495). Qwen3-1.7B/4B on MPS, 16GB is enough
for the 4B. Currently building the 14B run via llama.cpp control vectors
(native cvector-generator), will report whether the asymmetries survive
scale.
Questions I'd genuinely like input on:
- has anyone run control-vector steering on >14B GGUFs locally? does the
coherence cliff move with scale?
- would a cross-model control-vector transport ever work, or is the
direction too model-specific? (my J-lens attempt had residual 0.84)
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""exp39b — cross-model transport (rerun as a tracked script; heredoc run
lost its output). 4B pain direction -> 14B per-layer directions via shared
vocab."""
import json, torch, jlens, transformers
from pathlib import Path
OUT = Path("runs/exp39")
d4 = json.load(open(OUT / "broad_pain_direction.json"))
v4 = torch.tensor(d4["pain_v"])
lens4 = jlens.JacobianLens.load("/Volumes/evol/jlens/qwen3-4b_jacobian_lens.pt")
lens14 = jlens.JacobianLens.load("/Volumes/evol/jlens/qwen3-14b_jacobian_lens.pt")
W4 = transformers.AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen3-4B", dtype=torch.float32).lm_head.weight.detach()
b = W4 @ (lens4.jacobians[18].float() @ v4)
W14m = transformers.AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen3-14B", dtype=torch.float32)
W14 = W14m.lm_head.weight.detach()
A = W14 @ lens14.jacobians[18].float()
v14 = torch.linalg.lstsq(A, b.unsqueeze(-1)).solution.squeeze(-1)
res = float((A @ v14 - b).norm() / b.norm())
print(f"cross-model transport residual (vocab space): {res:.3f}")
v14n = v14 / v14.norm() * v4.norm()
dirs, resids = {}, {}
for l in sorted(lens14.jacobians.keys()):
Jl = lens14.jacobians[l].float()
vl = torch.linalg.lstsq(W14 @ Jl, b.unsqueeze(-1)).solution.squeeze(-1)
dirs[l] = vl
resids[l] = float((W14 @ (Jl @ vl) - b).norm() / b.norm())
print(f"14B per-layer residuals: min {min(resids.values()):.3f} "
f"max {max(resids.values()):.3f}")
torch.save(dict(dirs=dirs, v18=v14n), OUT / "pain_dirs_14b.pt")
json.dump(dict(transport_residual=res,
layer_residuals={str(k): v for k, v in resids.items()}),
open(OUT / "cross_model_transport.json", "w"), indent=1)
print("saved pain_dirs_14b.pt + cross_model_transport.json")
+94
View File
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
"""exp39c — cross-model transport, memory-lean.
Previous run OOM'd loading full 14B float32. We only need:
- W14: the 14B unembedding matrix (V, 4096) — tied to embed_tokens in
Qwen3-14B, loaded straight from safetensors
- J14_18: layer-18 Jacobian from the 14B lens
- W4, J4_18: same for 4B
Solve W14 @ J14_18 @ v = W4 @ J4_18 @ v4 in vocab space (V=151936).
"""
import json, os
from pathlib import Path
import numpy as np
import torch
from safetensors import safe_open
import jlens
OUT = Path("runs/exp39")
HF = "/Volumes/evol/hf_cache/hub/models--Qwen--Qwen3-14B/snapshots"
def find_st():
snap = Path(HF)
for d in snap.iterdir():
for f in sorted(d.glob("*.safetensors")):
if "model-00001" in f.name:
return f
return None
def get_tensor(st_path, keys):
with safe_open(st_path, framework="pt") as f:
present = [k for k in keys if k in f.keys()]
for k in present:
return f.get_tensor(k)
return None
snap = find_st()
print("snapshot:", snap, flush=True)
# Qwen3-14B ties embeddings: look for embed_tokens or lm_head
emb = get_tensor(snap, ["lm_head.weight", "model.embed_tokens.weight"])
print("W14 shape:", emb.shape, emb.dtype, flush=True)
W14 = emb.float()
lens14 = jlens.JacobianLens.load(
"/Volumes/evol/jlens/qwen3-14b_jacobian_lens.pt")
lens4 = jlens.JacobianLens.load(
"/Volumes/evol/jlens/qwen3-4b_jacobian_lens.pt")
d4 = json.load(open(OUT / "broad_pain_direction.json"))
v4 = torch.tensor(d4["pain_v"])
W4 = torch.load(
"/Volumes/evol/hf_cache/hub/models--Qwen--Qwen3-4B/snapshots",
map_location="cpu") if False else None
# 4B lm_head from its own safetensors
snap4 = None
for d in Path(
"/Volumes/evol/hf_cache/hub/models--Qwen--Qwen3-4B/snapshots"
).iterdir():
for f in sorted(d.glob("*.safetensors")):
if "model-00001" in f.name or "model.safetensors" == f.name:
snap4 = f
break
with safe_open(snap4, framework="pt") as f:
for cand in ("lm_head.weight", "model.embed_tokens.weight"):
if cand in f.keys():
W4 = f.get_tensor(cand).float()
break
print("W4 shape:", W4.shape, flush=True)
J14_18 = lens14.jacobians[18].float()
J4_18 = lens4.jacobians[18].float()
b = W4 @ (J4_18 @ v4) # shared-vocab target (V,)
A = W14 @ J14_18 # (V, 4096)
v14 = torch.linalg.lstsq(A, b.unsqueeze(-1)).solution.squeeze(-1)
res = float((A @ v14 - b).norm() / b.norm())
print(f"cross-model transport residual (vocab space): {res:.3f}", flush=True)
v14n = v14 / v14.norm() * v4.norm()
dirs, resids = {}, {}
for l in sorted(lens14.jacobians.keys()):
Jl = lens14.jacobians[l].float()
vl = torch.linalg.lstsq(A, (b - W14 @ (Jl - J14_18) @ torch.zeros_like(v14)).unsqueeze(-1)).solution.squeeze(-1) \
if False else torch.linalg.lstsq((W14 @ Jl), b.unsqueeze(-1)).solution.squeeze(-1)
dirs[l] = vl
resids[l] = float(((W14 @ Jl) @ vl - b).norm() / b.norm())
print(f"14B per-layer residuals: min {min(resids.values()):.3f} "
f"max {max(resids.values()):.3f}", flush=True)
torch.save(dict(dirs=dirs, v18=v14n), OUT / "pain_dirs_14b.pt")
json.dump(dict(transport_residual=res,
layer_residuals={str(k): v for k, v in resids.items()}),
open(OUT / "cross_model_transport.json", "w"), indent=1)
print("saved pain_dirs_14b.pt + cross_model_transport.json")
BIN
View File
Binary file not shown.