Part 10 of 20 in Tools we built and why. Previous: mojo-neuron: a microscope for a language model · Next: kinestride: physics for thousands of bodies at once
What this is about
A language model has habits. Some are useful. Some are not, such as agreeing with you when you are wrong. Researchers have found that a habit like this often lines up with a direction inside the model's internal numbers, like an arrow in a very large space. If you can find the arrow, you can push the model away from it.
mojo-ablate does this for local models. It finds the arrow from examples, applies a small edit to the model's weights, and saves a new model file. No retraining is needed. The first behavior we aimed at was sycophancy, which means agreeing to please.
Why it matters
Retraining a model is slow and costs a lot of compute. If one behavior is the problem, a small edit is a much cheaper tool. It is also easy to test: you can run the old and new files on the same prompts and compare.
But an edit that changes one behavior can also change others. A tool that edits a model needs a way to measure the side effects, not only the effect. mojo-ablate is built around that measurement.
How it works
Here is the flow, with plain names.
- Collect examples. Two sets of prompts. The first asks the model to agree with something (the bad set). The second is neutral (the good set). We record the model's hidden numbers on each, layer by layer.
- Find the direction. For each layer, take the average of the bad set minus the average of the good set. Scale it to length one, and remove the part that points along the good average. What is left is the direction tied to the behavior.
- Edit the weights. The edit is called rank-1. It subtracts a small multiple of that direction from two weight matrices in each layer, the attention output and the feed-forward down projection. The size of the multiple is called the strength.
- Search for the strength. A search tries many strengths, runs the model, and scores each by how much the behavior drops, how far normal answers move, and how much of normal behavior is kept. One scoring rule penalizes a keep rate below 0.80.
- Bake. The chosen edit is written into a copy of the model file. Supported file types are F32, F16, BF16 and Q8_0.
- Verify.
bake --verifyre-bakes the edit and compares the tensor hashes. It fails if there is no proof file, no control, or a specificity below 2.
A separate check, cert, tells you how far an edit moves healthy inputs before you run any model at all.
The strength search runs on our own chat engine, mojo-baro. The direction, edit and bake steps run on the CPU on Linux.
A picture of the idea
Imagine a room with a speaker playing one note too loud. You do not rebuild the room. You find the one dial for that note and turn it down a little. The risk is that the dial also touches the notes next to it. So you listen to the whole song before and after.
How we check it
The README lists the gates. Three examples:
- The per-row form of the edit must equal the dense edit. The largest error was 3.7e-15.
- Baked files in the F32, F16 and BF16 formats must equal a high-precision reference computation. The worst error was 0.5 ulp, half of the smallest step the format can store. A file that was never baked must fail this check, so we know the check can fail.
- The edit fit has three planted defects, and each must be caught.
The edit is also tuned to spare healthy inputs. One command turns a ban on certain words into a few small edits, and it counts healthy inputs 1000 times more than the rest while it fits them.
What it cannot fix
Be careful here.
- The first target was sycophancy only. A different behavior needs its own examples and its own test.
- A pass on a held-out split is not a pass on every prompt.
- An edit is a trade. Turning one thing down can change its neighbors. The keep-rate and KL checks measure this. They do not remove it.
- Not every failure has a direction. On our small Metis model, twenty surgical attempts (we call each one an arm) in six families fixed a runaway tool loop in none of the cases we tried. The post 223 Calls in One Message tells that story. Those were different attempts from the ones in this tool. The story is a reminder that an edit is a hypothesis.
- The strength search needs the mojo-baro engine on a GPU.
Words you may not know
- Weights: the numbers a model learned.
- Direction: an arrow in the model's internal number space.
- Rank-1 edit: a small change that follows a single direction.
- Sycophancy: agreeing with someone to please them.
- Bake: write an edit into a new copy of the model file.
- Held-out split: prompts not used to tune the edit.
- Specificity: how much more the edit changes the target than other behavior.
- KL divergence: a number for how far the model's answers moved.
- ulp: the smallest step between two numbers a file format can store.
- F32, F16, BF16, Q8_0: formats for storing a model's numbers, from more exact and larger to smaller and rougher.
- Tensor hash: a short fingerprint of one block of model numbers, used to see if it changed.
Try it
- Read the README at github.com/amarbaro/mojo-ablate.
- Run the
tests/checks first and see a planted defect get caught. - Look at
tests/prompts/bad.txtandgood.txtto see the two prompt sets. - To look inside a model before editing it, use mojo-neuron.
Read next
- mojo-neuron: a microscope for a language model: look before you edit.
- kinestride: physics for thousands of bodies at once: the next post in this series.

Comentarios
Aún no hay comentarios.
Iniciar sesión para comentar.