An HMM models a sequence of observations generated by an unobserved sequence of states . Two assumptions:
1. Markov: depends only on . 2. Output independence: depends only on .
Specified by:
- Initial state distribution
- Transition matrix
- Emission distribution
Three classical tasks
1. Filtering (likelihood): — given parameters and observations, how likely is this sequence? Solved by the forward algorithm. 2. Decoding (inference): — best explanation. Solved by the Viterbi algorithm. 3. Learning: estimate parameters from data. Solved by the Baum-Welch algorithm (Expectation-Maximization specialized to HMMs).
Forward algorithm
Compute recursively:
Time and space: . Linear in sequence length; quadratic in state cardinality.
Viterbi
Same recursion but with max instead of sum:
Plus backpointers to reconstruct the optimal state sequence. Same complexity as forward.
Backward and forward-backward
Backward . Combined with forward gives — useful for parameter learning.
When HMMs are the right tool
- Sequence labeling with strong locality and small state spaces: part-of-speech tagging, named entity recognition (pre-deep-learning).
- Speech recognition acoustic models (pre-deep-learning).
- Bioinformatics: gene finding, protein sequence analysis.
When they're not
- Long-range dependencies that don't fit in the Markov assumption (use RNN/transformer).
- Very large state spaces (Viterbi quadratic blows up).
- Rich emission distributions (neural network emissions extend HMMs but at that point you're in deep learning).
HMMs were the dominant sequence model from the 1980s through the early 2010s. RNNs and then transformers ate most of the application areas, but HMMs remain pedagogically central and still useful in low-resource or strongly-structured domains.