Structured Prediction in NLP -- A survey

Over the last several years, the field of Structured prediction in NLP has had seen huge advancements with sophisticated probabilistic graphical models, energy-based networks, and its combination with deep learning-based approaches. This survey provides a brief of major techniques in structured prediction and its applications in the NLP domains like parsing, sequence labeling, text generation, and sequence to sequence tasks. We also deep-dived into energy-based and attention-based techniques in structured prediction, identified some relevant open issues and gaps in the current state-of-the-art research, and have come up with some detailed ideas for future research in these fields.


Introduction
In structured prediction, we seek to predict structured outputs, which are essentially anything other than a scalar or categorical quantity. Many prediction problems in natural language processing, such as tagging, parsing, coreference resolution, and machine translation, require the prediction of outputs that are structured. For example, predicting a sequence of part-of-speech labels, a parse tree, a partition of a document's noun phrases, or a well-formed sentence, respectively. Intuitively, these sorts of predictions differ from those made in multi-class classification, in that the objects being predicted have an internal structure (unlike the discrete labels multi-class classification problems). This structured output is often found to be a useful intermediate representation for other applications. For example, downstream reasoning about the content of a news article may require predicting relational data about the individuals and events discussed in the text. The number of possible outputs for a particular input x also tends to be exponential in the size of x, which makes the problem challenging. Another major challenge in structured prediction is that often the inference becomes intractable.

HMMs, MEMMs, CRFs and Structured Perceptron
Hidden Markov Models [1] is a probabilistic graphical model which uses first order markov chain assumption and dependence of observed data only on emission states. HMM allows us to talk about both observed events and hidden events in our probabilistic model. The probability of a sequence(length=T ) is modeled as follows: p(y|x, θ) ∝ p(x, y, θ) = p(y 1 ) The forward algorithm allows to efficiently calculate the MLE or MAP estimate and Viterbi-style dynamic programming algorithm [2] can be used for inference. A clear drawback is that transition probabilities and emission probabilities do not encode any information other than the previous tag and also HMMs suffer from exposure bias problem and hence are often found to be quite inefficient.
Maximum Entropy Markov Models (MEMMs) [3] define a probabilistic model of sequences y ∈ Y = V T given an input sequence x, also of length T . The probability of a sequence is modeled as the product of locally normalized per-label distributions, as follows: MMEMs assume a first-order Markov assumption which means it assumes that the label y t given label y t−1 is independent of all the previous labels. This independence assumption allows for the arg max sequence to be calculated exactly with a Viterbi-style dynamic programming algorithm, similar to the inference in Hidden Markov Models. Also, this independence assumption gives features which only depend on x t , y t , and y t−1 for each t. As is evident from probability of sequence equation, the probability of a sequence y for an input x is the product of locally-normalized per-label probabilities. This leads to a problem known as label bias. [4] which uses global normalization and specifies the conditional distribution of a random variable Y given a random variable X with respect to the factorization implied by an undirected graphical model over X, Y . Distribution in a CRF following first-order markov property can be written as follows:

Condition Random Fields
Unlike MEMMs, the distribution p(y|x) is not the product of locally normalized distributions. It is rather globally normalized, using the partition function, and so this model does not suffer from label bias. Given the Markov assumptions implicit in the model above, we may again find the arg max sequence using a Viterbi-style algorithm. [5] has explained that computing the arg max, marginals or the partition function is usually not algorithmically efficient. Structured Perceptron [6] and structured SVM [7] based approaches only require efficiently compute the arg max, unlike CRFs which require computing many other marginals and partition function. These approaches are non-probabilistic, and they utilize a simple form for the score: Structured Perceptron and structured SVM are trained through gradient based approaches using margin and slack rescaling losses. These approaches do not suffer from exposure bias and label bias problem.

