用逻辑编程提升大模型数据提取的准确性和效率
Logic-Guided Data Extraction with Answer Set Programming and Large Language Models
- 结合大模型与答案集编程,用逻辑推理指导数据抽取
- 减少40%以上LLM调用次数,降低错误率
- 适合需要高可靠性、复杂推理的数据抽取任务
当大语言模型用于从非结构化文本中提取语义关系时,其输出在需要复杂组合推理和全局一致性的任务中仍不可靠。本文提出一种融合大模型与答案集编程(ASP)的逻辑引导式数据抽取框架:大模型生成候选事实,ASP负责验证、推理、一致性检查与控制。不同于传统独立查询所有目标谓词的流水线,该方法利用ASP推理判断各阶段可接受的谓词,并指导抽取查询。通过交错执行大模型调用与ASP推导,框架无需额外抽取即可推断逻辑蕴含的事实,并早期发现不一致。我们形式化了该流程并证明,在温和假设下,最终抽取结果与基线等价,但调用次数更少。还引入缓存机制,利用合取查询在逐步构建的事实集上的单调性,减少求解器调用。在基于ASP的基准测试中,该框架显著减少大模型调用,提升抽取质量,有效抑制冗余输出,验证了非单调逻辑编程在可控语义抽取中的价值。
原文摘要 · Abstract (English)
When Large Language Models (LLMs) are used for semantic data extraction from unstructured text, producing candidate relational facts from natural language, they may remain unreliable for tasks requiring complex combinatorial reasoning and global consistency. This paper proposes a logic-guided data extraction framework combining LLM-based extraction with Answer Set Programming (ASP). The LLM produces candidate facts, whereas ASP performs validation, inference, consistency checking, and control. Unlike existing pipelines that query the LLM independently for all target predicates, the proposed approach uses ASP reasoning to identify which predicates are logically admissible at each stage and to guide extraction queries. By interleaving LLM calls with ASP derivation, the framework infers logically implied facts without further extraction and detects inconsistencies early. We formalize the pipeline and prove that, under mild assumptions, it is equivalent to the baseline approach with respect to the final extracted facts, while requiring fewer LLM calls. We also introduce a caching mechanism for logic-based control queries, exploiting monotonicity of conjunctive queries over incrementally constructed fact sets to reduce solver invocations. Experiments on ASP-derived benchmarks show that the framework reduces LLM calls and improves extraction quality by mitigating spurious outputs, demonstrating the value of non-monotonic logic programming for controlled semantic extraction.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。