Notes

HMM Tagger

Part-of-speech tagging looks circular: you need a word's tag to know how it is being used, and you need to know how it is being used to pick the tag. An HMM tagger breaks the circle by treating the tags as a hidden sequence that produced the words you can see, then asking which hidden sequence was most likely.

Two tables and a search
Both tables are counts taken off an annotated corpus such as the Penn Treebank, and tagging a new sentence means finding the tag sequence that maximises their product — a search the Viterbi algorithm finishes in a single pass over the words.

  • Transition probabilities: how likely a tag is given the tag before it, so that determiner-then-noun outranks determiner-then-verb.
  • Emission probabilities: how likely a word is given a tag, so that "dog" is a probable noun and an improbable determiner.

Where the assumptions bite
The model sees one previous tag and the current word, and nothing else. Capitalisation, the word's suffix, the word that follows — all invisible, though each is strong evidence. A word absent from the training corpus has no emission probability at all and has to be guessed at from its ending. Those limits are what maximum entropy models and conditional random fields removed, by taking arbitrary overlapping features instead of two counted tables.

Why it still earns its place
It trains in seconds on a few thousand annotated sentences, runs anywhere, and reaches the mid-nineties on well-edited English — close enough that it stays the baseline a new tagger has to beat. NLTK ships one you can train in a couple of lines, and the forward-backward machinery underneath it reappears in word alignment and unsupervised tagging.

An HMM tagger labels each word with a part of speech by modelling the tag sequence as a hidden Markov chain: tag-to-tag transition probabilities and tag-to-word emission probabilities are counted from an annotated corpus, and the Viterbi algorithm recovers the most probable tag sequence for a sentence. It trains in seconds on little data and remains a standard baseline, but it cannot use evidence such as capitalisation or suffixes — the restriction that conditional random fields lifted.

The word "book" can be a thing you read or something you do to a hotel room. Before software can make sense of a sentence, it needs to work out which job each word is doing in it.

An HMM tagger settles that from habits rather than rules. From text that people labelled by hand, it has learned which kinds of words tend to follow which — a describing word before a naming word, say — and which words usually belong to which kind. It then picks the labelling of the whole sentence that fits those habits best, rather than judging each word alone. It is old, tiny and fast, and on tidy, well-edited writing it is still surprisingly hard to beat.