NCO: A Versatile Plug-in for Handling Negative Constraints in Decoding
NCO is a decoding plug-in that enforces multiple negative substring constraints during text generation without retraining or modifying the base model. It achieves this by using specialized online matching techniques, like Aho-Corasick for fixed patterns and parallel DFA simulation for regular expressions, to filter invalid tokens in real-time. This method maintains high generation speed while ensuring generated text avoids specified forbidden substrings.