Skip to main content

LexFrame: Lexical Reference Frames

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

PyPI Python CI License arXiv

LexFrame overview

LexFrame reads a hidden state the way the model reads it, in the model's own vocabulary. It is model-native: the state is transported layer by layer through the model's own remaining layers, with nothing fitted to the output. It is context-aware: along the way the state attends to its prefix, for a chosen number of rounds of attention.

Quickstart

pip install lexframe
import lexframe as lf

frame = lf.LexFrame(model, tokenizer).init(texts)   # a loaded Hugging Face model and any unlabelled texts
c = frame.view("The Eiffel Tower is located in the city of", k=5)
c.tokens                                            # the top 5 tokens of every layer at every position

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

Mechanism

A frame transports a hidden state through the model's own remaining layers, with the context the state attends to, and reads the result with the model's own unembedding. docs/MECHANISM.md explains the details.

Compatibility

LexFrame supports the same causal language models as 🤗 Transformers, including popular families such as Llama, Qwen, Gemma, Mistral and DeepSeek.

Citation

@article{gu2026lexframe,
  title   = {Lexical Reference Frames: Interpreting LM Residual Streams in Native Semantics},
  author  = {Gu, Jian and Zhang, Hongyu and Chen, Chunyang and Aleti, Aldeida},
  journal = {arXiv preprint arXiv:2610.22169},
  year    = {2026}
}

Metadata

Release files for lexframe 1.0.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 1.0.0
File Size Uploaded Provenance Actions
lexframe-1.0.0.tar.gz 31.3 kB With provenance Details for lexframe-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 54.9 kB

Release files / lexframe-1.0.0.tar.gz

Download URL lexframe-1.0.0.tar.gz
Size 31.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd27718be8d9edee2d4369e3054027f3a454347076c261bd4dea14a797c9c5e3
BLAKE2b-256 checksum
How to use checksums
2d2e5635813a94fb937631e8f1b8597efc224843c1921e9e8a90a7d3d7ef6237
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 18, 2026.

Transparency log

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

Download URL lexframe-1.0.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c41bfe8175cd92114be0cddce762f910dc48dfc56943247b00ca317e53c96509
BLAKE2b-256 checksum
How to use checksums
2fb4a1ee8d56f5b6f236b61fb9ef0781c529302fb297a917afd32df1e02cf5f2
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 18, 2026.

Transparency log

Security for lexframe 1.0.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

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

Select from 2 files

Attestation for lexframe-1.0.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 Oct 18, 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