Ensuring both syntactic and semantic correctness in Large Language Model (LLM) outputs remains a significant challenge, despite being critical for real-world deployment. In this paper, we introduce \texttt{SEM-CTRL}, a unified approach that allows for enforcing rich context-sensitive constraints, and task and instance specific semantics directly on the LLM decoder. Our approach integrates token-level MCTS which is guided by specific syntactic and semantic constraints. The constraints over desired outputs are expressed using Answer Set Grammars, which is a logic-based formalism that generalizes context sensitive grammars while incorporating background knowledge to represent task-specific semantics. We show that our approach helps guarantee valid completions for any off-the-shelf LLM without the need for fine-tuning. We evaluate \texttt{SEM-CTRL} on a range of tasks, including synthetic grammar synthesis, combinatorial reasoning, JSON parsing, and planning. Our experimental results demonstrate that \texttt{SEM-CTRL} allows even small pre-trained LLMs to efficiently outperform larger variants and state-of-the-art reasoning models (e.g., \textit{o4-mini}) while simultaneously guaranteeing semantic validity.


翻译:确保大型语言模型(LLM)输出在句法和语义上的正确性,对于其实际部署至关重要,但这仍然是一个重大挑战。本文提出了 \texttt{SEM-CTRL},这是一种统一的方法,允许直接在LLM解码器上强制执行丰富的上下文敏感约束,以及任务和实例特定的语义。我们的方法集成了由特定句法和语义约束引导的令牌级蒙特卡洛树搜索(MCTS)。对期望输出的约束使用答案集语法(Answer Set Grammars)来表达,这是一种基于逻辑的形式化方法,它泛化了上下文敏感语法,同时结合了背景知识来表示任务特定的语义。我们表明,我们的方法有助于保证任何现成的LLM都能生成有效的补全,而无需进行微调。我们在包括合成语法生成、组合推理、JSON解析和规划在内的一系列任务上评估了 \texttt{SEM-CTRL}。我们的实验结果表明,\texttt{SEM-CTRL} 使得即使是小型预训练LLM也能高效地超越更大的变体以及最先进的推理模型(例如 \textit{o4-mini}),同时保证语义的有效性。

0
下载
关闭预览

相关内容

SEM 是 Search Engine Marketing 的缩写,中文意思是搜索引擎营销。SEM 是一种新的网络营销形式。SEM 所做的就是全面而有效的利用搜索引擎来进行网络营销和推广。SEM 追求最高的性价比,以最小的投入,获最大的来自搜索引擎的访问量,并产生商业价值。
【斯坦福大学Xiang Lisa Li博士论文】控制语言模型
专知会员服务
22+阅读 · 2025年6月11日
【ICML2023】基于自然语言指令的受控文本生成
专知会员服务
29+阅读 · 2023年4月28日
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
三次简化一张图:一招理解LSTM/GRU门控机制
机器之心
16+阅读 · 2018年12月18日
干货|当深度学习遇见自动文本摘要,seq2seq+attention
机器学习算法与Python学习
10+阅读 · 2018年5月28日
TextInfoExp:自然语言处理相关实验(基于sougou数据集)
全球人工智能
12+阅读 · 2017年11月12日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关VIP内容
【斯坦福大学Xiang Lisa Li博士论文】控制语言模型
专知会员服务
22+阅读 · 2025年6月11日
【ICML2023】基于自然语言指令的受控文本生成
专知会员服务
29+阅读 · 2023年4月28日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员