Introduction
Following seminal work by Bengio and Collobert, the use of deep learning models for natural language processing (NLP) applications received an increasing attention in recent years. In parallel, initiated by the computer vision domain, there is also a trend toward understanding deep learning models through visualization techniques BIBREF0 , BIBREF1 , BIBREF2 , BIBREF3 , BIBREF4 , BIBREF5 or through decision tree extraction BIBREF6 . Most work dedicated to understanding neural network classifiers for NLP tasks BIBREF7 , BIBREF8 use gradient-based approaches. Recently, a technique called layer-wise relevance propagation (LRP) BIBREF4 has been shown to produce more meaningful explanations in the context of image classifications BIBREF9 . In this paper, we apply the same LRP technique to a NLP task, where a neural network maps a sequence of word2vec vectors representing a text document to its category, and evaluate whether similar benefits in terms of explanation quality are observed.
In the present work we contribute by (1) applying the LRP method to the NLP domain, (2) proposing a technique for quantitative evaluation of explanation methods for NLP classifiers, and (3) qualitatively and quantitatively comparing two different explanation methods, namely LRP and a gradient-based approach, on a topic categorization task using the 20Newsgroups dataset.
Explaining Predictions of Classifiers
We consider the problem of explaining a prediction $f(x)$ associated to an input $x$ by assigning to each input variable $x_d$ a score $R_d$ determining how relevant the input variable is for explaining the prediction. The scores can be pooled into groups of input variables (e.g. all word2vec dimensions of a word, or all components of a RGB pixel), such that they can be visualized as heatmaps of highlighted texts, or as images.
Layer-Wise Relevance Propagation
Layer-wise relevance propagation BIBREF4 is a newly introduced technique for obtaining these explanations. It can be applied to various machine learning classifiers such as deep convolutional neural networks. The LRP technique produces a decomposition of the function value $f(x)$ on its input variables, that satisfies the conservation property:
$$f(x)= {\textstyle \sum _d} R_d.$$   (Eq. 3)
The decomposition is obtained by performing a backward pass on the network, where for each neuron, the relevance associated with it is redistributed to its predecessors. Considering neurons mapping a set of $n$ inputs $(x_i)_{i \in [1,n]}$ to the neuron activation $x_j$ through the sequence of functions: $ z_{ij} &= x_i w_{ij} + {\textstyle \frac{b_j}{n}}\\ z_j &= {\textstyle \sum _i} z_{ij}\\ x_j &= g(z_j) $
where for convenience, the neuron bias $b_j$ has been distributed equally to each input neuron, and where $g(\cdot )$ is a monotonously increasing activation function. Denoting by $R_i$ and $R_j$ the relevance associated with $x_i$ and $x_j$ , the relevance is redistributed from one layer to the other by defining messages $R_{i \leftarrow j}$ indicating how much relevance must be propagated from neuron $x_j$ to its input neuron $x_i$ in the lower layer. These messages are defined as: $ R_{i \leftarrow j} = \frac{z_{ij} + \frac{s(z_j)}{n}}{\sum _{i} z_{ij} + s(z_j)} R_j $
where $s(z_j) = \epsilon \cdot (1_{z_j \ge 0} - 1_{z_j < 0})$ is a stabilizing term that handles near-zero denominators, with $\epsilon $ set to $0.01$ . The intuition behind this local relevance redistribution formula is that each input $x_i$ should be assigned relevance proportionally to its contribution in the forward pass, in a way that the relevance is preserved ( $\sum _i R_{i \leftarrow j} = R_j$ ).
Each neuron in the lower layer receives relevance from all upper-level neurons to which it contributes $ R_i = {\textstyle \sum _j} R_{i \leftarrow j}. $
This pooling ensures layer-wise conservation: $\sum _i R_i = \sum _j R_j$ . Finally, in a max-pooling layer, all relevance at the output of the layer is redistributed to the pooled neuron with maximum activation (i.e. winner-take-all). An implementation of LRP can be found in BIBREF10 and downloaded from www.heatmapping.org.
Sensitivity Analysis
An alternative procedure called sensitivity analysis (SA) produces explanations by scoring input variables based on how they affect the decision output locally BIBREF11 , BIBREF12 . The sensitivity of an input variable is given by its squared partial derivative: $ R_d = \Big (\frac{\partial f}{\partial x_d} \Big )^2. $
Here, we note that unlike LRP, sensitivity analysis does not preserve the function value $f(x)$ , but the squared $l_2$ -norm of the function gradient:
$$\Vert  \nabla _{x} f(x) \Vert _2^2 = {\textstyle \sum _d} R_d.$$   (Eq. 6)
This quantity is however not directly related to the amount of evidence for the category to detect. Similar gradient-based analyses BIBREF7 , BIBREF8 have been recently applied in the NLP domain, and were also used by Simonyan in the context of image classification. While recent work uses different relevance definitions for a group of input variables (e.g. gradient magnitude in Denil2 or max-norm of absolute value of simple derivatives in Simonyan), in the present work (unless otherwise stated) we employ the squared $l_2$ -norm of gradients allowing for decomposition of Eq. 6 as a sum over relevances of input variables.
Experiments
For the following experiments we use the 20news-bydate version of the 20Newsgroups dataset consisting of 11314/7532 train/test documents evenly distributed among twenty fine-grained categories.
CNN Model
As a document classifier we employ a word-based CNN similar to Kim consisting of the following sequence of layers: $ \texttt {Conv} \xrightarrow{} \texttt {ReLU} \xrightarrow{} \texttt {1-Max-Pool} \xrightarrow{} \texttt {FC} \\ $
By 1-Max-Pool we denote a max-pooling layer where the pooling regions span the whole text length, as introduced in BIBREF13 . Conv, ReLU and FC denote the convolutional layer, rectified linear units activation and fully-connected linear layer. For building the CNN numerical input we concatenate horizontally 300-dimensional pre-trained word2vec vectors BIBREF14 , in the same order the corresponding words appear in the pre-processed document, and further keep this input representation fixed during training. The convolutional operation we apply in the first neural network layer is one-dimensional and along the text sequence direction (i.e. along the horizontal direction). The receptive field of the convolutional layer neurons spans the entire word embedding space in vertical direction, and covers two consecutive words in horizontal direction. The convolutional layer filter bank contains 800 filters.
Experimental Setup
As pre-processing we remove the document headers, tokenize the text with NLTK, filter out punctuation and numbers, and finally truncate each document to the first 400 tokens. We train the CNN by stochastic mini-batch gradient descent with momentum (with $l_2$ -norm penalty and dropout). Our trained classifier achieves a classification accuracy of 80.19%.
Due to our input representation, applying LRP or SA to our neural classifier yields one relevance value per word-embedding dimension. From these single input variable relevances to obtain word-level relevances, we sum up the relevances over the word embedding space in case of LRP, and (unless otherwise stated) take the squared $l_2$ -norm of the corresponding word gradient in case of SA. More precisely, given an input document $d$ consisting of a sequence $(w_1, w_2,..., w_N)$ of $N$ words, each word being represented by a $D$ -dimensional word embedding, we compute the relevance $R(w_t)$ of the $t^\mathrm {th}$ word in the input document, through the summation:
$$R(w_t) = \sum _{i=1}^{D} R_{i, t}$$   (Eq. 14)
where $R_{i, t}$ denotes the relevance of the input variable corresponding to the $i^\mathrm {th}$ dimension of the $t^\mathrm {th}$ word embedding, obtained by LRP or SA as specified in Sections "Layer-Wise Relevance Propagation" & "Sensitivity Analysis" .
In particular, in case of SA, the above word relevance can equivalently be expressed as:
$$R_{\mathrm {SA}}(w_t) = \Vert  \nabla _{{w_t}} f({d}) \Vert _2^2$$   (Eq. 15)
where $f({d})$ represents the classifier's prediction for document $d$ .
Note that the resulting LRP word relevance is signed, while the SA word relevance is positive.
In all experiments, we use the term target class to identify the function $f(x)$ to analyze in the relevance decomposition. This function maps the neural network input to the neural network output variable corresponding to the target class.
Evaluating Word-Level Relevances
In order to evaluate different relevance models, we perform a sequence of “word deletions” (hereby for deleting a word we simply set the word-vector to zero in the input document representation), and track the impact of these deletions on the classification performance. We carry out two deletion experiments, starting either with the set of test documents that are initially classified correctly, or with those that are initially classified wrongly. We estimate the LRP/SA word relevances using as target class the true document class. Subsequently we delete words in decreasing resp. increasing order of the obtained word relevances.
Fig. 1 summarizes our results.
We find that LRP yields the best results in both deletion experiments. Thereby we provide evidence that LRP positive relevance is targeted to words that support a classification decision, while LRP negative relevance is tuned upon words that inhibit this decision. In the first experiment the SA classification accuracy curve decreases significantly faster than the random curve representing the performance change when randomly deleting words, indicating that SA is able to identify relevant words. However, the SA curve is clearly above the LRP curve indicating that LRP provides better explanations for the CNN predictions. Similar results have been reported for image classification tasks BIBREF9 . The second experiment indicates that the classification performance increases when deleting words with the lowest LRP relevance, while small SA values points to words that have less influence on the classification performance than random word selection. This result can partly be explained by the fact that in contrast to SA, LRP provides signed explanations. More generally the different quality of the explanations provided by SA and LRP can be attributed to their different objectives: while LRP aims at decomposing the global amount of evidence for a class $f(x)$ , SA is build solely upon derivatives and as such describes the effect of local variations of the input variables on the classifier decision. For a more detailed view of SA, as well as an interpretation of the LRP propagation rules as a deep Taylor decomposition see MontavonArXiv15.
Document Highlighting
Word-level relevances can be used for highlighting purposes. In Fig. 2 we provide such visualizations on one test document for different relevance target classes, using either LRP or SA relevance models. We can observe that while the word ride is highly negative-relevant for LRP when the target class is not rec.motorcycles, it is positively highlighted (even though not heavily) by SA. This suggests that SA does not clearly discriminate between words speaking for or against a specific classifier decision, while LRP is more discerning in this respect.
Document Visualization
Word2vec embeddings are known to exhibit linear regularities representing semantic relationships between words BIBREF14 . We explore if these regularities can be transferred to a document representation, when using as a document vector a linear combination of word2vec embeddings. As a weighting scheme we employ LRP or SA scores, with the classifier's predicted class as the target class for the relevance estimation. For comparison we perform uniform weighting, where we simply sum up the word embeddings of the document words (SUM).
For SA we use either the $l_2$ -norm or squared $l_2$ -norm for pooling word gradient values along the word2vec dimensions, i.e. in addition to the standard SA word relevance defined in Eq. 15 , we use as an alternative $R_{\mathrm {SA}(l_2)}(w_t) = \Vert  \nabla _{{w_t}} f({d}) \Vert _2$ and denote this relevance model by SA $(l_2)$ .
For both LRP and SA, we employ different variations of the weighting scheme. More precisely, given an input document $d$ composed of the sequence $(w_1, w_2,..., w_N)$ of $D$ -dimensional word2vec embeddings, we build new document representations $d^{\prime }$ and $d^{\prime }_{\mathrm {e.w.}}$ by either using word-level relevances $R(w_t)$ (as in Eq. 14 ), or through element-wise multiplication of word embeddings with single input variable relevances $(R_{i, t})_{i \in [1,D]}$ (we recall that $R_{i, t}$ is the relevance of the input variable corresponding to the $i^{\mathrm {th}}$ dimension of the $(w_1, w_2,..., w_N)$0 word in the input document $(w_1, w_2,..., w_N)$1 ). More formally we use:
$$d^{\prime } \; = \; \sum _{t=1}^{N} \; {{R(w_t)} \cdot {w_t}}$$   (Eq. 23)
or
$$d^{\prime }_{\mathrm {e.w.}} \; = \; \sum _{t=1}^{N} \; { \begin{bmatrix} R_{1, t} \\ R_{2, t} \\ \vdots \\ R_{D, t} \end{bmatrix} \odot {w_t}}$$   (Eq. 24)
where $\odot $ is an element-wise multiplication. Finally we normalize the document vectors $d^{\prime }$ resp. $d^{\prime }_{\mathrm {e.w.}}$ to unit $l_2$ -norm and perform a PCA projection. In Fig. 3 we label the resulting 2D-projected test documents using five top-level document categories.
For word-based models $d^{\prime }$ , we observe that while standard SA and LRP both provide similar visualization quality, the SA variant with simple $l_2$ -norm yields partly overlapping and dense clusters, still all schemes are better than uniform weighting. In case of SA note that, even though the power to which word gradient norms are raised ( $l_2$ or $l_2^2$ ) affects the present visualization experiment, it has no influence on the earlier described “word deletion” analysis.
For element-wise models $d^{\prime }_{\mathrm {e.w.}}$ , we observe slightly better separated clusters for SA, and a clear-cut cluster structure for LRP.
Conclusion
Through word deleting we quantitatively evaluated and compared two classifier explanation models, and pinpointed LRP to be more effective than SA. We investigated the application of word-level relevance information for document highlighting and visualization. We derive from our empirical analysis that the superiority of LRP stems from the fact that it reliably not only links to determinant words that support a specific classification decision, but further distinguishes, within the preeminent words, those that are opposed to that decision.
Future work would include applying LRP to other neural network architectures (e.g. character-based or recurrent models) on further NLP tasks, as well as exploring how relevance information could be taken into account to improve the classifier's training procedure or prediction performance.
Acknowledgments
This work was supported by the German Ministry for Education and Research as Berlin Big Data Center BBDC (01IS14013A) and the Brain Korea 21 Plus Program through the National Research Foundation of Korea funded by the Ministry of Education.

Question: Do the experiments explore how various architectures and layers contribute towards certain decisions?
Answer: No