Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add ndif-team/skills --skill attention-analysisgit clone --depth 1 https://github.com/ndif-team/skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/ndif-team/skills/attention-analysis)<a href="https://agentmods.dev/skills/ndif-team/skills/attention-analysis"><img src="https://agentmods.dev/badge/skills/ndif-team/skills/attention-analysis/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/ndif-team/skills/attention-analysis"><img src="https://agentmods.dev/badge/skills/ndif-team/skills/attention-analysis.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00131 | $0.03219 |
| Opus 5.5 | $0.00052 | $0.01288 |
| Sonnet 5.5 | $0.00026 | $0.00644 |
| Haiku 4.5 | $0.00013 | $0.00322 |
Grade A, and why
attention-analysis scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 278 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Attention Analysis
Two different objects get called "attention", and you need both:
- The pattern —
softmax(QK^T/√d), a[batch, heads, query, key]matrix saying where each head looks. Undereagerthe attention module hands it back asattn.output[1];.sourcereaches the raw softmax inside. - The per-head output — what each head writes into the residual stream. A slice of the output projection's input.
Patterns tell you about routing; outputs tell you about content.
import torch
import nnsight
from nnsight import TransformersModel
# eager is required — sdpa/flash never materialize the probability matrix
model = TransformersModel("openai-community/gpt2", dispatch=True,
attn_implementation="eager")
prompt = "When Mary and John went to the store, John gave a drink to"
n_layers = len(model.transformer.h)
n_heads = model.config.n_head
head_dim = model.transformer.h[0].attn._module.head_dim # not n_embd // n_heads
tokens = [model.tokenizer.decode([i]) for i in model.tokenizer(prompt).input_ids]
Getting patterns
Every layer in one pass (model.output.attentions also works, but only with
output_attentions=True; the loop lets you pick layers):
with torch.no_grad(): # a trace runs with autograd on
with model.trace(prompt):
patterns = nnsight.save([block.attn.output[1] for block in model.transformer.h])
print(len(patterns), patterns[0].shape) # 12 x [batch, heads, query, key]
If the weights are None, the model was not loaded with
attn_implementation="eager" — sdpa and flash_attention_2 never materialize
the matrix, and model.output.attentions is the empty tuple rather than an error.
Anchor before you score. Two properties are cheap and both must hold, or you are holding something that is not a probability matrix:
first_layer = patterns[0]
seq = first_layer.shape[-1]
upper = torch.triu(torch.ones(seq, seq, dtype=torch.bool), diagonal=1)
assert torch.allclose(first_layer.sum(-1), torch.ones_like(first_layer.sum(-1)))
assert (first_layer[..., upper] == 0).all() # causal mask: exactly zero, not small
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · -55 lines · +7 tokens per session 32dc9c3654b8
- 1mo ago First seen · 333 lines · 124 tokens per session scan A 716da33bc88b
attention-analysis is a skill published in the GitHub repository ndif-team/skills (14 stars, last pushed yesterday), licensed MIT. It adds 131 tokens to every session and 3,219 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-10.
Other skills, from other repositories
torchdrug
Builds and troubleshoots TorchDrug 0.2.1 workflows for molecular graphs, property prediction, self-supervised pretraining, molecule generation, retrosynthesis, protein representation learning, and knowledge graph reasoning. Use when code imports torchdrug or needs its datasets, models, tasks, or Engine.
arboreto
Infers candidate gene regulatory networks from bulk or single-cell expression data using AertsLab Arboreto GRNBoost2 and GENIE3. Use for transcription factor-target association ranking, compatible Dask execution, sparse expression inputs, and network stability checks.
deepspot-m
Generates transcriptome-wide virtual spatial transcriptomics from H&E histology with DeepSpot-M. Used for predicted log1p-CPM expression from 224x224 tiles at about 20x, querying the released protein-coding gene panel by symbol, and whole-slide prediction after resolution-aware tiling with histolab.
pyhealth
Builds and validates PyHealth clinical machine-learning pipelines for EHR, signals, imaging, and medical codes. Use for PyHealth dataset loading, MIMIC-III/IV, eICU or OMOP prediction tasks, patient-level evaluation, mortality/readmission/length-of-stay modeling, medication recommendation, sleep staging, Trainer…
ml-training-recipes
Battle-tested PyTorch training recipes for all domains — LLMs, vision, diffusion, medical imaging, protein/drug discovery, spatial omics, genomics. Covers training loops, optimizer selection (AdamW, Muon), LR scheduling, mixed precision, debugging, and systematic experimentation. Use when training or fine-tuning…
nemo-mbridge-perf-expert-parallel-overlap
Validate and use MoE expert-parallel communication overlap in Megatron-Bridge, including overlapmoeexpertparallelcomm, delaywgradcompute, and flex dispatcher backends such as DeepEP and HybridEP.