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 · DOI

Introduction

Knowledge Base Question Generation (KBQG) is the task of translating structured logical forms—such as SPARQL queries or s-expressions—into fluent, natural language questions. This capability is foundational for developing robust Question Answering (QA) systems and interactive dialogue agents. However, traditional approaches to KBQG face two primary obstacles: the extreme scarcity of high-quality human-annotated data and the inherent structural complexity of nested logical forms. Mapping complex joins, filters, and aggregations directly to a single sentence remains a significant compositional challenge for neural models, particularly in low-resource environments.

To address these issues, this paper introduces KQG-CoT, a training-free framework that leverages the reasoning capabilities of Large Language Models (LLMs) through sophisticated prompting. By decomposing the generation process into a "Chain-of-Thought" (CoT) of simpler sub-questions, the method significantly outperforms existing few-shot techniques and achieves performance comparable to models trained on full datasets.

Methodology

The KQG-CoT framework avoids the need for computationally expensive fine-tuning by focusing on two strategic stages: supportive exemplar selection and structured prompt construction.

1. Supportive Logical Forms Selection

To provide the LLM with the most effective few-shot examples, the system employs a diversity-oriented selection strategy. Rather than selecting examples based on raw content, the framework extracts the "skeleton" of logical forms by replacing specific entities and relations with generic placeholders (e.g., e and r). These skeletons are then encoded into vectors and clustered using K-means. By sampling representative logical forms from distinct clusters, the system ensures that the prompt includes a wide variety of syntactic and structural "grammars" present in the knowledge base.

2. Prompt Construction via Chain-of-Thought

The core innovation of KQG-CoT is treating question generation as a multi-step reasoning task rather than a direct translation task. Instead of prompting the LLM to generate a final question immediately, the prompt provides a reasoning chain. A complex logical form is decomposed into nested sub-graphs, and the model is guided to generate simpler intermediate questions for each sub-graph.

An enhanced version, KQG-CoT+, further refines this by ordering the demonstrations by complexity. By presenting examples in a curriculum—moving from simple one-hop questions to multi-hop queries—the LLM better learns the compositional building blocks required for complex generation.

Experimental Evaluation

The researchers evaluated KQG-CoT+ using text-davinci-003 across three benchmark datasets:

  • WebQuestions (WQ): Questions based on Google Freebase.
  • PathQuestions (PQ): Focused on multi-hop reasoning (2-hop and 3-hop).
  • GrailQA (GQ): A large-scale dataset featuring complex logic, including counting and superlatives across 86 domains.

Key Results and Insights

The experimental results demonstrate that KQG-CoT+ provides a substantial leap in few-shot performance:

  • State-of-the-Art Performance: On the PathQuestions dataset, KQG-CoT+ outperformed the previous few-shot state-of-the-art (SoTA) by 18.25 BLEU-4 points, with significant gains in METEOR and ROUGE-L metrics.
  • Parity with Supervised Models: On WebQuestions, using only 12 examples, the framework achieved a BLEU-4 score of 29.73. This is remarkably close to the performance of a T5-Large model (28.78) trained on the entire dataset, highlighting the efficiency of the prompting approach.
  • Human Evaluation: Human assessments confirmed that questions generated by KQG-CoT+ were superior in syntactic correctness, complexity, and logical relevance compared to standard prompting baselines.

The success of this method suggests that the "reasoning over mapping" paradigm is highly effective for KBQG. By providing a structural scaffold through sub-questions, the model is less likely to lose track of the underlying logic in complex, nested queries.

Limitations and Future Work

While KQG-CoT+ reduces the need for large-scale training data, it currently relies on manually written "rationales" (the step-by-step sub-questions) for the few-shot exemplars. This introduces a degree of human effort and potential bias. Additionally, the framework's efficacy is tied to the reasoning strength of the underlying LLM; performance may vary when using smaller or open-source models. Future research will focus on automating the generation of these CoT rationales to create a fully autonomous, zero-human-effort framework.

Conclusion

KQG-CoT demonstrates that complex structural mapping tasks can be effectively managed by LLMs when framed as decompositional reasoning problems. By combining diversity-aware exemplar selection with a curriculum-based Chain-of-Thought, the framework sets a new benchmark for few-shot Knowledge Base Question Generation, rivaling fully supervised alternatives.

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