Structured Prediction Energy Networks
Energy based approaches rely on the principle that there is an energy function which assign values to each output y given an input x such that the most compatible y has the minimum energy. Additive nature of energy makes it straightforward to incorporate domain knowledge and hard constraints in the model. Probability based approaches are a subset where probabilities can be thought as normalised energy. Most of the previous approaches assumed a particular graphical models for energy E x (.) which results in an excessively strict inductive bias. Structured prediction energy networks (SPENs) was introduced in [8] as the first framework for structured prediction in which energy is defined using neural networks over possible outputs and gradient based approaches for energy minimization is used for inference. SPENs were found to be very well suited to multi-label classification problems in the NLP domain. The neural network consist of two arbitrary neural network F (x) (feature network) and E(F (x),ȳ) (energy network). Energy network is sum of two terms, E x (ȳ) = E local The SSVM (structured support vector machine) technique is used for training and the loss is :- Where ∆(y i , y) is a error function between prediction and ground truth label and [.] + = max(0, .). Subgradient computation requires loss-augmented inference: y p = arg min y (−∆(y i , y) + E x i (y)) for every training example. SPENs are more expressive and scalable while being less vulnerable to overfitting and performing competitively to previous energy-based approaches. Like most energy networks, the inference involves optimization of E x (y) w.r.t y which limits the practical use of model to an extent. Also, non-convexity of E x (.) or relaxation used to getȳ from y can affect the model performance and convergence. Some of these can be tackled using techniques like inference network [9] and Input Convex Neural Networks [10].
Deep value networks(DVN), introduced in [11], are similar to SPENs but are much easier to train and works even when ∆(y, y * ) is non-continuous and require no convexity constraints. The key idea is that the loss function in every structured prediction problem can be used to define a quantitative value for a configuration as v(x, y) ≈ −∆(y, y * ). The deep network will model v(., .) and hence learn to mimic the loss function. Instead of using max-margin surrogate objective (SSVM) [8] or other complex approaches, this method just do a simple regression during training and has better performance than [8]. Training data ((x, y, v(x, y)) tuples) can be generated via random sampling, generating adversarial tuple, or samples generated during train-time inference. Therefore it needs lesser number of (x, y * ) ground truth pairs for training. Gradient based inference (deep dreaming) is found to iteratively refine prediction. SPEN objective (Eq. (1)) optimisation requires loss augmented inference which may fail to discover margin violations if exact energy minimisation is intractable. This can be tackled using End-to-End learning for SPENs, introduced in [12] where the energy function is discriminatively trained by back-propagating through gradient-based prediction. These are more accurate and allows non-convex energy. The idea is not to do exact energy minimization and instead assume a particular approximate minimisation algorithm and optimize performance of this algorithm. Suppose we chose T step gradient descent as our algorithm for minimization where T is some hyper-parameter. Then, the model's output is y T given by, The energy function is defined identically to the original SPEN paper. However, energy funciton must be twice sub-differentiable and it is not straightforward to implement this model using standard learning libraries. The model loss can be defined as, T −t+1 . Unlike in DVNs, here explicit energy function provides interpretability. Another benefit is that the model outputs inference procedure along with the energy function. The inference procedure has fixed T meaning that the inference time complexity is independent of x. Although it is worth noting that the learned energy may be such that the energy minima doesn't actually represents the best output as our model is learning just to optimise the inference procedure which may not be converging to minima.
The approaches used till now for training SPENs were supervised and required labeled data which are expensive to collect in many problems, so we are now exploring the space of semi-supervised learning where we use domain knowledge in form of reward functions and ranking based supervision. The first approach introduced in [13] is to rank every pair of consecutive candidates obtained from training time gradient-descent inference on y; and update energy network parameters by optimising an objective function if the energy values are not consistent with domain knowledge based ranking. In the above approach we collect training pairs from gradient descent based inference on energy functions, but it has several problems such as not able to get relevant pairwise rank violations, not reaching to a region of high reward or if we have plateaus in our energy functions. To overcome these issues, [14] introduced a new approach where for each example we start with a gradient descent inference output, and then use a randomized search procedure for iteratively selecting a random output variable, if the reward increases more than the margin we return the new sample or else we begin sampling again.
Graph Structured Prediction Energy Networks (GSPEN) [15] was introduced as a combination of classical structured prediction models and SPENs to score an entire set of predictions jointly which allows to both model explicit local and implicit higher-order correlations while maintaining tractability of inference. Inference in GSPENs is a maximization of a generally non-concave function with respect to structural constraints which is an approach inspired by [16]. GSPENs use Frank-Wolfe Inference as its objectives are non-linear while the constraints are linear and use Structured Entropic Mirror Descent for optimization, an approach similar to SPEN optimization with some additional entropy-based constraints. GSPENs are found to outperform SPENs and other baselines on multilabel classification and named entity recognition.

