Self-Improvement Programming for Temporal Knowledge Graph Question Answering

Zhuo Chen, Zhao Zhang, Zixuan Li, Fei Wang, Yutao Zeng, Xiaolong Jin, Yongjun Xu

Abstract

Temporal Knowledge Graph Question Answering (TKGQA) aims to answer questions with temporal intent over Temporal Knowledge Graphs (TKGs). The core challenge lies in understanding complex semantic information regarding multiple types of time constraints (e.g., before, first). Existing end-to-end methods implicitly model these constraints, which often fails to capture the full logic of the question. We introduce Prog-TQA, a novel self-improvement programming method that leverages the in-context learning of Large Language Models (LLMs) to generate program drafts. These drafts are aligned to TKGs via a linking module and executed to find answers. A self-improvement strategy bootstraps the LLM using high-quality self-generated drafts. Prog-TQA achieves significant improvements on MultiTQ and CronQuestions datasets, particularly in the Hits@1 metric.

Introduction

Answering questions over Temporal Knowledge Graphs (TKGs)—databases storing facts with timestamps—is a complex task. Unlike static queries, temporal questions often involve "combinatory constraints." For example, to answer "Which country was last visited by Obama before he visited the Foreign Minister of Cape Verde?", a system must identify a reference point in time, filter preceding events, and then select the most recent one.

Current approaches generally fall into two categories: embedding-based methods and semantic parsing. Embedding-based methods struggle with precise logical reasoning, while semantic parsing requires expensive, manually annotated logical forms. Prog-TQA addresses these issues by using LLMs to generate symbolic code drafts, which are then refined through a self-improvement loop.

Methods: The Prog-TQA Framework

Prog-TQA bridges the gap between the linguistic flexibility of LLMs and the logical precision of symbolic programming. The framework consists of three primary components:

  1. Extended Temporal Operators: The system extends the Knowledge-oriented Programming Language (KoPL) with specialized temporal operators such as FilterBefore, FilterFirst, and GetYear, allowing for concise expression of temporal logic.
  2. Modular Pipeline:
    • Draft Generation: Utilizing In-Context Learning (ICL), an LLM generates a "program draft" based on a few provided examples.
  3. Linking & Execution: A linking module maps entities and relations in the draft to the specific IDs in the TKG. The resulting grounded program is then executed against the database.
  4. Self-Improvement Strategy: To overcome the lack of annotated data, Prog-TQA uses gold answers as weak supervision. If a self-generated program yields the correct answer, it is used to fine-tune the LLM, iteratively enhancing its ability to handle complex reasoning.
The Prog-TQA framework architecture, illustrating the Draft Generation, Linking, and Execution modules.

Experimental Results

The researchers evaluated Prog-TQA on the MultiTQ and CronQuestions benchmarks. MultiTQ is particularly challenging due to its multi-constraint questions, while CronQuestions focuses on time intervals.

Prog-TQA established new state-of-the-art performance:

  • MultiTQ: Achieved a 60.9% improvement on multi-constraint questions and a 47.0% improvement on single-constraint questions (Hits@1).
  • CronQuestions: Showed a 2.1% relative improvement overall, with a 3.5% boost on complex queries.
Performance comparison between Prog-TQA and MultiQA across various temporal constraint types, showing significant gains in Hits@1.

The symbolic nature of the output also provides high interpretability, as the generated KoPL programs clearly show the reasoning path taken to reach an answer.

Conclusion and Future Work

Prog-TQA demonstrates that explicit symbolic modeling of temporal logic is superior to implicit embedding-based approaches for complex TKGQA. By leveraging LLMs as "draftsmen" and using a self-improvement loop, the system achieves high accuracy without massive manual annotation. Future research will focus on reducing "spurious programs"—where a flawed logic coincidentally produces the correct answer—and handling even finer temporal granularities.

Summary updated

BibTeX
@inproceedings{chen2024self,
  author = {Zhuo Chen and Zhao Zhang and Zixuan Li and Fei Wang and Yutao Zeng and Xiaolong Jin and Yongjun Xu},
  title = {{Self-Improvement Programming for Temporal Knowledge Graph Question Answering}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=9nO3Ejbvwh},
}
Figure