ML0089 Hidden Markov Model

What is a Hidden Markov Model, and what are its three fundamental problems?

Answer

A Hidden Markov Model is a doubly stochastic generative model for sequential data: a hidden state sequence evolves as a first-order Markov chain (each state depends only on the previous one), and each state emits an observable symbol according to a state-specific distribution. The model is defined by three quantities: the initial state distribution, the transition matrix between states, and the emission distributions. The three fundamental problems are evaluation (what is the probability of an observation sequence), decoding (what is the most likely state sequence given the observations), and learning (how to estimate the parameters from data). In production, DNN-HMM hybrids remain common for on-device keyword spotting, where the DNN estimates emission probabilities and the HMM’s Viterbi decoder integrates across frames, while profile HMMs (Pfam, HMMER) remain the standard for protein family classification across sequenced genomes.

(1) Evaluation (Forward Algorithm): given model parameters and an observation sequence, compute the total probability efficiently via dynamic programming in O(TN^2) instead of summing over all N^T possible state paths.
(2) Decoding (Viterbi Algorithm): find the single most likely state sequence via dynamic programming with backpointers, also O(TN^2); on-device keyword spotters use Viterbi to combine per-frame DNN scores into a detection decision.
(3) Learning (Baum-Welch / EM): estimate transition and emission parameters from unlabeled observation sequences using the forward-backward algorithm, an instance of EM that iterates between computing expected state occupancies (E-step) and updating parameters (M-step); profile HMM databases like Pfam build models from seed alignments and HMMER scores new sequences against them for genome annotation.

HMM architecture: hidden states s1 through s4 connected by transition arrows in a chain, each state emitting an observation o1 through o4 from its emission distribution, with the Markov property annotated

Figure 1: HMM architecture: hidden states form a first-order Markov chain (transitions depend only on the previous state), and each state emits an observation from its own distribution; only observations are visible, states are hidden.

In production, HMMs persist where their probabilistic sequence structure and low computational cost outweigh the accuracy advantage of end-to-end neural models. On-device voice triggers run DNN-HMM hybrids on low-power processors because the HMM’s Viterbi decoder integrates frame-level DNN scores into a keyword hypothesis with minimal power. GMM-derived i-vectors are still fed to DNN-HMM acoustic models as speaker-adaptation features, yielding 5-7% relative WER improvement. In bioinformatics, profile HMMs remain dominant: Pfam 38 (2025) uses HMMER for protein family classification across all sequenced genomes, and the HAVAC FPGA accelerator (2024) speeds up HMMER’s ungapped-Viterbi (SSV) filter stage by as much as 60x. In finance, HMMs are actively used for market regime detection, often hybridized with reinforcement learning for portfolio management.

Three panels: evaluation shows forward recursion summing over previous states; decoding shows Viterbi keeping only the best previous path with backpointers; learning shows Baum-Welch iterating between expected state counts and parameter updates

Figure 2: The three fundamental HMM problems: evaluation (forward algorithm sums over all paths), decoding (Viterbi keeps the single best path via backpointers), and learning (Baum-Welch iterates E-step expected counts with M-step parameter updates).

Mathematical Formulation:
\alpha_t(j) = \left[\sum_{i=1}^{N} \alpha_{t-1}(i)\, a_{ij}\right] b_j(o_t)
\delta_t(j) = \max_{i} \big[\delta_{t-1}(i)\, a_{ij}\big]\, b_j(o_t)
\gamma_t(i) = \frac{\alpha_t(i)\, \beta_t(i)}{\sum_{j} \alpha_t(j)\, \beta_t(j)}

Where:

  • \alpha_t(j) is the forward variable: the joint probability of emitting o_1, \ldots, o_t and landing in state j at time t; the evaluation problem sums \alpha_T(j) over all final states.
  • \delta_t(j) is the Viterbi variable: the highest probability of any single path ending in state j at time t; backpointers \psi_t(j) record the argmax to reconstruct the best path.
  • \gamma_t(i) is the posterior state occupancy, formed from the forward variable and the backward variable \beta_t(i), the probability of emitting the remaining observations o_{t+1}, \ldots, o_T given state i at time t.
  • a_{ij} is the transition probability from state i to state j and b_j(o_t) the emission probability of o_t in state j. Baum-Welch updates a_{ij} and b_j using \gamma_t and the pairwise posterior \xi_t(i,j).
ProblemAlgorithmComplexityProduction Use
EvaluationForward algorithmO(TN^2)Scoring sequences against Pfam profile HMMs
DecodingViterbi algorithmO(TN^2)On-device keyword spotting (DNN-HMM)
LearningBaum-Welch (EM)O(TN^2) per iterationTraining Pfam profile HMMs from seed alignments

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *