LP-LM: No Hallucinations in Question Answering with Logic Programming

Katherine Wu, Yanhong A. Liu
2/13/2025
cs.AIcs.CL

No official code found. Best implementation: katherinewu312/lp-lm (4 stars, last commit 2024-08-17).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

Question answering using DCG-enabled semantics parsing for PCFG

41Prolog, PythonMar 16, 20242 years ago

Similar Papers

Cite this paper

@article{wu2025lplm,
  title  = {LP-LM: No Hallucinations in Question Answering with Logic Programming},
  author = {Katherine Wu and Yanhong A. Liu},
  year   = {2025},
  eprint = {2502.09212},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.09212v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.09212.svg)](https://codeofpaper.com/paper/2502.09212)

Discussion