Temporal Knowledge Graph Forecasting Without Knowledge Using In-Context Learning

TL;DR

Using large language models (LLMs) with in-context learning (ICL) enables zero-shot temporal knowledge graph forecasting, matching SOTA performance without fine-tuning.

cs.CL 🔴 Advanced 2023-05-18 60 views
Dong-Ho Lee Kian Ahrabian Woojeong Jin Fred Morstatter Jay Pujara
Knowledge Graphs Temporal Forecasting Large Language Models In-Context Learning Zero-Shot Prediction

Key Findings

Methodology

This paper introduces a framework leveraging pre-trained LLMs (e.g., GPT-J, GPT-NeoX) for temporal knowledge graph (TKG) forecasting. Historical facts are converted into structured prompts using various strategies (entity, relation, unidirectional, bidirectional). These prompts encode the temporal and structural context, which the models process via token probability distributions to rank candidate entities. The approach avoids fine-tuning, relying solely on in-context learning. Multiple datasets (WIKI, YAGO, ICEWS) validate the method. The system captures complex temporal patterns, demonstrating that models can infer irregularities beyond simple recency or frequency biases, primarily depending on symbolic patterns in the context.

Key Results

  • Across datasets, GPT-NeoX with a history length of 100 achieves Hits@1 scores within ±3.6% of SOTA supervised models like RE-GCN and xERTE, indicating competitive zero-shot performance.
  • Replacing entity/relation names with random indices results in performance drops of only about 0.4%, showing semantic information is unnecessary; models leverage pattern recognition in symbols.
  • Increasing history length and model size consistently improves accuracy, confirming the scaling law and the importance of context in pattern learning.

Significance

This work challenges the conventional reliance on structured features and supervised training for knowledge graph forecasting. It demonstrates that large pre-trained models can perform effective temporal predictions purely through pattern recognition in context, opening pathways for unsupervised, scalable, and flexible knowledge inference. The findings have broad implications for deploying knowledge graphs in real-world, dynamic environments where data is sparse or rapidly changing, reducing the need for extensive annotation and structural engineering.

Technical Contribution

The paper pioneers a zero-shot, in-context learning approach for TKG forecasting, integrating multiple prompt strategies and fact filtering methods. It systematically evaluates the influence of historical context, prompt design, and model scale, establishing a new paradigm that relies on symbolic pattern extraction rather than explicit structural modeling. This approach simplifies the pipeline and enhances generalization, providing a foundation for future research in scalable, unsupervised knowledge inference.

Novelty

This is the first comprehensive study demonstrating that large language models can perform temporal knowledge graph forecasting without fine-tuning, solely based on context. It emphasizes the importance of symbolic pattern recognition over semantic content, diverging from traditional graph neural network-based methods and highlighting the emergent reasoning capabilities of pre-trained models.

Limitations

  • Model performance diminishes in highly sparse or complex relation scenarios where patterns are less explicit. The reliance on historical data quality can lead to error propagation.
  • Large-scale models entail significant computational costs, limiting practical deployment in resource-constrained settings.
  • The interpretability of predictions remains limited; understanding the reasoning behind specific forecasts is challenging.

Future Work

Future research could explore integrating multimodal data, enhancing interpretability, and developing lightweight models for real-time deployment. Combining few-shot learning with in-context methods may improve robustness. Further, efforts to explain model reasoning could increase trust and transparency, broadening application domains.

AI Executive Summary

This study introduces a groundbreaking approach to temporal knowledge graph forecasting by harnessing the power of large pre-trained language models through in-context learning (ICL). Traditional methods rely heavily on complex structural modeling and supervised training, which are often resource-intensive and limited in generalization. In contrast, the proposed framework converts historical facts into structured prompts, leveraging models like GPT-NeoX and GPT-J to predict future facts without any fine-tuning. The core idea is that these models, trained on vast amounts of text, can recognize and extrapolate complex temporal and structural patterns solely from context.

Experiments across multiple datasets, including WIKI, YAGO, and ICEWS, demonstrate that this approach achieves performance comparable to state-of-the-art supervised models, with Hits@1 scores within a 3.6% margin. Notably, replacing entity and relation names with random indices results in negligible performance loss (~0.4%), indicating that semantic content is not essential; instead, the models rely on symbolic patterns embedded in the context. Additionally, increasing the amount of historical data and model size consistently improves prediction accuracy, confirming the scalability and robustness of the method.

