A Sea of Words: An In-Depth Analysis of Anchors for Text Data
Gianluigi Lopardo, Frederic Precioso, Damien Garreau
TL;DR
This work provides the first theoretical analysis of Anchors for text data by formalizing an exhaustive p-Anchors framework under TF-IDF vectorization and UNK-based word removal. It proves sampling equivalence to independent word removals, establishes stability of exhaustive anchors under perturbations of the evaluation function, and characterizes anchor selection for simple if-then rules and linear classifiers, showing that anchors tend to pick words with positive influence weighted by IDF. For neural networks, it empirically links anchor selections to the words corresponding to the largest input gradients scaled by IDF, suggesting a fast gradient-based proxy for explanations when model access is available. The results offer solid theoretical guarantees for local rule-based explainers, illuminate the behavior of Anchors on different model classes, and provide a practical bridge between model-agnostic explanations and gradient-based interpretations. Collectively, the framework aids the principled design and analysis of interpretability methods in NLP and beyond.
Abstract
Anchors (Ribeiro et al., 2018) is a post-hoc, rule-based interpretability method. For text data, it proposes to explain a decision by highlighting a small set of words (an anchor) such that the model to explain has similar outputs when they are present in a document. In this paper, we present the first theoretical analysis of Anchors, considering that the search for the best anchor is exhaustive. After formalizing the algorithm for text classification, we present explicit results on different classes of models when the vectorization step is TF-IDF, and words are replaced by a fixed out-of-dictionary token when removed. Our inquiry covers models such as elementary if-then rules and linear classifiers. We then leverage this analysis to gain insights on the behavior of Anchors for any differentiable classifiers. For neural networks, we empirically show that the words corresponding to the highest partial derivatives of the model with respect to the input, reweighted by the inverse document frequencies, are selected by Anchors.
