On Guaranteed Optimal Robust Explanations for NLP Models
Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence. Main Track. Pages 2658-2665.
https://doi.org/10.24963/ijcai.2021/366
© 2021 International Joint Conferences on Artificial Intelligence
Keywords
- Machine Learning: Adversarial Machine Learning
- Machine Learning: Explainable/Interpretable Machine Learning
- Natural Language Processing: Sentiment Analysis and Text Mining
Abstract
We build on abduction-based explanations for machine learning and develop a method for computing local explanations for neural network models in natural language processing (NLP). Our explanations comprise a subset of the words of the input text that satisfies two key features: optimality w.r.t. a user-defined cost function, such as the length of explanation, and robustness, in that they ensure prediction invariance for any bounded perturbation in the embedding space of the left-out words. We present two solution algorithms, respectively based on implicit hitting sets and maximum universal subsets, introducing a number of algorithmic improvements to speed up convergence of hard instances. We show how our method can be configured with different perturbation sets in the embedded space and used to detect bias in predictions by enforcing include/exclude constraints on biased terms, as well as to enhance existing heuristic-based NLP explanation frameworks such as Anchors. We evaluate our framework on three widely used sentiment analysis tasks and texts of up to 100 words from SST, Twitter and IMDB datasets, demonstrating the effectiveness of the derived explanations.
- [Alzantot et al., 2018] Moustafa Alzantot, Yash Sharma, Ahmed Elgohary, Bo-Jhang Ho, Mani Srivastava, and Kai- Wei Chang. Generating natural language adversarial ex- amples. arXiv preprint arXiv:1804.07998, 2018.
- [Arras et al., 2016] Leila Arras, Franziska Horn, Grégoire Montavon, Klaus-Robert Müller, and Wojciech Samek. Explaining predictions of non-linear classifiers in nlp. arXiv preprint arXiv:1606.07298, 2016.
- [Arras et al., 2017] Leila Arras, Grégoire Montavon, Klaus- Robert Müller, and Wojciech Samek. Explaining recurrent neural network predictions in sentiment analysis. arXiv preprint arXiv:1706.07206, 2017.
- [Bach et al., 2015] Sebastian Bach, Alexander Binder, Grégoire Montavon, Frederick Klauschen, Klaus-Robert Müller, and Wojciech Samek. On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one, 10(7):e0130140, 2015.
- [Baroni et al., 2014] Marco Baroni, Georgiana Dinu, and Germán Kruszewski. Don't count, predict! a systematic comparison of context-counting vs. context-predicting se- mantic vectors. In Proceedings of the 52nd Annual Meet- ing of the Association for Computational Linguistics (Vol- ume 1: Long Papers), pages 238-247, 2014.
- [Chakraborty et al., 2017] Supriyo Chakraborty, Richard Tomsett, Ramya Raghavendra, Daniel Harborne, Moustafa Alzantot, Federico Cerutti, Mani Srivastava, Alun Preece, Simon Julier, Raghuveer M Rao, et al. Interpretabil- ity of deep learning models: a survey of results. In 2017 IEEE smartworld, ubiquitous intelligence & com- puting, advanced & trusted computed, scalable com- puting & communications, cloud & big data comput- ing, Internet of people and smart city innovation (smart- world/SCALCOM/UIC/ATC/CBDcom/IOP/SCI), pages 1- 6. IEEE, 2017. Link
- [Chollet and others, 2018] Franc ¸ois Chollet et al. Keras: The python deep learning library. Astrophysics Source Code Library, pages ascl-1806, 2018.
- [Darwiche and Hirth, 2020] Adnan Darwiche and Auguste Hirth. On the reasons behind decisions. arXiv preprint arXiv:2002.09284, 2020.
- [Darwiche, 2020] Adnan Darwiche. Three modern roles for logic in ai. In Proceedings of the 39th ACM SIGMOD- SIGACT-SIGAI Symposium on Principles of Database Sys- tems, pages 229-243, 2020.
- [Dillig et al., 2012] Isil Dillig, Thomas Dillig, Kenneth L McMillan, and Alex Aiken. Minimum satisfying assign- ments for SMT. In CAV, volume 7358 of LNCS, pages 394-409. Springer, 2012.
- [Ding et al., 2017] Yanzhuo Ding, Yang Liu, Huanbo Luan, and Maosong Sun. Visualizing and understanding neural machine translation. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1150-1159, 2017.
- [Go et al., 2009] Alec Go, Richa Bhayani, and Lei Huang. Twitter sentiment classification using distant supervision. CS224N project report, Stanford, 1(12):2009, 2009.
- [Huang et al., 2019] Po-Sen Huang, Robert Stanforth, Jo- hannes Welbl, Chris Dyer, Dani Yogatama, Sven Gowal, Krishnamurthy Dvijotham, and Pushmeet Kohli. Achiev- ing verified robustness to symbol substitutions via inter- val bound propagation. arXiv preprint arXiv:1909.01492, 2019.
- [Ignatiev et al., 2016] Alexey Ignatiev, Alessandro Previti, and Joao Marques-Silva. On finding minimum satisfying assignments. In International Conference on Principles and Practice of Constraint Programming, pages 287-297. Springer, 2016.
- [Ignatiev et al., 2019a] Alexey Ignatiev, António Morgado, Georg Weissenbacher, Joao Marques-Silva, and IS- DCT SB RAS. Model-based diagnosis with multiple ob- servations. In IJCAI, pages 1108-1115, 2019. IJCAI
- [Ignatiev et al., 2019b] Alexey Ignatiev, Nina Narodytska, and Joao Marques-Silva. Abduction-based explanations for machine learning models. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 1511-1519, 2019.
- [Ignatiev et al., 2019c] Alexey Ignatiev, Nina Narodytska, and Joao Marques-Silva. On relating explanations and ad- versarial examples. 2019.
- [Ignatiev et al., 2019d] Alexey Ignatiev, Nina Narodytska, and Joao Marques-Silva. On validating, repairing and refining heuristic ml explanations. arXiv preprint arXiv:1907.02509, 2019.
- [Jia et al., 2019] Robin Jia, Aditi Raghunathan, Kerem Göksel, and Percy Liang. Certified robustness to adversar- ial word substitutions. arXiv preprint arXiv:1909.00986, 2019.
- [Katz et al., 2019] Guy Katz, Derek A Huang, Duligur Ibel- ing, Kyle Julian, Christopher Lazarus, Rachel Lim, Parth Shah, Shantanu Thakoor, Haoze Wu, Aleksandar Zeljić, et al. The marabou framework for verification and analy- sis of deep neural networks. In International Conference on Computer Aided Verification, pages 443-452. Springer, 2019.
- [Ko et al., 2019] Ching-Yun Ko, Zhaoyang Lyu, Lily Weng, Luca Daniel, Ngai Wong, and Dahua Lin. Popqorn: Quan- tifying robustness of recurrent neural networks. In Inter- national Conference on Machine Learning, pages 3468- 3477. PMLR, 2019.
- [La Malfa et al., 2020] Emanuele La Malfa, Min Wu, Luca Laurenti, Benjie Wang, Anthony Hartshorn, and Marta Kwiatkowska. Assessing robustness of text classification through maximal safe radius computation. arXiv preprint arXiv:2010.02004, 2020.
- [Letham et al., 2015] Benjamin Letham, Cynthia Rudin, Tyler H McCormick, David Madigan, et al. Interpretable classifiers using rules and bayesian analysis: Building a better stroke prediction model. Annals of Applied Statis- tics, 9(3):1350-1371, 2015.
- [Li et al., 2015] Jiwei Li, Xinlei Chen, Eduard Hovy, and Dan Jurafsky. Visualizing and understanding neural mod- els in nlp. arXiv preprint arXiv:1506.01066, 2015.
- [Liu et al., 2018] Xuan Liu, Xiaoguang Wang, and Stan Matwin. Improving the interpretability of deep neural net- works with knowledge distillation. In 2018 IEEE Interna- tional Conference on Data Mining Workshops (ICDMW), pages 905-912. IEEE, 2018.
- [Maas et al., 2011] Andrew Maas, Raymond E Daly, Peter T Pham, Dan Huang, Andrew Y Ng, and Christopher Potts. Learning word vectors for sentiment analysis. In Pro- ceedings of the 49th annual meeting of the association for computational linguistics: Human language technologies, pages 142-150, 2011.
- [Mikolov et al., 2013] Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781, 2013.
- [Miyato et al., 2016] Takeru Miyato, Andrew M Dai, and Ian Goodfellow. Adversarial training methods for semi-supervised text classification. arXiv preprint arXiv:1605.07725, 2016.
- [Narodytska et al., 2019] Nina Narodytska, Aditya Shrotri, Kuldeep S Meel, Alexey Ignatiev, and Joao Marques- Silva. Assessing heuristic machine learning explanations with model counting. In International Conference on The- ory and Applications of Satisfiability Testing, pages 267- 278. Springer, 2019.
- [Ribeiro et al., 2016] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. " why should i trust you?" explain- ing the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD international conference on knowl- edge discovery and data mining, pages 1135-1144, 2016.
- [Ribeiro et al., 2018] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Anchors: High-precision model- agnostic explanations. In Proceedings of the AAAI Con- ference on Artificial Intelligence, volume 32, 2018.
- [Ruan et al., 2018] Wenjie Ruan, Xiaowei Huang, and Marta Kwiatkowska. Reachability analysis of deep neural networks with provable guarantees. arXiv preprint arXiv:1805.02242, 2018. IJCAI
- [Samek et al., 2017] Wojciech Samek, Thomas Wiegand, and Klaus-Robert Müller. Explainable artificial intelli- gence: Understanding, visualizing and interpreting deep learning models. arXiv preprint arXiv:1708.08296, 2017.
- [Shi et al., 2020] Weijia Shi, Andy Shih, Adnan Darwiche, and Arthur Choi. On tractable representations of binary neural networks. arXiv preprint arXiv:2004.02082, 2020.
- [Singh et al., 2018] Chandan Singh, W James Murdoch, and Bin Yu. Hierarchical interpretations for neural network predictions. arXiv preprint arXiv:1806.05337, 2018.
- [Socher et al., 2013] Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew Y Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pages 1631-1642, 2013.
- [Wang and Rudin, 2015] Fulton Wang and Cynthia Rudin. Falling rule lists. In Artificial Intelligence and Statistics, pages 1013-1022. PMLR, 2015.
- [Wang et al., 2018] Shiqi Wang, Kexin Pei, Justin White- house, Junfeng Yang, and Suman Jana. Efficient for- mal safety analysis of neural networks. arXiv preprint arXiv:1809.08098, 2018.
- [Zhang et al., 2018] Quanshi Zhang, Yu Yang, Yuchen Liu, Ying Nian Wu, and Song-Chun Zhu. Unsupervised learn- ing of neural networks to explain neural networks. arXiv preprint arXiv:1805.07468, 2018.
- [Zhang et al., 2019] Quanshi Zhang, Yu Yang, Haotian Ma, and Ying Nian Wu. Interpreting cnns via decision trees. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6261-6270, 2019.
References were extracted automatically from the PDF and may contain errors.
Full text extracted automatically from the PDF; figures, tables and equations may differ. The PDF is the version of record.
1 Introduction
The increasing prevalence of deep learning models in realworld decision-making systems has made AI explainability a central problem, as we seek to complement such highlyaccurate but opaque models with comprehensible explanations as to why the model produced a particular prediction [Samek et al., 2017; Ribeiro et al., 2016; Zhang et al., 2019; Liu et al., 2018; Letham et al., 2015]. Amongst existing techniques, local explanations explain the individual prediction in terms of a subset of the input features that justify the prediction. State-of-the-art explainers such as LIME and Anchors [Ribeiro et al., 2016; Ribeiro et al., 2018] use heuristics to obtain short explanations, which may generalise better beyond the given input and are more easily interpretable to human experts, but lack robustness to adversarial perturbations. The abduction-based method of [Ignatiev et al., 2019b], on the other hand, ensures minimality and robustness of the prediction by requiring its invariance w.r.t. any perturbation of the left-out features, meaning that the explanation is sufficient to imply the prediction. However, since perturbations are potentially unbounded, this notion of robustness may not be appropriate for certain applications.
∗ First Author, contact at emanuele.la.malfa@cs.ox.ac.uk
1 Code available at https://github.com/EmanueleLM/OREs
In this paper, we focus on natural language processing (NLP) neural network models and, working in the embedding space with words as features, introduce optimal robust explanations (OREs). OREs are provably guaranteed to be both robust, in the sense that the prediction is invariant for any (reasonable) replacement of the features outside the explanation, and minimal for a given user defined cost function, such as the length of the explanation. Our core idea shares similarities with abduction-based explanations (ABE) of [Ignatiev et al., 2019b], but is better suited to NLP models, where the unbounded nature of ABE perturbations may result in trivial explanations equal to the entire input. We show that OREs can be formulated as a particular kind of ABE or, equivalently, minimal satisfying assignment (MSA). We develop two methods to compute OREs by extending existing algorithms for ABEs and MSAs [Ignatiev et al., 2019b; Dillig et al., 2012]. In particular, we incorporate state-ofthe-art robustness verification methods [Katz et al., 2019; Wang et al., 2018] to solve entailment/robustness queries and improve convergence by including sparse adversarial attacks and search tree reductions. By adding suitable constraints, we show that our approach allows one to detect biased decisions [Darwiche and Hirth, 2020] and enhance heuristic explainers with robustness guarantees [Ignatiev et al., 2019d].
To the best of our knowledge, this is the first method to derive local explanations for NLP models with provable robustness and optimality guarantees. We empirically demonstrate that our approach can provide useful explanations for nontrivial fully-connected and convolutional networks on three widely used sentiment analysis benchmarks (SST, Twitter and IMDB). We compare OREs with the popular Anchors method, showing that Anchors often lack prediction robustness in our benchmarks, and demonstrate the usefulness of our framework on model debugging, bias evaluation, and repair of non-formal explainers like Anchors.
2 RelatedWork
Interpretability of machine learning models is receiving increasing attention [Chakraborty et al., 2017]. Existing methods broadly fall in two categories: explanations via globally interpretable models (e.g. [Wang and Rudin, 2015; Zhang et al., 2018]), and local explanations for a given input and prediction (to which our work belongs). Two prominent examples of the latter category are LIME [Ribeiro et al., 2016], which learns a linear model around the neighbourhood of an input using random local perturbations, and Anchors [Ribeiro et al., 2018] (introduced in Section 3). These methods, however, do not consider robustness, making them fragile to adversarial attacks and thus insufficient to imply the prediction. Repair of non-formal explainers has been studied in [Ignatiev et al., 2019d] but only for boosted trees predictors. [Narodytska et al., 2019] assesses the quality of Anchors' explanations by encoding the model and explanation as a propositional formula. The explanation quality is then determined using model counting, but for binarised neural networks only. Other works that focus on binarised neural networks, Boolean classifiers or similar representations include [Shi et al., 2020; Darwiche and Hirth, 2020; Darwiche, 2020]. Methods tailored to (locally) explaining NLP model decisions for a given input include [Li et al., 2015; Singh et al., 2018]. These identify input features, or clusters of input features, that most contribute to the prediction, using saliency and agglomerative contextual decomposition respectively. Layer-wise relevance propagation [Bach et al., 2015] is also popular for NLP explanations, and is used in [Arras et al., 2016; Arras et al., 2017; Ding et al., 2017]. Similarly to the above, these methods do not consider robustness. Robustness of neural network NLP models to adversarial examples has been studied in [Huang et al., 2019; Jia et al., 2019; La Malfa et al., 2020]. We note that robustness verification is a different (and arguably simpler) problem from deriving a robust explanation, as the latter requires performing multiple robustness verification queries (see Section 4). Existing neural network verification approaches include symbolic (SMT) [Katz et al., 2019], relaxation [Ko et al., 2019; Wang et al., 2018], and global optimisation [Ruan et al., 2018]. Research utilising hitting sets can be seen in [Ignatiev et al., 2019c], which relates explanations and adversarial examples through a generalised form of hitting set duality, and [Ignatiev et al., 2019a], which works on improving modelbased diagnoses by using an algorithm based on hitting sets to filter out non-subset-minimal sets of diagnoses.
3 Optimal Robust Explanations for NLP
Preliminaries. We consider a standard NLP classification task where we classify some given input text t into a plausible class y from a finite set Y. We assume that t is a fixed length sequence of words (i.e., features) l, t = (w1, . . . ,wl), where wi ∈ W with W being a finite vocabulary (possibly including padding). Text inputs are encoded using a continuous word embedding E : W → Rd , where d is the size of the embedding [Mikolov et al., 2013]. Thus, given a text t = (w1, . . . ,wl), we define the embedding E(t) of t as the sequence x = (xw1 , . . . , xwl ) ∈ Rl·d , where xwi = E(wi). We denote with WE ⊆ W the vocabulary used to train E. We consider embedding vectors trained from scratch on the sentiment task, a technique that enforces words that are positively correlated to each of the output classes to be gathered closer in the embedding space [Baroni et al., 2014], which is considered a good proxy for semantic similarity with respect to the target task compared to count-based embeddings [Alzantot et al., 2018]. For classification we consider a neural network M : Rl·d → Y that operates on the text embedding.
Robust Explanations. In this paper, we seek to provide local explanations for the predictions of a neural network NLP model. For a text embedding x = E(t) and a prediction M(x), a local explanation E is a subset of the features of t, i.e., E ⊆ F where F = {w1, . . . , wl}, that is sufficient to imply the prediction. We focus on deriving robust explanations, i.e., on extracting a subset E of the text features F which ensure that the neural network prediction remains invariant for any perturbation of the other features F \ E. Thus, the features in a robust explanation are sufficient to imply the prediction that we aim to explain, a clearly desirable feature for a local explanation. In particular, we focus on explanations that are robust w.r.t. bounded perturbations in the embedding space of the input text. We extract word-level explanations by means of word embeddings: we note that OREs work, without further extensions, with diverse representations (e.g., sentence-level, characters-level, etc.). For a word w ∈ W, with embedding xw = E(w) we denote with B(w) ⊆ Rd a generic set of word-level perturbations. We consider the following kinds of perturbation sets, depicted also in Fig. 1.
ϵ-ball: B(w) = {x ∈ Rd | ‖x - xw‖p ≤ ϵ}, for some ϵ > 0 and p > 0. This is a standard measure of local robustness in computer vision, where ϵ-variations are interpreted as manipulations of the pixel intensity of an image. It has also been adopted in early NLP robustness works [Miyato et al., 2016], but then replaced with better representations based on actual word replacements and their embeddings, see below.
k-NN box closure: B(w) = BB(E(NNk(w))), where BB(X) is the minimum bounding box for set X; for a set W ′ ⊆ W, E(W ′ ) = ⋃w′∈W ′{E(w′ )}; and NNk(w) is the set of the k closest words to w in the embedding space, i.e., words w′ with smallest d(xw, E(w′ )), where d is a valid notion of distance between embedded vectors, such as p-norms or cosine similarity, even though the box closure can be calculated for any set of embedded words. This provides an over-approximation of the k-NN convex closure, for which constraint propagation (and thus robustness checking) is more efficient [Jia et al., 2019; Huang et al., 2019].
For some word-level perturbation B, set of features E ⊆ F, and input text t with embedding (x1, . . . , xl), we denote with BE(t) the set of text-level perturbations obtained from t by keeping constant the features in E and perturbing the others according to B:

A robust explanation E ⊆ F ensures prediction invariance for any point in BE(t), i.e., any perturbation (within B) of the features in F \ E.
Def. 1 (Robust Explanation). For a text t = (w1, . . . ,wl) with embedding x = E(t), word-level perturbation B, and classifier M, a subset E ⊆ F of the features of t is a robust explanation iff
We denote (2) with predicate RobM,x(E).
Optimal Robust Explanations (OREs). While robustness is a desirable property, it is not enough alone to produce useful explanations. Indeed, we can see that an explanation E including all the features, i.e., E = F, trivially satisfies Definition 1. Typically, one seeks short explanations, because these can generalise to several instances beyond the input x and are easier for human decision makers to interpret. We thus introduce optimal robust explanations (OREs), that is, explanations that are both robust and optimal w.r.t. an arbitrary cost function that assign a penalty to each word.
Def. 2 (Optimal Robust Explanation). Given a cost function C : W → R+, and for t = (w1, . . . ,wl), x, B, and M as in Def. 1, a subset E∗ ⊆ F of the features of t is an ORE iff
Note that (3) is always feasible, because its feasible set always includes at least the trivial explanation E = F. A special case of our OREs is when C is uniform (it assigns the same cost to all words in t), in which case E∗ is (one of) the robust explanations of smallest size, i.e., with the least number of words.
Relation with Abductive Explanations. Our OREs have similarities with the abduction-based explanations (ABEs) of [Ignatiev et al., 2019b] in that they also derive minimalcost explanations with robustness guarantees. For an input text t = (w1, . . . ,wl), let C = ∧li=1 χi = xwi be the cube representing the embedding of t, where χi is a variable denoting the i-th feature of x. Let N represent the logical encoding of the classifier M, and ˆ y be the formula representing the output of N given χ1, . . . , χl.
Def. 3 ([Ignatiev et al., 2019b]). An abduction-based explanation (ABE) is a minimal cost subset C ∗ of C such that C ∗ ∧N |= ˆ y.
Note that the above entailment is equivalently expressed as C ∗ |= (N → ˆ y). Let B = ∧li=1 χi ∈ B(wi) be the constraints encoding our perturbation space. Then, the following proposition shows that OREs can be defined in a similar abductive fashion and also in terms of minimum satisfying assignments (MSAs) [Dillig et al., 2012]. In this way, we can derive OREs via analogous algorithms to those used for ABEs [2019b] and MSAs [Dillig et al., 2012], as explained in Section 4. Moreover, we find that every ORE can be formulated as a prime implicant [Ignatiev et al., 2019b], a property that connects our OREs with the notion of sufficient reason introduced in [Darwiche and Hirth, 2020].
Prop. 1. Let E∗ be an ORE and C ∗ its constraint encoding. Define φ ≡ (B ∧ N ) → ˆ y. Then, all the following definitions apply to C ∗ :
- C ∗ is a minimal cost subset of C such that C ∗ |= φ.
- C ∗ is a minimum satisfying assignment for φ.
- C ∗ is a prime implicant of φ.
The key difference with ABEs is that our OREs are robust to bounded perturbations of the excluded features, while ABEs must be robust to any possible perturbation. This is an important difference because it is hard (often impossible) to guarantee prediction invariance w.r.t. the entire input space when this space is continuous and high-dimensional, like in our NLP embeddings. In other words, if for our NLP tasks we allowed any word-level perturbation as in ABEs, in most cases the resulting OREs will be of the trivial kind, E∗ = F (or C ∗ = C), and thus of little use. For example, if we consider ϵ-ball perturbations and the review "the gorgeously elaborate continuation of the lord of the rings", the resulting smallest-size explanation is of the trivial kind (it contains the whole review) already at ϵ = 0.1.
Exclude and include constraints. We further consider OREs E∗ derived under constraints that enforce specific features F ′ to be included/excluded from the explanation:
where φ(E) is one of F ′ ∩ E = ∅ (exclude) and F ′ ⊆ E (include). Note that adding include constraints doesn't affect the feasibility of our problem, because the feasible region of (4) always contains at least the explanation E∗ ∪F ′ , where E∗ is a solution of (3) and F ′ are the features to include. See Def. 1. Conversely, exclude constraints might make the problem infeasible when the features in F ′ don't admit perturbations, i.e., they are necessary for the prediction, and thus cannot be excluded. Such constraints can be easily accommodated by any solution algorithm for non-constrained OREs: for include ones, it is sufficient to restrict the feasible set of explanations to the supersets of F ′ ; for exclude constraints, we can manipulate the cost function so as to make any explanation with features in F ′ strictly sub-optimal w.r.t. explanations without, that is, we use cost C ′ such that ∀w∈F\F ′C ′ (w) = C(w) and ∀w′∈F ′C ′ (w′ ) > ∑w∈F\F ′ C(w). The ORE obtained under cost C ′ might still include features from F ′ , which implies that (4) is infeasible (i.e., no robust explanation without elements of F ′ exists).
2 For this and any subsequent reference to the supplement/appendix, please refer to the full version of the paper on the arXiv.
Constrained OREs enable two crucial use cases: detecting biased decisions, and enhancing non-formal explainability frameworks.
Detecting bias. Following [Darwiche and Hirth, 2020], we deem a classifier decision biased if it depends on protected features, i.e., a set of input words that should not affect the decision (e.g., a movie review affected by the director's name). In particular, a decision M(x) is biased if we can find, within a given set of text-level perturbations, an input x′ that agrees with x on all but protected features and such that M(x) ̸= M(x′ ).
Def. 4. For classifierM, text t with features F, protected features F ′ and embedding x = E(t), decision M(x) is biased w.r.t. some word-level perturbation B, if
The proposition below allows us to use exclude constraints to detect bias.
Prop. 2. For M, t, F, F ′ , x and B as per Def. 4, decision M(x) is biased iff (4) is infeasible under F ′ ∩E = ∅.
Enhancing non-formal explainers. The local explanations produced by heuristic approaches like LIME or Anchors do not enjoy the same robustness/invariance guarantees of our OREs. We can use our approach to minimally extend (w.r.t. the chosen cost function) any non-robust local explanation F ′ in order to make it robust, by solving (4) under the include constraint F ′ ⊆ E. In particular, with a uniform C, our approach would identify the smallest set of extra words that make F ′ robust. Being minimal/smallest, such an extension retains to a large extent the original explainability properties.
Relation with Anchors. Anchors [Ribeiro et al., 2018] are a state-of-the-art method for ML explanations. Given a perturbation distribution D, classifier M and input x, an anchor A is a predicate over the input features such that A(x) holds and A has high precision and coverage, defined next.
In other words, prec(A) is the probability that the prediction is invariant for any perturbation x′ to which explanation A applies. In this sense, precision can be intended as a robustness probability. cov(A) is the probability that explanation A applies to a perturbation. To discuss the relation between Anchors and OREs, for an input text t, consider an arbitrary distribution D with support in B∅(t) (the set of all possible text-level perturbations), see (1); and consider anchors A defined as subsets E of the input features F, i.e., AE(x) = ∧w∈E xw = E(w). Then, our OREs enjoy the following properties.
Prop. 3. If E is a robust explanation, then prec(AE) = 1.
Note that when D is continuous, cov(AE) is always zero unless E = ∅, in which case cov(A∅) = 1 (as A∅ = true). Indeed, for E ̸= ∅, the set {x′ | AE(x′ )} has |E| fewer degrees of freedom than the support of D, and thus has both measure and coverage equal to zero. We thus illustrate the next property assuming that D is discrete (when D is continuous, the following still applies to any empirical approximation of D).
The above proposition suggests that using a uniform C, i.e., minimizing the explanation's length, is a sensible strategy to obtain high-coverage OREs.
4 Solution Algorithms
We present two solution algorithms to derive OREs, respectively based on the hitting-set (HS) paradigm of [Ignatiev et al., 2019b] and the MSA algorithm of [Dillig et al., 2012]. Albeit different, both algorithms rely on repeated entailment/robustness checks B∧E∧N |= ˆ y for a candidate explanation E ⊂ C. For this check, we employ two state-ofthe-art neural network verification tools, Marabou [Katz et al., 2019] and Neurify [Wang et al., 2018]: they both give provably correct answers and, when the entailment is not satisfied, produce a counter-example x′ ∈ BE(t), i.e., a perturbation that agrees with E and such that B ∧ C ′ ∧ N ̸|= ˆ y, where C ′ is the cube representing x′ . We now briefly outline the two algorithms. A more detailed discussion (including the pseudo-code) is available in the supplement.
Minimum Hitting Set. For a counterexample C ′ , let I ′ be the set of feature variables where C ′ does not agree with C (the cube representing the input). Then, every explanation E that satisfies the entailment must hit all such sets I ′ built for any counter-examples C ′ [Ignatiev et al., 2016]. Thus, the HS paradigm iteratively checks candidates E built by selecting the subset of C whose variables form a minimum HS (w.r.t. cost C) of said I ′ s. However, we found that this method often struggles to converge for our NLP models, especially with large perturbations spaces (i.e., large ϵ or k). We solved this problem by extending the HS approach with a sub-routine that generates batches of sparse adversarial attacks for the input C. This has a two-fold benefit: 1) we reduce the number of entailment queries required to produce counter-examples, and 2) sparsity results in small I ′ sets, which further improves convergence.

