Wrapper Boxes: Faithful Attribution of Model Predictions to Training Data

Yiheng Su, Junyi Jessy Li, Matthew Lease

TL;DR

The "Wrapper Box" pipeline combines the high accuracy of deep neural networks with the inherent interpretability of classic models like k-Nearest Neighbors and Decision Trees. By replacing the final layer of a neural network with these "white box" models, researchers can provide fully faithful, example-based explanations that attribute every prediction to specific training data, enabling users to contest model decisions effectively.

What Problem Does This Paper Address?

Modern neural networks are notoriously opaque "black boxes." While they achieve state-of-the-art performance, understanding why they make a specific prediction is difficult. Most existing interpretability methods are "post-hoc," meaning they try to explain a model after it has already made a decision. These explanations are often just approximations and can be unfaithful to the model's actual reasoning.

Furthermore, there is a growing need for algorithmic recourse: if a model makes an unfavorable decision (e.g., denying a loan or flagging a post as toxic), the user should be able to see the evidence and contest it. This paper addresses the challenge of building models that are interpretable by design, specifically through example-based explanations—showing users the specific training instances that most influenced a prediction.

Methods

The authors propose the Wrapper Box pipeline, which consists of three main steps:

  1. Feature Extraction: A standard neural model (like BART or DeBERTa) is trained on a task. Instead of using the final classification head, the authors extract the feature representations from the penultimate layer.
  2. Classic Wrapping: These high-quality, learned representations are fed into classic, transparent models: k-Nearest Neighbors (kNN), Decision Trees (DT), or L-Means (a clustering-based classifier).
  3. Faithful Attribution: Because these classic models are transparent, their reasoning is directly tied to training data. For instance, a kNN prediction is literally a vote by the $k$ most similar training examples.
Figure 1: Three wrapper boxes illustrated for toxic language detection (Hartvigsen et al., 2022). Red and blue dots denote harmful vs. benign speech. Smaller dots represent examples, while larger dots represent clusters (e.g., DT leaf nodes). A neural model’s penultimate layer provides the feature representation for the white wrapper boxes. Our results show that classic models can achieve comparable performance to the underlying neural models while also providing intuitive, example-based explanations (described in Section 4).

The paper also introduces a greedy algorithm to identify the minimal subset of training data ($S_t$) that, if removed, would flip the model's prediction. This provides a concrete way for developers to audit data and for users to contest decisions.

Datasets

The approach was evaluated on two primary tasks:

  • TOXIGEN: A dataset for toxic speech detection containing 9,900 human-labeled instances.
  • E-SNLI: A large-scale Natural Language Inference dataset (569k pairs) that includes human-annotated explanations for why a premise entails or contradicts a hypothesis.

The authors also tested the generalizability of the approach using zero-shot representations from modern Large Language Models (LLMs) including Llama 2/3, Mistral, and Gemma.

Key Insights and Ideas

  • Leveraging Linear Separability: The "aha moment" is that while neural networks are complex, their penultimate layers often produce representations where classes are nearly linearly separable. This allows simple classic models to perform almost as well as the original complex neural head.
  • Faithfulness by Design: Unlike methods like LIME or SHAP, Wrapper Box explanations are not estimates. They are fully faithful because the examples shown are the exact ones the model used to calculate the output.
  • The LLM Performance Boost: Surprisingly, using a Wrapper Box on top of zero-shot LLM embeddings often significantly outperformed the base LLM's own zero-shot classification performance.
  • kNN for Recourse: kNN emerged as the "clear winner" for training data attribution. Because it requires no retraining, the authors could efficiently identify exactly which training points caused a prediction flip in under a second.

Key Results

  • Comparable Accuracy: Across various models and metrics, Wrapper Boxes maintained performance levels largely comparable to the original neural baselines (often within 1-2%).
  • Superior Attribution: In the task of identifying which data to remove to flip a prediction, Wrapper Boxes achieved 100% coverage and correctness for kNN and L-Means, whereas prior state-of-the-art methods (Yang et al., 2023) struggled with label skew, achieving only ~27% coverage on TOXIGEN.
  • Efficiency: The greedy approach for kNN is exceptionally fast, making it feasible for real-time model auditing and recourse.
Table 4: Benchmarking results for training data attribution, showing the superiority of kNN and L-Means wrappers.

Limitations and Future Work

  • Storage Overhead: Providing example-based explanations requires storing the training data (or their embeddings), which can be a significant storage burden for massive datasets.
  • Human-AI Alignment: The paper assumes that the "similarity" measured by the model in embedding space aligns with human intuition. The authors acknowledge that user studies are needed to verify if these retrieved examples are actually helpful to non-experts.
  • Minimal Subsets: While the greedy algorithm finds a subset to flip a prediction, it doesn't guarantee the absolute minimal subset, which remains a computationally difficult problem for models that require retraining (like Decision Trees).

Summary updated

Abstract

Can we preserve the accuracy of neural models while also providing faithful explanations of model decisions to training data? We propose a "wrapper box'' pipeline: training a neural model as usual and then using its learned feature representation in classic, interpretable models to perform prediction. Across seven language models of varying sizes, including four large language models (LLMs), two datasets at different scales, three classic models, and four evaluation metrics, we first show that the predictive performance of wrapper classic models is largely comparable to the original neural models. Because classic models are transparent, each model decision is determined by a known set of training examples that can be directly shown to users. Our pipeline thus preserves the predictive performance of neural language models while faithfully attributing classic model decisions to training data. Among other use cases, such attribution enables model decisions to be contested based on responsible training instances. Compared to prior work, our approach achieves higher coverage and correctness in identifying which training data to remove to change a model decision. To reproduce findings, our source code is online at: https://github.com/SamSoup/WrapperBox.
BibTeX
@inproceedings{su2024wrapper,
  author = {Yiheng Su and Junyi Jessy Li and Matthew Lease},
  title = {{Wrapper Boxes: Faithful Attribution of Model Predictions to Training Data}},
  booktitle = {BlackBoxNLP ARR Commitment @ EMNLP},
  year = {2024},
  url = {https://openreview.net/forum?id=cRNicP5q20},
}
Figure