Python Library
The Neuronpedia Python library makes it easy to use the API from Python.
pip install neuronpedia
Source code: webapp-python-client on GitHub
Set Your API Key
Some calls need an API key, for example calls that upload data or change your account.
- Sign in at neuronpedia.org.
- Copy your API key from neuronpedia.org/account.
- Set the environment variable
NEURONPEDIA_API_KEY, for example in a.envfile.
from dotenv import load_dotenv
load_dotenv() # loads NEURONPEDIA_API_KEY from .env
Example - Get a Feature
from neuronpedia.np_sae_feature import SAEFeature
sae_feature = SAEFeature.get("gemma-2-2b", "20-gemmascope-res-16k", "10956")
print(sae_feature)
Example - Upload a Vector, Then Steer With It
from neuronpedia.np_vector import NPVector
from neuronpedia.sample_data import GEMMA2_2B_IT_DINOSAURS_VECTOR
np_vector = NPVector.new(
label="dinosaurs",
model_id="gemma-2-2b-it",
layer_num=20,
hook_type="hook_resid_pre",
vector=GEMMA2_2B_IT_DINOSAURS_VECTOR,
default_steer_strength=44,
)
response = np_vector.steer_chat(
steered_chat_messages=[{"role": "user", "content": "Write a one sentence story."}]
)
print("UI Steering at: " + response["shareUrl"])
Example Notebooks
| Notebook | What it does |
|---|---|
| get_sae_feature | Get a feature and its data. |
| steer_completion | Steer a completion with a vector. |
| upload_vector_and_activations | Upload a vector, test it, and upload its activations. |
| upload_features | Upload your own features. See Upload Your SAEs. |
| new-model | Add a new model. |
| generate_graph | Make an attribution graph. |
| upload_graph | Upload an attribution graph. See Upload Graphs. |
| llama_3.3_70b_instruct | Get activations and top features for your text, with Goodfire's Llama 3.3 70B SAE. |
Other Libraries
These libraries work with Neuronpedia:
- SAELens - Train and load SAEs. Many SAEs on Neuronpedia can be loaded with SAELens.
- circuit-tracer - Make attribution graphs on your own GPU, then upload them to Neuronpedia.
- interp-engine - The library that Neuronpedia uses to run models. See interp-engine.