Explaining neural network models is important for increasing their trustworthiness in real-world applications. Most existing methods generate post-hoc explanations for neural network models by identifying individual feature attributions or detecting interactions between adjacent features. However, for models with text pairs as inputs (e.g., paraphrase identifi-cation), existing methods are not sufficient to capture feature interactions between two texts and their simple extension of computing all word-pair interactions between two texts is computationally inefficient. In this work, we propose the Group Mask (GMASK) method to implicitly detect word correlations by grouping correlated words from the input text pair together and measure their contribution to the corresponding NLP tasks as a whole. The proposed method is evaluated with two different model architectures (decomposable attention model and BERT) across four datasets, including natural language inference and paraphrase identification tasks. Experiments show the effectiveness of GMASK in providing faithful explanations to these models 1 . Explaining deep neural networks is critical for revealing their prediction behaviors and enhancing the trustworthiness of applying them in real-world applications. Many methods have been proposed to explain neural network models from the posthoc manner that generates faithful explanations based on model predictions (Ribeiro et al., 2016; Lundberg and Lee, 2017; Sundararajan et al., 2017; Guidotti et al., 2018). Most existing work focuses on identifying word attributions (Rocktschel et al., 2015; Li et al., 2016; Thorne et al., 2019) for NLP tasks. Knowing which individual features are important might not be enough for explaining model 1 Code for this paper is available at https://github. behaviors. Then, other recent work exploits feature interactions as explanations (Singh et al., 2018; Chen et al., 2020; Tsang et al., 2020). However, they could suffer computation inefficiency while computing interactions between all word pairs, and they also fall short for identifying multiple important words correlated from different input sources for predictions. Such intuitions are particularly important for explaining sentence pair modeling tasks such as natural language inference (NLI) (Bowman et al., 2015) and paraphrase identification (PI) (Yin and Schtze, 2015). Figure 1 shows an example of NLI, where the model makes correct prediction as CONTRADICTION . The first column visualizes individual word attributions to the prediction, where the top four important words are man , banjo , guitar , a . However, the correlations between them are unclear and intuitively man and a are irrelevant to the model prediction, which makes the explanation untrustworthy. A good explanation should be able to capture correlated words between the sentence pair, and identify their importance to the model prediction. In this work, we propose Group Masks (GMASK), a model-agnostic approach that considers the importance of correlated words from two input sentences. In particular, it distributes correlated words into a group and learns the group importance. In Figure 1, the input words are distributed in four groups with importance G 2 > G 1 > G 3 > G 4 . The color saturation of purple lines represents the probability of a word belonging to a group. Different from individual word attributions, GMASK assigns electric , guitar , and banjo into important groups ( G 2 /G 1 ), while man and a into unimportant groups ( G 3 /G 4 ). The weighted word attributions computed as the weighted sum of group importance identify the important words electric , guitar from x 1 and banjo from x 2 , which explains the model prediction. The contribution of this work is three-fold: (1) we introduce GMASK method to explain sentence pair modeling tasks by learning weighted word attributions based on word correlations; (2) we propose a sampling-based method to solve the optimization objective of GMASK; and (3) we evaluate the proposed method with two types neural network models (decomposable attention model (Parikh et al., 2016) and BERT (Devlin et al., 2018)), for two types of sentence pair modeling tasks on four datasets. Experiments show the superiority of GMASK in generating faithful explanations compared to other competitive methods. Many approaches have been proposed to explain deep neural networks from the post-hoc manner, such as gradient-based explanation methods (Hechtlinger, 2016; Sundararajan et al., 2017), attention-based methods (Ghaeini et al., 2018; Serrano and Smith, 2019), and decomposition-based methods (Murdoch et al., 2018; Du et al., 2019). However these white-box explanation methods are either rendering doubt regarding faithfulness (Jain and Wallace, 2019; Wiegreffe and Pinter, 2019) or being limited to specific neural networks. In this work, we mainly focus on model-agnostic explanation methods, which are applicable to any black-box models. Feature attributions Many approaches explain models by assigning feature attributions to model predictions. For example, perturbation-based methods quantify feature attributions by erasing features (Li et al., 2016) or using local linear approximation as LIME (Ribeiro et al., 2016). KernelSHAP (Lundberg and Lee, 2017) utilized Shapley values (Shapley, 1953) to compute feature attributions. Another line of work proposed learning feature attributions, such as L2X (Chen et al., 2018) which maximizes mutual information to recognize important features, and IBA (Schulz et al., 2020) which identifies feature attributions by optimizing the information bottleneck (Tishby et al., 2000). However, these approaches produce individual word attributions without considering feature correlations. Our proposed method implicitly detects correlated words and generates weighted word attributions. Feature interactions Some work proposed to generate explanations beyond word-level features by detecting feature interactions. Murdoch et al. (2018) proposed contextual decomposition (CD) to compute word interactions and Singh et al. (2018) and Jin et al. (2019) further proposed hierarchical versions based on that. Other work adopted Shapley interaction index to compute feature interactions (Lundberg et al., 2018) and build hierarchical explanations (Chen et al., 2020). However, computing feature interactions between all word pairs is computationally inefficient (Tsang et al., 2018). Methods which only consider the interactions between adjacent features are not applicable to sentence pair modeling tasks as critical interactions usually form between words from different sentences. GMASK distributes correlated words from the input text pair into a group, and learns the group importance, without explicitly detecting feature interactions between all word pairs. Word masks Some related work utilized word masks to select important features for building interpretable neural networks (Lei et al., 2016; Bastings et al., 2019) or improving the interpretability of existing models (Chen and Ji, 2020). De Cao et al. (2020) proposed to track the information flow of input features through the layers of BERT models. Different from the prior work, GMASK applies masks on a group of correlated words. This section introduces the proposed GMASK method. GMASK implicitly learns word correlations, and distributes correlated words from different input sentences into a group. GMASK learns the importance of each group by randomly masking out groups of words. Finally, the weighted word attributions are computed based on word group distributions and group importance. As the left part of Figure 2 shows, the word masks are applied on input word embeddings, learning to select important words to explain the model prediction. For each input data, we generate a post-hoc explanation by learning a set of mask values which represent the word attributions. For sentence pair modeling tasks, the input contains two sentences x 1 = [ x T 1 , 1 , . . . , x T 1 ,n 1 ] T and x 2 = [ x T 2 , 1 , . . . , x T 2 ,n 2 ] T , where x i,j  R d ( i  { 1 , 2 } , j  { 1 , . . . , n i } ) represents the word embedding and n 1 and n 2 are the number of words in the two texts respectively. We denote the neural network model as f (  ) which takes x 1 and x 2 as input and outputs a prediction label y = f ( x ) , where x = [ x 1 , x 2 ] T . To explain the model prediction, we learn a set of word masks W = [ W 1 , 1 , . . . , W 1 ,n 1 , W 2 , 1 , . . . , W 2 ,n 2 ] T to identify important words by multiplying the masks with input word embeddings,  x = W (cid:12) x , (1) where (cid:12) is an element-wise multiplication, the masked input  x = [  x 1 ,  x 2 ] T ,  x i,j = W i,j  x i,j ( i  { 1 , 2 } , j  { 1 , . . . , n i } ), and W i,j  { 0 , 1 } is a binary random variable with 1 and 0 indicating to select or mask out the word x i,j respectively. To generate an effective explanation, the word masks W should have the following properties: (1) correctly selecting important words for the model prediction; (2) removing as many irrelevant words as possible to keep the explanation concise; (3) selecting or masking out correlated words together from the sentence pair. Previous work on learning individual word masks only focuses on the first two properties (Chen and Ji, 2020; De Cao et al., 2020). To satisfy the third property, We propose GMASK to implicitly detect word correlations and distribute the correlated words into a group (e.g. electric , guitar , and banjo are assigned to G 1 or G 2 in Figure 1), and learn a group mask for these words. Specifically, we decompose each W i,j in W into two random variables, W i,j = t (cid:88)  =1  ( Z i,j ,  )  ( G,  ) , (2) where t is the predefined number of groups, and we will introduce how to pick up a t in subsection 3.3. Z i,j  { 1 , . . . , t } indicates the word x i,j belonging to which group, and G  { 1 , . . . , t } indicates which group takes the mask value 1, which means all words in this group are selected as important words, while other words in the rest groups are masked out. ( a, b ) is the Delta function with  ( a, b ) = 1 when a = b , and 0 otherwise. The conditional dependency of W , Z , and G can be represented as a graphical model 2 . The problem of learning W is equivalent to learning Z and G , that 2 Z  W  G : Z and G are dependent given W . is learning word distributions among the groups and group importance. According to  ( Z i,j ,  ) and  ( G,  ) , the word masks W will keep or mask out all words in group  , which satisfies the third property. where  and  are parameters of Z and G respectively, and z and g are samples of Z and G respectively. We denote LZ and LG as regularizations on Z and G respectively, which are applied to make the learned masks satisfy the required properties. We will introduce the two regularization terms subsequently. 1 ,  2  R + are coefficients. Optimizing the first term in Equation 3 is to make the word masks W satisfy the first property, that is the model outputs the same prediction on the selected words as on the whole text. Given Z and G , we have word masks W , and multiply them with input word embeddings, and obtain the masked input  x as in Equation 1. The model output on  x is  y = f (  x ) . If the masks correctly select important words, the predicted label on the selected words should be equal to that on the whole input text. We can optimize the first term by minimizing the cross entropy loss ( L ce (  ,  ) ) between  y and y . The objective Equation 3 can be rewritten as min  ,  L ce ( y,  y ) +  1 LZ +  2 LG . The last two terms in the optimization objective are to make word masks satisfy the second and third properties. We regularize Z to encourage each group contains some words from different sentences. We regularize G to ensure only one or few groups are identified as important (with relatively large probabilities). Optimizing the cross entropy loss with the two regularization terms can make the word masks select the important group of words, where the words are selected from the input sentence pair and are correlated. Regularizations on Z and G As each Z i,j ( i  { 1 , 2 } , j  { 1 , . . . , n i } ) indicates a word belonging to a specific group, it follows categorical distribution with probabilities [  i,j (1) , . . . ,  i,j ( t )] , where t is the predefined number of groups, and  i,j (  ) (   { 1 , . . . , t } ) represents the probability of the word in group  . Then we denote the parameters of Z as  ,  =    1 , 1 (1)     1 , 1 ( t ) ...    ...  1 ,n 1 (1)     1 ,n 1 ( t )  2 , 1 (1)     2 , 1 ( t ) ...    ...  2 ,n 2 (1)     2 ,n 2 ( t )   (5) To ensure that each group contains some words from both input sentences, and also avoid assigning a bunch of words into one group, we distribute the words in each sentence evenly among all groups. Then each group implicitly captures the words from different sentences. We can regularize Z to achieve this goal. We sum each column of  along the upper half rows and lower half rows respectively, and obtain two vectors by taking averages,  U = 1 n 1 [ (cid:80) n 1 j =1  1 ,j (1) , . . . , (cid:80) n 1 j =1  1 ,j ( t )] ,  L = 1 n 2 [ (cid:80) n 2 j =1  2 ,j (1) , . . . , (cid:80) n 2 j =1  2 ,j ( t )] . Then  U and  L are the distributions of two discrete variables ZU and ZL , which also represent the word distributions of the two input sentences among groups. To make the distributions of words even, we maximize the entropy of ZU and ZL , and have LZ =  ( H ( ZU ) + H ( ZL )) , (6) where H (  ) is entropy. G  { 1 , . . . , t } also follows categorical distribution with probabilities  = [  (1) , . . . ,  ( t )] , where  (  ) (   { 1 , . . . , t } ) represents the probability of group  being selected. According to the relation of W , Z , G in Equation 2, the word masks only keep the words assigned to the selected group. To ensure one or few groups have relatively large probabilities to be selected, we regularize G by minimizing its entropy, that is LG = H ( G ) . The final optimization objective is min  ,  L ce ( y,  y )   1 ( H ( ZU )+ H ( ZL ))+  2 H ( G ) . Optimization via sampling We adopt a sampling based method to solve Equation 7 by learning the parameters of Z and G (i.e. {  ,  } ). As the right part of Figure 2 shows, we sample a z from the categorical distributions of Z , where each row z i,j is a one-hot vector, indicating the word x i,j assigned to a specific group. And we sample a g from the categorical distribution of G , which is a vertical one-hot vector, indicating the selected group. Then we obtain a sample of word masks by multiplying z and g , i.e. w = z  g , where the mask values corresponding to the words in the selected group are 1, while the rest are 0. We apply the masks on the input word embeddings and optimize Equation 7 via stochastic gradient descent. There are two challenges of the learning process: discreteness and large variance. We apply the Gumbel-softmax trick (Jang et al., 2016; Maddison et al., 2016) to address the discreteness of sampling from categorical distributions in backpropagation. See Appendix A for the continuous differentiable approximation of Gumbel-softmax. We do the sampling multiple times in subsection 3.3 and generate a batch of masked inputs of the original input data to decrease the variance in probing the model, and train for multiple epochs until the learnable parameters {  ,  } reach stable values. Weighted word attributions After training, we learn the parameters of Z , i.e.  , where each element  i,j (  )  (0 , 1) ( i  { 1 , 2 } , j  { 1 , . . . , n i } ,   { 1 , . . . , t } ) represents the probability of word x i,j belonging to group  . We also learn the parameters of G , i.e.  , where each element  (  )  (0 , 1) represents the importance of group  . According to the definition of word masks W in subsection 3.1, we know that each mask variable W i,j follows Bernoulli distribution, and the probability of W i,j taking 1 is denoted as  i,j . We can compute  i,j based on the relation of W i,j , Z i,j and G in Equation 2, that is  i,j = t (cid:88)  =1  i,j (  )  (  ) . We can see that  i,j is the expectation of W i,j , representing the weighted attribution of the word x i,j to the model predicition. Hence, we have a set of weighted word attributions  = [  1 , 1 , . . . ,  1 ,n 1 ,  2 , 1 , . . . ,  2 ,n 2 ] T for extracting important words as an explanation. Complexity For a set of n words, computing interactions between all word pairs costs O ( n 2 ) and aggregating words step by step to form a tree structure even costs more time (Singh et al., 2018; Chen et al., 2020). GMASK circumvents the feature interaction detection by learning word groups. The complexity is O ( nt + t ) , where t is the number of groups and usually t (cid:28) n in practice. We initialize the parameters of all categorical distributions ( {  ,  } ) with 1 t , which means all words have the same importance and do not have any preference to be in a specific group at the start of training. To stabilize the learning process, we sample 100 1000 examples (depending on the model and datasets) and train at most 100 epochs until converge. The coefficients  1 and  2 are hyperparameters. We empirically found  1 = 10 and  2 = 1 work well in our experiments. In our pilot experiments, we found that preliminarily filtering out some noisy or irrelevant words can help decrease the learnable parameters, hence accelerating the training process. Specifically, we adopt a simple word mask method from (Chen and Ji, 2020) to select a set of individual words for an input sentence pair before running GMASK. This simple method, denoted as IMASK, will learn individual word attributions as masks R = { R i,j } i { 1 , 2 } , j { 1 ,...,n i }  { 0 , 1 } n 1 + n 2 regardless any correlation. Then, based on the expected values of R , we preliminarily select top k words for GMASK to further learn weighted word attributions. Within these top k words, assume k 1 words from the first input text and k 2 words from the second text, then we will set the number of groups as t = min( k 1 , k 2 ) , so that at least one group contains words from both sentences. k is a hyper-parameter associated with the average length of input texts. In the experiments, we set k = 10 . Note that, the IMASK method adopted here can also be used as a baseline method for comparison. We evaluate GMASK with two kinds of neural network models, decomposable attention model (DAttn) (Parikh et al., 2016) and BERT (Devlin et al., 2018), for two types of sentence pair modeling tasks on four datasets. We compare our method with four baselines. Datasets e-SNLI (Camburu et al., 2018) is natural language inference task, where the model predicts the semantic relationship between two input sentences as entailment, contradiction, or neutral. Quora (Wang et al., 2017), QQP (Wang et al., 2018) and MRPC (Dolan and Brockett, 2005) are paraphrase identification tasks, where the model Models e-SNLI Quora QQP MRPC DAttn 86.62 86.78 85.00 68.30 BERT 90.38 90.48 89.00 83.70 Table 1: The prediction accuracy (%) of different models on the four datasets. decides whether two input texts are semantically equivalent or not. The statistics of the four datasets are in Appendix B. Models We adopt the decomposable attention model (DAttn) (Parikh et al., 2016) and BERT (De-vlin et al., 2018) model, and fine-tune the models on each downstream task to achieve the best performance, as Table 1 shows. The test results on QQP and MRPC are scored by the GLUE benchmark 3 . The corresponding validation accuracy for each reported test accuracy is in Appendix C Baselines We compare GMASK with four baseline methods: (1) LIME (Ribeiro et al., 2016)-fitting a local linear model with perturbations to approximate the neural network and produce word attributions; (2) L2X (Chen et al., 2018)-constructing a network to learn feature attributions by maximizing the mutual information between the selected features and model output; (3) IBA ( Per-Sample framework) (Schulz et al., 2020) learning feature attributions by optimizing the information bottleneck which restricts feature information flow by adding noise; (4) IMASK (subsection 3.3)-learning individual word masks. Note that here we use stan-dalone IMASK as one of the baselines, as oppose to applying it for selecting preliminary important words for GMASK as in subsection 3.3. We compare the faithfulness of generated post-hoc explanations via both quantitative and qualitative evaluations. We adopt three metrics from prior work to evaluate the faithfulness of learned feature attributions: AOPC score (Nguyen, 2018; Samek et al., 2016), post-hoc accuracy (Chen et al., 2018; Chen and Ji, 2020), and degradation score (Ancona et al., 2017; Schulz et al., 2020). We evaluate explanations on all test data for the MRPC dataset, and on 2000 examples randomly selected from the test set for other three datasets due to computational complexity. The average runtime is in Appendix D. 5.1.1 AOPC score We adopt the area over the perturbation curve (AOPC) (Nguyen, 2018; Samek et al., 2016) metric to evaluate the comprehensiveness of explanations to models. It calculates the average change of prediction probability on the predicted class over all examples by removing top 1 . . . u words in explanations. where p ( y | x \ 1 ...u ) is the probability for the predicted class when words 1 . . . u are removed and (cid:104)(cid:105) x denotes the average over all test examples. Higher AOPC score indicates better explanations. Table 2 shows the results of AOPC scores of different explanation methods when U = 10 . GMASK outperforms other baseline methods on most of the datasets. Especially for the BERT model, GMASK achieves significantly higher AOPC scores than other methods, indicating that BERT tends to rely on word correlations to make predictions. IBA and IMASK, either learning continuous or binary individual word masks, perform better than learning word attributions via an additional network (L2X) or using linear approximation (LIME). The post-hoc accuracy (Chen et al., 2018; Chen and Ji, 2020) evaluates the sufficiency of important words to the model prediction. For each test data, we select top v important words based on word attributions for the model to make a prediction, and compare it with the original prediction made on the whole input text. We compute the post-hoc accuracy on M examples, post-hoc-acc ( v ) = 1 MM (cid:88) m =1 1 [ y ( m ) v = y ( m ) ] , where y ( m ) is the predicted label on the m-th test data, and y ( m ) v is the predicted label based on the top v important words. Higher post-hoc accuracy indicates better explanations. Figure 3 shows the results of post-hoc accuracy of different explanation methods where we increase v from 1 to 10. Similar to the results of the AOPC scores, GMASK achieves higher post-hoc accuracy than other methods for both DAttn and BERT models. The explanations of GMASK for the BERT model achieve about 80% post-hoc accuracy on all datasets except the MRPC dataset. This is only by relying on top 4 important words, which means that GMASK captures informative words for model predictions. The post-hoc accuracies of the BERT model on the MRPC dataset are lower than those on other three datasets because the average sentence length of MRPC is twice as long as the others, indicating that BERT tends to use larger context for predictions. The post-hoc accuracies of the DAttn model on the MRPC dataset are extremely high for all the explanation methods. The reason is that the prediction accuracy of DAttn model on the MRPC dataset is relatively low (Table 1). Any random words picked up by explanations could make the model output wrong predictions since the original predictions on the whole texts are also wrong, hence causing high post-hoc accuracy. Degradation test (Ancona et al., 2017; Schulz et al., 2020) evaluates the ranking of importance by removing the most important words or least important words first, and observing model prediction probability drop on the predicted class. We draw Models Methods Texts DAttn LIME a man playing an electric guitar on stage . two curves as shown in Figure 4, one with the most relevant words removed first (MoRF) and another one with the least relevant words removed first (LeRF). x-axis is the percentage of words removed (degradation proportion), and y-axis is the normalized model output probability as S ( x  ) = p ( y | x  )  p ( y | x o ) p ( y | x )  p ( y | x o ) , (10) where x is the original input, y is the predicted label, x  means  %(   [0 , 100]) degradation of x , and x o is full degradation. We compute the averages of p ( y | x  ) , p ( y | x ) , and p ( y | x o ) over all test examples. The degradation score is calculated as the integral between the MoRF and LeRF curves, degra-score = (cid:90) 100  =0 SL ( x  )  SM ( x  ) 100 d, (11) where SL ( x  ) and SM ( x  ) are normalized model outputs by removing the least or most important words respectively. Higher degradation score is better. Table 4 shows the results of degradation scores of different explanation methods. GMASK shows superiority to other baseline methods under this metric. Figure 4 shows the degradation test results of DAttn model on the e-SNLI dataset. GMASK can distinguish both important and unimportant words, while IBA does not learn the correct order of unimportant words. LIME does not perform well in identifying important words, but captures the correct order of unimportant words. The MoRF and LeRF curves of L2X and IMASK are relatively symmetric, but not as expanded as GMASK. Table 3 shows different explanations on two examples from e-SNLI and Quora respectively. See Appendix E for more examples. For the first example, the DAttn model makes a correct prediction as CONTRADICTION . For the second example, the BERT model also makes a correct prediction as PARAPHRASES . We highlight the top four important words, where the words in the first and second sentences are in pink and blue colors respectively. The color saturation indicates word attribution. For the first example, LIME and IBA mainly capture the important words from the first sentence, while ignoring the ones in the second sentence (e.g. banjo , floor ). On the contrary, L2X focuses on the words in the second sentence, while ignoring the important word guitar in the first sentence. IMASK picks up two irrelevant words man and a as important words, which can not explain the model prediction. GMASK correctly identifies top four important words and captures two correlated words guitar and banjo from the two input sentences respectively. For the second example, only GMASK captures the two important correlated words horned and horns , which explains why the BERT model predicts the two input questions as paraphrases. LIME captures the overlapped word helmets in the two sentences, while L2X only selects some irrelevant words. Both IBA and IMASK identify a question mark as the important word, which is untrustworthy to the model prediction. In this paper, we focused on sentence pair modeling and proposed an effective method, GMASK, learning group masks for correlated words and calculating weighted word attributions. We tested GMASK with two different neural network models on four datasets, and assessed its effectiveness via both quantitative and qualitative evaluations. The motivation of this work is aligned with the merits of explainable AI, in which the goal is to increase the trustworthiness of neural network models in decision making. One potential ethical concern of this work is that explanations can be used to design adversarial examples for attacking. Although the main focus of this work is about generating faithful explanations, we do realize the importance of whether human users can actually understand explanations. To address this concern, a better strategy is to collaborate with HCI experts in our future work. In addition, we provide necessary implementation details to make sure the results in this paper are reproducible.
abstain abstain abstain objective abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain objective abstain abstain abstain abstain abstain other abstain other other method other other other other other objective other other other other other other other other other abstain abstain abstain abstain abstain method other method method abstain abstain method method abstain abstain abstain abstain abstain abstain abstain method method abstain abstain method abstain abstain method abstain abstain method method abstain other method abstain method method abstain method abstain abstain method abstain method method method method method abstain method abstain method method method method method method method abstain abstain abstain method method abstain method method method abstain method method abstain method abstain method method abstain abstain abstain method abstain method method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain result abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain objective abstain abstain method method abstain abstain