Token-Trace
A tool and UI to construct prompt-centric views of SAE feature attributions.
Main functionality:
- We use this tool to identify which SAE features have the most 'attribution' towards decreasing the model loss.
- In combination with Neuronpedia, we can identify what each SAE feature represents; this then gives us a rough idea of what computation the model is performing.
This tool is a first step towards discovering information flow between the features / layers of a transformer
Quickstart
Installation
pip install token-trace
Example Usage
from token_trace import compute_node_attribution
text = "When John and Mary went to the shops, John gave the bag to Mary"
df: pd.DataFrame = compute_node_attribution(
model_name = "gpt2",
text
)
Each row of df describes one node corresponding to an SAE feature or error term.
Visualizing SAE attribution statistics in frontend.
We use Streamlit to create a UI. Start the app as follows:
streamlit run app/token_trace_app.py
Methodology
Under the hood, we use attribution patching to compute indirect effect of the loss with respect to SAE features. The method is adapted heavily from Sparse Feature Circuits.
Development
We use PDM to manage dependencies. Set up a development environment as follows:
pdm install # creates a .venv
source .venv/bin/activate
Once in the virtual environment, make sure to also install the pre-commit hooks
pre-commit install
Metadata
Release files for token-trace 0.3.2
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 |
|---|---|---|---|---|
| token_trace-0.3.2.tar.gz | 20.3 kB | Without provenance | Details for token_trace-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| token_trace-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for token_trace-0.3.2-py3-none-any.whl |
Total release size: 42.5 kB
Release files / token_trace-0.3.2.tar.gz
| Download URL | token_trace-0.3.2.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26541081e149d1cae5589e6fe86b906396f842d4e63e1ee52bd081eee6237ada
|
|
BLAKE2b-256 checksum How to use checksums |
ca1762155df0a456daccda6f59009529dbff4d89ee3f0cce17e0843b5f30a6b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.15.1 CPython/3.10.12 Linux/6.5.0-1018-azure
|
Release files / token_trace-0.3.2-py3-none-any.whl
| Download URL | token_trace-0.3.2-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e381f43c66a59584142960d2e70add71081bb4029842991a7f7ddb4f607d18b8
|
|
BLAKE2b-256 checksum How to use checksums |
5282c0d33e0ec9b5d7695449d5cff3d26a9f1901721308779420461c8364b535
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.15.1 CPython/3.10.12 Linux/6.5.0-1018-azure
|
Security for token-trace 0.3.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.