WeightLang
A programming language for building neural networks — and shipping their weights.
Install · Quick start · Language · Reuse · Packages · Docs · Limitations
You write a network in a .wgt file. weightc uses PyTorch to build it,
initialise it, train it or import weights into it, and writes an artifact: a
directory holding the weights plus everything needed to load and run them —
architecture, input/output contract, versions, hashes, and where every tensor
came from. Artifacts can be published as packages addressed by GitHub path,
Go-style, and their weights reused by other programs.
WeightLang is meant to be written mostly by AI coding models, so the syntax is small, line-oriented and strict. It should still be easy for a person to review.
xor.wgt ──weightc build──▶ build/xor_mlp/ ──weightc run──▶ {"prob": [[0.00003], [0.9999], ...]}
├─ manifest.json structure · I/O · provenance · hashes
├─ weights.safetensors float32 tensors, no pickle
└─ source.wgt the exact source
Install
Linux / macOS
curl -fsSL https://github.com/WeightLang/WeightLang/releases/latest/download/install.sh | sh
Windows (PowerShell)
irm https://github.com/WeightLang/WeightLang/releases/latest/download/install.ps1 | iex
Both scripts download the weightlang wheel from the GitHub release, check its
sha256 against the release's SHA256SUMS, and install it with
uv tool if uv is available, otherwise into a
private virtual environment (no sudo / admin needed). On Linux they install the
CPU build of PyTorch by default (WEIGHTLANG_TORCH=default for PyPI's CUDA
build). Pin a version with WEIGHTLANG_VERSION=v0.1.0. Read the scripts before
piping them to a shell: install.sh, install.ps1.
Other ways to install
# With uv, straight from the release wheel
uv tool install https://github.com/WeightLang/WeightLang/releases/download/v0.1.0/weightlang-0.1.0-py3-none-any.whl
# From PyPI (once published there; see "Release status" below)
uv tool install weightlang # or: pipx install weightlang
# From source, for development
git clone https://github.com/WeightLang/WeightLang && cd WeightLang
python -m venv .venv && .venv/bin/pip install -e '.[test]'
If PyTorch is already installed system-wide, reuse it:
python -m venv --system-site-packages .venv && .venv/bin/pip install --no-build-isolation --no-deps -e .
Requirements: Python ≥ 3.10, PyTorch ≥ 2.2, safetensors ≥ 0.4.
Quick start
weightc check examples/xor.wgt # parse and type-check, no build
weightc build examples/xor.wgt -o build # init → train → build/xor_mlp/
weightc run build/xor_mlp --input '[[0,0],[0,1],[1,0],[1,1]]'
weightc inspect build/xor_mlp # I/O contract + where each tensor came from
weightc verify build/xor_mlp # re-check hashes, shapes, loadability
built build/xor_mlp
weights sha256 7969227a9c0e3528317e1cd22b8da766e5b1a7a705e0ba96078a86cde8296ba2
tensors trained=4
training loss 0.7066 -> 0.0001 on 4 rows (xor), train accuracy 1.00
From Python:
from weightlang import load_artifact
model = load_artifact("build/xor_mlp") # verifies hashes and shapes
model.predict([[0, 1], [1, 1]]) # tensor([[0.9999], [0.0001]])
model.module # a plain torch.nn.Sequential
Artifacts can also be loaded with only torch + safetensors — see
docs/artifact.md.
| Command | What it does |
|---|---|
weightc check FILE |
Parse and type-check a .wgt file |
weightc build FILE -o DIR |
Build an artifact into DIR/<model>/ |
weightc run ARTIFACT --input JSON |
Run inference; JSON in, JSON out |
weightc inspect ARTIFACT [--json] |
Show interface, layers and tensor provenance |
weightc verify ARTIFACT |
Check hashes, tensor shapes and loadability |
weightc get [DIR] |
Download, verify and lock the packages in wgt.mod |
weightc publish PKG --version vX.Y.Z |
Build a package's release assets |
The language
wgt 0.1
model xor_mlp
input bits: f32[2]
output prob: f32[1]
layer hidden: linear(in=2, out=8)
layer act: tanh
layer head: linear(in=8, out=1)
layer out: sigmoid
data xor:
[0, 0] -> [0]
[0, 1] -> [1]
[1, 0] -> [1]
[1, 1] -> [0]
init seed=42
train data=xor loss=bce optimizer=adam lr=0.05 epochs=1000
- One statement per line, keyword first,
key=valueoptions. No expression language. - Shapes are checked before anything runs; errors read
xor.wgt:9: shape mismatch: .... - Every tensor has an honest origin, recorded in the manifest:
| origin | meaning |
|---|---|
random-init |
seeded random values, never trained — outputs are not meaningful |
trained |
initialised, then trained by this program |
imported |
copied unchanged from another artifact (upstream_origin says what it was there) |
imported+trained |
copied, then fine-tuned |
A program without train still builds, but build, run, inspect and the
Python loader all flag it, and importing an untrained tensor does not make it
trained. Training metrics are reported on the training rows only.
Full reference: docs/language.md.
Reusing weights
Import a layer from another artifact, optionally pin its hash and freeze it:
init seed=7
import hidden from "../build/xor_mlp" layer=hidden freeze
train data=xnor loss=bce optimizer=adam lr=0.05 epochs=300
examples/xnor_reuse.wgt takes the trained hidden
layer of xor_mlp, freezes it and trains only a new head for XNOR. The tests
check that the imported tensors are bit-identical to the source and stayed
frozen, that the source hash is recorded (and enforced with sha256=), and that
mismatched layer sizes are rejected. This shows the reuse mechanism; with four
training rows it does not show that reuse helps learning — a fresh network fits
XNOR too.
Packages
Packages are identified by GitHub path, versions are Git tags, and weights are GitHub release assets — not files in Git history.
wgt.mod require github.com/WeightLang/WeightLang/packages/gates v0.1.0
xnor.wgt import hidden from "github.com/WeightLang/WeightLang/packages/gates/xor_mlp" layer=hidden freeze
wgt.sum commit + sha256 of the index, manifest, weights and source — commit this file
weightc get examples/remote_reuse # network: fetch, verify, write wgt.sum
weightc build examples/remote_reuse/xnor.wgt -o build # offline: cache checked against wgt.sum
weightc get resolves the tag to a commit, checks every asset's size and sha256
against the release's wgt.index.json, requires the shipped source.wgt to equal
the file in the repository at that commit, and verifies the artifact. A later
moved tag or replaced asset no longer matches wgt.sum and is an error.
The first published package is
packages/gates → release
packages/gates/v0.1.0.
Publishing your own:
weightc publish path/to/pkg --version v0.1.0 -o dist # prints the git tag + gh release commands
Design, lock-file format and known gaps: docs/packages.md.
Documentation
| docs/language.md | Syntax, checks, weight sources and origins |
| docs/artifact.md | Artifact files, manifest fields, verification, loading without WeightLang |
| docs/packages.md | Module paths, wgt.mod, wgt.sum, publishing, fetching, open design |
Development
.venv/bin/python -m pytest # no network
WEIGHTLANG_NETWORK_TESTS=1 .venv/bin/python -m pytest # + fetch the real gates release
ruff check src tests && ruff format --check src tests
The suite covers parsing and line-numbered errors, a full XOR build, bit-exact outputs after save/reload, byte-stable rebuilds, tamper detection, loading with plain PyTorch, untrained labelling, weight reuse, and the package flow (publish, get, offline build, tampered assets, moved tags, mismatched source) against an in-memory fake of GitHub.
Release status
| Channel | Status |
|---|---|
GitHub release v0.1.0 (wheel, sdist, SHA256SUMS, install scripts) |
published |
PyPI weightlang |
not yet — needs a PyPI trusted publisher, then the manual publish-pypi workflow uploads the same files as the GitHub release |
Limitations
- Small language: sequential networks only (
linear,relu,tanh,sigmoid), one 1-Df32input and output, inline training data, full-batch training,mse/bce,sgd/adam. - Imports copy whole
linearlayers. Packages support direct requirements only, GitHub releases only, and trust-on-first-use hashes without signatures; consumers use the publisher's prebuilt weights. - Reproducibility: rebuilds are byte-identical on the same PyTorch version and CPU; across versions or hardware weights may differ, and the hashes will show it.
- Runtime: PyTorch only; no ONNX or other exports.
- Stability: 0.x — syntax and formats may change. The Windows installer has not been run on Windows yet.
License
Metadata
Release files for weightlang 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weightlang-0.1.0.tar.gz | 34.4 kB | With provenance | Details for weightlang-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| weightlang-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for weightlang-0.1.0-py3-none-any.whl |
Total release size: 62.0 kB
Release files / weightlang-0.1.0.tar.gz
| Download URL | weightlang-0.1.0.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6eba48269ab0e37f70a0a5bb82d91a250107b4a7274e89136ed1cdf456227363
|
|
BLAKE2b-256 checksum How to use checksums |
5d3214f424135e62ca742a1d804b40df0a77408e1110134d46ce80e7a1cba913
|
| 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 3, 2026.
Transparency logRelease files / weightlang-0.1.0-py3-none-any.whl
| Download URL | weightlang-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1534d699cfcd83fa2c9b2b2cd7ace5ec4d9468c434e4389394849363204a7d46
|
|
BLAKE2b-256 checksum How to use checksums |
9d0c4c8ffdce5eb09cc14df3a956d7b38ac0337ebf222ed0aa576d4551a39da9
|
| 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 3, 2026.
Transparency logSecurity for weightlang 0.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for weightlang-0.1.0.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 3, 2026.
Transparency logA 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.