Understanding Text Classification Data and Models Using Aggregated Input Salience

Katja Filippova, Sebastian Ebert, Alice Shoshana Jakobovits · DOI · OpenReview

TL;DR

This paper introduces a novel method for understanding text classification models and their underlying data by aggregating individual input salience maps. By applying clustering and nearest neighbor search to these aggregated representations, the authors demonstrate how to automatically identify spurious correlations, model sensitivities, and dataset weaknesses, moving beyond the limitations of analyzing single examples.

What Problem Does This Paper Address?

When deploying machine learning models, especially in sensitive areas like text classification, it's crucial to ensure they are not just accurate but also reliable and fair. A common challenge is that models can achieve high performance by exploiting "shortcuts" – superficial patterns in the data that don't reflect true understanding. For instance, a model might learn that the presence of the word "not" strongly indicates a negative sentiment, without truly grasping the nuances of negation.

Traditional methods for understanding these issues, like input salience (which highlights important words), are often applied to individual examples. However, this approach is tedious, time-consuming, and makes it difficult to spot broader patterns across an entire dataset or understand the model's overall behavior. The authors aim to bridge this gap by enabling a more systematic, dataset-level analysis of model reasoning.

Methods

The core of the proposed method involves transforming raw input salience maps into fixed-length representations that can be analyzed in aggregate. Here's a breakdown:

  1. Input Salience Method: The paper starts with an existing input salience method. They primarily use Gradient L2 (Grad-L2) for BERT models, as it's shown to be effective for identifying lexical shortcuts. However, their approach is compatible with any method that assigns a weight to each token.
  2. Fixed-Length Representations: To aggregate salience information, they convert the salience maps into fixed-length vectors. Two main types are explored:
  3. Vocabulary Vector (S1): For each example, this vector's dimension corresponds to the model's vocabulary. Each entry stores the highest absolute salience value for a given token across the example. They then often select the top-k tokens to create a sparser representation.
  4. Embedding Vector (S2): This representation combines the vocabulary-based salience with pre-trained word embeddings (from BERT), creating a dense vector.
  5. Analysis Methods: These fixed-length representations are then analyzed using standard techniques:
  6. Clustering (k-means): Grouping similar examples based on their salience representations to identify common patterns or data artifacts.
  7. Nearest Neighbor Search: Finding examples with similar salience profiles to understand why a specific, potentially surprising, prediction was made.
  8. Visualization (t-SNE): Projecting the high-dimensional salience representations into a lower-dimensional space for visual exploration.

Datasets

The authors evaluate their approach on three datasets:

  • Synthetic SST2: A modified version of the Stanford Sentiment Treebank (SST2) dataset. They synthetically introduce specific two-token rules to create known shortcuts, allowing them to validate if their method can detect them.
  • IMDB: A standard binary classification dataset of movie reviews.
  • Wikipedia Toxicity: A dataset of Wikipedia edit comments labeled for toxicity.

Key Insights and Ideas

  • From Single Examples to Datasets: The most significant contribution is shifting the focus from analyzing individual predictions to understanding aggregate patterns across entire datasets. This allows for the discovery of systemic issues rather than isolated incidents.
  • Automated Discovery of Shortcuts: The method can automatically identify "shortcut learning" patterns, such as the reliance on specific numbers (e.g., "3/10 stars") for negative sentiment in movie reviews, which were previously found through manual analysis.
  • Revealing Dataset Weaknesses: By clustering salience maps, the approach can uncover data artifacts or biases that models exploit, like the prevalence of "redirect talk:" prefixes in non-toxic Wikipedia comments, which might not be indicative of actual toxicity but rather a data generation artifact.
  • Identifying Model Sensitivities: The method can pinpoint terms that a model is overly sensitive to, meaning their presence strongly influences the prediction regardless of context. This is crucial for understanding potential biases, especially in toxicity detection.
  • Salience-Based Representations Outperform Baselines: The proposed salience-based representations (S1 and S2) consistently outperform traditional baselines (like PMI-weighted vectors or CLS token embeddings) in identifying spurious correlations and understanding model behavior.

Key Results

  • Synthetic Data Validation: The method successfully identified synthetically introduced shortcuts in SST2, achieving near-perfect precision and recall in clustering these examples.
  • IMDB Spurious Correlations: For the IMDB dataset, clustering salience representations (specifically S1) identified a cluster of examples dominated by numeric ratings (e.g., "3/10 stars") with high precision (98%) and recall (50% for 20 clusters), demonstrating the ability to find these patterns automatically.
  • Wikipedia Toxicity Patterns: Visualizations revealed that non-toxic Wikipedia comments mentioning "gay" often shared terms related to sexuality or "redirect talk:" prefixes, providing a more nuanced understanding of how the model interprets these terms.
  • Model Sensitivity Measurement: In toxicity prediction, aggregated salience identified terms that, when inserted into non-toxic text, increased the probability of a toxic prediction by an average of 41%. Masking these terms decreased the probability by 34%, highlighting significant model sensitivity.
  • Nearest Neighbors for Explanation: For surprising misclassifications, retrieving nearest neighbors based on salience representations helped uncover rationales for the model's predictions in 22 out of 28 cases, significantly more than baseline methods.

Limitations and Future Work

  • Order Agnosticism: The current salience-based representations are order-agnostic, meaning they cannot detect patterns that depend on word order, example length, or token position.
  • Model Architecture Dependence: While the approach is generally compatible with transformer-based models, it was primarily tested on BERT. Future work could explore its applicability to other architectures.
  • Task Specificity: The current experiments focus on binary text classification. Extending the method to multi-class, regression, or text generation tasks would be valuable.
  • Direct Fixes: The method primarily aids in understanding and identifying weaknesses. While this is a necessary first step, it doesn't directly provide robustness fixes, which might require further techniques like data rebalancing.
  • Representation Enhancement: The authors suggest exploring techniques like PCA to transform sparse vocabulary representations into dense ones.

Summary updated

BibTeX
@misc{filippova2022understanding,
  author = {Katja Filippova and Sebastian Ebert and Alice Shoshana Jakobovits},
  title = {{Understanding Text Classification Data and Models Using Aggregated Input Salience}},
  year = {2022},
  eprint = {2211.05485},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.05485},
}
Figure