Skip to content

Machaon

Direct weight surgery for LLMs — edit the weights, not the gradients.

Machaon changes a model's parameters directly, then proves the change did not break anything: what the edit was allowed to touch, what it actually moved, and how to put the model back if the answer is wrong.

One sentence to a verified edit

machaon teach --model ./models/Qwen2.5-0.5B \
  --say "The Eiffel Tower is in the city of -> Rome"

The sentence becomes an exact prompt/answer contract. Machaon checks whether the model already knows the answer, searches a depth window of edit sites, projects each candidate away from an unrelated baseline panel, applies the best one inside the budget, and keeps it only when the target and locality checks pass. A rejected candidate is rolled back byte-for-byte. The default output is <checkpoint>-machaon; the source checkpoint is never modified.

machaon intent "..." shows the parse without loading a model, and the local browser console makes it the primary Teach a fact action: one page handles starter download, open, save and a saved-bytes verification without a setup wizard.

For a repeatable, shareable run, put the model, facts, protected prompts and budget in one weight program. machaon program plans it without loading a model, runs the teaching chain, and reloads the saved checkpoint before calling it accepted. The report is content-addressed, so machaon program-verify can later validate the report, the program file and the saved facts without trusting the artifact. machaon program-new generates that same file from plain teaching sentences when you do not want to start from a template.

              edit spec (DSL)
                    │
        ┌───────────▼───────────┐
        │ linalg                │  rank-1 · null-space · ablation
        └───────────┬───────────┘
                    │ delta
        ┌───────────▼───────────┐
        │ transaction · store   │  rollback · content addressing
        └───────────┬───────────┘
     ┌──────────────┼──────────────┐
┌────▼────┐   ┌─────▼─────┐   ┌────▼─────┐
│ runtime │   │ hygieia   │   │ interop  │
│ HF      │   │ gates     │   │ OpenWSP  │
└─────────┘   └───────────┘   └──────────┘

Start here

  • New to weight editing?


    Read Weight editing for what an edit is and why locality is the hard part, then follow the quickstart.

  • Want numbers?


    Benchmarks lists every dataset, its licence, and the exact protocol. Results has the current numbers.

  • Integrating with another tool?


    OpenWSP interop — the edit format is byte-identical, so edits move both ways.

  • Reading the API?


    Python API documents every public function and the invariants it keeps.

The three guarantees

guarantee how checked by
protected keys do not move ΔW k⊥ = 0 by construction verify.check_protected
a rejected edit is undone exactly originals copied before applying transaction.rollback
an unmeasured edit is rejected missing metrics count as failures hygieia.evaluate

A 30-second taste

import numpy as np
from machaon import rank1_constrained

W_new, delta = rank1_constrained(W, key, value, preserve=protected, max_rel_norm=0.02)
from machaon.verify import check_protected

report = check_protected(W, delta, protected)
assert report["passed"] and report["max_drift"] < 1e-12

That second block is the point. The first block is a formula; the second is a verdict.

Status

Alpha with a measured core. The maths, transactions, storage, gates, runtime, safetensors adapter and OpenWSP format are implemented and tested on Python 3.9–3.13. Real-model evidence covers GPT-2 124M, Qwen2.5 0.5B / 1.5B / 3B / 7B and Llama-3.1-8B; the 7B and 8B runs use int8/int4 weights with a densified local window. Seven CI jobs cover lint, the test matrix, adapters and coverage, the MCP transport, the Web console, the documentation build, and wheel/sdist installation. See the roadmap for what is next.