openlair/dr-claw/nnsight
Claude Code and agent skill by openlair/dr-claw
- community
Checking that the SKILL.md file is still in the repository.
Provides guidance for interpreting and manipulating neural network internals using nnsight with optional NDIF remote execution. Use when needing to run interpretability experiments on massive models (70B+) without local GPU resources, or when working with any PyTorch architecture.
Install
npx vskill@latest install openlair/dr-claw/nnsightSKILL.md
The same SKILL.md was published earlier as openlair/dr-claw/nnsight.
nnsight: Transparent Access to Neural Network Internals
nnsight (/ɛn.saɪt/) enables researchers to interpret and manipulate the internals of any PyTorch model, with the unique capability of running the same code locally on small models or remotely on massive models (70B+) via NDIF.
GitHub: ndif-team/nnsight (730+ stars) Paper: NNsight and NDIF: Democratizing Access to Foundation Model Internals (ICLR 2025)
Key Value Proposition
Write once, run anywhere: The same interpretability code works on GPT-2 locally or Llama-3.1-405B remotely. Just toggle remote=True.
When to Use nnsight
Use nnsight when you need to:
- Run interpretability experiments on models too large for local GPUs (70B, 405B)
- Work with any PyTorch architecture (transformers, Mamba, custom models)
- Perform multi-token generation interventions
- Share activations between different prompts
- Access full model internals without reimplementation
Consider alternatives when:
- You want consistent API across models → Use TransformerLens
- You need declarative, shareable interventions → Use pyvene
- You're training SAEs → Use SAELens
- You only work with small models locally → TransformerLens may be simpler
Installation
For remote NDIF execution, sign up at login.ndif.us for an API key.
Core Concepts
LanguageModel Wrapper
Tracing Context
The trace context manager enables deferred execution - operations are collected into a computation graph:
Proxy Objects
Inside trace, module accesses return Proxy objects that record operations:
Workflow 1: Activation Analysis
Step-by-Step
Checklist
- [ ] Load model with LanguageModel wrapper
- [ ] Use trace context for operations
- [ ] Call
.save()on values you need after context - [ ] Access saved values outside context
- [ ] Use
.shape,.norm(), etc. for analysis
Workflow 2: Activation Patching
Step-by-Step
Systematic Patching Sweep
Workflow 3: Remote Execution with NDIF
Run the same experiments on massive models without local GPUs.
Step-by-Step
NDIF Setup
- Sign up at login.ndif.us
- Get API key
- Set environment variable or pass to nnsight:
Available Models on NDIF
- Llama-3.1-8B, 70B, 405B
- DeepSeek-R1 models
- Various open-weight models (check ndif.us for current list)
Workflow 4: Cross-Prompt Activation Sharing
Share activations between different inputs in a single trace.
Workflow 5: Gradient-Based Analysis
Access gradients during backward pass.
Note: Gradient access not supported for vLLM or remote execution.
Common Issues & Solutions
Issue: Module path differs between models
Issue: Forgetting to save
Issue: Remote timeout
Issue: Memory with many saved activations
Issue: vLLM gradient limitation
Key API Reference
| Method/Property | Purpose | |
|---|---|---|
model.trace(prompt, remote=False) | Start tracing context | |
proxy.save() | Save value for access after trace | |
proxy[:] | Slice/index proxy (assignment patches) | |
tracer.invoke(prompt) | Add prompt within trace | |
model.generate(...) | Generate with interventions | |
model.output | Final model output logits | |
model._model | Underlying HuggingFace model |
Comparison with Other Tools
| Feature | nnsight | TransformerLens | pyvene | |
|---|---|---|---|---|
| Any architecture | Yes | Transformers only | Yes | |
| Remote execution | Yes (NDIF) | No | No | |
| Consistent API | No | Yes | Yes | |
| Deferred execution | Yes | No | No | |
| HuggingFace native | Yes | Reimplemented | Yes | |
| Shareable configs | No | No | Yes |
Reference Documentation
For detailed API documentation, tutorials, and advanced usage, see the references/ folder:
| File | Contents | |
|---|---|---|
| references/README.md | Overview and quick start guide | |
| references/api.md | Complete API reference for LanguageModel, tracing, proxy objects | |
| references/tutorials.md | Step-by-step tutorials for local and remote interpretability |
External Resources
Tutorials
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mechanistic-interpretability/nnsight/SKILL.md
Popularity
- Repository stars
- 1,139
- Repository forks
- 131
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/openlair/dr-claw/nnsight)