Structured Attention networks
Attention networks are now a standard part of the deep learning toolkit and are found effective approach for embedding categorical inference but they often fail to model richer structural dependencies in end-to-end training. Structured Attention networks [17] was proposed as a simple extension of the basic attention procedure which allow for extending attention to partial segmentations or to subtrees. They explain how they can implement a linear-chain conditional random field and a graph-based parsing model as classes of structured attention networks, which are equivalent to neural network layers. It is shown that provide a structural bias by modelling structural dependencies at the final output layer, most notably in seminal work on graph-based neural architectures [18], [19].
In the structured attention model, the attention distribution p(z|x, q) is defined as conditional random field (CRF) or other graph based model to specify independent structure of z: a vector of discrete latent variables. The CRF is parameterized with clique log-potentials θ C (z C ) ∈ R where the z C indicates subset of z given by clique C, and attention probability is p(z|x, q; θ) = softmax( C θ C (z C )) where x is the input sequence and q is the query. In practice we use a neural CRF, where θ comes from a deep model over x, q. Here also, it is assumed that annotation function f factors into clique annotation functions f (x, z) = C f C (x, z C ) and the context is defined as In short,the attention mechanism is taking expectation of an annotation function f (x, z) with respect to a latent variable z ∼ p, where p is parameterized as function of x and q. Instead of linear-chain CRF, syntactic tree-based attention can also be used for modelling richer structural dependencies using similar approach. Also, unlike previous approaches which add Graphical models as the final layer, they proposes that these can be added within deep networks in place of simple attention layers.
Using the two ways mentioned for structured attention, they experiment on a variety of synthetic and real tasks: neural machine translation, question answering, and natural language inference and found that it outperformed baseline attention models. They also conclude that structured attention leads to learning interesting unsupervised hidden representations that generalize simple attention. Structural attention network for graph [20] is a novel approach to learn node representations for graph modelling. It uses a graph-based attention network, to pay attention to the topology of the graph.
Graph classification is a problem with many practical applications and an approach [21] using structural attention was proposed recently. It's the first model to uses attention to learn representations for general attributed graphs. A major problem in graph-based classification was that graphs are mostly noisy and large and processing the entire graph can inadvertently caused noise to be introduced into the calculated feature and also computationally inefficient which increased the need for structured attention in graphs. The approach used an RNN based model that processes only a portion of the graph by adaptively selecting a sequence of "informative" nodes. Furthermore, the attention-guided walk mechanism relies only on local information from the graph which keeps computation costs low since there is no need to load the entire graph into memory. With various experiments on real-world datasets, they concluded that the proposed method is competitive against various well-known methods in graph classification even though our method is limited to only a portion of the graph.

Tree LSTM
Tree LSTMs [22] were proposed to generalize LSTMs (chain-structured) to tree-structured network topologies and they were found to outform all LSTM baselines on predicting semantic relatedness of two sentences and sentiment classification and hence found superior for representing sentence meaning. Tree-LSTM, composes its hidden state from an input vector and the hidden states of arbitrarily many child units unlike hidden state of previous time step in normal LSTM.
Recently, Tree-LSTMs have been widely applied in structured prediction tasks like dependency and constituency parsing. Works on Recursive LSTM Tree have been proposed for feature Representation of parse trees in dependency and constituency parsing [23], [24], [25]. These approaches have removed the need of handcrafted structural features and have shown better performance as well.
Recently, many works in the community have tried to improve Tree-LSTMs [26] proposed encoding variants of decomposable attention inside a Tree-LSTM cell for dependency and constituency trees. To avoid the bias problem of the root node dominance, capsule tree-LSTM [27] was proposed, which uses dynamic routing algorithm to build sentence representation by assigning different weights to nodes according to their contributions to prediction.

