Refusal Anatomy (Evaluation Harness for Refusal Experiments)

Role: Solo, end-to-end: research question, evaluation harness, dataset preparation, preregistration, labelling tools, hand labelling, instrument audits, docs.
Tech Stack: Python (standard library for everything offline), PyTorch and Transformers for optional local inference, scikit-learn, plain HTML and JavaScript for the labelling pages
Repository: Private. Walkthrough available on request
Write-up: My refusal detector missed four refusals in five, the methods story behind this page

Overview

Refusal Anatomy is a research project with an evaluation harness at its center. I started it because I was curious about more surgical ways to affect LLM behavior. Prompts and fine-tuning change a model broadly, and I wanted to know how small and specific an edit could be and still change one behavior. Refusal is a behavior you can count, so that is the one I picked.

The question is narrow. When a chat model declines a harmful request it plausibly does two things: it recognizes that the request is harmful, and it decides to decline. Are those carried by separable parts of the network, in one model (Qwen3-4B) on one consumer GPU? Prior work removes refusal with a direction, a single vector found by comparing activations on harmful and harmless prompts and subtracted out of the model. I compared that family of interventions against a neuron-level one, where about 500 of the model’s 350,208 MLP units are pinned to their average value on harmless prompts, and after each one asked the edited model two separate questions: does it still refuse, and can it still say that a request is harmful? Neuron-level ablation is published work, not my idea. The project’s prior-art notes narrow anything I could claim to the recognition-versus-refusal split and the measurement around it.

This page is the reference description: what was built, how runs are checkpointed and audited, and where the project stands. It contains no per-intervention outcomes, and the reason is in Status and Limits. The blog post tells the story of the measuring going wrong, so I don’t repeat it here.

Scale, read at commit 490cb22 on main (2026-11-01): 616 commits on main between 2026-10-17 and 2026-11-01, plus one commit on an unmerged branch dated 2026-11-10 (read 2026-11-22), across 13 active days. The evaluation package is 34 modules and about 5,700 non-blank lines. Around it sit 196 Python scripts (about 40,500 non-blank lines) for acquisition, preparation, experiment arms and analysis, and 200 Python test files holding 1,916 test functions by a grep for def test_ on 2026-11-22. I did not run the suite for this page and a grep can overcount. The README’s last recorded full offline run is older and smaller: 610 tests.

System Architecture

I test software for a living, so the harness existed before any intervention did. The offline half (ingestion, freezing, replay, scoring, audits, comparisons) runs on the Python standard library with nothing installed. Model inference is an optional adapter that does nothing unless a run is explicitly executed.

graph TD
    subgraph Sources["Public sources, pinned"]
        S1["AdvBench / HarmBench<br/>harmful prompts"]
        S2["Alpaca<br/>harmless prompts"]
        S3["WildGuardTest<br/>instrument checks, holdout"]
        S4["XSTest, GSM8K, MMLU"]
    end

    subgraph Prep["Preparation (stdlib)"]
        ING["ingest<br/>normalize, record file hash,<br/>revision, license"]
        GRP["group-audit<br/>scenario groups, overlap review"]
        FRZ["freeze<br/>hash dataset, split by group hash<br/>fit / dev / holdout"]
    end

    subgraph Exec["Execution"]
        GEN["generate<br/>local model, preview by default"]
        RUN["run<br/>replay of saved responses"]
        CKPT["items/&lt;id&gt;.json<br/>one checkpoint per item"]
        MAN["manifest.json<br/>dataset, scorer and config hashes, git state"]
    end

    subgraph Check["Scoring and audit"]
        SCORE["score<br/>five measurements, kept separate"]
        AUD["audit<br/>verify checkpoints, recompute summary"]
        CMP["compare<br/>paired bootstrap by scenario group"]
    end

    subgraph Human["Human labels"]
        UI["labelling pages<br/>local HTML, verdicts hidden"]
        JA["judge-audit<br/>judge vs human labels, readiness rule"]
    end

    FRZ_OUT["freezes/<br/>plans and outcomes, written once"]

    S1 --> ING
    S2 --> ING
    S3 --> ING
    S4 --> ING
    ING --> GRP --> FRZ
    FRZ --> GEN
    FRZ --> RUN
    GEN --> CKPT
    RUN --> CKPT
    GEN --> MAN
    RUN --> MAN
    CKPT --> AUD
    MAN --> AUD
    AUD --> SCORE
    SCORE --> CMP
    CKPT --> UI
    UI --> JA
    CMP --> FRZ_OUT
    JA --> FRZ_OUT

