Saved in:
Bibliographic Details
Main Authors: Jin, Hyundong, Han, Yo-Sub
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2605.10065
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911670648963072
author Jin, Hyundong
Han, Yo-Sub
author_facet Jin, Hyundong
Han, Yo-Sub
contents Controlling Large Language Models (LLMs) to prevent the generation of undesirable content, such as profanity and personally identifiable information (PII), has become increasingly critical. While earlier approaches relied on post-processing or resampling, recent research has shifted towards constrained decoding methods that control outputs during generation to mitigate high computational costs and quality degradation. However, preventing multiple forbidden hard constraints or regex constraints from appearing anywhere in the output is computationally challenging. A straightforward solution is to convert these constraints into a single automaton that tracks all forbidden patterns during decoding, but this often becomes impractically large. Standard regex engines also do not readily support the operations needed to build such a constraint, such as complement and intersection. In order to address these limitations, we propose NCO, a decoding strategy that performs online pattern matching over finite hard constraints and regex constraints, reducing computational overhead without inducing state explosion. NCO is fully compatible with standard inference strategies, including various sampling methods and beam search, while also supporting soft masking for probabilistic suppression. We empirically demonstrate its effectiveness across practical tasks, including PII and profanity suppression. Our implementation is available at https://github.com/hyundong98/NCO-Decoding.git .
format Preprint
id arxiv_https___arxiv_org_abs_2605_10065
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle NCO: A Versatile Plug-in for Handling Negative Constraints in Decoding
Jin, Hyundong
Han, Yo-Sub
Computation and Language
Artificial Intelligence
Controlling Large Language Models (LLMs) to prevent the generation of undesirable content, such as profanity and personally identifiable information (PII), has become increasingly critical. While earlier approaches relied on post-processing or resampling, recent research has shifted towards constrained decoding methods that control outputs during generation to mitigate high computational costs and quality degradation. However, preventing multiple forbidden hard constraints or regex constraints from appearing anywhere in the output is computationally challenging. A straightforward solution is to convert these constraints into a single automaton that tracks all forbidden patterns during decoding, but this often becomes impractically large. Standard regex engines also do not readily support the operations needed to build such a constraint, such as complement and intersection. In order to address these limitations, we propose NCO, a decoding strategy that performs online pattern matching over finite hard constraints and regex constraints, reducing computational overhead without inducing state explosion. NCO is fully compatible with standard inference strategies, including various sampling methods and beam search, while also supporting soft masking for probabilistic suppression. We empirically demonstrate its effectiveness across practical tasks, including PII and profanity suppression. Our implementation is available at https://github.com/hyundong98/NCO-Decoding.git .
title NCO: A Versatile Plug-in for Handling Negative Constraints in Decoding
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2605.10065