Modeladvanced
BiLSTM-CRF
Also called BiLSTM-CRF tagger, neural CRF tagger.
A bidirectional LSTM gives each token tag scores, and a linear-chain CRF layer on top adds tag transitions and decodes by Viterbi.
A BiLSTM-CRF is a neural sequence tagger in two layers. A bidirectional LSTM, a recurrent network read once from left to right and once from right to left, turns each token into a vector that depends on the whole sentence and gives a score for each tag at each position. A linear-chain conditional random field on top adds a learned score for each pair of adjacent tags and normalizes over whole tag sequences. Compared with a plain CRF, the token scores are learned from words and characters instead of hand-made features. Compared with a BiLSTM that picks each tag on its own with a softmax, the CRF layer scores tag pairs, so it can learn constraints such as "I-PER does not follow B-LOC", and it decodes with the Viterbi algorithm.
The machine
The input is a sentence and a tag set of size .
Word representations. Each word gets a vector from an embedding table, usually pretrained (word embedding). Lample et al. (2016, Section 4.1) also run a bidirectional LSTM over the characters of the word and concatenate its two final states, of 25 dimensions each, with the word embedding; this gives information about prefixes, suffixes and capitals and a vector for unknown words. Huang, Xu and Yu (2015) instead add hand-made spelling and context features.
Bidirectional LSTM. A forward LSTM reads the word vectors from left to right and gives , which summarizes . A backward LSTM, with its own parameters, reads from right to left and gives , which summarizes . The vector represents word in its context. A linear layer (Lample et al. add one hidden layer before it) maps to numbers. These form an matrix , where is the score of tag for word .
CRF layer. A matrix holds the score of tag right after tag , with extra start and end tags and . The score of a tag sequence is
and its probability is , a softmax over all tag sequences (Lample et al. 2016, Section 2.2). This is a linear-chain CRF whose token potentials are the outputs of the network.
Training. Maximize over the training pairs. The second term is computed by the forward algorithm with the log-sum-exp trick in time. The gradient flows into , into , and through into the LSTMs and the embeddings by backpropagation through time. Lample et al. used stochastic gradient descent with learning rate 0.01 and gradient clipping at 5.0, and dropout with rate 0.5 on the input of the BiLSTM (Sections 4.3 and 5.1).
Decoding. , by the Viterbi algorithm over the tag lattice with edge scores .
What it counts
- The BiLSTM costs time for hidden size (with the input size of the same order), in two passes of steps each. Each step depends on the one before, so the steps of one direction cannot run in parallel.
- The CRF layer costs time for the normalizer in training and for Viterbi decoding, and space. For the usual tag sets, is small and this is much less than the cost of the LSTM.
- The parameters are the embeddings, the LSTM weights, the output layer and the entries of . The CRF layer adds only .
Relation to other models
- Linear-chain CRF: the same output layer and the same training objective. The difference is only where the token scores come from: learned features of the whole sentence instead of a weighted sum of hand-made features.
- BiLSTM with a softmax per token: drops and picks each tag on its own. It cannot rule out invalid BIO sequences and does worse on entity recognition (see the results below).
- Maximum entropy Markov model and greedy neural taggers: they normalize each step and can have the label bias problem. The CRF layer normalizes over whole sequences.
- Conv-CRF of Collobert et al. (2011): a convolutional network over word embeddings with the same kind of tag-transition layer, which Huang, Xu and Yu and Lample et al. both describe as the closest earlier model.
- Pretrained encoders: replacing the BiLSTM by a pretrained transformer encoder such as BERT, with or without the CRF layer, keeps the same output structure.
- Structured perceptron: the same score form and the same Viterbi decoding, but a fixed feature map and perceptron updates in place of a learned encoder and the likelihood.
Known results in the model
All results here are measurements on standard data sets.
- Huang, Xu and Yu (2015, Table 2), with Senna embeddings: the BI-LSTM-CRF reached 97.55% accuracy on Penn Treebank POS tagging, F1 94.46 on CoNLL-2000 chunking, and F1 88.83 on CoNLL-2003 NER (90.10 with gazetteer features). In the same table, a CRF with the same features got 97.45, 93.83 and 86.13, and a BI-LSTM without the CRF layer got 97.40, 93.92 and 85.17.
- With word features only (Huang, Xu and Yu 2015, Section 4.3.2, Table 3), the CRF lost about 3 to 9 points, while the BI-LSTM-CRF lost little; for example it still got F1 94.40 on chunking.
- Lample et al. (2016, Tables 1 to 4), with character representations and no gazetteers: F1 90.94 on CoNLL-2003 English, 78.76 on German, and 81.74 on CoNLL-2002 Dutch and 85.75 on Spanish.
- Ablation on English (Lample et al. 2016, Section 5.4, Table 5): pretrained embeddings gave the largest gain, +7.31 F1; the CRF layer gave +1.79, dropout +1.17 and character representations +0.74.
- Tagging scheme (Lample et al. 2016, Section 2.4): they used IOBES tags but saw no significant gain over IOB.
References
- Huang, Xu and Yu 2015, Section 2 (LSTM, BI-LSTM, CRF, LSTM-CRF and BI-LSTM-CRF; the sentence score as the sum of transition and network scores, Equation 5), Table 2 (POS, CoNLL-2000 and CoNLL-2003 results), Section 4.3.2 and Table 3 (results with word features only)
- Lample et al. 2016, Section 2.2 (the score s(X, y), the softmax over all tag sequences, Equations 1 and 2), Section 2.4 (IOB and IOBES), Section 4 (character-based word representations, pretrained embeddings, dropout), Section 5.3 and Tables 1 to 4 (CoNLL-2002 and CoNLL-2003 results), Section 5.4 and Table 5 (ablation)
- Lafferty, McCallum and Pereira 2001, the linear-chain CRF used as the output layer
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag PD9FA6 Edit this page History Report an error Markdown