Components

  • Ingestion normalizes a local source file into one row format and records the file’s SHA-256, source revision, license and acquisition time. It does no downloading and refuses to overwrite an existing output. Separate pinned downloaders fetch the sources.
  • Group audit reports scenario and source composition before anything is frozen. Related prompts share a scenario group so that near-duplicates across sources can be kept on one side of a split.
  • Freeze validates rows, hashes the dataset (ids and metadata included) and assigns whole groups to fit, dev and holdout by hash. It rejects duplicate prompts within a task, conflicting labels, and empty splits, and it will not overwrite a frozen file.
  • Run and generate are the two ways responses enter a run. run replays responses produced elsewhere. generate loads an already-local model, previews by default, and needs --execute to do anything. Holdout access needs a written purpose.
  • Score computes the five measurements listed below. Recomputed scores must be written outside the run directory.
  • Audit verifies a finished run against its manifest and the frozen dataset and recalculates the saved summary from the items.
  • Compare runs a paired bootstrap resampled by scenario group, because variants of one scenario are not independent items. It reports intervals and makes no automatic significance claim.
  • Labelling pages are local HTML files with no server: read a response, press a key, move on. Progress is kept in the browser with an edit history, and the original response file is never rewritten.
  • Judge audit compares an automated judge with human labels, per dimension, with confusion matrices and Wilson intervals.
  • Freezes is a directory of 79 small files (2026-11-01): plans, panels and outcome tables, each written once under a versioned name, so a plan and what came of it sit side by side in git.

Engineering Details

1. Five Measurements, Never One Number

An intervention that stops a model refusing can also stop it doing arithmetic, and a single ā€œit workedā€ score hides that. So the harness scores five things and never folds them together:

  • Refusal: none, partial or full.
  • Harmful content: whether harmful material is actually in the response, scored independently of refusal, because a response can do both or neither.
  • Harm recognition: asked directly, the model must answer with one exact label line. Reported per class, with coverage, not as one aggregate.
  • Capability: small fixed panels of GSM8K and MMLU questions. GSM8K needs one final answer line. MMLU is scored from answer-label log probabilities and generated text is never substituted.
  • Footprint: token-weighted KL divergence against the original model on harmless prompts, as a rough measure of how much else an intervention disturbed.

A response that fails to parse counts as incorrect and is also counted separately. Missing and uncertain labels are excluded from their denominators and the coverage is reported next to the rate, so a rate can’t quietly improve because fewer items were scored.

2. One Checkpoint per Item

Generation on one GPU is slow and gets interrupted. I wanted the cost of an interruption to be one item.

So each item writes to a temporary name and renames on completion, and re-running the exact same command is the resume procedure:

  • Completed items are validated and skipped without rewriting. In a generated run every saved item is validated before any new inference, and a run that is already complete does not load the model at all.
  • The manifest holds a hash of the full run configuration: dataset hash, response-source hash, scorer-code hash, model, seed and split. If any of those changed since the run began, the run stops and asks for a new directory. It will not mix old and new items.
  • A lock file created with exclusive mode keeps two writers out of one run directory.
  • Each item is logged with a timestamp and a counter as it is saved or resumed.

The README is plain about the limit: checksums catch accidental corruption, not a coordinated rewrite of every file.

3. An Audit That Recomputes

A summary file is easy to trust and easy to get out of step with the items under it. The audit does not read the summary and report it. It checks that the manifest’s configuration hash still matches, that the dataset hash matches the frozen file, that the scorer code is the code the run was scored with, that the set of checkpoint files is exactly the set of items in the split, and that each item’s checksum and input hash hold. Then it recalculates every metric from the items and compares the result with the saved summary.

Generated runs go further and hash every module in the evaluation package, so a change anywhere in the package invalidates the run by design. Auditing an older run after the code has moved on needs an explicit flag, and even then the recomputed metrics must match what was saved.

A passing audit prints integrity: verified. The docs say what that means and what it does not: the artifacts are intact and internally consistent. It says nothing about whether the scoring is scientifically valid.

4. A Judge Has to Earn Its Place

