Paper commentary
Analysis Methods in Neural Language Processing: A Survey
Survey reviews how researchers analyze and interpret neural language processing models
- Problem End-to-end neural NLP models have no named features to inspect, so their linguistic knowledge is hard to read off. Feature-based systems allowed direct inspection of how each feature was weighted.
- Method The authors review analysis methods in neural language processing and group them into prominent research trends. They also point out existing limitations and possible directions for future work.
- Results The survey finds that neural NLP models learn a substantial amount of linguistic information, though rare properties are harder to learn. NMT encodings predicted tense about 90% of the time, yet only 79% of outputs had correct tense.
Why end-to-end NLP models are hard to read
End-to-end neural networks now lead many NLP tasks, including language modeling, syntactic parsing and machine translation. Feature-rich systems used features a person could name, such as morphological properties, lexical classes and syntactic categories. Such features could be inspected, since one could observe how a statistical model weighted them.
An end-to-end network instead takes input such as word embeddings and generates an output such as a sentence classification. Because no named feature is visible inside that network, much analysis work asks which linguistic concepts from feature-based NLP end up captured in it.
Interpretability is debated more broadly in machine learning, and the debate also shapes how NLP researchers view their models. Opponents typically stress performance as the most important desideratum. The authors argue that all these arguments naturally apply to machine learning applications in NLP. So the question of why to analyze NLP models is not only a general machine learning concern.
The effort to read neural networks is older than the recent deep learning revival. Elman trained recurrent neural networks on synthetic sentences in a language prediction task. Through extensive analyses, he showed that networks discover the notion of a word when predicting characters. His networks also captured syntactic structures like number agreement and acquired word representations reflecting lexical and syntactic categories.
Elman's methods, such as visualizing activations in time and clustering words by hidden state activations, remain relevant today.
Probing classifiers and what they reveal
Probing starts by training a network on a task such as MT and then freezing its weights. The trained model then runs on a corpus with linguistic annotations, and its hidden state activations are recorded as feature representations. A separate classifier predicts a property of interest, such as part-of-speech tags, from those recorded representations.
That classifier's performance serves as a proxy for the quality of the representations, and so for the original model. The same setup goes by several names: auxiliary prediction tasks, diagnostic classifiers and probing tasks.
Shi et al. (2016b) applied this recipe to analyze syntax in NMT, training two models, English→French and English→German. They ran the trained encoders on an annotated corpus and fed their hidden states to a logistic regression classifier. Comparing encoding layers, the lower layer preserved local features, while the upper layer stored more global, abstract information.
Because the probe runs on each layer, the comparison exposes structure inside a single model, not only across models.
Some studies skip the classifier and compute correlations between activations and a property directly. Alishahi et al. (2017) instead defined an ABX discrimination task, asking whether the representation of X is closer to A or to B. Their phoneme-level test showed that lower layers generally encode more phonological information.
A probe's success doesn't by itself show that the network uses the information it finds. Vanmassenhove et al. (2017) trained a classifier on NMT sentence encodings that predicted tense about 90% of the time. The output translations had the correct tense only 79% of the time, so the authors suggest decoding loses some aspect information. Cífka and Bojar (2018) found a negative correlation between translation quality (BLEU) and representation quality across NMT models.
Artetxe et al. (2018) showed that a linear transformation can uncover linguistic information that word embeddings contain but do not surface directly.
Most analysis work measures correlation, which leaves open whether an encoded property affects the system output. That intervention improved agreement prediction accuracy, and the effect persisted over the rest of the sentence. They didn't report the effect on overall model quality, such as perplexity. The probes are usually simple classifiers, and deeper ones gave better results without changing the trends across models.
Still, the auxiliary-task approach is usually taken for granted, lacking a solid theoretical or empirical foundation.
What linguistic information the networks encode
Neural networks in NLP appear to learn a substantial amount of information on many linguistic phenomena. Frequent properties are captured especially well, while some rare properties are harder for the models to learn. The authors note that it is difficult to synthesize a holistic picture from this diverse body of work. The probed information covers properties from sentence length and word order up to morphological, syntactic, and semantic information.
Linzen et al. (2016) found that LSTM language models capture subject-verb agreement in many common cases. Harder cases, however, needed direct supervision to be solved. This result shows a split: the frequent cases are learned from raw text, while the rare ones are not.
Models trained with latent trees perform better on NLI (Williams et al., 2018; Maillard and Clark, 2018) than models trained with linguistically-annotated trees. The learned trees don't resemble syntactic trees from known linguistic theories. That result casts doubt on how much syntax learning actually happens in the underlying network.
Probing is not proof of use: a classifier can find information that the network doesn't rely on. Vanmassenhove et al. (2017) trained a classifier on NMT sentence encodings and predicted tense about 90% of the time. When they evaluated the output translations, the correct tense appeared only 79% of the time. The authors read this gap as evidence that part of the aspectual information is lost during decoding.
What visualization shows, and how little of it is checked
Visualization plots activations on specific examples, such as a heatmap of a neuron that captures the position of words in a sentence. The heatmap uses blue and red for negative and positive activation values, so a reader can quickly grasp what the neuron does. The attention mechanism from NMT also lends itself to a natural visualization of alignments.
Bahdanau et al. showed grayscale attention weights between English source words in columns and French translation words in rows. The same figure also shows word order, such as the reordering of noun and adjective in the phrase “European Economic Area”.
Saliency methods compute measures that attribute a prediction to input features. The salient features can then be displayed in selected examples. Clustering is another technique, which groups neural network activations and compares them to a linguistic property. Elman clustered RNN activations and found that they organize in lexical categories.
LSTMVis visualizes RNN activations and focuses on tracing hidden state dynamics. Seq2Seq-Vis visualizes modules of attention-based seq2seq models, so users can examine decisions and test alternative ones. Rikters built a tool for comparing attention alignments that also gives translation confidence scores from the attention weight distribution.
NeuroX finds and analyzes individual neurons, with a focus on machine translation.
Evaluating visualization quality is hard, and most work stays with qualitative examples. Singh et al. (2018) asked humans to judge hierarchical clusterings of input words produced by two interpretation methods. Singh et al. asked which method is more accurate, or which one the humans trusted more. Freeman et al. (2018) and Mullenbach et al.
(2018) also ran human evaluations, on attention visualization in conversation modeling and medical code prediction. The authors note it remains to be seen how useful these visualizations turn out to be.
Challenge sets for fine-grained evaluation
Challenge sets, also called test suites, target phenomena that average-case benchmarks may miss. Benchmarks drawn from text corpora mirror the natural frequency distribution of language phenomena, so rare cases get little weight. Lehmann et al. (1996) named systematicity and exhaustivity as key properties, alongside control over data and negative examples.
Lehmann et al. set test suites against test corpora, whose chief strength is that they mirror real usage.
Most recent challenge sets target NLI and MT, since these tasks need inference at several linguistic levels. Reading comprehension and question answering have received less attention, though they could benefit from careful challenge sets. The GLUE analysis set for NLI covers more than 30 phenomena in four coarse categories. Burchardt et al.
(2017) reported MT results on a test suite covering 120 phenomena.
Hand-built challenge sets are typically in the hundreds of examples. Linzen et al. (2016) extracted subject-verb agreement examples from raw texts with heuristics, reaching more than one million examples. A few manually constructed datasets contain up to 10K examples.
The vast majority of challenge sets are in English, which makes MT the main exception. The MT datasets feature other languages, so multilingual coverage comes mostly from that task. Gulordava et al. (2018) covered number agreement in English, Russian, Hebrew and Italian. Systems are usually scored with the original metric or a proxy, such as the contrastive pairs used by Sennrich.
Adversarial examples for discrete text
An adversarial example is a slightly changed input that a model assigns a different label to. The attacker seeks an x′ with minimal distance from x, where f(x) = l and f(x′) = l′ with l ≠ l′. For images, the distance ||x − x′|| is straightforward to measure, and gradients with respect to the input can find x′ because all quantities are continuous.
Text is discrete, such as a sequence of words, so this breaks in two places. First, it is unclear how to measure the distance between two discrete objects, such as two words or sentences. Second, minimizing that distance can't be cast as a simple optimization problem, because it requires gradients with respect to a discrete input.
The paper organizes attacks by the adversary's knowledge, the attack's specificity, the linguistic unit modified, and the task attacked. White-box attacks need gradients with respect to the input, which is discrete for text, so the authors call them difficult to adapt. One option computes gradients with respect to the input word embeddings and perturbs the embeddings.
Ebrahimi et al. (2018b) instead represent text edit operations as a vector, such as a binary vector marking which characters would change, and approximate the change in loss along that vector. Because white-box generation is hard for text, much research uses black-box examples. Black-box attacks often borrow edits humans might make naturally, such as typos and misspellings.
Zhao et al. (2018c) used GANs to minimize the distance between latent representations and perturbed in latent space, which is a black-box attack because those representations need not come from the attacked model. Alzantot et al. (2018) used a population-based genetic algorithm that does not require model parameters, but it does use prediction scores.
Targeted attacks specify a particular false class l′, while non-targeted attacks only require the predicted class to be wrong. Targeted attacks are harder to generate because they typically need knowledge of model parameters, so they are white-box attacks. The authors suggest this might explain why most adversarial examples in NLP are non-targeted.
Liang et al. (2018) specified a desired class to fool a text classifier. Most work modifies text at the character or word level, while some add sentences or text chunks.
In the text domain, measuring distance isn't as straightforward as in images, and even small edits may be perceptible to humans. Some studies limit the number of edit operations, as Gao et al. (2018) did. Others filter replacements by word or sentence similarity, as in Alzantot et al. (2018) and Kuleshov et al. (2018). Some report whether a human classifies the adversarial example correctly, but that doesn't show how perceptible the changes are.
Explaining individual predictions
Explaining a single prediction is a desideratum that the survey treats as hard for deep neural networks. An alternative approach uses parts of the input as explanations instead. They evaluated these rationales on sentiment analysis.
They then found the most relevant associations among those perturbations. Gupta and Schütze (2018) inspected how information accumulates in RNNs toward a prediction. They associated peaks in prediction scores with important input segments.
These input-based methods show which input segments matter, but they don't reveal the internal computations of the network. Relatively little work has gone beyond visualizations for explaining predictions. Our ability to explain predictions of neural networks in NLP is still limited.
Open problems in analysis methods for neural NLP
Auxiliary classification tasks have become standard practice for finding which linguistic properties neural networks capture. The approach is usually taken for granted, and the survey argues it lacks a theoretical foundation. Researchers don't yet have a firm account of when a probe's success says anything about how the original model uses that information.
Explaining predictions is the weakest area, since the survey finds relatively little work beyond visualizations. Input-based methods, such as the rationale generator of Lei et al. (2016), show which input segments matter. The survey calls for progress here because of the increasing public demand for explaining algorithmic choices in machine learning systems.
The vast majority of challenge sets are in English, with MT as the partial exception. In MT evaluation, all datasets feature other languages, so the gap is smaller there. Gulordava et al. (2018) constructed number agreement examples for English, Russian, Hebrew, and Italian, which is a notable exception. Beyond MT, the survey argues the field needs large-scale non-English datasets to develop neural models for popular NLP tasks.
Most challenge sets test NLI and MT, so more challenge sets for other tasks are needed.
Evaluation of analysis work is often limited or qualitative, especially for visualization techniques. Newer forms of evaluation are needed to determine the success of different methods.
Paper info
- Authors
- Yonatan Belinkov, James Glass
- Venue
- arXiv · Preprint
- First published
- 2018-12-21
- Added
- 2026-11-6
- Updated
- 2019-1-14
- Version
- v2
- arXiv
- 1812.08951
- Category
- cs.CL · cs.LG · cs.NE
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
The field of natural language processing has seen impressive progress in recent years, with neural network models replacing many of the traditional systems. A plethora of new models have been proposed, many of which are thought to be opaque compared to their feature-rich counterparts. This has led researchers to analyze, interpret, and evaluate neural networks in novel and more fine-grained ways. In this survey paper, we review analysis methods in neural language processing, categorize them according to prominent research trends, highlight existing limitations, and point to potential directions for future work.
Quote from the paper
Yonatan Belinkov, James Glass (2018). Analysis Methods in Neural Language Processing: A Survey. arXiv:1812.08951v2. https://arxiv.org/abs/1812.08951v2
BibTeX
@misc{belinkov2018analysis,
title = {{Analysis Methods in Neural Language Processing: A Survey}},
author = {Yonatan Belinkov and James Glass},
year = {2018},
eprint = {1812.08951},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1812.08951v2}
}