Skip to main content

astro-weights logo: astronaut with a gold visor and a violet chest patch

astro-weights

Small course corrections for open LLMs.
Agent-driven weight edits. Democratizing AI for all.

PyPI version Python versions CI

Docs · PyPI · Changelog · Contributing

The goal is an agent that proposes small, targeted low-rank edits to a model's weights and keeps the ones that hold up under paired tests, saved as plain PEFT LoRA adapters. The agent loop is not here yet. What the library ships today is the toolkit that loop needs:

  • Edits: build low-rank edits from numpy recipes, rebuild one from a recipe file (astro-weights build), or convert a dense update with from_dense.
  • Export: save and load edits as hash-checked LoRA adapters, write a GGUF adapter for llama.cpp, and write a Hugging Face model card.
  • Runners: apply edits to transformers models and remove them again, and generate eval records from a local model or an OpenAI-compatible endpoint.
  • Directions: difference-of-means directions with a split-half gate.
  • Eval: graders and paired comparison of a base arm and an edit arm.

LoRA is the output format because every serving stack already loads it (transformers, PEFT, vLLM, llama.cpp and the rest), so an edit needs no custom runtime: ship the adapter, load it like any other, and drop it to get the base model back.

Status: pre-alpha. The API will change without notice until 1.0.

Install

pip install astro-weights

To apply edits to transformers models, add the hf extra (pulls in torch, transformers and peft):

pip install "astro-weights[hf]"

Quick look

Build a rank-1 edit with numpy and save it as a LoRA adapter:

import numpy as np
from astro_weights.edits import Edit, masked_rank1
from astro_weights.export import save_peft

W0 = np.random.default_rng(0).standard_normal((16, 48), dtype=np.float32)
u = np.eye(16, dtype=np.float32)[0]
mask = np.ones(48, dtype=np.float32)
delta = masked_rank1("model.layers.1.mlp.down_proj", W0, u, mask, alpha=0.5)
save_peft(Edit(deltas=(delta,), base_model="org/name"), "my-edit")

Summarize and verify the saved adapter:

astro-weights inspect my-edit

To apply an edit to a real model, build it from that model's own weights; the edit above is random and 16x48, so it matches no real model. Tutorial: first edit does this end to end on a small model that runs on CPU. Once you have an adapter built for your base model, apply and remove it like this (hf extra):

from transformers import AutoModelForCausalLM

from astro_weights.export import load_peft
from astro_weights.runners.hf import apply, remove

edit = load_peft("my-adapter")  # an adapter built for its base model
model = AutoModelForCausalLM.from_pretrained(edit.base_model)
peft_model = apply(model, edit)
model = remove(peft_model)  # base weights were never modified

apply also finds layers named differently, as in text-only and multimodal loads of one checkpoint: see How-to: apply across model classes.

Agent over MCP (0.2)

The agent loop is new in 0.2 (pip install "astro-weights[mcp,hf]"). astro-weights mcp RUN_DIR serves the agent tools over stdio MCP, with a budget and an OS sandbox, to Claude Code or any MCP client (the Codex setup is documented but not tested). astro-weights run CONFIG runs a whole edit session with a built-in editor: scripted, a local model or Claude on your own key. Start with Tutorial: first agent run.

Development

git clone https://github.com/astro-weights/astro-weights
cd astro-weights
uv sync
uv run pytest

See CONTRIBUTING.md for the full set of checks and how to send a pull request.

Citation

If you use astro-weights in your work, please cite it. The metadata is in CITATION.cff; on GitHub, use Cite this repository in the sidebar.

License

Apache-2.0.

The logo is based on the Noto Emoji "person astronaut" glyph, Copyright Google LLC, Apache-2.0. See docs/assets/LOGO-LICENSE.md.

Metadata

Release files for astro-weights 0.2.2

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

Source distribution (sdist)

Source distribution for astro-weights 0.2.2
File Size Uploaded Provenance Actions
astro_weights-0.2.2.tar.gz 126.8 kB With provenance Details for astro_weights-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for astro-weights 0.2.2
File Interpreter ABI Platform Actions
astro_weights-0.2.2-py3-none-any.whl Python 3 none any Details for astro_weights-0.2.2-py3-none-any.whl

Total release size: 274.1 kB

Release files / astro_weights-0.2.2.tar.gz

Download URL astro_weights-0.2.2.tar.gz
Size 126.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4dd1893dd4d4d918298a2d9265dd6ef8042a860a2a4ee65e94593f4b84aaf7e9
BLAKE2b-256 checksum
How to use checksums
c4926528499c383843d8cebf3a5c0ab0ad6f68772180052a39db7c07524c0117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / astro_weights-0.2.2-py3-none-any.whl

Download URL astro_weights-0.2.2-py3-none-any.whl
Size 147.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb1489758b1deea4f6e194c3d944b0077998254ca3a6255cddf81926aa6b03b1
BLAKE2b-256 checksum
How to use checksums
12995e653b00d198c5e3f23232004e5cb1c568540f3cdc911bd3a094418d4ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for astro-weights 0.2.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for astro_weights-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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