nnsight-basics
Core nnsight concepts for neural network interpretability. Use when setting up models, tracing activations, saving values, or making basic interventions on model internals.
npx skills add majiayu000/claude-skill-registry --skill nnsight-basics --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# NNsight Basics NNsight provides full access to neural network internals during forward passes. This skill covers the fundamental patterns for tracing, saving, and modifying activations. ## Installation ```python pip install nnsight pip install torch transformers ``` ## Loading Models **For language models (recommended):** ```python from nnsight import LanguageModel model = LanguageModel("openai-community/gpt2", device_map="auto", dispatch=True) ``` **For any PyTorch model:** ```python from nnsight import NNsight model = NNsight(your_pytorch_model) ``` ## The Tracing Context All interventions happen inside `model.trace()`. Your code interleaves with the forward pass. ```python with model.trace("The Eiffel Tower is in"): # Access any layer's output hidden_states = model.transformer.h[5].output[0].save() # Access final logits logits = model.lm_head.output.save() # Values available after tracing print(hidden_states.value.shape) ``` ## Accessing Module Values | Property | Returns | | -------- | ------- | | `.output` | Module's return value | | `.input` | First positional argument | | `.inputs` | All arguments (tuple + kwargs dict) | ```python with model.trace(prompt): layer_output = m
- Installation
- Loading Models
- The Tracing Context
- Accessing Module Values
- Saving Values
- Basic Interventions
- Batched Processing with Invokers
- Cross-Prompt Interventions (Barriers)
- Multi-Token Generation
- Gradient Access
- Utility Features
- Remote Execution (NDIF)
- Common Pitfalls
What does the nnsight-basics skill do?
Core nnsight concepts for neural network interpretability. Use when setting up models, tracing activations, saving values, or making basic interventions on model internals.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill nnsight-basics --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