NER, POS and other Sequence Labelling tasks
Linguistic sequence labeling tasks like POS tagging and named entity recognition (NER), are one of the first stages in language understanding and its importance has been well recognized. Many NLP systems like coreference resolution and syntactic parsing are becoming more sophisticated by utilizing output information of POS tagging or NER.
Linear statistical models like HMMs, MEMMs and CRFs give high performance on such sequence labelling tasks by using hand-crafted features and task-specific resources like English POS taggers benefit from carefully designed word spelling features. However, such task-specific knowledge is costly to develop. Due to this, deep-learning based approaches which use word embeddings as features are being applied to these tasks and are giving great results. Several RNN together with its variants such as long-short term memory (LSTM) [28] and gated recurrent unit (GRU) [29] have been proposed to solve sequence labeling tasks like POS tagging [30] and NER [31], [32]. As these models depend a lot on neural embeddings, often its performance drops rapidly and so new approaches combining linear statistical models on top of RNN-based models. Approaches like [33], [34] combine character and word-level representations, feed them into a BiLSTM and then use a CRF on top of it to jointly decode labels for the whole sentence and they give great accuracies in sequence labelling tasks. Hierarchical RNN based encoders along with CRFs have also been used for sequence labelling [35]

Semantic Parsing and Semantic analysis
Semantic Processing involves the understanding the meaning of phrases, sentence or documents. Research have directed attention towards learning word representation methods from a large unlabeled corpus and claim to capture the meaning of words such as Word Embedding [36] and GloVe [37].
Research have also shown that [38] semantic structures helps in defining effective word embedding. SENSE [38] uses hierarchically organized data that could be used in generating semantic structures to exploit the semantic relationship such as parent, brother and child semantic attributes to learn effective embedding. This explicitly uses the external semantic structured information to learn the word representations by optimizing the prediction ability between target word and context. Semantic Parsing is task of mapping the natural language to logical representation on which we can support various application such as machine translation, question answering, etc. Semantic role labeling, a second-order structured prediction task is one such application of semantic parsing also known as Shallow semantic parsing, in which we are concerned with labelling phrases of sentences with its corresponding semantic roles, but not encovering deeper compositional semantics of text. Approached based on contextualized embeddings, such as ELMo [39], BERT [40], XLM-R [41] have been emerged as state-of-the-art for various structured prediction tasks such as semantic role labelling, chunking etc. Research have also showed that word representation based on the ensembling or concatenation of multiple pretrained embedding and non-contextual embedding can further improve the performance of structured prediction tasks [42].

Structured Prediction in Dependency Parsing
In recent year, there have been more focus transition-based approaches for parsing, which generates one parse tree. Arc-standard parsing starts with the an empty stack and a queue consisting of whole input sequence. At each step, a word input is consumed and corresponding stack operations are applied. At the end whole sentence is consumed and stack contain only ROOT label. Transition based methods have been giving top accuracies for dependency parsing [43] [44] [45]. Neural parsing with global learning and beam search have also come out to be start-of-the-art transition-based parsers [46], which also leverages structured-prediction model to optimize whole sequence of stack actions [44] instead of using local classifier that optimizes each action. There have been efforts in proposing structured prediction model for probabilistic dependency parsing [47], which maximizes the likelihood of arc-standard based action sequence instead of individual actions.
The probability of the action sequence y i is given by above equation. Here o(x, y i , k, a k ) denotes the neural network score for the action a k given x, y i . The probability captures the likelihood of all action sequence instead of individual actions. Results showed that this model outperformed greedy dependency parsers, and also able to have comparable results with small parameter size.

