An interpretability tool for transformer models built on TransformerLens
This guide will ensure you have the right environment and run the othelloscope example.
Tested in Windows Subsystem for Linux with Ubuntu 22.04.2 LTS.
Also see the environment.yml workflow for a CI tested setup procedure.
- Ensure you have a working Python installation (at least version 3.7, tested with version 3.10.7).
- Ensure you have a working Rust toolchain (if you can use the
cargocommand it should be fine). See here to get one. Any version from the last few years should work. The newest one definitely will. - Clone the repo and move to the root.
- Set up a python environment using
python -m venv .env. - Activate the environment.
- Install globally required packages by running
python -m pip install -r requirements.txt. - Build the package by moving to the
transformer-scopedirectory and runningmaturin develop --release. The package will now be installed in your environment. - Move back to the root and run
python -m pip install -r examples/othelloscope/requirements.txtto install the example's dependencies. - Run
python -m examples.othelloscope.mainand wait as the example runs. - Run
cargo run --release -- examples/othelloscope/output/payloadto start the server. - Wait until it displays the message
Serving site.... - Visit localhost:8080 in a browser to view the website.
On Windows, Maturin works less well, but there are work arounds.
- Make sure you clone the project into a path with no spaces.
- When building with Maturin, if you get the error
Invalid python interpreter versionorUnsupported Python interpreter, this is likely because Maturin fails to find your environment's interpreter. To fix this, instead of building withmaturin develop, usematurin build --release -i py.exe(maybe replacepy.exewith e.g.python3.exeif that is how you call Python) and then callpython -m pip install .. The-iargument tells Maturin the name of the Python interpreter to use.
Problems arise when your Python version does not match your machines architecture. This can happen on M1 chips, since it is possible to run x86 Python even if the architecture is ARM. In this case you can get an error that looks like
error[E0463]: can't find crate for `core`
|
= note: the `x86_64-apple-darwin` target may not be installed
= help: consider downloading the target with `rustup target add x86_64-apple-darwin
Simply download the x86 target with the suggested command and everything should work.