TARGA: Targeted Synthetic Data Generation for Practical Reasoning over Structured Data

Xiang Huang, Jiayu Shen, Shanshan Huang, Sitao Cheng, Xiaxia Wang, Yuzhong Qu

Abstract

Semantic parsing, which converts natural language queries into logic forms, plays a crucial role in reasoning within structured environments. However, existing methods encounter two significant challenges: reliance on extensive manually annotated datasets and limited generalization capability to unseen examples. To tackle these issues, we propose Targeted Synthetic Data Generation (TARGA), a practical framework that dynamically generates high-relevance synthetic data without manual annotation. Starting from the pertinent entity and relation of a given question, we probe for the potential relevant queries through layer-wise expansion and cross-layer combination. Then, we generate corresponding natural language questions for these constructed queries to jointly serve as the synthetic demonstration for in-context learning. Experiments on multiple knowledge-based question answering (KBQA) datasets demonstrate that TARGA, using only a 7B-parameter model, substantially outperforms existing non-fine-tuned methods that utilize close-sourced models, achieving notable improvements in F1 scores on GrailQA (+7.7) and KBQA-Agent (+12.2). Furthermore, TARGA also exhibits superior sample efficiency, robustness, and generalization capabilities under non-IID settings.

Introduction: The Challenge of Semantic Parsing

Semantic parsing translates natural language questions into executable logic (like SQL or SPARQL) to interact with structured environments like databases or Knowledge Bases (KBs). Currently, the best-performing models rely heavily on either massive, manually annotated datasets for fine-tuning or retrieving examples from those datasets for In-Context Learning (ICL).

This reliance creates two major bottlenecks:

  1. Annotation Cost: Collecting manual annotations for specific, massive environments (like Freebase, which has billions of triples) is incredibly labor-intensive.
  2. Poor Generalization: Even with large datasets, models struggle with "non-I.I.D." data—questions involving unseen entities, relations, or novel query structures. If a test question's structure isn't in the static training set, retrieval-based ICL methods fail to find helpful demonstrations.
Comparison of TARGA with previous methods, highlighting the shift from manual/static data to automated/targeted synthetic data.

The TARGA Framework

To bypass the need for static datasets, TARGA dynamically synthesizes custom examples tailored to the user's specific question at inference time. The pipeline operates in four distinct steps:

  1. Candidate KB Items Retrieval: TARGA extracts potential entities and relations relevant to the input question from the Knowledge Graph.
  2. Synthetic Query Construction: It builds valid logic forms (using a simplified language called PyQL) from these items. To avoid combinatorial explosion, it uses a simple-to-complex search: Layer-wise Expansion (for multi-hop queries) and Cross-layer Combination (for multi-constraint queries). Crucially, it only expands sub-structures that return non-empty execution results on the actual KB, filtering out invalid paths early.
  3. Synthetic Query Re-ranking: The valid synthetic queries are translated into pseudo-natural language using simple heuristic rules ("Query Textification"). An embedding model then ranks these pseudo-questions based on their similarity to the user's original question.
  4. Question Answering: The top-ranked synthetic (pseudo-question, query) pairs are fed into a Large Language Model (LLM) as demonstrations for standard In-Context Learning, guiding the LLM to parse the actual user question.
The four-step pipeline of the TARGA framework, from KB-item linking to final question answering.

Experimental Evaluation

The authors evaluated TARGA across several complex datasets, including GrailQA (divided into I.I.D., Compositional, and Zero-shot levels), GraphQ (compositional questions), KBQA-Agent (a difficult mixed dataset), MetaQA-3Hop, and WikiSQL (Text2SQL requiring aggregation and arithmetic).

Key Insights

  • Dynamic Synthesis beats Static Retrieval: Generating targeted examples on the fly naturally solves the generalization problem. Because the demonstrations are built using the specific entities and relations relevant to the test question, the model is never truly operating "zero-shot."
  • Execution as a Filter: By only expanding query graphs that actually execute and return results on the KB, TARGA performs joint entity-relation disambiguation. This drastically reduces the search space without needing a highly precise, fine-tuned relation-linking model.
  • Pseudo-Language is Sufficient: Rule-based "textification" (e.g., turning a query into "what mass_unit, mass_unit has weight...") works effectively for embedding-based retrieval and LLM prompting, saving significant compute time compared to using an LLM for natural language generation.
  • High-Quality Prompts Democratize LLMs: Highly relevant demonstrations allow smaller open-source models (like Qwen-7B) to outperform massive closed-source models (like GPT-4) that rely on generic prompts.

Results and Performance

  • State-of-the-Art Performance: Using a Qwen-2.5-7B-Instruct model, TARGA achieved an F1 score of 69.0 on GrailQA (+7.7 over the previous non-fine-tuned SOTA) and 46.5 on KBQA-Agent (+12.2 F1).
  • Extreme Sample Efficiency: TARGA achieves peak performance with just ~10 demonstrations. Remarkably, TARGA with just one synthetic demonstration outperformed baseline methods using 20 retrieved demonstrations.
  • Efficiency & Robustness: TARGA's token cost is approximately 1/10th that of other ICL-based methods, processing questions in ~4.5 seconds. In adversarial settings, TARGA's performance dropped only ~25%, compared to 40-75% drops in baseline methods.

Conclusion

Targa demonstrates that targeted synthetic data generation is a powerful alternative to manual annotation and static retrieval for semantic parsing. By leveraging the structure of the Knowledge Base itself to guide data generation, it achieves superior generalization and efficiency, even when using relatively small open-source models.

Summary updated

BibTeX
@inproceedings{huang2025targa,
  author = {Xiang Huang and Jiayu Shen and Shanshan Huang and Sitao Cheng and Xiaxia Wang and Yuzhong Qu},
  title = {{TARGA: Targeted Synthetic Data Generation for Practical Reasoning over Structured Data}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=IFR3B55hwr},
}
Figure