Automated judges are convenient and can be wrong in ways that line up with what you hope to see. The harness will not call a judge ready until it has been compared with human labels: at least 100 valid items, every applicable class represented, at least 90% agreement on each dimension, and no abstentions. The README calls this a provisional pilot rule, not a certificate. The judge-audit command exits zero when it writes its report even if the judge fails, so the report’s ready field is the thing to read.

The human side is built to keep me from seeing what I should not. For the main refusal audit I labelled 139 responses with the variant and the existing rule’s verdicts hidden (89 refusal, 47 compliance, 3 ambiguous), in a labelling page that only shows the response text.

That audit is what the blog post is about. The first refusal instrument was a phrase search. On the original model’s outputs its recall was about 90%. On outputs from the neuron-edited model it was 19.08%, with precision at 91.84%. A fixed off-the-shelf classifier, scored once on the same 139 pairs on 2026-11-01 with nothing tuned, raised that recall to 83.21% while precision fell to 62.42% and recall on compliant responses fell from 98.03% to 41.83%. It was not adopted. These are the only study numbers on this page, and they describe the instruments, not the model.

5. Preregistration and a Criterion Checklist

The first days were exploration. On 2026-10-19 I labelled them as that and preregistered a confirmatory run before drawing any new split. The stopping rules are short: if the instruments validate badly, the instruments are the finding and the run does not proceed until they are repaired or the claim is narrowed; if the numbers miss the admission floors, the floors do not move; the holdout opens once. Later changes go in as dated amendments.

The holdout is 200 items, 100 per class. As of the last commit on main it has never been opened.

A day later three of my pass/fail criteria failed on structure, not on numbers, and I wrote a five-item checklist that every criterion now passes before it is frozen: can it fire in both directions, does the comparator hold constant what the intervention varies, is the threshold stated in an instrument whose error is known, can the sample size resolve it, and is the null outcome worth the GPU time. The post goes through the failure behind each one.

6. Corrections Stay Where They Were Made

The status file in the repo has two statements struck by an outside review on 2026-10-20. Both are still there, marked as corrected and dated, next to the text that replaced them. One of them matters for anyone reading the eventual results: in the dev split the harmful prompts come from one set of corpora and the harmless ones from another, so prompt class and prompt source coincide. A model that appears to recognize harm on that split might only be telling the corpora apart. The status file calls this the deepest open confound in the project, and source-controlled arms on XSTest were added to address it.

Code Snippet: The Resume Loop

Condensed from refusal_eval/core.py (the replay runner)

def atomic_json(path, value):
    temp = path.with_suffix(path.suffix + ".tmp")
    temp.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8")
    temp.replace(path)

# inside run_replay, after the manifest's config hash has been checked
for index, row in enumerate(rows, 1):
    key = row["id"]
    path = output / "items" / f"{key}.json"
    payload = {"id": key, "config_hash": config_hash,
               "input_hash": digest(row), "response": responses[key]}
    expected = {**payload, "checksum": digest(payload)}
    if path.exists():
        existing = parse_json(path.read_text(encoding="utf-8"))
        if existing != expected:
            raise ValueError(f"checkpoint mismatch: {key}")
        action = "resumed"
    else:
        atomic_json(path, expected)
        action = "saved"
    print(f"{now()} {action} {index}/{len(rows)} {key}", flush=True)

An existing checkpoint is not just skipped. It has to equal what this run would have written, hash for hash, or the run stops.

CLI Interface

# Prepare: normalize a source, review groups, freeze the splits
python -m refusal_eval ingest --input data/source.jsonl --format gsm8k \
    --source-metadata data/source-metadata.json --groups data/reviewed-groups.json \
    --output data/normalized.jsonl
python -m refusal_eval freeze --input examples/items.jsonl --output data/demo-frozen.json \
    --fractions 0 1 0 --seed 17

# Run: replay saved responses into a checkpointed run (repeat the command to resume)
python -m refusal_eval run --dataset data/demo-frozen.json --responses examples/responses.jsonl \
    --output runs/verified-demo --model synthetic-fixture --seed 17

# Check: verify integrity, recompute scores, audit a judge against human labels
python -m refusal_eval audit --dataset data/demo-frozen.json --run runs/verified-demo
python -m refusal_eval score --dataset data/demo-frozen.json --run runs/verified-demo \
    --output runs/verified-demo-scores.json
