Skip to main content

Neyra

Neyra edits the weights of local language models.

CI Apache 2.0 PyPI Python 3.10+ 312 conformance vectors

Install · Usage · Commands · Design · Results · Docs · Spec


Neyra writes facts and behaviour changes into safetensors checkpoints. An edit is a patch: about 170 KB for one fact on Qwen3-0.6B, tied to the digest of its base, and reversible bit for bit. neyra edit uses a MEMIT style closed-form solve across several MLP layers. neyra fix finds the direction behind a reasoning loop and writes a patch that projects it out of the columns that write it.

It also reads changes made with other tools. diff recovers the form of an edit from two checkpoints, check recomputes a LoRA merge with the rounding PEFT and mlx-lm use, and hop walks base, adapter, merged model and GGUF to the first one that differs.

neyra diff on the Weight-Space Programming edit

neyra diff on the loop edit from Sparks of Weight-Space Programming, reading 4% of both checkpoints over HTTP range requests. The authors' notes give the same formula with a strength of 6.

Install

pip install neyra        # or: uv tool install neyra
neyra demo

Needs Python 3.10 or later. The base install handles patches, diffs and verification with numpy and cryptography. To run models, add neyra[mlx] on Apple Silicon or neyra[torch] elsewhere. neyra edit runs on both. neyra doctor lists the backends you have.

neyra demo takes about 0.1 s and downloads nothing. It builds a toy model and a LoRA in memory, then runs check on a merge that dropped the adapter and on one that kept it.

Usage

Paths and Hugging Face repo names both work.

neyra probe MODEL                             # loops, runaway thinking, missing answers
neyra fix MODEL -o fix.neyra                  # candidate patch for a loop direction
neyra edit MODEL "The capital of [France] is" Rome   # write one fact
neyra edit MODEL facts.json -o edit.neyra     # write many facts, measure, sign
neyra apply MODEL edit.neyra -o edited-model  # rebuild, checking digests

neyra diff BASE OTHER --sample 4              # compare two checkpoints from a few percent of the bytes
neyra check BASE MERGED --adapter ADAPTER     # recompute a LoRA merge and compare bits
neyra hop BASE ADAPTER MERGED model.gguf      # first artifact that differs

neyra tune lint data.jsonl MODEL --trainer trl   # before training: tokens, loss mask, what is wrong
neyra tune verdict BASE ADAPTER cases.jsonl --examples train.jsonl --gguf model-Q4_K_M.gguf   # after: did it work, did you need it
neyra tune train MODEL data.jsonl -o run         # Apple silicon: lint, LoRA with mlx-lm, merge, exact patch, check

Commands

Edit

Command
edit Write facts as a low-rank patch. Exits 1 if it misses its gates
fix Find a loop direction and write a candidate patch
probe Run a fixed battery and report loops, runaway thinking and missing answers
patch, apply, show Write the difference between two checkpoints as a patch, rebuild from it, inspect it
merge Sum, TIES, DARE, SLERP and Model Stock with exact arithmetic. Order does not change the bytes
bisect Find the smallest part of a patch that keeps its effect
import, export Read and write Delta League, OpenWSP, weightspace and ballast edits, PEFT LoRAs and GGUF LoRAs

Inspect

Command
tune lint Before fine-tuning: the token ids and loss mask TRL, mlx-lm, Unsloth, Axolotl or LLaMA-Factory would build from your jsonl, and what is wrong with them
tune verdict After fine-tuning: on your own cases, paired and with intervals, base, base with a few-shot prompt, the tuned model and its quantized files, and whether you needed to train at all
tune train On an Apple silicon Mac: lint, fine-tune with mlx-lm's LoRA trainer, then keep the merged result as an exact patch and check the merge
diff Compare two checkpoints and name the form of the change
check Recompute a merge per tool and compare bits
hop Report the first artifact that differs across base, adapter, merged model and GGUF
identity Compare a model with its declared base: same weights, named transform, derivative, unrelated

Sign

