NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Prompting Large Language Models with Chain-of-Thought for Few-Shot Knowledge Base Question Generation

Yuanyuan Liang, Jianing Wang, Hanlun Zhu, Lei Wang, Weining Qian, Yunshi Lan

Abstract

This paper introduces KQG-CoT, a training-free framework that enables Large Language Models (LLMs) to generate high-quality natural language questions from complex Knowledge Base (KB) logical forms using only a few examples. By treating question generation as a multi-step reasoning task and strategically selecting diverse, complexity-sorted examples, the method significantly outperforms existing few-shot techniques and even rivals models trained on full datasets.

Introduction

Knowledge Base Question Generation (KBQG) is the task of converting a structured logical form (like a database query) into a human-readable question. This is vital for building datasets for Question Answering (QA) systems and improving AI dialogue. However, the core challenge remains data scarcity. Traditional methods rely on fine-tuning neural networks on massive amounts of annotated data, which is expensive and labor-intensive to produce. Furthermore, logical forms are highly compositional and complex—small changes in the query structure can lead to vastly different questions. Existing few-shot methods often struggle to generalize across these diverse structures, especially in "low-resource" scenarios.

Methodology

The authors propose a two-stage prompting framework called KQG-CoT (and its enhanced version, KQG-CoT+). The framework reframes the generation task as a reasoning problem, leveraging the in-context learning capabilities of LLMs.

The high-level pipeline of the KQG-CoT framework.

The framework consists of two primary components:

1. Supportive Logical Forms Selection

Instead of picking random examples for the prompt, the system extracts the "skeleton" (structure) of logical forms from an unlabeled pool. It replaces specific entities and relations with symbolic variables (e.g., r and e). These structures are encoded into embeddings and grouped using K-means clustering. The system then samples representative examples from different clusters to ensure the LLM sees a diverse range of syntactic patterns, effectively filtering out semantic noise to focus on structural logic.

2. Chain-of-Thought (CoT) Prompting

The authors reframe question generation as a reasoning problem. Instead of asking the LLM to produce a complex question in one go, the prompt provides "rationales" that break the process down. It generates a series of sub-questions based on sub-graphs of the logical form, gradually building up to the final, complex question. This prevents the model from "hallucinating" or skipping parts of a multi-hop logical form.

Detailed workflow of the two-stage KQG-CoT process: Supportive Logical Forms Selection and Prompt Construction.

3. Complexity Sorting (KQG-CoT+)

The "plus" version adds a simple but effective tweak: it sorts the examples in the prompt by complexity (from short to long). This acts as a form of "in-context curriculum learning," helping the model handle increasingly difficult structures by establishing a clear flow from simple to complex requirements.

Experimental Setup

The framework was evaluated on three widely used KBQG benchmarks:

  • WebQuestions (WQ): Questions, answers, and annotated subgraphs.
  • PathQuestions (PQ): Focuses on "chains of relations," requiring 2-hop or 3-hop reasoning.
  • GrailQA (GQ): A large-scale dataset featuring complex operations like counting, ranking, and superlatives across 86 domains.

Key Results

The KQG-CoT+ method demonstrated remarkable performance using only 12 demonstrations:

  • New Few-Shot SoTA: On the PathQuestions dataset, it surpassed previous state-of-the-art few-shot results by 18.25 points in BLEU-4, 10.72 in METEOR, and 10.18 in ROUGE-L.
  • Beating Baselines: It consistently outperformed other prompting strategies like Auto-CoT and Manual-CoT across all three datasets.
  • Competitive with Full Training: In many cases, this few-shot, training-free approach achieved results comparable to models fine-tuned on the entire training set. For instance, on WebQuestions, it reached a BLEU-4 of 29.73, while a fully-trained Transformer baseline only hit 8.94.

Conclusion

KQG-CoT provides a robust, training-free solution for KBQG in low-resource settings. By prioritizing structural diversity and multi-step reasoning, it bridges the gap between few-shot prompting and supervised fine-tuning. Future work may involve automating the rationale-writing process to further reduce human effort in prompt engineering.

Summary updated

BibTeX
@inproceedings{liang2023prompting,
  author = {Yuanyuan Liang and Jianing Wang and Hanlun Zhu and Lei Wang and Weining Qian and Yunshi Lan},
  title = {{Prompting Large Language Models with Chain-of-Thought for Few-Shot Knowledge Base Question Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.263},
}
Figure