Minimum Satisfying Assignment. This algorithm exploits the duality between MSAs and maximum universal subsets (MUSs): for cost C and formula φ ≡ (B ∧N) → ˆ y, an MUS X is a set of variables with maximum C such that ∀X.φ, which implies that C \ X is an MSA for φ [Dillig et al., 2012] and, in turn, an ORE. Thus, the algorithm of [Dillig et al., 2012] focuses on deriving an MUS, and it does so in a recursive branch-and-bound manner, where each branch adds a feature to the candidate MUS. Such an algorithm is exponential in the worst-case, but we mitigated this by selecting a good ordering for feature exploration and performing entailment checks to rule out features that cannot be in the MUS (thus reducing the search tree).

5 Experimental Results
Settings. We have trained fully connected (FC) and convolutional neural networks (CNN) models on sentiment analysis datasets that differ in the input length and difficulty of the learning task 3 . We considered 3 well-established benchmarks for sentiment analysis, namely SST [Socher et al., 2013], Twitter [Go et al., 2009] and IMDB [Maas et al., 2011] datasets. From these, we have chosen 40 representative input texts, balancing positive and negative examples. Embeddings are pre-trained on the same datasets used for classification [Chollet and others, 2018]. Both the HS and MSA algorithms have been implemented in Python and use Marabou [Katz et al., 2019] and Neurify [Wang et al., 2018] to answer robustness queries. Marabou is fast at verifying ReLU FC networks, but it becomes memory intensive with CNNs. On the other hand, the symbolic interval analysis of Neurify is more efficient for CNNs. A downside of Neurify is that it is less flexible in the constraint definition (inputs have to be represented as squared bi-dimensional grids, thus posing problems for NLP inputs which are usually specified as 3-d tensors). In the experiments below, we opted for the kNNbox perturbation space, as we found that the k parameter was easier to interpret and tune than the ϵ parameter for the ϵ-ball space, and improved verification time. Further details on the experimental settings, including a selection of ϵ-ball results, are given in the supplement.
3 Experiments were parallelized on a server with two 24-core Intel Xenon 6252 processors and 256GB of RAM, but each instance is single-threaded and can be executed on a low-end laptop.