Command
attest, render, supersede, withdraw, status Sign a statement of a change for OpenSSF model signing and CycloneDX tools
verify, log, keygen Check receipts and hash-chained ledgers
index, prove Prove rows of a tensor against a root by reading only those rows
conformance Run the test vectors against your install

Automate

neyra mcp MCP server for agents, with a fixed budget, a sealed holdout and a hash-chained ledger
action.yml GitHub Action that fails a job when a merge does not match its adapter
hf-neyra hf neyra diff and hf neyra check

Design

A patch is a safetensors file, so loading one runs no code. It records the digest of the tensors it expects and the digest it produces, and apply stops on a mismatch. The weights root hashes every tensor and ignores sharding, so a resharded model keeps its root.

merge sums deltas as integers and rounds once, because bf16 addition does not associate. At an entry with value 1 - 2^-8, three patches that each add 2^-8 give 1.0 in pairs and 1 + 2^-7 together.

neyra edit solves in float64 and measures the rounded weights the patch produces. Its gates cover efficacy, neighbouring facts, drift on neutral text and fluency. The limits are constants in editeval.py. A failed run still gets a receipt.

Sampled reads report their coverage. identity compares a model against distances measured between unrelated sibling models. Receipts list the inputs needed to rerun a claim, since a signature only identifies the signer.

hop takes artifacts in the order a fine-tune passed through them:

base, adapter, merged and GGUF, with merged marked as the first hop that differs

Results

Result Rerun
edit, Qwen3-0.6B, 200 unseen CounterFact cases Efficacy 1.00, paraphrase 0.95, neighbours 0.70 (0.745 before) bench/edit_counterfact.py
diff, planted edits, 50 trials each 100% form recovery on 12 of 14 conditions, 0 false alarms in 250 noise trials bench/forensics.py
check, real merges PEFT 0.21.2 and mlx-lm 0.32.2 in fp32, bf16 and fp16, matched bit for bit tests/test_check_real.py
merge Matches brute-force rounding on all 24 orders of four patches tests/test_merge.py
Python and Go verifiers Agree on 312 vectors and on mutated inputs from a differential fuzzer fuzz/differential.py

So far these edits rewrite facts and remove loops. None has been shown to add ability. ROME led edit on the 20 development cases compared, and the full comparison is unfinished. Nothing has been tested above 1B parameters. The limits page has the rest.

Documentation

Guides: edit, merge, bisect, check, hop, identity, signing, lab, tune lint, tune verdict, tune train.

Reference: specification, protocol notes, vectors, accuracy, limits, prior work, changelog.

Status

Early. Formats can change until v1.

Neyra can send anonymous usage stats if you say yes when asked; the stats page lists what is sent and how to turn it off.

See CONTRIBUTING.md to work on it and SECURITY.md to report a vulnerability. If you write a verifier from the spec and vectors, open an issue. The Go one here shares an author with the Python one.

License

Apache 2.0

Metadata

Release files for neyra 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neyra 0.3.0
File Size Uploaded Provenance Actions
neyra-0.3.0.tar.gz 714.1 kB Without provenance Details for neyra-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neyra 0.3.0
File Interpreter ABI Platform Actions
neyra-0.3.0-py3-none-any.whl Python 3 none any Details for neyra-0.3.0-py3-none-any.whl

Total release size: 1.5 MB

Release files / neyra-0.3.0.tar.gz

Download URL neyra-0.3.0.tar.gz
Size 714.1 kB
Tags Source
SHA-256 checksum
How to use checksums
22cc2acafc8388aea5fef749aade76d1351cd9864774ed2a5a333f94ad8fe830
BLAKE2b-256 checksum
How to use checksums
084686fc1f977cb9458aded9649eb22449f7a2919badb32c75b355127ba577b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / neyra-0.3.0-py3-none-any.whl

Download URL neyra-0.3.0-py3-none-any.whl
Size 746.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b17338995607467406d9ffff4f2c115e4013dc5486d633cb147a47be1b7c5ac
BLAKE2b-256 checksum
How to use checksums
b5afaf08c0b34fbfbd9ff727297c4ec1c83a0e17bef5504a2037dd24ff8c5cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for neyra 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page