FlexKBQA: A Flexible LLM-Powered Framework for Few-Shot Knowledge Base Question Answering

Zhenyu Li, Sunqi Fan, Yu Gu, Xiuxing Li, Zhichao Duan, Bowen Dong, Ning Liu, Jianyong Wang

Introduction

Knowledge Base Question Answering (KBQA) systems aim to translate natural language queries into structured programs, such as SPARQL, that can be executed against large-scale databases like Freebase or Wikidata. Despite their utility, traditional KBQA models are constrained by high data requirements, necessitating thousands of manually annotated question-query pairs. This "data-hungry" nature makes them difficult to scale as knowledge bases evolve or when transitioning between different schemas. While Large Language Models (LLMs) can mitigate these issues through in-context learning (ICL), they are often limited by high inference costs and restricted context windows.

Methodology

FlexKBQA introduces a novel framework that reverses the standard training pipeline by generating structured programs first and then utilizing LLMs to translate them into natural language questions. This approach leverages the inherent strength of LLMs in natural language generation from structured data.

Overview of the FlexKBQA framework (b) compared to standard In-Context Learning (a)

The framework consists of four primary components:

  1. Automatic Program Sampling: The system samples diverse templates from the KB and populates them with entities and relations to generate valid, executable programs.
  2. Low-Resource Program Translation: An LLM acts as a translator, converting these programs into synthetic questions. This dataset is used to pre-train a lightweight student model.
  3. Execution-Guided Self-Training (EGST): To address the distribution shift between synthetic and real-world questions, the model employs unlabeled real-world data. A teacher model predicts queries, which are filtered based on their execution success on the KB, ensuring high-quality training signals.
  4. Inherent Reasoning (IR) Augmentation: The framework utilizes the LLM's internal knowledge as both a validator for query results and a fallback mechanism when structured queries fail.

Results and Discussion

FlexKBQA was evaluated on three major benchmarks: GrailQA, WebQSP, and KQA Pro. The framework consistently outperformed state-of-the-art few-shot methods.

Performance comparison of FlexKBQA against state-of-the-art few-shot methods as training data scales

On the GrailQA dataset, FlexKBQA achieved an F1 score of 69.4 with only 25 manual annotations, significantly surpassing previous models like Pangu. The system reached 93% of the performance of fully supervised models while using a tiny fraction of the labeled data. A key driver of this success was the EGST process, which provided a boost of over 10 points in F1 score by effectively bridging the gap between synthetic and real-world question distributions. The performance scales remarkably well with the amount of synthetic data generated, eventually surpassing LLMs limited by their context window.

Conclusion

FlexKBQA provides a robust solution to the data scarcity problem in KBQA. By combining automated program sampling with LLM-based translation and execution-guided self-training, the framework enables the creation of high-performance, lightweight models that are both cost-effective and adaptable to diverse knowledge base schemas. Future work will focus on improving entity linking and automating template discovery to further enhance zero-shot capabilities.

Summary updated

BibTeX
@inproceedings{li2024flexkbqa,
  author = {Zhenyu Li and Sunqi Fan and Yu Gu and Xiuxing Li and Zhichao Duan and Bowen Dong and Ning Liu and Jianyong Wang},
  title = {{FlexKBQA: A Flexible LLM-Powered Framework for Few-Shot Knowledge Base Question Answering}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i17.29823},
}
Figure