arXiv:2604.10667cs.CLcs.AI2026-04ACL被引 2

让小模型自动学会并遵守生成约束,无需人工设计规则。

Learning and Enforcing Context-Sensitive Control for LLMs

  • 通过两阶段学习自动提取上下文相关生成规则
  • 10亿参数小模型实现完美约束遵守,超越大模型表现
  • 适合需要可靠生成控制的AI应用开发者

通过上下文敏感约束控制大型语言模型(LLMs)的输出,已成为克服上下文无关语法(CFGs)在保证生成有效性方面局限性的有前景方法。然而,这类约束通常需手动指定,存在专业门槛。本文提出一种框架,通过两阶段过程自动从LLM交互中学习上下文敏感约束:第一阶段为语法探索,收集多样化输出以支持约束学习;第二阶段为约束利用,在生成过程中强制执行所学规则。实验表明,该方法使小型模型(1B参数)能完全遵守约束,性能优于更大模型及现有最优推理模型。这是首个将上下文敏感语法学习与LLM生成相结合的工作,无需人工设定规则即可保障生成有效性。

原文摘要 · Abstract (English)

Controlling the output of Large Language Models (LLMs) through context-sensitive constraints has emerged as a promising approach to overcome the limitations of Context-Free Grammars (CFGs) in guaranteeing generation validity. However, such constraints typically require manual specification -- a significant barrier demanding specialized expertise. We introduce a framework that automatically learns context-sensitive constraints from LLM interactions through a two-phase process: syntactic exploration to gather diverse outputs for constraint learning, followed by constraint exploitation to enforce these learned rules during generation. Experiments demonstrate that our method enables even small LLMs (1B parameters) to learn and generate with perfect constraint adherence, outperforming larger counterparts and state-of-the-art reasoning models. This work represents the first integration of context-sensitive grammar learning with LLM generation, eliminating manual specification while maintaining generation validity.

大模型控制语法学习生成约束

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。