用逻辑编程杜绝问答幻觉,答案始终基于知识库事实。
LP-LM: No Hallucinations in Question Answering with Logic Programming
- 通过Prolog语法解析将问题转为可执行逻辑表达式
- 在知识库上运行时准确率显著高于主流大模型,零幻觉
- 适合对可靠性要求高的场景,如医疗、法律问答
大型语言模型(LLMs)虽能生成类人回答,但存在固有缺陷,尤其易产生幻觉。本文提出LP-LM系统,通过在知识库(KB)中基于已知事实进行问答,并利用Prolog的语义解析确保答案可靠。LP-LM采用Prolog确定性短语结构语法(DCG)对输入问题生成最可能的成分解析树及其对应的Prolog项,再在由自然语言句子构成的知识库(以Prolog项表示)上执行该表达式完成问答。借助DCG与表化机制,当规则足够多时,系统时间复杂度为输入句长的线性函数。实验表明,即使面对简单问题,大模型仍会幻觉,而LP-LM始终保持准确。
原文摘要 · Abstract (English)
Large language models (LLMs) are able to generate human-like responses to user queries. However, LLMs exhibit inherent limitations, especially because they hallucinate. This paper introduces LP-LM, a system that grounds answers to questions in known facts contained in a knowledge base (KB), facilitated through semantic parsing in Prolog, and always produces answers that are reliable. LP-LM generates a most probable constituency parse tree along with a corresponding Prolog term for an input question via Prolog definite clause grammar (DCG) parsing. The term is then executed against a KB of natural language sentences also represented as Prolog terms for question answering. By leveraging DCG and tabling, LP-LM runs in linear time in the size of input sentences for sufficiently many grammar rules. Performing experiments comparing LP-LM with current well-known LLMs in accuracy, we show that LLMs hallucinate on even simple questions, unlike LP-LM.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。