NCO:一种处理解码中负约束的多功能插件
NCO: A Versatile Plug-in for Handling Negative Constraints in Decoding
AI总结:
本文提出NCO,一种通过在线模式匹配处理硬约束和正则表达式约束的解码策略,减少计算开销并避免状态爆炸,适用于多种采样和束搜索方法,并支持软掩码。
摘要:
本文提出NCO,一种通过在线模式匹配处理硬约束和正则表达式约束的解码策略,减少计算开销并避免状态爆炸,适用于多种采样和束搜索方法,并支持软掩码。
英文摘要:
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 .
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。