Viterbi Algorithm (1967) › The Problem: Finding Needles in Exponential Haystacks
History of Language AIAll chapters Viterbi Algorithm (1967) › The Problem: Finding Needles in Exponential HaystacksOne section · Sections in this chapter2 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The core challenge that motivated the Viterbi algorithm appears whenever you need to determine the most likely hidden sequence from observations. In error-correcting codes, the hidden sequence is the original message bits, and the observations are the noisy received signal. In speech recognition, the hidden sequence is the words or phonemes being spoken, and the observations are acoustic features extracted from audio. In part-of-speech tagging, the hidden sequence is the grammatical categories of words, and the observations are the words themselves.
In each case, the challenge is the same: given an observation sequence of length , how do you find the hidden state sequence that most likely produced those observations? If you have possible states at each time step, there are possible sequences to consider. For even modest values.say, states and observations.you're dealing with possible sequences, a number so large that enumerating all possibilities is computationally impossible.
The naive approach would be to compute the probability of each possible sequence given the observations and select the one with the highest probability. But this requires evaluating an exponential number of sequences. Even if each evaluation took only a microsecond, examining all sequences would take longer than the age of the universe. Clearly, a different approach was needed.
The key insight that makes the Viterbi algorithm possible is the Markov property: the probability of being in a particular state at time depends only on the state at time , not on the entire history of states. This means that optimal sequences have optimal prefixes. If the optimal sequence ending at time passes through state at time , then the path from the start to state at time must also be optimal. Otherwise, you could improve the overall sequence by replacing that suboptimal prefix with an optimal one.
The problem becomes even more challenging when you consider that observations can be ambiguous. In speech recognition, the same acoustic feature might be consistent with multiple different phonemes. In part-of-speech tagging, the word "bank" could be a noun (financial institution) or a verb (to deposit). The system must use context.both the transition probabilities between states and the observation probabilities for each state.to resolve these ambiguities. But doing so requires reasoning about sequences, not just individual decisions.
Before the Viterbi algorithm, researchers attempted various approximations. Some systems made greedy decisions, choosing the most likely state at each time step independently without considering how these choices affected later decisions. This local optimization often led to globally suboptimal sequences. Other systems explored only a subset of possible sequences using heuristics, but couldn't guarantee finding the true optimal solution. What was needed was an algorithm that could efficiently find the globally optimal sequence without exhaustive enumeration.