Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with Perceptron Algorithms
Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002))
Subscriber deck — free during early access
26 cards
1 Introduction
- What does Collins (2002) propose, and as an alternative to what?Perceptron-based training for tagging models (HMM-style taggers with rich features) as an alternative to maximum-entropy models and CRFs: decode each training example with Viterbi and make simple additive updates, justified by adapting the perceptron convergence proof.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §1, p. 1
- What was the motivation for the structured perceptron, given MaxEnt taggers and CRFs?MaxEnt taggers allow flexible features, but Lafferty et al. (2001) had shown problems with their (locally normalized) parameter estimation, and CRFs fix this at a higher training cost. The voted/averaged perceptron of Freund and Schapire (1999) was competitive with SVMs, but had mainly been applied to classification, not tagging or parsing.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §1, p. 1
- Beyond tagging, where did Collins expect the perceptron framework to apply?To any model where Viterbi-style algorithms can decode: e.g. probabilistic context-free grammars (weights for a weighted CFG could be trained this way) or ME models for parsing.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §1, p. 1
2.1 HMM Taggers
- How does a trigram HMM tagger score a tagged sentence, in Collins’s formulation?\(\sum_{i=1}^{n} \alpha_{t_{i-2}, t_{i-1}, t_i} + \sum_{i=1}^{n} \alpha_{t_i, w_i}\), with a parameter per tag trigram and per tag/word pair. With \(\alpha_{x,y,z} = \log P(z \mid x, y)\) and \(\alpha_{t,w} = \log P(w \mid t)\) this is the log joint probability, and Viterbi finds the best tag sequence.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.1, pp. 1–2
- Describe the perceptron training algorithm for a trigram tagger.Set all parameters to zero. For \(T\) passes over the data, for each sentence: Viterbi-decode with the current parameters to get \(z\); for every tag trigram or tag/word pair seen \(c_1\) times in the gold tags and \(c_2\) times in \(z\), add \(c_1 - c_2\) to its parameter. If \(z\) is correct, nothing changes.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.1, pp. 1–2
- Gold: the/D man/N saw/V the/D dog/N. Predicted: the/D man/N saw/N the/D dog/N. Which parameters does the perceptron update change?Add 1 to \(\alpha_{D,N,V}\), \(\alpha_{N,V,D}\), \(\alpha_{V,D,N}\), \(\alpha_{V,\textit{saw}}\) (features missing from the prediction) and subtract 1 from \(\alpha_{D,N,N}\), \(\alpha_{N,N,D}\), \(\alpha_{N,D,N}\), \(\alpha_{N,\textit{saw}}\) (incorrect features). Shared features cancel out.
Only trigrams and pairs that touch saw differ: +1 for gold, −1 for predicted - Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.1, pp. 1–2
2.2 Local and Global Feature Vectors
- What is a history in a MaxEnt-style tagger, and what is a local feature vector?A history is \(\langle t_{-1}, t_{-2}, w_{[1:n]}, i \rangle\): the previous two tags, the whole sentence and the current position. A local representation \(\phi: \mathcal{H} \times \mathcal{T} \to \mathbb{R}^d\) maps a history/tag pair to features, typically indicators, e.g. \(\phi_{1000}(h, t) = 1\) iff the current word is the and \(t = \text{DT}\).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.2, pp. 2–3
- How does Collins define global features, and what are they when local features are indicators?\(\Phi_s(w_{[1:n]}, t_{[1:n]}) = \sum_{i=1}^{n} \phi_s(h_i, t_i)\): local features summed over all positions. For indicator features, global features are counts, e.g. how often the is tagged DT in the sentence.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.2, pp. 2–3
2.3 Maximum-Entropy Taggers
- How does a maximum-entropy tagger score a tag sequence?Each decision is locally normalized: \(P(t \mid h, \bar\alpha) = e^{\sum_s \alpha_s \phi_s(h, t)} / Z(h, \bar\alpha)\), so the sequence log probability is \(\sum_i \sum_s \alpha_s \phi_s(h_i, t_i) - \sum_i \log Z(h_i, \bar\alpha)\). Parameters are trained by maximum likelihood (e.g. Generalized Iterative Scaling); Viterbi finds the best sequence.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.3, p. 3
2.4 A New Estimation Method
- How does the perceptron tagger’s scoring differ from a MaxEnt tagger’s?It scores a sequence by \(\sum_i \sum_s \alpha_s \phi_s(h_i, t_i) = \bar\alpha \cdot \Phi(w_{[1:n]}, t_{[1:n]})\): the same features, but without the local normalization terms \(\log Z(h_i, \bar\alpha)\). Decoding is the same Viterbi search, minus computing the normalizers.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.4, pp. 3–4
- Give the perceptron update for tagging with global feature vectors.Decode \(z_{[1:n_i]} = \arg\max_{u \in \mathcal{T}^{n_i}} \bar\alpha \cdot \Phi(w^i, u)\); if \(z \ne t^i\), set \(\bar\alpha = \bar\alpha + \Phi(w^i, t^i) - \Phi(w^i, z)\). With indicator features this adds \(c_s - d_s\) to each \(\alpha_s\), where \(c_s\) and \(d_s\) count feature \(s\) in the gold and predicted sequences.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.4, pp. 3–4
2.5 Averaging Parameters
- What is the averaged perceptron?Instead of the final parameters \(\alpha_s^{T,n}\), output the average of the parameter vectors after every training example in every pass: \(\gamma_s = \sum_{t=1}^{T} \sum_{i=1}^{n} \alpha_s^{t,i} / nT\). It is simple to maintain during training and performed significantly better than the final parameters.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §2.5, p. 4
3 Theory Justifying the Algorithm
- What is the general setting of Collins’s perceptron algorithm, beyond tagging?Training pairs \((x_i, y_i)\); a function \(\text{GEN}(x)\) enumerating candidate outputs; a feature map \(\Phi(x, y) \in \mathbb{R}^d\); parameters \(\bar\alpha\). The model outputs \(F(x) = \arg\max_{y \in \text{GEN}(x)} \Phi(x, y) \cdot \bar\alpha\). For tagging, \(\text{GEN}(w_{[1:n]}) = \mathcal{T}^n\), all tag sequences of length \(n\).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3, pp. 4–5
- When is a training set separable with margin \(\delta\), in Collins’s sense?If some \(\mathbf{U}\) with \(\|\mathbf{U}\| = 1\) scores every correct output at least \(\delta\) above every incorrect candidate: \(\mathbf{U} \cdot \Phi(x_i, y_i) - \mathbf{U} \cdot \Phi(x_i, z) \ge \delta\) for all \(i\) and all \(z \in \text{GEN}(x_i) - \{y_i\}\).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3, pp. 4–5
- State Collins’s Theorem 1 (perceptron convergence for structured outputs).If the training data is separable with margin \(\delta\), the perceptron makes at most \(R^2/\delta^2\) mistakes, where \(\|\Phi(x_i, y_i) - \Phi(x_i, z)\| \le R\) for all \(i\) and candidates \(z\). So with a zero-error \(\mathbf{U}\), training converges to zero training error after finitely many passes.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3, pp. 4–5
- Why is it crucial that the mistake bound doesn’t depend on the size of GEN(x)?In NLP, GEN(x) is often exponential in the input length (e.g. \(|\mathcal{T}|^n\) tag sequences). The bound depends only on the separation of the data, so learning stays feasible however many candidates there are, as long as decoding (e.g. Viterbi) is efficient.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3, pp. 4–5
- Sketch the proof of the mistake bound \(k \le R^2/\delta^2\).Let \(\bar\alpha^k\) be the weights before the \(k\)th mistake. Lower bound: each update adds at least \(\delta\) to \(\mathbf{U} \cdot \bar\alpha\), so \(\|\bar\alpha^{k+1}\| \ge k\delta\). Upper bound: \(\|\bar\alpha^{k+1}\|^2 \le \|\bar\alpha^k\|^2 + R^2\), because the cross term \(\bar\alpha^k \cdot (\Phi(x_i, y_i) - \Phi(x_i, z)) \le 0\) when \(z\) was the argmax; so \(\|\bar\alpha^{k+1}\|^2 \le kR^2\). Hence \(k^2\delta^2 \le kR^2\).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3, pp. 4–5
3.1 Theory for inseparable data
- What does the perceptron guarantee when the training data is not separable?For any \(\mathbf{U}\), \(\delta\), let \(\epsilon_i = \max\{0, \delta - m_i\}\) be how far example \(i\) falls short of margin \(\delta\), and \(D_{\mathbf{U},\delta} = \sqrt{\sum_i \epsilon_i^2}\). Theorem 2: the first pass makes at most \(\min_{\mathbf{U},\delta} (R + D_{\mathbf{U},\delta})^2/\delta^2\) mistakes, so a few hard or mislabelled examples don’t ruin it.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3.1, p. 5
- How is the inseparable-case bound (Theorem 2) proved?By reduction to the separable case: add one extra feature per training example, nonzero only for that example’s correct output, with weight \(\epsilon_j/\Delta\). The extended data is separable with a smaller margin, the extra features never affect other examples, and minimizing over \(\Delta\) (\(\Delta = \sqrt{R D_{\mathbf{U},\delta}}\)) gives the bound.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3.1, p. 5
3.2 Generalization results
- What is the voted perceptron, and how does the averaged perceptron relate to it?Each parameter setting \(\bar\alpha^{1,i}\) during the first pass votes for its output on a test input; the majority wins. The averaged perceptron approximates this with a single decoding using the averaged weights, instead of \(n\) decodings.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3.2, pp. 5–6
- What generalization guarantee carries over from Freund and Schapire to structured outputs?Assuming i.i.d. examples, the probability that the voted perceptron errs on a new example is at most \(\frac{2}{n+1} E_{n+1}\big[\min_{\mathbf{U},\delta} (R + D_{\mathbf{U},\delta})^2/\delta^2\big]\): few training mistakes suggest good generalization, again independent of the size of GEN.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §3.2, pp. 5–6
4 Experiments
- On which tasks and data did Collins test the structured perceptron?POS tagging on the Penn WSJ treebank (train sections 0–18, dev 19–21, test 22–24), with Ratnaparkhi’s (1996) MaxEnt tagger features, and base NP chunking on Ramshaw and Marcus’s data (sections 15–18 train, 20 test), measured by F-measure.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §4, pp. 6–7
- How was NP chunking cast as tagging in Collins (2002)?As a three-tag task: B begins a chunk, I continues it, O is outside. Every chunk starts with B whether the previous word is O or I. Features combine the current chunk tag \(t_i\) with nearby words and POS tags (from Brill’s tagger), up to two positions away, plus bigram and trigram combinations.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §4, pp. 6–7
- What did development experiments show about averaging and feature cut-offs?Averaging improved the perceptron significantly and made it much more stable across iterations. Including all features (count cut-off 0) helped the perceptron but hurt the MaxEnt model, which did better with a cut-off of 5. The perceptron also needed far fewer training iterations (about 6–39 vs 100–900).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §4, pp. 6–7
- How did the averaged perceptron compare with the MaxEnt tagger on test data?POS tagging: 2.89% error vs 3.28% (an 11.9% relative error reduction). NP chunking: F-measure 93.63% vs 93.29% (a 5.1% relative error reduction).
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §4, pp. 6–7
6 Conclusions
- What makes the structured perceptron attractive compared with CRFs?It uses the same features and Viterbi decoding, but training needs only decoding and additive updates: no normalizers, no gradients of a partition function. Its guarantees depend on separability of the data rather than on the number of candidate outputs, and it beat a MaxEnt tagger on both tasks.
- Collins, 2002, Discriminative Training Methods for Hidden Markov Models (Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002)), §6, p. 8
Source
- Michael Collins. 2002. Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with Perceptron Algorithms. In Proceedings of the 2002 Conference on Empirical Methods in Natural Language Processing (EMNLP 2002), pp. 1–8. https://aclanthology.org/W02-1001/