Skip to main content

LexFrame: Lexical Reference Frames

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

PyPI Transformers Tests arXiv License

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 carries 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 works well with any causal language model in 🤗 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}
}

Licensed under the Apache License 2.0.

Metadata

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

Built distribution (wheel)

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

Total release size: 53.9 kB

Release files / lexframe-0.1.2.tar.gz

Download URL lexframe-0.1.2.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cc058388f07d0225ffb4c46e1d9ed064e891f23b8d48d90f355e1049fdcee90e
BLAKE2b-256 checksum
How to use checksums
f111770d48e1660084f5eda6d22ebf9c8bde04fd4f6297c7a8e08d4f766637c1
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 17, 2026.

Transparency log

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

Download URL lexframe-0.1.2-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6de31cbd66bf3ab3e15b5fa4a140a9ebd9c3ff65e157c16929f54d82d9f777cb
BLAKE2b-256 checksum
How to use checksums
de2be9627842d0d8d58b4c236d5381b06732e0efd8a54e58303cbf240d660698
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 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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