Text generation
The importance of global normalization for text generation was emphasized by [48] which has led to introduction of statistical models like CRFs combined with neural network architectures in text generation domain. Sequential autoregressive models which predict make predictions based on past predictions are the predominant architecture for text generation in a maximum likelihood setup but MLE based training leads to teacher forcing and exposure bias. Feedback loops have been used to overcome this issue where one provides the last predicted token as a feature to the computation of the next state. Recently, [49] proposed modeling temporal correlations as part of the observation model by a neural CRF observation model that leverages word-embeddings to explain local word correlations in a global sequence score. The resultant autoregressive model kept hidden state evolution less affected by observation noise while generating coherent word sequences.
Fully-autoregressive models are state-of-the-art in text generation but beam-searching can not be parallelized, to speedup decoding using parallel generation models assumes independence of output words which leads to problems like repetitions. Markov Transformers [50] proposed a slightly different architecture for modern autoregressive models such that they can parameterize hierarchical CRFs, on which we use refinement based decoding procedures which are parallelizable. Such models are partially-autoregressive, and has trade off between speedup and autoregressive nature of the model which requires finding a best configuration with speedup and performance. With distillation and good configuration this model performs comparable to other parallel decoding models, has good candidate search, and less problem of repetition.
Modeling language as a sequence of discrete tokens is a widely used approach, which is only constraint to sequence dynamics. Recently, syntax driven approach [51] is proposed, where token generation is driven by dependency parse tree with iterative generation procedure. Iterative Expansion Language Models, given a level of dependency parse tree produces tokens for next level of dependency parse tree with expansion placeholders (non-terminal tokens which can be expanded to multiple tokens for next iteration), inference is done by starting from fix root token as first level of dependency parse tree and iteratively generating all levels till terminals are generated, requiring only few iterations and beam-search can be used across iterations. This iterative non-autoregressive model generates text with diversity quality between LSTM and transformers. 7 Future Directions 1. Structured Attention networks [17] proposed an approach to add graphical models anywhere within deep networks in place of simple attention layers. Also, we read about SPENs [8] used as output layers for structured prediction in energy-based models and it may be interesting to explore how to use SPEN layer as as internal neural network layers in the form of attention-based modules (replace CRF based attention module with SPEN based module), using approximate inference methods and end-to-end training mechanism mentioned in [17], [12], and [10]. We may try finding alternatives to ICNN [10] approach which is less restrictive for enforcing convexity or employ a regularization method that enforces convexity as a soft constraint. Also, GLOM [52] mentioned about consensus based attention mechanism which can be modelled using linear-chain CRF with pairwise dependencies. 2. Much work has not been done in the field of seq-to-seq models and Natural language inference using structured prediction based techniques and recently it has been found that transformers [53] give great accuracy on these tasks but it was found in TaxiNLI [54] that many taxonomic categories were found to be difficult to be predicted accurately by transformers in Natural Language inference and question answering. We want to experiment by adding structured prediction based methods on top of the output layer in such seq-to-seq tasks and see which are more robust to all taxonomic categories. Also, we would like to experiment how transformer would work if we replace its normal soft attention layer by structured attention layer. 3. Recent structured prediction approaches that we surveyed like SPENs, DVNs and TreeLSTMs are being applied to a very small set of tasks which are simpler than majority of structured prediction tasks. We would like to extend these ideas to other language understanding tasks where we have to predict a structured output and see if these techniques improve the baselines. There may be some problems in making the model tractable but the end-to-end training mechanisms of these individual methods or application of certain restrictions suggested in ICNNs [10] would make the model training work properly. 4. Many natural language understanding datasets contain annotation artifacts or biases and we would like to explore how various NLP approaches are robust to dataset biases. We believe structured prediction techniques would result in more robust models. We would further like to work on making the models even more robust, come up with new training methods to combat bias, and extending the ideas to other language understanding tasks.

Conclusion
This survey has explored a wide variety of methods of Structured Prediction and its applications in NLP. Our goal has been to study the general usefulness of statistical, graphical, energy-based and attention-based methods to model the structural dependencies in structured prediction tasks with more focus towards such tasks in NLP domain like POS tagging, Named Entity Recognition, Semantic Role labelling and analysis, Dependency and Semantic Parsing and Text generation. Linear statistical and graphical methods like CRFs are effective but output dependencies are modeled by hand, and has significant inductive bias SPENs are its further recent work is a great contribution in the step towards incorporating deep networks and energy-based approaches in structured prediction resulting in more expressive models, and have huge potential for future work in its scalability and application to more complex tasks. Structured Attention is a great approach of adding statistical models in between neural network layers and should be explored with other structured prediction based techniques as well. TreeLSTMs are found to give good accuracy on Dependency and semantic parsing and they should be used in other NLP domains as well like seq-to-seq models using hierarchical encoders and decoders made of TreeLSTMs . Structured prediction methods may have great potential when combined with Transformer [53] which are the current SOTA in most of the NLP tasks.