Two-stage Generative Question Answering on Temporal Knowledge Graph Using Large Language Models

Yifu Gao, Linbo Qiao, Zhigang Kan, Zhihua Wen, Yongquan He, Dongsheng Li

Abstract

Temporal Knowledge Graphs (TKGs) represent facts with associated timestamps, reflecting the dynamic nature of real-world information. Answering natural language questions over TKGs (TKGQA) requires sophisticated reasoning over both graph structure and temporal dimensions. While Large Language Models (LLMs) excel at general reasoning, they often struggle with specific temporal facts and chronological dependencies. We present GenTKGQA, a two-stage generative framework that leverages LLMs for constraint mining and integrates Temporal Graph Neural Network (T-GNN) signals through Virtual Knowledge Indicators (VKIs). GenTKGQA achieves state-of-the-art results on major benchmarks, demonstrating significant improvements in complex temporal reasoning and robustness to limited training data.

Introduction

Most knowledge graphs (KGs) are static, but the real world is dynamic. Temporal Knowledge Graphs (TKGs) store facts with timestamps—for example, knowing that Barack Obama was President only between 2009 and 2017. Answering natural language questions over these graphs (TKGQA) is incredibly difficult because it requires reasoning over both structure (who is connected to whom) and time (when did this happen?). While LLMs like ChatGPT are great at general reasoning, they often "hallucinate" or fail on specific temporal facts. Simply feeding an LLM a list of facts as text often isn't enough for complex reasoning, as the model may struggle to grasp the underlying chronological order and structural dependencies.

Methodology

The authors propose GenTKGQA, a two-stage generative framework designed to bridge the gap between structured temporal data and natural language reasoning:

  1. Stage 1: Subgraph Retrieval: Instead of searching the entire massive TKG, the system uses an LLM's intrinsic knowledge to narrow the search space. It performs "Relation Ranking" to find relevant predicates and "Time Mining" to identify temporal constraints (e.g., "after 2016") directly from the question. This allows the system to extract a small, highly relevant subgraph from the TKG.
  2. Stage 2: Answer Generation: To help the LLM truly "understand" the graph, the authors don't just convert facts to text. They use a Temporal Graph Neural Network (T-GNN) to encode the subgraph's structural and temporal features. They then introduce Virtual Knowledge Indicators (VKIs)—special tokens like [SUB], [REL], and [OBJ]—that act as bridges, projecting the T-GNN's high-dimensional signals into the LLM's word-embedding space. Finally, they fine-tune an open-source LLM (Llama 2-7B) using instruction tuning to generate the final answer based on these fused signals.
The GenTKGQA architecture: Stage 1 retrieves subgraphs using LLM-mined constraints, and Stage 2 fuses T-GNN signals with LLM text via Virtual Knowledge Indicators.

Key Insights and Results

GenTKGQA was evaluated on two major benchmarks: CronQuestions (410k pairs) and TimeQuestions (13.5k pairs). The model set new records across the board, particularly on the Hits@1 metric:

  • CronQuestions Performance: Achieved an overall Hits@1 of 0.978, significantly outperforming the previous best model (TempoQR at 0.918) and far surpassing ChatGPT with retrieved facts (0.754).
  • Complex Reasoning: On difficult "Before/After" or "First/Last" questions, GenTKGQA improved performance by 11.3% over the second-best method.
  • Robustness to Small Data: The model shows impressive "few-shot" capabilities. Even with only 20% of the training data, GenTKGQA outperformed the next best model by 32% on complex questions, suggesting that the two-stage approach effectively leverages the LLM's pre-existing reasoning strengths.

Qualitatively, GenTKGQA demonstrates a superior ability to synthesize retrieved facts into precise answers. As shown in the comparison below, while standard LLMs might apologize for a lack of info or get chronological details wrong, GenTKGQA accurately identifies specific years for complex temporal queries.

Comparison of responses: GenTKGQA correctly identifies specific years for complex temporal queries where standard LLMs fail.

Conclusion

GenTKGQA represents a significant step forward in temporal knowledge graph reasoning. By combining the zero-shot mining capabilities of LLMs with the structural awareness of T-GNNs through deep fusion, the framework overcomes common limitations like hallucination and chronological confusion. Future work will focus on extending this approach to multi-hop temporal problems and refining prompt template sensitivity.

Summary updated

BibTeX
@inproceedings{gao2024two,
  author = {Yifu Gao and Linbo Qiao and Zhigang Kan and Zhihua Wen and Yongquan He and Dongsheng Li},
  title = {{Two-stage Generative Question Answering on Temporal Knowledge Graph Using Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.401},
}
Figure