Inferensys

Glossary

Direct Logit Attribution

A linear decomposition technique that attributes the final logit output for a token directly to the individual contributions of each attention head and MLP layer in a transformer model.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
LINEAR DECOMPOSITION TECHNIQUE

What is Direct Logit Attribution?

A method for attributing a model's final output logits directly to the individual contributions of its internal components.

Direct Logit Attribution (DLA) is a linear decomposition technique that attributes the final logit output for a specific token directly to the individual, additive contributions of each attention head and MLP layer in a transformer model. By leveraging the residual stream's linear structure, DLA approximates the logit difference between two tokens as the sum of independent, component-wise effects, enabling precise localization of which parts of the network drove a prediction.

The method works by multiplying each component's output written to the residual stream by the model's unembedding matrix, projecting it directly into logit space. This bypasses nonlinear interactions between layers to provide a first-order, causal approximation of a component's direct effect. DLA is a foundational tool in mechanistic interpretability for identifying circuits and is closely related to the logit lens and activation patching techniques.

DECOMPOSITION TECHNIQUE

Key Characteristics of Direct Logit Attribution

Direct Logit Attribution (DLA) is a linear decomposition method that explains a model's final output token prediction by assigning a precise numerical contribution score to every attention head and MLP layer in the transformer architecture.

01

Linear Additive Decomposition

DLA exploits the residual stream architecture of transformers. Since each component writes its output additively to the residual stream, the final logit for a token can be expressed as the sum of the direct contributions from every attention head and MLP neuron across all layers. This provides a complete accounting of how the final prediction was constructed, with no unexplained variance.

100%
Variance Explained
02

Direct Path via Unembedding

The attribution is computed by taking the output vector of a specific component (e.g., an attention head at layer 12) and multiplying it directly by the model's unembedding matrix. This yields the component's direct effect on the output logits, bypassing all subsequent layers. This isolates what a component writes into the residual stream that directly influences the final prediction, separate from its indirect effects through later layers.

03

Causal Intervention Baseline

DLA is a zero-ablation method at its core. The contribution of a component is defined as the difference between the logit with the component's output present and the logit with it set to zero. This provides a clean causal interpretation: the score represents what happens when you surgically remove that component's direct output, holding all other computations constant.

04

Distinct from Accumulated Residual

DLA measures the direct effect, not the total causal effect. A component may write information to the residual stream that is later amplified, suppressed, or copied by downstream layers. DLA intentionally ignores these indirect interactions to provide a clean, layer-by-layer decomposition. For total causal effects, techniques like activation patching or path patching are required.

05

Head-Specific Token Attribution

For attention heads, DLA can decompose the contribution further by source token. Since an attention head computes a weighted sum of value vectors from previous positions, the logit contribution can be split across each attended token. This reveals which specific input tokens each head is using to influence the final prediction, enabling precise tracing of information flow.

06

Logit Lens Relationship

DLA is closely related to the logit lens technique. While the logit lens decodes the accumulated residual stream at each layer to see the model's current best guess, DLA decomposes the final logit into the marginal contributions of each component. Together, they provide a complete picture: the logit lens shows the evolving prediction, and DLA shows which components caused each shift.

DIRECT LOGIT ATTRIBUTION

Frequently Asked Questions

Direct Logit Attribution (DLA) is a linear decomposition technique that attributes the final logit output for a token directly to the individual contributions of each attention head and MLP layer. The following questions address the core mechanisms, applications, and limitations of this foundational interpretability method.

Direct Logit Attribution (DLA) is a linear decomposition technique that attributes the final logit output for a token directly to the individual contributions of each attention head and MLP layer. It works by exploiting the residual stream architecture of transformer models. Since each component writes its output additively to the residual stream, and the final logits are computed by applying the unembedding matrix to the accumulated residual stream, the logit contribution of any component is simply the dot product of its output vector with the unembedding matrix. This provides a first-order, linear approximation of how much each model component directly increases or decreases the logit for a specific output token, without requiring any causal interventions or additional forward passes.

MECHANISTIC INTERPRETABILITY METHODS

Direct Logit Attribution vs. Related Techniques

A comparison of Direct Logit Attribution with other linear decomposition and probing techniques used to decode transformer internals.

FeatureDirect Logit AttributionLogit LensTuned LensActivation Patching

Primary Objective

Attribute final logit to individual attention heads and MLP layers

Decode intermediate residual stream into next-token predictions

Improve decoded prediction accuracy at each layer

Causally isolate the function of a specific component

Methodology

Linear decomposition of logits using attention output weights and MLP contributions

Apply unembedding matrix directly to residual stream at each layer

Apply learned affine transformation per layer before unembedding

Replace activation with corrupted or alternative forward pass value

Causal Intervention

Requires Training

Granularity

Per-component (head/MLP) contribution to final output

Per-layer next-token distribution

Per-layer next-token distribution

Per-component functional role

Output Type

Scalar logit contribution per component

Probability distribution over vocabulary

Probability distribution over vocabulary

Change in model behavior or performance metric

Key Limitation

Assumes linear additivity of component contributions

Decoded predictions are often noisy and low-confidence

Requires curated training data for affine probes

Requires careful experimental design to avoid confounding paths

Primary Use Case

Identifying which heads and layers drive a specific token prediction

Quickly inspecting how predictions evolve across layers

More accurate layer-wise prediction analysis

Testing causal hypotheses about component function

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.