用抽象语法树提升自然语言转一阶逻辑的准确率与可解释性
NL2LOGIC: AST-Guided Translation of Natural Language into First-Order Logic with Large Language Models
- 以抽象语法树为中间表示,约束生成语法结构
- 在三个基准上达到99%语法正确率,语义正确率提升30%
- 适合法律、治理等需高可解释推理的场景
自动化推理在法律与治理等领域至关重要,验证声明是否符合文档事实需要兼具准确性和可解释性。现有方法通过将自然语言翻译为一阶逻辑并交由自动求解器处理来实现。随着大语言模型的发展,GCD和CODE4LOGIC等方法利用其推理与代码生成能力提升了逻辑解析效果。然而,这些方法因全局语法约束弱而存在语法脆弱性,且因缺乏句级语义理解导致语义忠实度低。我们提出NL2LOGIC,一种基于抽象语法树(AST)的中间表示框架,结合递归式大语言模型语义解析器与受AST引导的确定性生成器,直接输出求解器可用的一阶逻辑代码。在FOLIO、LogicNLI和ProofWriter基准上的实验表明,NL2LOGIC达到99%的语法准确率,语义正确率相比最优基线最高提升30%。此外,将其集成到Logic-LM中,使执行成功率接近完美,下游推理准确率比原方法提升31%。
原文摘要 · Abstract (English)
Automated reasoning is critical in domains such as law and governance, where verifying claims against facts in documents requires both accuracy and interpretability. Recent work adopts structured reasoning pipelines that translate natural language into first-order logic and delegate inference to automated solvers. With the rise of large language models, approaches such as GCD and CODE4LOGIC leverage their reasoning and code generation capabilities to improve logic parsing. However, these methods suffer from fragile syntax control due to weak enforcement of global grammar constraints and low semantic faithfulness caused by insufficient clause-level semantic understanding. We propose NL2LOGIC, a first-order logic translation framework that introduces an abstract syntax tree as an intermediate representation. NL2LOGIC combines a recursive large language model based semantic parser with an abstract syntax tree guided generator that deterministically produces solver-ready logic code. Experiments on the FOLIO, LogicNLI, and ProofWriter benchmarks show that NL2LOGIC achieves 99 percent syntactic accuracy and improves semantic correctness by up to 30 percent over state-of-the-art baselines. Furthermore, integrating NL2LOGIC into Logic-LM yields near-perfect executability and improves downstream reasoning accuracy by 31 percent compared to Logic-LM's original few-shot unconstrained translation module.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。