Skip to content
Back to skills

Residual Logit Lens

ASecurity

Apply logit-lens unembedding and additive residual contribution checks for mechanistic transformer circuit analysis.

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
developmentpythonbashangulargit

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill residual_logit_lens --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Residual Logit Lens?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Residual Logit Lens
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-residual-logit-lens/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-residual-logit-lens)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: residual_logit_lens
description: Apply logit-lens unembedding and additive residual contribution checks for mechanistic transformer circuit analysis.
---

# Residual Logit Lens

Use this skill when you need to inspect how a transformer's residual stream or named additive residual components affect output logits. It is appropriate for attention-only or simplified transformer-circuit analysis where the residual stream is treated as a linear communication channel. Do not use it as a standalone causal proof when component activations are not defined.

## Inputs

- A residual state matrix shaped `positions x features`.
- An unembedding matrix shaped `features x vocabulary`.
- Optional named residual components with the same shape as the residual state.

## Outputs

- Full logits for every position.
- Optional per-component logits.
- A reconstruction error showing whether component logits sum to the full logits.

## Workflow

1. Validate that all matrices are rectangular and dimension-compatible.
2. Compute `logits = residual @ unembedding`.
3. For each named component, compute `component @ unembedding`.
4. If components are meant to sum to the residual, compare the sum of component logits to the full logits.
5. Report the maximum absolute difference and preserve component names.

## Validation

Run `python tests/test_logit_lens.py` or validate the full tree with:

```bash
python /share/project/yuyang/workspace/Paper2Skills/Distiller/skills/module-to-skill/scripts/validate_skill_tree.py <skill_dir> --run-tests
```

## Limitations

This skill uses standard-library Python lists for tiny or moderate matrices. For large models, use the same contracts with a tensor library and avoid materializing unnecessary dense intermediates.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.