This research signifies a paradigm shift in knowledge graph forecasting, emphasizing the potential of pre-trained models to perform complex reasoning tasks in a zero-shot setting. It reduces dependence on extensive labeled data and structural engineering, making knowledge inference more accessible and adaptable to real-world, dynamic environments. The findings open avenues for further exploration into multimodal integration, interpretability, and resource-efficient deployment, promising a future where large models serve as flexible, general-purpose reasoning engines for knowledge-based applications.

Deep Analysis

Background

Knowledge graphs (KGs) have evolved from static representations to dynamic, temporal structures (TKGs), capturing evolving relationships over time. Early works like TransE and Know-Evolve focused on embedding entities and relations, but struggled with capturing complex temporal patterns and requiring large labeled datasets. Recent advances include graph neural networks (RE-GCN, xERTE) that model structural dependencies, yet they depend heavily on explicit features and supervised training. Meanwhile, large language models (LLMs) like GPT-3 have demonstrated emergent reasoning abilities, prompting investigations into their applicability for knowledge inference. This paper situates itself at this intersection, exploring how pre-trained LLMs can perform TKG forecasting without task-specific fine-tuning, leveraging their pattern recognition capabilities to address limitations of prior models.

Core Problem

Existing TKG forecasting models rely on supervised learning, structural assumptions, and extensive labeled data, which hinder scalability and adaptability. They often require dataset-specific architectures and struggle with generalization in sparse or evolving environments. The core challenge is to develop a method that can perform accurate future event prediction in a zero-shot manner, utilizing the implicit knowledge embedded in pre-trained models. This involves designing prompts that effectively encode historical information and extracting predictions solely from token probabilities, bypassing the need for explicit structural modeling or additional training. Addressing this challenge could significantly simplify deployment and improve robustness across diverse scenarios.

Innovation

The paper introduces a novel zero-shot forecasting framework based on in-context learning, where large language models process structured prompts derived from historical facts. Key innovations include: 1) employing multiple fact filtering strategies (entity, relation, unidirectional, bidirectional) to tailor context; 2) designing prompt templates using entity indices or lexical forms; 3) demonstrating that semantic information is non-essential by replacing names with random indices; 4) systematically analyzing the impact of historical length, model size, and prompt design. These innovations enable models to learn complex temporal and structural patterns solely from context, reducing reliance on explicit graph structures and supervised data, thus broadening the applicability of LLMs for knowledge inference.

Methodology

  • �� Select relevant historical facts from previous graph snapshots based on query type and filtering strategy. • Convert facts into structured prompts using either index-based or lexical templates, encoding entity and relation information. • Append the query to the prompt, forming a context for the model. • Use the pre-trained LLM to generate token probabilities for candidate entities, ranking them accordingly. • For multi-step prediction, incorporate previous predictions as additional context, iterating the process. • Experiment with different prompt formats, historical lengths, and model scales to evaluate performance. • Employ time-aware filtering to exclude known valid answers during evaluation, ensuring fair ranking. • Analyze the influence of semantic content by replacing names with random indices, assessing reliance on semantic priors.

Experiments

The experimental setup involves multiple datasets—WIKI, YAGO, ICEWS14, ICEWS18, and a newly constructed ACLED dataset—covering diverse temporal and structural characteristics. Baselines include supervised models (RE-GCN, xERTE) and heuristic heuristics (frequency, recency). Metrics such as Hits@1, 3, 10 assess prediction accuracy. Models tested include GPT-J, GPT-NeoX, and GPT-3.5-turbo, with parameters ranging from 124M to 20B. Experiments vary historical length, prompt design, and model size, with multiple runs to ensure robustness. Evaluation employs time-aware filtering to prevent penalizing valid predictions, and ablation studies analyze the effects of prompt strategies and semantic content. Results demonstrate that large, pre-trained models can perform competitively in a zero-shot setting, with performance improving with larger context and models.

Results

