ReAGent: A Model-agnostic Feature Attribution Method for Generative Language Models

Zhixue Zhao, Boxuan Shan

TL;DR

This paper introduces ReAGent, a novel model-agnostic method for understanding which input tokens are most important for generative language models (like GPT). Unlike previous methods that often require internal model access or fine-tuning, ReAGent works by iteratively replacing input tokens with predictions from another model (RoBERTa) and observing how the generative model's output probability changes. ReAGent demonstrates superior faithfulness in explaining generative models across various tasks and model sizes.

What Problem Does This Paper Address?

Explaining why a machine learning model makes a particular prediction is crucial for building trust and debugging. For text classification, feature attribution (FA) methods have been developed to highlight important input words. However, these methods often struggle when applied to generative language models (LMs), which produce text sequentially rather than classifying it. Generative models have different architectures (decoder-only vs. encoder-only) and tasks (text generation vs. classification), making direct application of existing FAs problematic. Furthermore, many FA methods require access to internal model weights or gradients, which is not feasible for "black-box" models accessed via APIs. There's also no single FA method that works best across all models and tasks, making selection a costly process. This paper aims to bridge this gap by proposing a model-agnostic FA method specifically for generative LMs that is efficient and effective.

Methods

The core of ReAGent is a recursive approach to estimate token importance. It works by:

  1. Initialization: Starting with random importance scores for each input token.
  2. Iterative Replacement: In each iteration, a small percentage (e.g., 30%) of the input tokens are randomly selected. These selected tokens are then replaced with tokens predicted by a pre-trained RoBERTa model. The rest of the input remains the same.
  3. Measuring Impact: The change in the generative model's probability of predicting the next token (given the original and the modified input) is calculated. The intuition is that if a replaced token was important, this change in probability will be more significant.
  4. Updating Scores: The importance scores are updated based on the observed probability change and the replaced tokens. This process is repeated until a stopping condition is met (e.g., when the model's top predicted tokens remain consistent).

Crucially, ReAGent is "model-agnostic" because it only relies on the generative model's output probabilities (forward passes) and does not require access to its internal weights, gradients, or architecture details. It also doesn't require fine-tuning the generative model itself.

Datasets

The paper evaluates ReAGent on three standard text generation datasets:

  • Long-Range Agreement (LongRA): Designed to test a model's ability to predict a specific word based on contextual clues, often including distractor sentences.
  • TellMeWhy: A dataset for answering "why" questions in narratives, requiring understanding of causal relationships.
  • WikiBio: A dataset of Wikipedia biographies, where models are prompted to continue generating biographical text.

Key Insights and Ideas

  • Generative Models Need Specialized FA: Existing FA methods, primarily developed for classification, don't directly translate to generative tasks due to fundamental differences in model architecture and output.
  • Model-Agnosticism is Key: The ability to explain models without internal access is vital, especially with the rise of large, API-based LMs.
  • Replacement Strategy Matters: Replacing tokens with predictions from a strong, general-purpose model like RoBERTa proves more effective and faster for convergence than using random tokens or tokens of the same part-of-speech.
  • Faithfulness Varies: The effectiveness of FA methods is not universal; it depends on the specific model family and the nature of the generation task.

Key Results

ReAGent consistently outperformed seven other popular FA methods (including Input X Gradient, Integrated Gradients, Gradient Shap, Attention-based methods, and LIME) in terms of faithfulness across all tested tasks and models.

  • Overall Superiority: ReAGent achieved the highest scores in 17 out of 18 column-wise comparisons across tasks and models when averaged.
  • LongRA Performance: On the LongRA task, ReAGent significantly outperformed others, demonstrating its ability to capture crucial hints in the input for specific predictions.
  • Model Family Trends: The paper observed that FAs tended to perform more similarly within model families (e.g., GPT vs. OPT) than across them, suggesting internal architectural similarities influence explanation methods.
  • Efficiency: ReAGent's iterative replacement strategy, especially with RoBERTa-predicted tokens, converged to high faithfulness scores much faster than methods using random replacements.

Limitations and Future Work

  • Hyperparameter Sensitivity: While ReAGent is generally robust, its performance can be influenced by hyperparameters like the replacement ratio and stopping conditions. The paper provides recommendations for optimal settings.
  • Stochasticity: The method relies on random token selection, so multiple runs are needed to average results and ensure stability.
  • Future Directions: The authors suggest extending ReAGent to other generative model types, such as encoder-decoder models and diffusion models, and applying it to tasks like translation and summarization. They also plan to explore the impact of different replacement models beyond RoBERTa.

Summary updated

BibTeX
@inproceedings{zhao2025reagent,
  author = {Zhixue Zhao and Boxuan Shan},
  title = {{ReAGent: A Model-agnostic Feature Attribution Method for Generative Language Models}},
  booktitle = {myPublications at the University of Sheffield},
  year = {2025},
  url = {https://openreview.net/forum?id=yYLeIKCtD0},
}
Figure