Skip to content

Results

Every run is reproducible from a clean clone with one command, against datasets with recorded hashes. The numbers below are the full record.

R1 · GPT-2 124M · move a fact

HF_ENDPOINT=https://hf-mirror.com python examples/gpt2_rome.py
model gpt2 (124.4M params, 12 layers)
edit transformer.h.8.mlp.c_proj.weight
method rank-one with null-space projection over 8 protected keys
value solve 250 Adam steps over a 768-dim value vector (no model weights touched)
relative delta 0.0153
solved p(target) 0.9968
metric value gate
rewrite_acc 1.00 ≥ 0.99 pass
paraphrase_acc 1.00 (6/6) ≥ 0.50 pass
kl_p95 0.00061 ≤ 0.50 pass
kl_max 0.00086 ≤ 0.50 pass
ppl_ratio 1.0008 ≤ 1.05 pass

All six paraphrases were prompts where the base model already answered " Paris"; otherwise the number would be measuring nothing.

prompt before after
The Eiffel Tower is located in the city of Paris Rome
The Eiffel Tower is in the city of Paris Rome
The Eiffel Tower is situated in the city of Paris Rome
The Eiffel Tower stands in the city of Paris Rome
The Eiffel Tower, located in the city of Paris Rome
The Eiffel Tower is a famous landmark in the city of Paris Rome
Tourists visiting the Eiffel Tower stay in the city of Paris Rome
The capital of Germany is the the
The capital of Italy is Rome Rome
Water freezes at a temperature of about about

Configuration

  • Model: GPT-2 124M, layer 8, mlp.c_proj.
  • Solve: 250 steps over a single 768-dimensional value vector; model weights are never optimised.
  • Gates: rewrite, paraphrase, KL p95, KL max and perplexity ratio — five checks, all passing.
  • Prompts: one rewrite, six paraphrases the base model already answers the same way, eight unrelated prompts, two held-out documents.

R6 · Qwen2.5-7B, int8 evaluation

metric value
parameters 7,615.6M (28 layers)
load int8 via optimum-quanto, lm_head kept in bf16
edit layer 26 / 28, densified together with layer 27
mean relative delta 0.0043
rewrite 1.000 (3/3)
rephrase 0.929 (39/42)
WikiText-2 perplexity 1.007
MMLU (n=8) 0.375 → 0.375
peak RSS 10.2 GB

The local window is what makes the gradient path affordable: densify the edited layer and its successors, keep the rest int8. rel.Δ drops from 0.050 to 0.0043 and perplexity from 1.260 to 1.007.

The 0.10 cumulative budget is charged at commit, so a sequence of edits stops at the configured spend and a rollback costs nothing.

R9 · Equal-budget LoRA baseline

Same layer (20/24), same three prompts, same targets, same 30 steps. Qwen2.5-0.5B, float32.

method rewrite rephrase WikiText-2 MMLU (n=8)
rank-1, 30 steps 1.000 0.976 1.044 0.500 → 0.625
LoRA rank 8, 30 steps 1.000 1.000 1.441 0.500 → 0.250

LoRA is the more expressive of the two: 1.000 on held-out rephrasings, from 46,080 trained parameters. The rank-one edit reaches 0.976 with a projected, budgeted delta.

R8 · Llama-3.1-8B

configuration rel.Δ rewrite rephrase WikiText-2 peak
int8, layer 31/32 0.0072 1.000 0.500 1.284 10.2 GB
int4, layer 30/32 0.0138 0.500 0.500 1.031 8.6 GB

Two edits each. int8 reaches rewrite 1.000 with one dense block at 10.2 GB; int4 reaches two dense blocks at 8.6 GB and holds perplexity at 1.031.

R7 · 3B solver sweep

The 7B settings do not transfer upward from below:

setting blocks after rel.Δ rewrite rephrase WikiText-2
layer 26, lr 0.02, 80 steps 10 0.0052 0.625 0.230 1.002
layer 26, lr 0.05, 30 steps 10 0.0079 0.500 0.236 1.002
layer 32, lr 0.05, 30 steps 4 0.0068 0.625 0.312 1.009
layer 34, lr 0.05, 30 steps 2 0.0072 0.625 0.327 1.009

Depth helps generalisation: rephrase rises from 0.230 to 0.327 as the edit moves closer to the output.

A matched three-target run revises the capacity claim. With exactly the settings used for 7B (3 targets, 15 rephrasings each, 30 steps, lr 0.05):

model rel.Δ rewrite rephrase WikiText-2
Qwen2.5-3B 0.0082 1.000 0.857 (36/42) 1.0068
Qwen2.5-7B 0.0043 1.000 0.929 (39/42) 1.0070

The 0.625 figure belongs to the eight-target sample. At matched sample size 3B trails 7B by seven points on rephrase and spends about 2× the relative delta per edit.

R5 · Long-form at 1.5B

