Promoting Knowledge Base Question Answering by Directing LLMs to Generate Task-relevant Logical Forms

Jianqi Gao, Ranran Bu, Nengjun Zhu, Wei Guan, Hang Yu

Introduction

Knowledge Base Question Answering (KBQA) is a critical task that requires systems to answer natural language questions by querying structured databases like Freebase. Traditionally, this involves semantic parsing, where a question is translated into a Logical Form (LF)—executable code such as SPARQL.

While Large Language Models (LLMs) demonstrate strong code generation capabilities, they often struggle when provided with retrieved context from a database. This "knowledge conflict" occurs because retrieved subgraphs frequently contain numerous irrelevant reasoning paths. When an LLM is fine-tuned to generate a single LF amidst this noise, it often produces inaccurate or non-executable queries. The FM-KBQA framework addresses this by aligning the model's attention through a multi-task learning approach.

Methodology

The authors introduce FM-KBQA (Faithful Multi-task KBQA), which fine-tunes a Llama-2-7B model to perform two simultaneous tasks: generating logical forms and identifying specific reasoning paths.

The FM-KBQA framework overview, illustrating the pipeline from question input to final answer extraction through multi-task LLM reasoning.
  1. Enhanced Retriever: A generative T5 model filters the massive Knowledge Base to select only the most relevant triples, forming a set of candidate reasoning paths.
  2. Multi-task Fine-tuning: The LLM is trained to output both a Logical Form (Task 1) and the index of the correct reasoning path (Task 2). This "indexing" strategy anchors the model's attention to the correct data within a noisy context.
  3. Faithful Reasoning Module: During inference, the system first attempts to execute the generated LF. If the LF is non-executable, it falls back to the answer provided by the selected reasoning path, ensuring a robust "safety net."

Experimental Setup

The framework was evaluated on two gold-standard benchmarks using the Freebase knowledge graph:

  • WebQuestionsSP (WQSP): 4,737 relatively simple questions.
  • ComplexWebQuestions (CWQ): 34,689 difficult questions requiring multi-hop reasoning.

Results and Discussion

FM-KBQA achieved new state-of-the-art (SOTA) results, notably outperforming much larger models like GPT-4. On the CWQ dataset, FM-KBQA reached a Hits@1 of 79.50%, significantly higher than GPT-4 with KG context (68.51%). On the WQSP dataset, it achieved an F1 score of 84.24, surpassing GPT-4's 78.32.

A key insight from the study is the synergy between the Logical Form and the Reasoning Path. While LFs are precise but fragile, RPs are robust but less expressive. Combining them yields a more reliable system. Ablation studies confirm that the "LF+RP" combination consistently outperforms versions using only one objective.

Ablation study on the WQSP dataset showing the performance gain from combining Logical Form (LF) generation and Reasoning Path (RP) selection.

Conclusion

FM-KBQA demonstrates that directing LLMs to select task-relevant indices can effectively mitigate the noise inherent in retrieved Knowledge Base contexts. While the system's performance remains dependent on the initial retriever's quality, the multi-task approach provides a significant leap in accuracy and robustness for complex reasoning tasks. Future work will focus on scaling this method to larger, more diverse knowledge sources and improving the interpretability of the reasoning process.

Summary updated

BibTeX
@inproceedings{gao2025promoting,
  author = {Jianqi Gao and Jian Cao and Ranran Bu and Nengjun Zhu and Wei Guan and Hang Yu},
  title = {{Promoting Knowledge Base Question Answering by Directing LLMs to Generate Task-relevant Logical Forms}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i22.34564},
}
Figure