Pre-trained models like GPT-NeoX achieve Hits@1 scores within ±3.6% of supervised SOTA models across datasets, confirming strong zero-shot capabilities. Replacing entity/relation names with random indices causes performance drops of only about 0.4%, indicating semantic content is not critical. Increasing historical context length and model scale consistently enhances accuracy, validating the scalability principle. The models outperform simple heuristics (frequency, recency) by significant margins (+10% to +28%), demonstrating their ability to learn complex, irregular patterns beyond straightforward temporal cues. These findings underscore the potential of large models to generalize temporal reasoning without task-specific training.

Applications

This approach is applicable in real-time event prediction, dynamic knowledge inference, and intelligent decision-making systems where annotated data is scarce or rapidly changing. It simplifies deployment by removing the need for dataset-specific training, making it suitable for industries like finance, security, and social media analysis. The method can be integrated into existing knowledge management platforms, providing adaptive, scalable forecasting capabilities. Long-term, it paves the way for autonomous reasoning systems that leverage pre-trained models for diverse knowledge inference tasks, reducing reliance on handcrafted features and extensive labeled datasets.

Limitations & Outlook

Despite promising results, the approach struggles with highly sparse or noisy data where patterns are less explicit. Large models incur high computational costs, limiting practical deployment in resource-constrained environments. The lack of interpretability hampers understanding of specific predictions, raising trust issues. Furthermore, the method's reliance on historical data quality means that biased or incomplete data can lead to inaccurate forecasts. Future work should focus on improving model efficiency, interpretability, and robustness, especially in complex, real-world scenarios where data quality varies.

Plain Language Accessible to non-experts

想象你在一家工厂工作,工厂每天都在做不同的任务。有时候,工厂会按照一定的规律工作,比如每周都做一样的事情。有时候,工厂会突然改变计划,做一些新奇的事情。工厂的管理者希望能提前知道下一步会发生什么,但没有详细的计划表。于是,他们用了一台非常聪明的机器(就像大模型),只看过去的任务记录(历史事实),让它自己学习工厂的规律。只要给它一些过去的任务,它就能猜出下一步可能发生的事情。最厉害的是,这台机器不用专门学习每个任务的具体内容,只依靠观察到的符号和模式,就能做出准确的预测。这就像你用观察工厂的日常操作,自己猜测明天的生产计划一样,既简单又高效。

ELI14 Explained like you're 14

想象你在学校里,每天都有不同的事情发生,比如运动会、考试、聚会。你想知道明天会发生什么,但没有老师提前告诉你。你可以回想过去的事情,比如上次运动会、上次考试的时间,然后根据这些记忆猜测未来的事情。其实,你不用知道每件事情的具体内容,只要记住一些规律,比如每年运动会都在春天,考试一般在学期中,就能大致猜到明天可能会发生什么。这个猜测的方法就像用大模型一样,它通过观察过去的事件,学习到一些隐藏的规律,然后用这些规律预测未来。最酷的是,它不需要你告诉它每个细节,只要给它一些过去的记录,它就能自己推断出下一件可能发生的事情。这就像你用自己的观察和经验,变成了一个聪明的小预测家!

Abstract

Temporal knowledge graph (TKG) forecasting benchmarks challenge models to predict future facts using knowledge of past facts. In this paper, we apply large language models (LLMs) to these benchmarks using in-context learning (ICL). We investigate whether and to what extent LLMs can be used for TKG forecasting, especially without any fine-tuning or explicit modules for capturing structural and temporal information. For our experiments, we present a framework that converts relevant historical facts into prompts and generates ranked predictions using token probabilities. Surprisingly, we observe that LLMs, out-of-the-box, perform on par with state-of-the-art TKG models carefully designed and trained for TKG forecasting. Our extensive evaluation presents performances across several models and datasets with different characteristics, compares alternative heuristics for preparing contextual information, and contrasts to prominent TKG methods and simple frequency and recency baselines. We also discover that using numerical indices instead of entity/relation names, i.e., hiding semantic information, does not significantly affect the performance ($\pm$0.4\% Hit@1). This shows that prior semantic knowledge is unnecessary; instead, LLMs can leverage the existing patterns in the context to achieve such performance. Our analysis also reveals that ICL enables LLMs to learn irregular patterns from the historical context, going beyond simple predictions based on common or recent information.

cs.CL