Few-shot In-context Learning for Knowledge Base Question Answering

Tianle Li, Xueguang Ma, Alex Zhuang, Yu Gu, Yu Su, Wenhu ChenarXiv 2023 · DOI

Introduction

Knowledge Base Question Answering (KBQA) involves translating natural language questions into structured queries (e.g., SPARQL) executable against a database. Traditionally, this task has required extensive supervised fine-tuning on large-scale datasets to navigate the complex schemas of massive knowledge bases like Freebase. This reliance on labeled data presents two significant challenges: the high cost of data collection and poor generalization across different database schemas.

While Large Language Models (LLMs) exhibit impressive reasoning capabilities, their limited context windows prevent direct ingestion of massive knowledge bases. To address this, researchers have introduced KB-BINDER, a framework that leverages LLMs as "drafters" to generate initial logical forms, which are then grounded in the knowledge base through a specialized "binding" process.

Methodology: The KB-BINDER Framework

KB-BINDER operates as a training-free, few-shot in-context learning pipeline. It bypasses the need for massive labeled datasets by using the LLM's internal semantic knowledge to bridge the gap between natural language and structured queries.

Overview of the KB-BINDER framework, illustrating the flow from exemplars and LLM drafting to KB binding and final answer execution.

The pipeline consists of two primary stages:

  1. Draft Generation: The system prompts an LLM (such as Codex) with a few pairs of questions and logical forms. To enhance the LLM's performance, cryptic machine identifiers (MIDs) are replaced with human-readable surface names. This allows the model to "hallucinate" a plausible logical structure based on semantic intent.
  2. Knowledge Base Binding: The generated draft is often "noisy" and may not perfectly match the target schema. The Binder component corrects this through two sub-modules:
  3. Entity Binder: Maps surface names in the draft to actual database IDs using BM25 similarity and entity linking resources like FACC1.
  4. Relation Binder: Explores the local neighborhood of identified entities in the KB to find relations that best match the LLM's drafted relations.

The framework further improves accuracy using Majority Voting across multiple generated drafts and Dynamic Exemplar Retrieval to select the most relevant prompts for each query.

Experimental Setup and Datasets

The effectiveness of KB-BINDER was evaluated across four diverse KBQA benchmarks:

  • GrailQA: Tests generalization across I.I.D., compositional, and zero-shot scenarios.
  • WebQSP: Focuses on simple questions answerable via Freebase.
  • GraphQA: Evaluates compositional generalization across multiple domains.
  • MetaQA: Focuses on multi-hop reasoning (up to 3 hops) in the movie domain.

Results and Discussion

KB-BINDER demonstrates that LLMs can achieve state-of-the-art performance with minimal supervision. A key finding is the "Draft and Ground" paradigm's ability to handle "zero-shot" relations—those never seen in the few-shot examples—by relying on semantic similarity rather than pattern memorization.

Performance metrics (Coverage and EM score) on the GrailQA dataset as a function of the number of shots provided in the prompt.

Significant results include:

  • GraphQA: KB-BINDER (100 shots) achieved a 39.5 F1 score, outperforming the previous supervised state-of-the-art by 7.7 points.
  • MetaQA: The model essentially solved the 3-hop benchmark with only 5 examples, reaching 99.5% Hits@1.
  • GrailQA: With just 40 examples, the system achieved an Exact Match (EM) score of 50.6, comparable to BERT-based models trained on 45,000 examples.

Limitations and Future Directions

Despite its success, KB-BINDER faces challenges such as sensitivity to prompt selection ("prompting lottery") and inference latency due to multiple LLM calls and KB searches. Furthermore, if the initial logical structure of a draft is fundamentally flawed, the binder may fail to recover the correct query. Future work may explore iterative generation, where the LLM receives feedback from the KB to refine its drafts dynamically.

Summary updated

BibTeX
@misc{li2023few,
  author = {Tianle Li and Xueguang Ma and Alex Zhuang and Yu Gu and Yu Su and Wenhu Chen},
  title = {{Few-shot In-context Learning for Knowledge Base Question Answering}},
  year = {2023},
  eprint = {2305.01750},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.01750},
}
Figure