Functional MRI for Large Language Models
A unified toolkit for real-time visualization and analysis of LLM internal activations, functional connectivity, and feature extraction. Think of it as a brain scanner for transformer models.
- Feature Extraction -- SAE-based decomposition of activations into interpretable features (the "voxels")
- Functional Connectivity -- Graph-based mapping of co-activation patterns (the "connectome")
- Activation Narration -- Oracle models that describe what features represent (the "radiologist")
- Real-time Visualization -- 3D brain-scan-style dashboard (the "scanner")
pip install -e ".[all]"from neuroscope import NeuroScanner
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
scanner = NeuroScanner(model, tokenizer, layers=[0, 6, 11])
result = scanner.scan("The capital of France is")
for sae_result in result.sae_results:
print(f"Layer {sae_result.layer_idx}: {len(sae_result.features)} active features")
for f in sae_result.features[:5]:
print(f" Feature {f.feature_idx}: strength={f.activation_strength:.3f}")neuroscope/
extractors/ # Activation hooks + SAE feature extraction
hooks.py # Forward hook infrastructure
sae.py # Sparse autoencoder implementation
connectivity/ # Functional connectivity analysis
graph.py # Co-activation graphs + network discovery
visualization/ # 3D rendering + web dashboard
scanner.py # Main orchestrator (the "fMRI machine")
- Brain-Inspired Exploration of Functional Networks in LLMs (COLING 2025)
- Probing Neural Topology of LLMs (2025)
- Scaling Monosemanticity (Anthropic, 2024)
- Activation Oracles (2025)
- SAE Survey (2025)
MIT