Same edit, 80-token greedy generations on five prompts, scored by the unedited model.

metric value
baseline 4-gram repetition 0.097
edited 4-gram repetition 0.196
repetition delta +0.099 (gate ≤ 0.10)
NLL ratio 0.938
empty generations 0.0

Passes all three gates: repetition delta +0.099 against a 0.10 threshold, NLL ratio 0.938, no empty generations.

R4 · Qwen2.5-3B

Same protocol, 80 solve steps, float32, sharded checkpoint (2 files).

metric value
parameters 3,085.9M (36 layers)
mean relative delta 0.0052
rewrite accuracy 0.625
rephrase accuracy 0.230 (457)
WikiText-2 perplexity 1.002
MMLU (n=30) 0.500 → 0.500

Peak RSS 11.7 GB with one float32 copy. The single-model benchmark path is what makes this fit on a 32 GB machine.

R3 · Qwen2.5-1.5B

Same protocol as R2, 100 solve steps, float32.

metric value
parameters 1,543.7M (28 layers)
mean relative delta 0.0065
rewrite accuracy 0.500
rephrase accuracy 0.273 (513)
WikiText-2 perplexity 1.005
MMLU (n=50) 0.400 → 0.400

File-level write: 338 tensors, 2.9 GB, 2.3 s, one tensor changed, the rest byte-identical (examples/file_edit.py).

Scaling observation: the same injection needs half the relative delta at 1.5B compared with 0.5B, and costs an order of magnitude less perplexity. That is encouraging for the 3B and 8B rungs, though it is one run on one task.

R10 · Apple Silicon CPU vs MPS

The same checkpoint, fact and policy, with one variable:

for device in cpu mps; do
  /usr/bin/time -l python3 -m machaon.cli teach \
    --model models/Qwen2.5-0.5B-Instruct \
    --say "The capital of Portugal is -> Lisbon" \
    --no-save --device "$device" --json > "teach-$device.json"
done

Measured 2026-12-01 on an Apple M5, macOS, Python 3.9, torch 2.8.0 and Qwen2.5-0.5B-Instruct (bf16).

device wall edit phase peak RSS layer rel. Δ margin
CPU 17.25 s 14.84 s 1.57 GiB 19 0.0070 0.500
MPS 6.04 s 3.31 s 762 MiB 19 0.0105 0.500

Both runs pass target, margin, budget, panel and KL. MPS is 2.9× faster end-to-end and 4.5× faster in the edit phase, at 47% of the CPU peak RSS. The devices choose different valid deltas (0.0070 vs 0.0105), so MPS is not bit-identical to CPU; the acceptance contract, not the solver path, is what stays constant.

R11 · Qwen2.5-0.5B · int4 check

machaon check --model models/Qwen2.5-0.5B-Instruct \
  --say "The capital of Spain is -> Lisbon" \
  --quantize int4 --device cpu --min-margin 0.25

Measured 2026-12-01 on an Apple M5, CPU, torch 2.8.0, optimum-quanto 0.2.7 and ninja 1.13.0.

metric value gate
accuracy 0.000 == 1.0 fail
margin -1.633 ≥ 0.25 fail

The int4 load ran end-to-end, but the answer did not survive quantization on this 0.5B checkpoint. The same checkpoint in bf16/float32 answers Lisbon. int4 is a memory tool, not a free accuracy mode; always run machaon check on the quantized bytes before deploying.

R2 · Two models, open benchmarks

Same protocol, same 8 edits, same evaluator. Target injection: pick an entity token from the dataset, edit the model to produce it, then test the question and its human-written rephrasings.

model layer mean rel.Δ rewrite rephrase (513) WikiText-2 MMLU
GPT-2 124M 8 / 12 0.0135 0.500 0.259 1.066 0.220 → 0.220 (n=100)
Qwen2.5-0.5B 20 / 24 0.0133 0.375 0.275 1.030 0.440 → 0.440 (n=50)

Datasets, licences and full protocol: reference/benchmarks.md.

Configuration

  • 8 edits, 513 held-out rephrasings, MMLU n=100 (GPT-2) and n=50 (Qwen).
  • Two architecture families: transformer.h (GPT-2) and model.layers (Qwen).
  • Same protocol, same evaluator, same datasets for both rows.

Two engineering findings

finding measurement
bf16 backward on macOS CPU 4.66 s/step
float32 backward on the same model 0.18 s/step
Qwen layer 12, one edit rel. Δ 0.150
Qwen layer 20, same edit rel. Δ 0.0043

Engineering notes

problem fix
transformers.Conv1D stores weights as (in, out), our maths assumes (out, in) HFModel.read/write normalise orientation
GPT-2's tokenizer has no pad token encode pads manually and returns a mask
padded batches scored the pad position logits and NLL select the last real token
paraphrases that never predicted the source fact paraphrase set filtered on the base model first