Edit a language model inside a range, and let anyone check, byte for byte, what changed and what did not. Fine-tuning, LoRA, merging and quantization can move the output at any position. After such an edit, the only way to know that "nothing else changed" is to evaluate everything again, and even then you only know it for the prompts you tried. In our runs on Qwen3.5-9B and Qwen3-8B, a 4-bit quantization and a public fine-tuned derivative each left 0 of 150 greedy answers the same as the original's. Kestrom takes the other side. Each edit comes with a range that is read from the weights or from the decoding, not from what the editor claims, and a report that anyone can rebuild on their own machine and compare with cmp. original weights ──edit──▶ edited weights ──kestrom-verify──▶ report.json │ W every byte the same but the changed rows │ U0 the original equal to itself on this machine │ G1 every logit outside the range equal, bit for bit (row edits) │ G2 greedy output the same until the range is reached ▼ the receiver rebuilds report.json ─▶ same bytes Two packages: Three tiers of guarantee The checks that pass say which tier an edit is in. Kestrom does not blur them. Determinism (U0: the original model gives the same logits and the same greedy output twice on your machine) is checked by logits and measure, which run the original twice, and by compare, on the two outputs of the original you give it. If U0 fails, G1 and G2 in that report mean nothing. range and diff read only bytes. compare checks the output files you give it: write them yourself, running the original twice. For decode-time edits it checks the output against the events the decoding records, not that a loop or a condition was really there. The editing tools Product scope: Supported (enterprise evaluation / audit): kestrom-verify (Apache-2.0), kestrom audit, kestrom inspect (including mirror and disarm), kestrom ifc (control / firewall), kestrom kv + kestrom generate --rules (open, loopguard, phrase, add, ban), kestrom rules (fit, run, build, weigh), kestrom steer, kestrom rows ban-row / ban, and kestrom bridge. Experimental (research / reproduction): kestrom edit, kestrom trigger, kestrom find, kestrom rows lsq / ftpo, kestrom rules write-mlp, kestrom train sft-data, and kestrom merge. Every tool is in, whether or not it reached the target we set for it. The table gives the tier and what we measured, with the target where one was missed. A tool's guarantee says what did not change; whether the edit does what you want is measured, and for several tools it fell short. Each command's help (kestrom, kestrom --help, python -m pydoc kestrom.) has the details. The decode-time edits are all written in one rules language (python -m pydoc kestrom.rules) and combine freely. For example, plain style for free-form questions only, no Chinese tokens in the answer after thinking, no **, and the loop guard: in free: prompt style.npz 16 # a condition read on the prompt (kestrom steer direction) in think: thinking h1 f: all(free) h1 answer: all(!think) h2 plain: all(f) h2 ans: all(answer) add style.npz 16: 14.6*plain # conditional steering ban 的 了 们: ans # these tokens never, once thinking is over phrase: "**" # go back and avoid it loopguard: 512 kestrom generate MODEL prompts.json out.jsonl --rules edit.dsl records the events of every line, and kestrom-verify compare events checks that each output is the original's until its first event. Rules that read probed features of the hidden state are fitted first (kestrom rules fit, optionally at a decoder LAYER >= 0 so kestrom bridge rules can transfer FIT.npz across models). An open line connects rules written with no model to a model's answer: open meter: router.dsl ask runs the rules of router.dsl (a network of their own, below) on each prompt's data and makes the output open with the class their head meter answers and a line feed, or with ask where they answer none (without the last word, nothing is done there). Where the model's own top tokens already spell that class nothing is changed and no event is recorded; the first token replaced is an event, and what follows is the model's own continuation of the opening it was given. The answer is what follows the last </think>, and nothing is done while the model thinks. The line acts only where the model begins the answer with a class: where the top token that begins it starts none of the head's classes nor the class given in the line, the answer is left alone, as were four chat questions sent through the same rules. An answer that begins with the first characters of a class is opened whatever was asked, and a class written later in the answer is not touched. With a text as the last word (open meter: router.dsl ask "The rules have decided line 1: {}."), the thinking of a model that thinks also opens with that text, {} in it the class, and a line feed, so that the model thinks with the rules' answer before it. That text is written wherever thinking begins (with another token than </think>) and the rules answer or the line gives a class, so nearly every such output has an event at its first position and the check covers almost nothing of it; what the model thinks after the text is its own, and it may not stop. kestrom-verify compare events checks the output up to the first event; that the opening is the rules' class is read from OUT (open, data and the text), and whether the reason after it is true is not checked. A kv line (kv: BANK_DIR [MAX_MATCH]) connects standalone rules directly to compiled per-fact prefix KV caches (kestrom kv compile MODEL RULES.dsl FACTS.json OUT_DIR [PREV_DIR]). Each fact in FACTS.json is prefilled offline once as a system-turn prefix of MODEL into its own .safetensors cache file, and PREV_DIR copies unchanged entries without recomputing so editing one subset of facts leaves unrelated caches bit-identical. At decode time, kestrom generate --rules evaluates any in NAME: prompt FILE LAYER conditions (including cross-model probes mapped by kestrom bridge map) on the raw prompt before decoding and passes their 0/1 results into data["values"] alongside each prompt's data (with "steps", into the last step's: earlier steps give their own; values given in data win; allowing "data" to be omitted when the bank reads only those prompt inputs): when an entry uniquely matches (or 2..MAX_MATCH match when MAX_MATCH > 1, composed and prefilled once via an in-memory LRU cache), only the prompt tokens after the shared prefix (with zero knowledge text in the prompt) are decoded on top of that cache, recording event 0 and "kv": KEY (a list when composed); when no entry matches (or more than MAX_MATCH match), no cache is injected and the kv line records no event ("kv": null); where no other line of the rules acts, events=[] and the output is bit-identical to the unchanged model. Because event 0 marks the start of a matched prompt, kestrom-verify compare events checks unmatched prompts up to the first event of another line and covers nothing after position 0 on matched ones. For multi-turn conversations, kestrom kv chat (MODEL BANK_DIR [MAX_TOKENS] [MAX_MATCH] [TURNS.json] [OUT.jsonl] [PROBES.dsl]) evaluates optional PROBES.dsl in ... prompt conditions on each raw turn together with the cumulative steps history through the bank's prev rules, reuses the live KV cache incrementally while the active keys stay unchanged and the chat template remains a strict prefix extension, and swaps/composes/re-prefills only when topics change or history tokens shift. Both kestrom generate and kestrom kv chat refuse a bank whose rules.dsl or cache files are not the ones its manifest.json hashed, or whose model fingerprint differs; the mechanism requires a chat template that places the system turn as a clean prefix before the user turn. kestrom rules run RULES.dsl DATA.json OUT.jsonl runs rules of in, h1, h2, out and set lines as a network of their own, with no model: match, count and number lines read each entry's text by a regex, the other inputs are values given in DATA, and the out lines name classes. A layer may have any number of units. An entry may be a list of steps: the network runs once per step and in NAME: prev UNIT reads whether a unit fired at the step before, so the rules can keep a state (a parity, a mode, what was seen). A set REGISTER: a % b if UNIT line keeps a number along the steps and rewrites it where a unit fires, computed with + - * / // % (a counter, Euclid's algorithm); after one step it is a numeric output, scored against targets. Classes named HEAD/CLASS are answered per head. kestrom rules weigh RULES.dsl DATA.json OUT.dsl rewrites the out lines with coefficients fitted to the labels. run prints how many answers agree with the labels. Use it to try rules on inputs you choose, or to write a small classifier by hand. It edits nothing, so it has no tier; where a rule can be written as plain code, plain code does the same job. To find where to edit, kestrom find reads the model and changes nothing: direction (the difference of two behaviours per layer, with Cohen's d on held-out answers), lens (what each MLP neuron writes into the vocabulary, or the neurons that write given words), reverse (neurons whose down_proj column points along the difference), writers (neurons by what they actually write along a direction) and heads (heads by how much zeroing each one lowers a direction). These and the edit commands rest on known methods (below) and add the declaration of the rows each edit wrote; each command's help says the choices we made. Not included: orthogonalizing a direction out of every matrix that writes the residual (it removes refusals, which we do not provide a tool for; on a style direction it broke Qwen3.5-9B, JMMLU 0.74 → 0.16). "Earlier PyTorch form": the numbers come from the research code on PLaMo 3 Translate; the Kestrom command is its MLX port, checked to run and to change only what it declares on Qwen3.5, not rerun for its effect. "Not measured": checked the same way, effect not measured. All on a Mac (MLX, and llama.cpp where noted). Every guarantee check of the tier-1 edits passed, and those reports were built twice in separate processes and compared byte for byte. Ban Chinese tokens in Qwen3.5-9B's weights (tier 1). 25,451 Chinese-only tokens, their rows of the output layer set to one fixed row; no other byte changes. Mixing = share of 300 Japanese answers with a Chinese-only token or a kanji outside JIS X 0213, sampled with the model card's settings (temperature 0.7). The guarantee checks are greedy. The range does not say whether each banned token should be banned: some also occur inside correct Japanese words (両性具有 came out as 両性具). Read the list before you ship. Switch the style only where a condition fires (tier 1). Qwen3.5-9B, conditional steering towards the plain (だ・である) style. The condition fired on all 50 free-writing prompts and on none of 100 JMMLU questions. Polite sentences 0.641 → 0.0 on the free writing; JMMLU 0.72 → 0.72; the 100 quiet prompts gave exactly the original's outputs (G2 150/150). Stop thinking loops at decode time (tier 1), against a published weight edit (tier 2). Qwen3.5-0.8B on 100 MATH-500 problems, thinking on, greedy, 16,384 tokens. The loop guard's outputs are the original's up to the first loop (G2 100/100). This is greedy decoding on 100 problems with the same maximum output length (going back costs extra decoding steps), not Astra's published protocol (all 500 problems, 4 samples each, temperature 0.6, presence penalty 1.5, 32,768 tokens), so it neither confirms nor refutes their numbers. kestrom-verify diff on Astra's checkpoint: 2 of 488 tensors changed, 64 columns in each as published (131,072 elements, of which 130,188 changed their bytes); the README and the safetensors metadata changed too, so a declaration of the two tensors alone fails D. Write relations behind a key (tier 2). Qwen3.5-9B. In each run, 32 fictional people, each "P works at O" written by its own kestrom edit keyed call into down_proj of layer 5 (of 32), at the last token of P's name in three phrasings of the organization question. The value of each call (DIRECTION.npz) was fitted beforehand by our own script, outside Kestrom, so that O follows there. The prompts list facts about other people and organizations and say nothing about P; our script chooses each answer among the item's candidates by log-probability. diff passed D in every run (1 of 775 tensors). Two sets of people; the criteria (at least 15 of 16 per group on each of the first three columns and on every stated fact) were fixed before each run, and the second set's first row was report only. The leak changed with what DATA left: The other facts in the prompts (where each organization is) were kept, 32/32 in every run. Outside: 240 prompts about other people; top token changed out of 23,964 positions. Afterwards, without criteria and on the first set: since diff shows that one tensor is the whole change, the 32 fitted values split it into the 32 written terms, and their push can be read position by position. The key, built at P's name, also opened on another name in the same slot of a question ("Which organization does Q work at?"); DATA had left that slot filled only by the 32 people's names. Leaving it filled by unused names as well brought that person's organization back, though the push there fell per item only to 0.55–0.91 of what it was: why the answers recovered was not traced. A choice between two people of who works in P's city: 30 and 31 of 32 with the relation stated in the prompt, 19 and 16 with no relation, 26 and 15 with it written (last setting). Rebuilding the second-set write (kestrom edit keyed, diff D PASS, exact home reproduction: 32/32 org, 32/32 city, 32/32 fact_city, 31/32 fact_q, 15/32 choice) and evaluating on 64 fresh unseen contexts (new distractors and unseen organization cities per person; kestrom-verify measure U0 256/256 PASS with 1,011/21,993 top-token changes and max top-logit change 16.92; report-only because context-stated choice ceiling was 56/64 against a frozen 0.90 check while org/city/fact ceilings were 64/64), the key still fired cleanly at P (median κ·x 0.9616, min 0.8197, other-key max median 0.0132, median push 100.65) and stated facts held (64/64 organization's city, 63/64 Q's organization), yet unseen accuracy fell to 40/64 org (unwritten 22/64) and 32/64 city (unwritten 26/64), matching direct hooks of the single-context fitted values on the unwritten model (38/64 org and 32/64 city). Evaluating tier 1 kestrom kv (cached system-turn KV context via standalone exact-name rules rather than a weight edit; 720 prompts on the exact same 32 people, 64 unseen contexts, 32 bare Level-0, 128 stated facts, and 240 outside; 820.31 MB total bank on Qwen3.5-9B ArraysCache; 6.25s compile and 4.25s PREV_DIR measured on kestrom-kv-v1 72a2dad, stale under current main's kestrom-kv-v2 full-shard SHA-256 fingerprint) reached 64/64 unseen org (vs 40/64 keyed), 64/64 unseen city (vs 32/64 keyed), and 32/32 bare Level-0 (both log-prob and CLI greedy), while keeping all 368/368 unmatched prompts (240/240 outside plus 128/128 stated-fact prompts that remain bit-identical to the unchanged base model's 64/64) bit-identical with U0/G2 720/720 PASS. Extending this exact-key kestrom kv setup to MAX_MATCH=2 dynamic 2-fact composition on Qwen3.5-9B (32-head bank, 64 unseen 2-person pairs + 32 bare_1 + 32 3-person over_max + 240 outside = 688 prompts, kestrom-kv-v1 72a2dad) reached 64/64 both org and both city with 0/64 cross-person swaps (same 0.8438 vs 0.5938 with both facts in prompt), kept 272/272 unmatched (32/32 over_max and 240/240 outside) bit-identical with U0/G2 688/688 PASS, and updated 4 edited people (4.17s PREV_DIR on 72a2dad) while preserving 16/16 unmodified partners' org and city. Running the exact same unchanged MAX_MATCH=2 688-prompt script on google/gemma-4-E4B-it (strip_prefix=[2], pure-attention KVCache/RotatingKVCache, 28.77 MB total bank = ~28.5× smaller than Qwen3.5-9B; 3.87s compile, 3.98s PREV_DIR on 72a2dad; gen kv 94.02s vs base 116.59s due to shorter matched conclusions than base abstentions) replicated 64/64 both org and both city with 0/64 swaps (same 0.8281 / same_flip 0.8594), 32/32 bare_1, 272/272 unmatched bit-identical (U0/G2 688/688 PASS), and 16/16 updated org/city switches with 16/16 partners preserved. On a separate 4-occupational-role non-exact prompt-probe benchmark (google/gemma-4-E4B-it layer 22, 3.99 MB, 0/128 canonical regex hits, 384 prompts = 128 unseen paraphrases + 16 ambiguous 2-role + 240 outside), pure kestrom steer direction routing progressed from 1/128 (Q7 FAIL on kestrom-kv-v1 72a2dad, bimodal QUIET midpoint bias) to 99/128 (Q8 PARTIAL on kestrom-kv-v2 2330682, 8.44s compile, coarse spec + 1-vs-3, ambiguous 5/16) to 114/128 (0.8906; Q9 PARTIAL on 2330682, 8.48s compile, 3-gate Condorcet spec + single + 6 pairwise 1-vs-1 probes; 95/96 without r2): 0.9375 city, 0.8438 scored / 0.7188 greedy org (below 0.85 PASS), swap_org 0.1562 / swap_city 0.0625 (above <= 0.05 target), 16/16 ambiguous and 240/240 outside bit-identical (U0/G2 384/384 PASS, gen kv 310.09s vs base 79.07s), and probe-preserved 8.57s PREV_DIR reusing 3/3 SHAs and switching 16/16 on updated r1 while preserving unmodified roles at org 38/48 and city 44/48 (all_checks_ok = false), with residual errors concentrated in unregularized mean-difference probe p12 (13/14 misroutes) and greedy title output on r0. Acceptance reports for edits with no guarantee (tier 3). kestrom-verify measure against the original, 150 prompts: Quickstart pip install "kestrom-verify[mlx]" # Apache-2.0 checker on PyPI ([torch] or [gguf] in place of [mlx]) # one-command acceptance audit (from a clone; emits deterministic audit.json, audit.html, audit.sarif) pip install "./verify[torch]" "./edit[torch]" kestrom audit MODEL_DIR OUT_DIR none none nf4 4 64 torch # the range of a row edit, from the bytes (safetensors folders or GGUF files) kestrom-verify range ORIGINAL EDITED range.json # greedy outputs: the original twice, the edited once, then compare against the range kestrom-verify generate mlx ORIGINAL prompts.json base.jsonl kestrom-verify generate mlx ORIGINAL prompts.json base2.jsonl kestrom-verify generate mlx EDITED prompts.json edited.jsonl kestrom-verify compare range.json base.jsonl base2.jsonl edited.jsonl ORIGINAL greedy.json # any two models: every tensor compared, against what the editor declared kestrom-verify diff ORIGINAL EDITED diff.json declared.json kestrom-verify summary diff.json prompts.json is [{"id": ..., "ids": [prompt token ids]}, ...]. See docs/guarantees.md for every command and check, and examples/ for five runs from start to end. Two agent skills, skills/kestrom (the commands, the checks and what each tier lets you claim) and skills/kestrom-acceptance (acceptance inspection of a delivered fine-tune with kestrom inspect), restate these documents for an agent to follow. Technical write-ups Stop prompt injection and secret leaks by construction, then prove it byte for byte: kestrom ifc Detect and disarm quantization-triggered LLM backdoors with no base model and no trigger: kestrom inspect mirror Zero-regression KV hot-patching and zero-shot cross-model control transfer: kestrom kv and kestrom bridge Questions & evaluation discussions: GitHub Discussions What Kestrom does not guarantee That the range is right: whether a banned token should be banned, whether a condition fires on the right prompts. Agreement across runtimes. llama.cpp and MLX give different greedy outputs even for the same original weights. Compare the original and the edited model in the same runtime. Sampling. The guarantees are about teacher-forced logits and greedy decoding. Anything on the outputs for tier 2 and 3 edits: there the report only counts. That a fine-tune has no backdoor. kestrom inspect shows evidence to read; nothing found does not mean nothing is there. shape does not flag a write inside the declared rank, a change spread by quantizing again, or a tensor whose shorter side is below 32 (it lists those), behavior shows a backdoor only when its target leaks to ordinary prompts, and from the trigger output the readers of our blind tests named the trigger's words for at most 2 of 5 backdoors, and 2 of 4. In our Q4_K_M GGUF test shape flagged nothing on all 12 models (the rounding hid the LoRA's rank). inspect gguf was tested on Qwen3.5 with Q4_K_M only. Tested primarily on Apple Silicon: MLX and llama.cpp with Qwen3.5 (0.8B, 4B, 9B), Qwen3-8B, and (for kestrom kv / kv: and kestrom bridge) Gemma 4 E4B; PyTorch with Qwen3.5 0.8B and 9B on MPS and 0.8B on the CPU; and Linux + NVIDIA L4 CUDA (torch 2.14.1+cu130, bitsandbytes 0.50.2) for kestrom ifc, kestrom inspect mirror/disarm (bitsandbytes NF4, FP4, INT8), and kestrom-verify generate torch / compare events / diff on Qwen3.5-0.8B/4B (plus benign DeepSeek-R1-Distill-Llama-8B mirror scan; kestrom audit invokes diff and inspect mirror and is unit-tested on Linux CI with NumPy nf4, not yet run end-to-end on CUDA). Not tested on Linux/CUDA yet: weight edits (rows, edit), kv/rules/bridge, inspect commands outside mirror/disarm, logits/measure, models whose output layer is tied to the embedding in GGUF. For a tied output layer (Qwen3.5-0.8B), a changed row is also an input: the guarantees hold for the inputs (prompts, teacher-forced sequences) that hold no changed id, and the reports count the others. Related work Fine-Tuning Integrity (arXiv 2604.04738) proves cryptographically that a deployed model differs from a base only within a declared class of updates. Kestrom's diff checks the same kind of declaration in the clear, by recomputation, when both weights are at hand. Weight diff tools (ckpt, weight-inspect) compare tensors; Kestrom adds the declaration check, reports that rebuild to the same bytes, and output guarantees where the edit allows them. Conditional activation steering (CAST, arXiv 2409.05907), orthogonal Procrustes cross-model alignment (Plato's Key, Hazy Research, 2026), the Antislop backtracking sampler (arXiv 2510.15061), and transformers' no_repeat_ngram_size are the methods behind the in … prompt and add lines, the phrase lines, rows ftpo and the loopguard line; Kestrom adds the range and its check. Astra's edit (rikiyat.github.io/blog/weight-space-programming) is the form of edit subtract. find, add lines and edit use the logit lens (nostalgebraist, 2020), differences of means as directions (CAA, arXiv 2312.06681), ablating and scaling heads (Michel et al., arXiv 1905.10650), MLP neurons as keys and values (Geva et al., arXiv 2012.14913), and rank-1 writes kept off the inputs to preserve (ROME, arXiv 2202.05262; AlphaEdit, arXiv 2410.02355). The combination and the defaults of the neuron and head edits follow the documentation of gguf-neuron-explorer. Smoothie-Qwen also rewrites the output layer to suppress tokens. kestrom inspect compares a fine-tune with its original, as do spectral checks of fine-tunes and LoRA adapters (MIST, arXiv 2605.21146; PEFTGuard, arXiv 2411.17453) and the tracing of rank-one edits (arXiv 2505.20819); Microsoft's scanner (2026) looks for backdoors without the original. What it adds is the reading against the declared recipe: reference fine-tunes retrained from it, and for QLoRA the original quantized again with the setting the weights show. Licensing kestrom-verify (folder verify/): Apache-2.0. Anyone may use it, including companies, to check an edit. kestrom (folder edit/): your choice of PolyForm Small Business 1.0.0, PolyForm Noncommercial 1.0.0 or PolyForm Free Trial 1.0.0. In short: Small Business, with our additional permission, covers a company with fewer than 100 people whatever its revenue, counted together with the organisations it controls, is controlled by or is under common control with; Noncommercial covers any noncommercial purpose, personal use without any anticipated commercial application, and charities, schools, public research organisations and governments; Free Trial covers evaluating kestrom for a particular application for less than 32 consecutive days, for a company of any size. The license texts decide. Any other use needs a commercial license: 3,000 USD a year for a company of 100 to 999 people, 10,000 USD a year for 1,000 or more; see edit/COMMERCIAL.md. See LICENSE.md. Contributing Issues are welcome; pull requests are not accepted for now (see CONTRIBUTING.md). Work with us CAPH TECH Inc. builds custom bounded edits (banned token lists, output formats, styles) and acceptance reports for edited or fine-tuned models. Contact: Ryoichi Izumita, r.izumita@caph.jp.
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL
Show HN: Kestrom – Byte-verifiable LLM edits, IFC decoding, and backdoor scans
Article URL: https://github.com/CAPHTECH/kestrom Comments URL: https://news.ycombinator.com/item?id=50654870 Points: 1 # Comments: 0
번역 서비스가 일시 중지되어 원문을 표시합니다.