Reversed Attention: On The Gradient Descent Of Attention Layers In GPT

Shahar Katz, Lior Wolf

Introduction

Transformer-based Large Language Models (LLMs) like GPT rely heavily on the attention mechanism to synthesize information across sequences. However, interpreting the resulting attention weights is notoriously difficult. Forward attention maps are often noisy and plagued by "attention sinks"—where the model assigns disproportionately high scores to irrelevant tokens (like the first token or punctuation) simply to satisfy the softmax normalization requirement. This paper introduces Reversed Attention (RA), a novel interpretability framework that looks at the "backward pass" of the model to reveal the true causal importance of tokens.

Methodology: The Mathematics of the Backward Pass

While most research focuses on inference (the forward pass), the authors argue that the gradients generated during backpropagation contain a cleaner signal of model intent. By deriving the Vector-Jacobian Products (VJPs) of GPT's attention layers, they identify the softmax derivative as an implicit attention matrix.

Comparison of dense forward pass attention and sparse backward pass (Reversed Attention) for the query "Florence".

As illustrated above, while forward attention is dense and distributed, the backward pass attention (RA) is remarkably sparse. This sparsity allows researchers to see exactly which connections the model "wants" to strengthen to produce a specific output, such as linking "Italy" to the target answer "Florence."

Beyond visualization, the authors introduce Attention Patching. This technique involves calculating the average RA for a specific task (e.g., capitalization) and injecting that map directly into the forward pass of new prompts. This allows for "weight-free editing," steering the model's behavior without the computational cost of fine-tuning.

Key Insights: Sparsity and Interpretability

The primary advantage of RA is its inherent sparsity. Because RA is derived from the gradient of the softmax function, it is not bound by the same constraints as forward attention. It naturally zeros out tokens that do not contribute to the final output, providing a "causal map" of the model's reasoning.

Heatmaps and matrices comparing forward and reversed attention across layers and tokens.

In technical evaluations, RA heatmaps (shown in Figure 3a) reveal that specific heads and layers are more critical for certain tasks. The comparison between the forward matrix (3b) and the RA matrix (3c) highlights how RA ignores the "In" token (an attention sink) to focus strictly on the relevant "Cherry tomato" tokens.

Key Results

The researchers validated RA across several architectures, including GPT2, OPT, and Llama2-7B, using 21 interpretability benchmarks.

  • Efficiency and Accuracy: RA achieved results comparable to Causal Mediation (CM)—the current gold standard for localization—but with significantly higher efficiency. For instance, in a "country-capital" task, RA achieved an Area Under the Curve (AUC) of 0.42, outperforming CM's 0.40.
  • Steering Performance: The "Attention Patching" method proved highly effective. In a zero-shot capitalization task where GPT2-xl originally failed completely (0% accuracy), applying RA patching boosted accuracy to 94% without any changes to the model's underlying weights.

Conclusion and Future Work

Reversed Attention offers a powerful, computationally efficient alternative to traditional interpretability methods. By leveraging the information inherent in the backward pass, researchers can better understand and even control LLM behavior. Future research will aim to extend this framework to more modern architectures utilizing Rotary Positional Embeddings (RoPE) and investigate the specific functional roles of the attention heads identified by RA.

Summary updated

BibTeX
@inproceedings{katz2025reversed,
  author = {Shahar Katz and Lior Wolf},
  title = {{Reversed Attention: On The Gradient Descent Of Attention Layers In GPT}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.52},
}
Figure