Abstract
Modern neural sequential decoders excel at pattern recognition but often fail to adhere to hard logical constraints, particularly when training data is limited. We present a general-purpose framework that enforces these constraints by integrating Finite State Automata (FSA) and Pushdown Automata (PDA) directly into the decoding process. By reshaping the model's probability distribution in lock-step with the automaton's state, our algorithm guarantees valid outputs. To maintain efficiency, we introduce an "active set" optimization that lazily applies constraints only when violated. Evaluations on constituency parsing and Semantic Role Labeling (SRL) demonstrate that this approach significantly improves performance in low-resource scenarios and ensures 100% constraint satisfaction.
Introduction
In structured prediction tasks such as Semantic Role Labeling (SRL) or syntactic parsing, the output must conform to strict structural rules. For instance, a sentence should not contain duplicate subjects, and parentheses in a parse tree must be perfectly balanced. While modern neural models are powerful, they generate outputs sequentially and often struggle to maintain these hard logical constraints without explicit guidance.
Historically, researchers relied on tools like Integer Linear Programming (ILP) to enforce such rules. However, these methods are difficult to integrate with modern neural decoders. Current solutions are often task-specific "hacks" that lack generalizability. This paper introduces a framework to bring general-purpose constrained inference to the neural era, ensuring that models produce valid structures regardless of the amount of training data available.
Methodology
The core of the proposed approach is representing logical constraints as automata. Most NLP rules can be described as regular languages (modeled by FSAs) or context-free languages (modeled by PDAs).
During decoding—whether using beam search or greedy search—the algorithm maintains the state of the constraint automaton. At each step, the model's predicted probability distribution is "reshaped" by the automaton. If a specific token is deemed illegal by the automaton's current state, its probability is set to zero (or $-\infty$ in log-space), resulting in a constrained distribution.
To handle the computational complexity of intersecting multiple complex automata, the authors employ an Active Set Method. Instead of enforcing all constraints upfront, the decoder initially runs unconstrained. If a violation occurs, the specific violated constraint is added to an "active set," and the inference is re-run with this subset of constraints. This "lazy" approach provides a 5.2x speedup over naive intersection, as many constraints are naturally satisfied by the model.
Experimental Evaluation
The framework was tested on two major benchmarks:
- Penn Treebank (PTB): For constituency parsing using a seq2seq model with attention.
- CoNLL 2005: For Semantic Role Labeling (SRL), using an off-the-shelf model to identify predicate arguments.
Key Results and Insights
A critical finding is that models do not simply "learn" rules from data. Even when trained on 100% of the PTB dataset, unconstrained models produced invalid parse trees approximately 7% of the time. In contrast, the constrained algorithm achieved 100% coverage, guaranteeing valid, balanced trees for every output.
The benefits are most pronounced in low-resource settings. Constraints serve as a form of prior knowledge, preventing the model from making fundamental structural errors when it has seen few examples. For SRL, imposing constraints like "no duplicate arguments" improved the $F_1$ score by 1.5 points overall.
Furthermore, the framework allows for the decoupling of logic from learning. Researchers can modify or add constraints at inference time without the need for retraining. The efficiency of the Active Set Method was also validated; for SRL, 80% of test instances required no active constraints, and the average active automaton remained small (34 states).
Conclusion and Future Work
This general-purpose framework effectively bridges the gap between neural flexibility and logical rigor. By using automata to reshape decoding distributions, it ensures valid outputs and boosts performance in data-scarce environments. Future work may extend this to non-deterministic automata and explore "soft" constraints that penalize rather than strictly forbid certain transitions.
Summary updated