Introduction
Knowledge Graphs (KGs) are prevalent resources for representing real-world facts in a structured way.
While traditionally, KGs have been utilized for representing static snapshots of “current” knowledge, recently, temporal KGs (TKGs) have gained popularity to preserve the complex temporal dynamics of knowledge Leblay and Chekol ( 2018 ); García-Durán et al. ( 2018 ); Goel et al. ( 2020 ); Lacroix et al. ( 2020 ) .
Recent endeavors in the area of TKGs have been focused on predicting future missing links ( i.e., forecasting), given a query quadruple q=\left(s_{i},p_{j},?,t_{T}\right) and a set of associated historical facts \mathcal{E}_{q}=\left\{\left(s,p,o,t\right)|t<t_{T}\right\}\subseteq\mathcal{E} Gastinger et al. ( 2022 ) .
An illustrative example of this task is the question “ Which team will win the Super Bowl in 2023? ” that can be expressed as q= ( Super bowl , Champion , ?, 2023) and \mathcal{E}_{q}= {( Super bowl , Champion , Los Angeles , 2022), ( Super bowl , Champion , Tampa Bay , 2021), …} (See Table 1 ).
The ultimate objective is to identify the most suitable entity among all the football teams \mathcal{E} ( e.g., St Louis , Baltimore ) to fill the missing field.

Prior research on TKG forecasting has been primarily focused on developing supervised approaches such as employing graph neural networks to model interrelationships among entities and relations Jin et al. ( 2020 ); Li et al. ( 2021 ); Han et al. ( 2021b , a ) , using reinforcement learning techniques Sun et al. ( 2021 ) , and utilizing logical rules Zhu et al. ( 2021 ); Liu et al. ( 2022 ) .
However, these techniques have prominent limitations, including the need for large amounts of training data that include thorough historical information for the entities.
Additionally, model selection is a computationally expensive challenge as the state-of-the-art approach differs for each dataset.

In this paper, we develop a TKG forecasting approach by casting the task as an in-context learning (ICL) problem using large language models (LLMs).
ICL refers to the capability of LLMs to learn and perform an unseen task efficiently when provided with a few examples of input-label pairs in the prompt Brown et al. ( 2020 ) .
Prior works on ICL usually leverage few-shot demonstrations, where a uniform number of examples are provided for each label to solve a classification task Min et al. ( 2022 ); Wei et al. ( 2023 ) .
In contrast, our work investigates what the model learns from irregular patterns of historical facts in the context.
We design a three-stage pipeline to control (1) the background knowledge selected for context, (2) the prompting strategy for forecasting, and (3) decoding the output into a prediction.
The first stage uses the prediction query to retrieve a set of relevant past facts from the TKG that can be used as context (Section 3.1 ).
The second stage transforms these contextual facts into a lexical prompt representing the prediction task (Section 3.3 ).
The third stage decodes the output of the LLM into a probability distribution over the entities and generates a response to the prediction query (Section 3.4 ).
Our experimental evaluation performs competitively across a diverse collection of TKG benchmarks without requiring the time-consuming supervised training, or custom-designed architectures.

We present extensive experimental results on common TKG benchmark datasets such as WIKI Leblay and Chekol ( 2018 ) , YAGO Mahdisoltani et al. ( 2014 ) , and ICEWS García-Durán et al. ( 2018 ); Jin et al. ( 2020 ) .
Our findings are as follows:
(1) LLMs demonstrate the ability to make predictions about future facts using ICL without requiring any additional training.
Moreover, these models show comparable performance to supervised approaches, falling within the (-3.6%, +1.5%) Hits@1 margin, relative to the median approach for each dataset;
(2) LLMs perform almost identically when we replace entities’ and relations’ lexical names with numerically mapped indices, suggesting that the prior semantic knowledge is not a critical factor for achieving such a high performance;
and (3) LLMs outperform the best heuristic rule-based baseline on each dataset ( i.e., the most frequent or the most recent, given the historical context) by (+10%, +28%) Hits@1 relative margin, indicating that they do not simply select the output using frequency or recency biases in ICL Zhao et al. ( 2021 ) .