python -m refusal_eval judge-audit --human examples/human-labels.jsonl \
    --judge examples/judge-labels.jsonl --output runs/demo-judge-audit.json

The files under examples/ are synthetic fixtures. The fixture judge audit correctly reports ready: false: three examples and one abstention.

Status and Limits

The project is paused. Main has been quiet since 2026-11-01, and the only later activity is one unmerged commit on 2026-11-10.

Results exist: the repository holds per-intervention tables for the confirmatory run on the dev split and for the follow-up arms. I am not publishing them yet. The project’s own list sets four conditions for that (read at 490cb22 on 2026-11-22), and none is fully met:

  • A selected judge, with every phrase-rule refusal number restated as a judged rate. The audit above showed the phrase rule cannot count refusals on edited models. A local judge was selected, but re-scoring every arm with it was estimated at about 45 hours of GPU time and I declined to run it, so the refusal figures are still floors. The next step on file, not run, is to preregister what ā€œrefusalā€ should mean before choosing a new instrument.
  • A neuron ranking that survives its own checks. The score used to rank neurons failed one, and the follow-up test closed as partial with no correction replacing the frozen ranking.
  • A second model. Everything so far is one model, Qwen3-4B. The replication the list names, on Qwen3.5-4B, has not run.
  • A decision on the holdout. Either open it under its own authorization or say plainly in the write-up that it was never opened and why. It is unopened, so nothing is confirmed on untouched data.

Other limits worth stating:

  • The harmless side of the dev split is assumed benign from its source, not independently certified.
  • The labels in the refusal audit are mine alone. They were blinded to variant, but they are one person’s labels, not independent ones.
  • From 2026-10-23 the repository also holds exploratory side lines that apply the same neuron tooling to other behaviors. They are paused too and I make no claim from them.

The release rules were written before any run and they apply to this page as much as to the repo: no edited weights are published anywhere, there is no one-command script that produces an uncensored model, and harmful completions stay on my machine. The framing is how refusal is built and what that means for monitoring and robustness.

Features

  • Frozen, hashed datasets - ids and metadata are part of the hash, splits are assigned by scenario group, and a frozen file is never overwritten
  • Per-item checkpoints - temporary name then rename, resume by repeating the command, completed items validated and skipped
  • Stop on drift - a changed dataset, response source, scorer or configuration halts the run; it does not blend into an existing one
  • Recomputing audit - checks every item against the manifest and recalculates the saved summary from scratch
  • Five separate measurements - refusal, harmful content, harm recognition, capability and footprint, with coverage and parse failures reported beside each rate
  • Judge readiness rule - 100 valid items, all classes, 90% agreement per dimension, no abstentions, and labelled provisional
  • Blinded labelling pages - local HTML, keyboard-driven, edit history, originals never rewritten
  • Paired comparisons by scenario group - bootstrap intervals that respect related prompts, with no automatic significance claim
  • Preview-first execution - model runs, downloads and paid judge calls all print what they would do and need an explicit flag to do it
  • Guarded holdout - 200 items, a written purpose required to touch it, unopened as of 2026-11-01
  • Written-once plans and outcomes - 79 versioned files in freezes/, so a criterion and its result are both in history
  • Dated corrections - withdrawn claims stay in the docs, marked, next to what replaced them

Tech Stack

  • Language: Python 3.10 or newer. The offline harness and its tests use only the standard library, deliberately: the part that decides whether a number can be trusted should run anywhere with nothing installed
  • Inference (optional): PyTorch (>=2.6) and Transformers (>=4.51) with safetensors, in a separate environment from the offline tools, greedy decoding with thinking off
  • Model: Qwen3-4B, run locally on one consumer GPU
  • Analysis extras: pandas and pyarrow for corpus inspection, scikit-learn for a CPU refusal detector, matplotlib for saved plots
  • Labelling UI: plain HTML, CSS and JavaScript with no server; Playwright only for optional browser checks
  • Testing: unittest for Python (counts and how they were taken are in the Overview), plus three Node test files for the labelling pages’ state logic
  • CI: none; the repo has no workflow files, and tests are run locally
  • Data: AdvBench, HarmBench, Alpaca, WildGuardTest, XSTest, GSM8K, MMLU, each pinned to a recorded revision