Algorithm Search⌘K

Modelcore

Maximum entropy Markov model

Also called MEMM.

A tagger with a log-linear distribution of each tag given the previous tag and features of the input, decoded by Viterbi.

A maximum entropy Markov model (MEMM) tags a sequence with a chain of local classifiers. Each one gives a distribution of the current tag, conditioned on the previous tag and on any features of the input, in the log-linear form of softmax regression. The probability of a tag sequence is the product of these local probabilities, and Viterbi finds the best sequence. Compared with the HMM tagger, it models P(y∣x)P(y \mid x) instead of P(x,y)P(x, y), so its features can overlap and can look at the whole input. Compared with the conditional random field, it normalizes each step on its own, which makes training simple but causes the label bias problem.

The machine

A sentence x=x1…xnx = x_1 \ldots x_n is given, and the tags come from a set YY of kk tags, with y0=⟨s⟩y_0 = \langle s \rangle. A feature function f(x,i,y′,y)∈Rdf(x, i, y', y) \in \mathbb{R}^d describes position ii with previous tag y′y' and current tag yy. It can test the word xix_i, its suffixes and capitalization, nearby words, and the pair (y′,y)(y', y). The model has one weight vector w∈Rdw \in \mathbb{R}^d and defines

P(yi=y∣yi−1=y′,x)=exp⁡(w⋅f(x,i,y′,y))Z(x,i,y′),Z(x,i,y′)=∑t∈Yexp⁡(w⋅f(x,i,y′,t)),P(y_i = y \mid y_{i-1} = y', x) = \frac{\exp(w \cdot f(x, i, y', y))}{Z(x, i, y')}, \qquad Z(x, i, y') = \sum_{t \in Y} \exp(w \cdot f(x, i, y', t)),
P(y∣x)=∏i=1nP(yi∣yi−1,x).P(y \mid x) = \prod_{i=1}^{n} P(y_i \mid y_{i-1}, x).

McCallum, Freitag and Pereira (2000) write it as one maximum entropy model per source state y′y', each giving the distribution of the next state given the observation; with features that include the previous tag this is the same model. Ratnaparkhi's tagger (1996) conditions on the two previous tags.

Training maximizes the conditional log likelihood ∑(x,y)∑ilog⁡P(yi∣yi−1,x)\sum_{(x,y)} \sum_i \log P(y_i \mid y_{i-1}, x), with the gold previous tag in each term. This is a sum of independent multiclass logistic regression problems, one per position, so it is concave in ww and needs no dynamic programming: the gradient of each term is the observed feature vector minus its expectation under the local distribution. The original papers used generalized iterative scaling; any convex optimizer such as L-BFGS works, usually with a Gaussian prior on ww.

Decoding finds arg⁡max⁡y∑ilog⁡P(yi∣yi−1,x)\arg\max_y \sum_i \log P(y_i \mid y_{i-1}, x) with the Viterbi algorithm, where the score of the edge from y′y' at i−1i - 1 to yy at ii is log⁡P(y∣y′,x)\log P(y \mid y', x). Ratnaparkhi used a beam search instead.

What it counts

  • Decoding time: O(nk2)O(n k^2) evaluations of local scores, plus the cost of the kk normalizers Z(x,i,y′)Z(x, i, y') at each position, each a sum over kk tags, so O(nk2)O(n k^2) in all when the features of a position are computed once. With features of two previous tags, O(nk3)O(n k^3).
  • Training time: one gradient of the objective costs O(Nk)O(N k) score evaluations for NN training tokens, because each term needs only the normalizer for the gold previous tag. A CRF needs forward-backward over each sentence, which costs O(Nk2)O(N k^2) per gradient. The MEMM treats each position as an independent example.
  • The model is a probability distribution over tag sequences: the sum of P(y∣x)P(y \mid x) over all knk^n sequences is 1, since each local distribution sums to 1.

Relation to other models

  • HMM tagger: the HMM is generative and factors as P(yi∣yi−1)P(xi∣yi)P(y_i \mid y_{i-1}) P(x_i \mid y_i). To add a feature such as a suffix to an HMM, one must model how the tag generates that feature, and overlapping features break the independence assumptions. The MEMM conditions on xx, so overlapping features cost nothing; see generative and discriminative models.
  • Conditional random field: the linear-chain CRF uses the same features but one global normalizer, P(y∣x)=exp⁡(∑iw⋅f(x,i,yi−1,yi))/Z(x)P(y \mid x) = \exp(\sum_i w \cdot f(x, i, y_{i-1}, y_i)) / Z(x). Lafferty, McCallum and Pereira (2001) introduced it to avoid label bias. Training needs forward-backward.
  • Structured perceptron: also scores whole sequences with the same features, but trains by Viterbi decoding and additive updates, with no normalization at all.
  • Greedy classifiers: tagging left to right with a classifier that sees the previously predicted tags is the MEMM with greedy decoding in place of Viterbi. It suffers from the same mismatch between training on gold previous tags and testing on predicted ones (exposure bias).

Known results in the model

  • Label bias (a theorem about the model class, shown by example): because each local distribution sums to 1 whatever the observation is, a state with one successor passes all its mass to it, and the observation at that step cannot change the score of the path. Lafferty et al. (2001, Section 2, Figure 1) give the rib and rob example, where the MEMM cannot learn to read the second letter. See label bias problem.
  • Synthetic data (a measurement): on data generated by an HMM, designed to show label bias, the MEMM had an error rate of 42% against 4.6% for the CRF (Lafferty et al. 2001, Section 5.1).
  • Part-of-speech tagging (a measurement, Penn Treebank, Lafferty et al. 2001, Section 5.3 and Figure 4): with first-order features only, the error rates were 5.69% for the HMM, 6.37% for the MEMM and 5.55% for the CRF; on unknown words 45.99%, 54.61% and 48.05%. With spelling features added, the MEMM got 4.81% (26.99% on unknown words) and the CRF 4.27% (23.76%). The MEMM gains much from the extra features, which the HMM cannot use easily, but stays behind the CRF.
  • Training is a convex problem (a theorem): the conditional log likelihood of each local model is concave in ww, so a global optimum can be found.

References

  1. McCallum, Freitag and Pereira 2000, the MEMM, with one maximum entropy model of the next state per source state, its Viterbi decoding and its training
  2. Ratnaparkhi 1996, the maximum entropy tagger with word, affix and previous-tag features, and its search
  3. Lafferty, McCallum and Pereira 2001, Section 2 (the label bias problem of MEMMs, Figure 1), Section 5.1 (synthetic data), Section 5.3 and Figure 4 (part-of-speech tagging error rates of HMM, MEMM and CRF)

Where this leads

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/GH9RD1/text.yaml