arXiv:2512.17093cs.AIcs.CL2025-12AAAI被引 5

用求解器反馈优化大模型生成逻辑谜题的ASP代码

A Solver-in-the-Loop Framework for Improving LLMs on Answer Set Programming for Logic Puzzle Solving

  • 让求解器实时反馈,筛选出有效的代码片段进行训练
  • 在两个数据集上,不同提示设置下均显著提升生成效果
  • 适合研究逻辑推理与程序生成交叉方向的学者

大型语言模型(LLMs)在编程辅助领域备受关注,但针对领域特定语言的代码生成仍具挑战。本文聚焦于答案集编程(ASP)代码的生成,该方法对组合搜索问题求解尤为有效。当前LLMs在ASP生成上的表现受限于预训练阶段所见示例数量有限。为此,本文提出一种求解器-闭环框架,通过求解器反馈引导指令微调,解决ASP代码生成中的复杂语义解析问题。仅需自然语言描述的问题及其解,即可采样候选ASP语句并根据求解器反馈分为正确与错误实例。利用这些标注数据进行监督微调,并结合最佳N抽样等求解器引导搜索策略增强鲁棒性。实验表明,在两个数据集和两种提示设置下均取得一致性能提升。

原文摘要 · Abstract (English)

The rise of large language models (LLMs) has sparked interest in coding assistants. While general-purpose programming languages are well supported, generating code for domain-specific languages remains a challenging problem for LLMs. In this paper, we focus on the LLM-based generation of code for Answer Set Programming (ASP), a particularly effective approach for finding solutions to combinatorial search problems. The effectiveness of LLMs in ASP code generation is currently hindered by the limited number of examples seen during their initial pre-training phase. In this paper, we introduce a novel ASP-solver-in-the-loop approach for solver-guided instruction-tuning of LLMs to addressing the highly complex semantic parsing task inherent in ASP code generation. Our method only requires problem specifications in natural language and their solutions. Specifically, we sample ASP statements for program continuations from LLMs for unriddling logic puzzles. Leveraging the special property of declarative ASP programming that partial encodings increasingly narrow down the solution space, we categorize them into chosen and rejected instances based on solver feedback. We then apply supervised fine-tuning to train LLMs on the curated data and further improve robustness using a solver-guided search that includes best-of-N sampling. Our experiments demonstrate consistent improvements in two distinct prompting settings on two datasets.

逻辑推理ASP代码生成微调

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