First is Better Than Last for Language Data Influence

Chih-Kuan Yeh, Ankur Taly, Mukund Sundararajan, Frederick Liu, Pradeep Kumar Ravikumar

TL;DR

While most researchers calculate "data influence" using a model’s final layer for efficiency, this paper reveals that the first layer—the word embeddings—is actually far more effective for NLP tasks. By introducing TracIn-WE, the authors bypass a "cancellation effect" that plagues later layers, resulting in influence scores that are significantly more accurate and provide granular, word-level explanations for model behavior.

The Problem with Last-Layer Influence

In machine learning, "data influence" methods help us answer a critical question: Which specific training examples caused the model to make this prediction? This is vital for debugging mislabeled data, explaining model bias, and understanding why a model might fail on certain test cases.

However, modern deep learning models (like BERT) have millions of parameters. Calculating the influence of every training point across every parameter is computationally impossible. To solve this, the standard practice has been to look only at the last layer of the network, assuming it captures the most "high-level" semantic information.

The authors of this paper argue that this assumption is flawed for language models. They identify a "cancellation effect" in later layers: because many different training examples share the same high-level "logic" in the final activations, their individual influence signals often have massive magnitudes but opposite signs, effectively canceling each other out. This leaves us with "noisy" influence scores that fail to reliably identify the most important training data.

Methodology: Introducing TracIn-WE

The researchers propose TracIn-WE (TracIn on Word Embeddings). TracIn is an existing method that "traces" how much a training example reduces the loss of a test example during the gradient descent process. The key innovations in this paper include:

  1. Shifting to the First Layer: Instead of the last layer, they apply TracIn to the word embedding layer.
  2. Gradient-Powered Semantics: While the first layer might seem too "low-level" (just raw words), the authors show that because gradients are backpropagated from the output through the entire network, the gradients at the embedding layer actually do encode high-level semantic context.
  3. TracIn-WE-Topk: To handle the massive size of embedding matrices (vocab size × embedding dimension), they introduce a sparse approximation. They only save and compute gradients for the "top-k" most important words in a sentence, making the method computationally feasible for large-scale models.
  4. Word-Level Decomposition: Because the method operates on embeddings, the influence score can be broken down to show exactly which word in a training sentence was responsible for the influence.
Word-level decomposition of influence scores using TracIn-WE

Experimental Setup

The authors evaluated their method using BERT-Small and BERT-Base models across three major NLP classification benchmarks:

  • Toxicity: A dataset for identifying toxic vs. non-toxic comments.
  • AGnews: A four-class news categorization dataset.
  • MNLI (Multi-Genre Natural Language Inference): A complex task requiring models to determine if a premise entails or contradicts a hypothesis.
  • Toxicity-Roberta: They also tested a more modern RoBERTa model to ensure the findings generalized beyond BERT.

Key Insights

  • The "Cancellation Effect" is the Villain: The paper demonstrates that bias parameters and later layers have much higher "cancellation ratios." This explains why removing "influential" points identified by last-layer methods often fails to change a model's prediction—the signal was never actually discriminative.
  • Gradients are Context-Aware: A word like "not" has a different gradient depending on whether it's used in a simple negation ("I do not like him") or a double negation/idiom ("not only... but"). This allows TracIn-WE to capture semantic similarity even when sentences use the same words in different ways.
  • The Power of [CLS] and [SEP]: Even when a training sentence and a test sentence have zero overlapping words, TracIn-WE can still find a connection. Special tokens like the "start" ([CLS]) and "end" ([SEP]) tokens act as anchors that capture the overall sentence sentiment through their gradients.

Key Results

The authors used a "case deletion" metric: they identified the top "proponents" (examples that help the prediction) and "opponents" (examples that hurt it), removed them, and retrained the model to observe the prediction score change.

  • Massive Performance Leap: TracIn-WE outperformed last-layer methods by 4x to 10x on the case deletion metric.
  • Superior Debugging: In the Toxicity dataset, TracIn-WE was significantly better at identifying the specific training examples that, if removed, would most change the model's classification of a toxic comment.
  • Efficiency: The "Top-k" approximation performed almost as well as using the full sentence, proving the method is scalable to very long documents.
Prediction score changes when removing top opponents and proponents

Limitations and Future Work

  • Word Overlap Dependency: While special tokens help, the method still performs best when there is some level of keyword or token overlap between the training and test sets.
  • Scope of Tasks: The study focused on classification. The authors note that the "cancellation effect" might behave differently in generative models (like GPT) or tasks with generative outputs, which remains an open area for research.
  • Computational Storage: Even with the Top-k approximation, saving gradients across multiple training checkpoints requires significant storage space compared to simpler, non-gradient-based methods.

Summary updated

BibTeX
@inproceedings{yeh2022first,
  author = {Chih-Kuan Yeh and Ankur Taly and Mukund Sundararajan and Frederick Liu and Pradeep Kumar Ravikumar},
  title = {{First is Better Than Last for Language Data Influence}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=yfrDD_rmD5},
}
Figure