Back to Classic ML Mind Map
中文·English
📊 Classic MLID: viterbi

Viterbi Decoding

HMM 维特比解码
🎯Core Definition
The decoding problem asks for the most probable hidden state sequence q=argmaxqP(qO,λ)q^* = \arg\max_q P(q \mid O, \lambda) given λ=(A,B,π)\lambda = (A, B, \pi) and observations OO. Viterbi maintains the DP quantity δt(j)\delta_t(j) — the maximum probability over all paths that end in state jj at time tt after emitting o1oto_1 \dots o_t — via
📌Overview
δt(j)=maxi[δt1(i)aij]bj(ot),\delta_t(j) = \max_i[\delta_{t-1}(i)\, a_{ij}]\, b_j(o_t),
📌Overview
with a backpointer table ψt(j)=argmaxiδt1(i)aij\psi_t(j) = \arg\max_i \delta_{t-1}(i) a_{ij} storing the optimal predecessor; initialized by δ1(j)=πjbj(o1)\delta_1(j) = \pi_j b_j(o_1), it terminates with P=maxjδT(j)P^* = \max_j \delta_T(j) and then walks the ψ\psi table backward (backtracking) to recover the full best sequence. Complexity is O(N2T)O(N^2 T), the same order as the forward algorithm.
💡Use Cases
part-of-speech tagging, named-entity recognition, best-path search in speech and handwriting recognition; interviews often contrast Viterbi with the forward algorithm and with greedy/beam search.
Key Problems Solved
enumerating NTN^T paths is intractable; like forward, Viterbi caches subproblems but replaces summation with max and keeps predecessors to reconstruct the trajectory, guaranteeing a globally optimal path rather than greedy step-wise optima; the cost is O(N2)O(N^2) comparisons per step and retaining the full ψ\psi table for backtracking (it cannot be rolled over like evaluation).
🎯5 High-Frequency Exam Points
1
Write the Viterbi recursion δt(j)=maxi[δt1(i)aij]bj(ot)\delta_t(j) = \max_i[\delta_{t-1}(i)a_{ij}]b_j(o_t) and the backtracking procedure; what is the complexity?
2
How do Viterbi and the forward algorithm differ (sum vs max, their outputs, and why Viterbi needs the backpointer table ψ\psi)?
3
Why does Viterbi guarantee a global optimum, unlike greedy per-position choice or beam search?
4
Work through a concrete example (e.g. N=2N=2, T=3T=3) by hand, deriving the best path and explaining backtracking.
5
How is Viterbi used in CRF/MEMM inference (the same decoding DP with different score functions)?
📖 In-depth Guide:📄 probabilistic-models
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Viterbi Decoding"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardHMM Forward Algorithm (Evaluation)Next CardBaum-Welch (HMM EM)

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestGBDT Negative GradientConfusion Matrix