Effect of classifier's accuracy and robustness. We find that our approach generally results in meaningful and compact explanations for NLP. In Figure 2, we show a few OREs extracted for negative and positive texts, where the returned OREs are both concise and semantically consistent with the predicted sentiment. However, the quality of our OREs depends on that of the underlying classifier. Indeed, enhanced models with better accuracy and/or trained on longer inputs tend to produce higher quality OREs. We show this in Figures 4, 3 and 5, where we observe that enhanced models tend to result in more semantically consistent explanations. For lower-quality models, some OREs include seemingly irrelevant terms (e.g., "film", "and"), thus exhibiting shortcomings of the classifier.

Detecting biases. As per Prop. 2, we applied exclude constraints to detect biased decisions. In Figure 6, we provide a few example instances exhibiting such a bias, i.e., where any robust explanation contains at least one protected feature. These OREs include proper names that shouldn't constitute a sufficient reason for the model's classification. When we try to exclude proper names, no robust explanation exists, indicating that a decision bias exists.


Debugging prediction errors. An important use-case for OREs is when a model commits a misclassification. Misclassifications in sentiment analysis tasks usually depend on over-sensitivity of the model to polarized terms. In this sense, knowing a minimal, sufficient reason behind the model's prediction can be useful to debug it. As shown in the first example in Figure 7, the model cannot recognize the double negation constituted by the terms not and dreadful as a syntax construct, hence it exploits the negation term not to classify the review as negative.
Comparison to Anchors. We evaluate the robustness of Anchors for FC and CNN models on the SST and Twitter datasets: accuracies are 0.89 for FC+SST, 0.82 for FC+Twitter, 0.89 for CNN+SST, and 0.77 for CNN+Twitter. To compute robustness, we assume a kNN-box perturbation space B with k = 15 for FC and k = 25 for CNN models. To extract Anchors, we set D to the standard perturbation distribution of [Ribeiro et al., 2018], defined by a set of contextwise perturbations generated by a powerful language model. Thus defined Bs are small compared to the support of D, and so one would expect high-precision Anchors to be relatively robust w.r.t. said Bs. On the contrary, the Anchors extracted for the FC models attain an average precision of 0.996 on SST and 0.975 on Twitter, but only 12.5% of them are robust for the SST case and 7.5% for Twitter. With CNN models, high-quality Anchors are even more brittle: 0% of Anchors are robust on SST reviews and 5.4% on Twitter, despite an average precision of 0.995 and 0.971, respectively.
We remark, however, that Anchors are not designed to provide such robustness guarantees. Our approach becomes useful in this context, because it can minimally extend any local explanation to make it robust, by using include constraints as explained in Section 3. In Figure 8 we show a few examples of how, starting from non-robust Anchors explanations, our algorithm can find the minimum number of words to make them provably robust.

6 Conclusions
We have introduced optimal robust explanations (OREs) and applied them to enhance interpretability of NLP models. OREs provide concise and sufficient reasons for a particular prediction, as they are guaranteed to be both minimal w.r.t. a given cost function and robust, in that the prediction is invariant for any bounded replacement of the left-out features. We have presented two solution algorithms that build on the relation between our OREs, abduction-based explanations and minimum satisfying assignments. We have demonstrated the usefulness of our approach on widely-adopted sentiment analysis tasks, providing explanations for neural network models beyond reach for existing formal explainers. Detecting biased decisions, debugging misclassifications, and repairing non-robust explanations are some of key use cases that our OREs enable. Future research plans include exploring more general classes of perturbations beyond the embedding space.
Acknowledgements
This project has received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (FUN2MODEL, grant agreement No. 834115) and the EPSRC Programme Grant on Mobile Autonomy (EP/M019918/1).
@inproceedings{ijcai2021p366,
title = {On Guaranteed Optimal Robust Explanations for NLP Models},
author = {La Malfa, Emanuele and Michelmore, Rhiannon and Zbrzezny, Agnieszka M. and Paoletti, Nicola and Kwiatkowska, Marta},
booktitle = {Proceedings of the Thirtieth International Joint Conference on
Artificial Intelligence, {IJCAI-21}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {Zhi-Hua Zhou},
pages = {2658--2665},
year = {2021},
month = {8},
note = {Main Track},
doi = {10.24963/ijcai.2021/366},
url = {https://doi.org/10.24963/ijcai.2021/366},
}
TY - CPAPER TI - On Guaranteed Optimal Robust Explanations for NLP Models AU - La Malfa, Emanuele AU - Michelmore, Rhiannon AU - Zbrzezny, Agnieszka M. AU - Paoletti, Nicola AU - Kwiatkowska, Marta T2 - Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, IJCAI-21 PB - International Joint Conferences on Artificial Intelligence Organization PY - 2021 SP - 2658 EP - 2665 DO - 10.24963/ijcai.2021/366 UR - https://doi.org/10.24963/ijcai.2021/366 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: