logit-lens
Decode intermediate layer predictions using the Logit Lens technique. Use when analyzing what a model predicts at each layer, understanding information flow, or visualizing layer-wise processing.
npx skills add majiayu000/claude-skill-registry --skill logit-lens --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.
# Logit Lens Logit Lens decodes intermediate layer activations into vocabulary predictions, revealing what the model "thinks" at each processing step rather than just the final output. ## Concept Transformer language models build predictions incrementally across layers. By applying the final layer norm and unembedding head to intermediate hidden states, we can see evolving predictions. ## Basic Implementation ```python from nnsight import LanguageModel import torch model = LanguageModel("openai-community/gpt2", device_map="auto", dispatch=True) prompt = "The Eiffel Tower is in the city of" layers = model.transformer.h probs_layers = [] with model.trace(prompt): for layer_idx, layer in enumerate(layers): # Get layer output, apply final layer norm, then lm_head hidden = layer.output[0] normed = model.transformer.ln_f(hidden) logits = model.lm_head(normed) # Convert to probabilities probs = torch.nn.functional.softmax(logits, dim=-1).save() probs_layers.append(probs) ``` ## Extract Top Predictions ```python # Stack all layer probabilities all_probs = torch.stack([p.value for p in probs_layers]) # [n_layers, batch, seq, vocab] # Get top prediction at each layer for final token final_to
- Concept
- Basic Implementation
- Extract Top Predictions
- Full Sequence Visualization
- Efficient Batched Version
- Remote Execution for Large Models
- Interpretation Tips
- Visualization with Plotly
- Use Cases
What does the logit-lens skill do?
Decode intermediate layer predictions using the Logit Lens technique. Use when analyzing what a model predicts at each layer, understanding information flow, or visualizing layer-wise processing.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill logit-lens --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.
