Structured prediction—predicting sequences, trees, or graphs—is a cornerstone of Natural Language Processing (NLP). Linear-chain Conditional Random Fields (CRFs) are the "bread and butter" for sequence labeling tasks because they efficiently model local dependencies between adjacent tags. However, they rely heavily on a Markov assumption: a tag's probability only depends on its immediate neighbors.
This assumption makes standard CRFs "blind" to global or non-local constraints. For example, in Semantic Role Labeling (SRL), a sentence usually shouldn't have two "Agent" roles for the same verb. A standard CRF has no inherent way to enforce this global arity constraint. While researchers often use "constrained decoding"—cleaning up the model's output after the fact using Viterbi decoding heuristics—this creates a fundamental mismatch. The model is trained to explore a space of invalid sequences that it is never actually allowed to predict during inference.
To solve this, researchers introduce the Regular-constrained CRF (RegCCRF), a generalization of standard CRFs that restricts output sequences to a specific regular language. By embedding non-local constraints directly into the model's structure, RegCCRF allows for "constrained training," which theoretically and empirically outperforms the common practice of only enforcing constraints during decoding.
The RegCCRF Approach
The authors propose using the formalism of Regular Languages to define the exact space of valid outputs. The method breaks down into three core components:
- NFA Integration: The desired global constraints are represented as a Non-deterministic Finite Automaton (NFA). Any sequence the NFA accepts is considered "valid," while everything else is "invalid."
- State Space Expansion: The authors construct an auxiliary CRF where the "tags" are actually the edges of the NFA. By doing this, the model maintains its computationally tractable linear-chain structure but effectively "remembers" its history through the NFA states.
- Constrained Training: Unlike previous methods that only apply constraints during inference, RegCCRF incorporates them directly into the loss function during training. The model is trained to maximize the probability of the correct sequence relative only to other valid sequences, rather than the entire combinatorial space of all possible tag combinations.
The authors mathematically prove a hierarchy of performance: Constrained Training $\ge$ Constrained Decoding $\ge$ Unconstrained CRF.
Key Insights: Why Training Matters
The most significant insight from this work is that enforcing constraints during training is strictly better than doing it only at decoding. When a model is trained without constraints, it wastes valuable "probability mass" on impossible sequences. Constrained training forces the model to learn the nuances within the valid space.
Furthermore, regular expressions and NFAs serve as a well-understood, flexible bridge to describe these constraints. By mapping NFA edges to CRF tags, the authors provide a "drop-in" replacement for standard CRFs that can handle surprisingly complex global logic. While CRFs are usually local, the NFA state can track information across the entire sequence (e.g., "Have I seen an ARG0 yet?"), effectively relaxing the Markov assumption without making the math intractable.
Experimental Results
The paper evaluates the model on two fronts: synthetic data designed to highlight non-local dependencies (e.g., sequences that must follow specific repeating patterns), and the real-world OntoNotes corpus for Semantic Role Labeling.
- Synthetic Superiority: In synthetic tests, as sequence length increased, the performance gap between constrained training and constrained decoding grew significantly. The unconstrained model's likelihood plummeted, while RegCCRF maintained near-perfect performance that aligned with the true data distribution.
- State-of-the-Art in SRL: By combining a RoBERTa-based encoder with a RegCCRF output layer, the authors achieved a new state-of-the-art F1 score of 87.51 on the OntoNotes SRL task, outperforming previous ensemble models and standard CRF baselines.
- MAP Inference Agreement: The authors demonstrated that constrained training actually changes the "mode" (the most likely prediction) of the model to align better with the true data distribution, whereas constrained decoding often settles for a "second-best" valid sequence.
Limitations and Future Work
While powerful, the RegCCRF approach has a few limitations:
- State Space Explosion: The primary bottleneck is the size of the NFA. For the SRL task, a full NFA representing all possible constraints would have millions of states. The authors had to "prune" the constraints (focusing on the most common roles) to keep the Viterbi algorithm running efficiently on current hardware.
- Manual Constraint Engineering: Currently, the rules defining the regular language must be hand-crafted. Future work could involve Regular Language Induction to automatically learn constraints from the data itself.
- Beyond Regular Languages: While regular languages cover many use cases, they cannot represent "nested" structures (like balanced parentheses). Moving toward Context-Free Languages would be more expressive but significantly more computationally expensive.
Summary updated