Skip to main content

lexframe

A toolkit for interpreting LM residual streams in their native semantics.

pip install lexframe
import lexframe as lf

frame = lf.LexFrame(model, tokenizer).init(texts)   # a loaded Hugging Face model; texts: any unlabelled text
frame.view("The Eiffel Tower is located in the city of", k=5).tokens

demo.py walks through every command: where SmolLM3 decides that the Eiffel Tower is in Paris, who wrote that decision, and how to change it.

Commands

Command Returns
LexFrame(model, tokenizer, order=1, allow_untested=False) a frame with order rounds of attention between positions; "inf" is the native frame
frame.init(texts, size=256, cache=True, cache_dir=None, tol=0.05) the frame, calibrated on size sequences of 128 tokens (cached on disk) and checked: frame.identities
frame.config(steps=30, ridge=1e-3, warm=False) the frame, with these LSMR settings for basis: frame.solver
frame.view(text, k=1, layers=None) View: tokens, ids, probs [layer, position, k] and kl [layer, position]
frame.state(text, layer) State: vector [position, hidden] and layer; s + d and s - d give a moved state
frame.basis(text, tokens, layers=None) Delta: vectors that add one logit to each token, and coef, the state's coefficients
frame.readout(text, tokens, layers=None) Delta: covectors that measure each token's logit; readout @ basis has ones on the diagonal
frame.output(state) the model's log-probabilities from a (moved) state, [position, vocab]
frame.attr(text, component="block", target=None) each layer's contribution to the target's logit, [layer, position]; "block", "attn" or "mlp"
frame.bound(texts, token, layers=None) the best agreement any fixed lens can reach, [layer]

view and attr take a list of texts of one token length; view, basis and readout also take a State. basis and readout cover layers 0..num_layers, where the last is the output. d[token] selects one token's vectors, and d @ x takes inner products with a Delta, a State or a vector.

Supported models are SmolLM3 and OLMo3; Llama, OLMo2 and Qwen3 load with allow_untested=True and should pass the identity check first.

Citation: Lexical Reference Frames: Interpreting LM Residual Streams in Native Semantics (2027).

Licensed under the Apache License 2.0.

Metadata

Release files for lexframe 0.1.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 lexframe 0.1.0
File Size Uploaded
lexframe-0.1.0.tar.gz 27.2 kB Details

Built distribution (wheel)

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

Total release size: 50.9 kB

Release files / lexframe-0.1.0.tar.gz

Download URL lexframe-0.1.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
397ad949430c41744070a8e82e524ceca634047e88abf5d98312e5211cd4baed
BLAKE2b-256 checksum
How to use checksums
0af1e6659442e5c71d00c715720fc01a950217a06c437fcf07aaf6dbf934c4b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 16, 2026.

Transparency log

Release files / lexframe-0.1.0-py3-none-any.whl

Download URL lexframe-0.1.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9700cdb9f7df63805d1dfc57b24c11a8bdfd5d46292b52a5d807258003163c92
BLAKE2b-256 checksum
How to use checksums
838325bdc29982694230d9fa6125cb5791c2b8493e2d6bf44674cba3d29f0cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

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