How CRFs Overcome the Label Bias Problem in Sequence Prediction
In artificial intelligence, structured sequence prediction tasks like part-of-speech tagging and named entity recognition require models to understand the context of an entire data sequence. Earlier discriminative models, specifically Maximum Entropy Markov Models (MEMMs), suffered from a critical flaw known as the label bias problem, which skewed predictions toward states with fewer outgoing transitions. Conditional Random Fields (CRFs) were introduced to resolve this exact issue. This article explains the mechanics of the label bias problem in MEMMs and demonstrates how CRFs eliminate it by replacing local per-state normalization with a global normalization factor over the entire sequence.
Understanding Maximum Entropy Markov Models (MEMMs)
MEMMs are discriminative sequence models that predict a sequence of labels given a sequence of observations. They combine the structure of Hidden Markov Models (HMMs) with the flexibility of maximum entropy (logistic regression) classifiers.
In an MEMM, the probability of transitioning from one state (label) to the next, given the current observation, is calculated locally. At each step in the sequence, the model uses a softmax function to ensure that the probabilities of all possible next states sum to 1. This is known as local normalization.
What is the Label Bias Problem?
The label bias problem is a direct consequence of the local normalization used in MEMMs. Because the transition probabilities leaving any given state must sum to 1, states with a low-entropy distribution over the next possible states (meaning they have very few outgoing transitions) end up dominating the prediction path.
Consider a state that only has one possible outgoing transition. Because of local normalization, the probability of taking that single transition is forced to be 1.0, completely regardless of what the current observation actually is. Consequently, the model ignores the observation data at that step. During decoding, the model will systematically favor paths that go through states with fewer outgoing transitions, because their local probabilities are inherently higher and suffer less dilution than states with many possible outgoing transitions.
Furthermore, because MEMMs are directed graphical models where probabilities are normalized step-by-step from left to right, information from future observations cannot influence decisions made at earlier states during training.
How Conditional Random Fields (CRFs) Solve the Problem
Conditional Random Fields eliminate the label bias problem by abandoning directed, local normalization in favor of an undirected graphical model that uses global normalization.
1. Undirected Graphical Structure
Unlike MEMMs, which use directed edges that force a sequential, step-by-step probability conservation, linear-chain CRFs use undirected edges between states. The model does not compute the probability of the next state given the current state. Instead, it computes a joint score for the entire label sequence given the entire observation sequence.
2. Potential Functions Instead of Local Probabilities
At each step in a CRF, transitions and observations are evaluated using feature functions, which are weighted and summed to create "potential functions." Crucially, these potentials are not probabilities. They are unnormalized scores that do not have to sum to 1 at each step. If a state has only one outgoing transition, its score is still entirely dependent on how well the current observation matches the state, rather than being artificially forced to a value of 1.0.
3. Global Normalization (The Partition Function)
To turn the unnormalized sequence scores into a valid probability distribution, CRFs normalize once across the entire sequence. The model adds up the potential scores for a specific path and divides it by a global normalization factor, often called the partition function (\(Z\)).
The partition function is the sum of the unnormalized scores of all possible label sequences for the given input. Because normalization happens only at the very end over all possible paths:
- States with few outgoing transitions are no longer given an unfair mathematical advantage.
- The observation data is never ignored, as every observation directly contributes to the global score of the path.
- Future observations can influence past label predictions, allowing the model to revise an earlier path choice if a later observation makes a current path globally improbable.
By trading local normalization for global normalization, CRFs ensure that every state transition competes fairly on a sequence-wide level, successfully eradicating the label bias problem.