TimeLlama is an instruction-finetuned Llama2 series that improves complex temporal reasoning ability.
In this work, we introduce the first multi-source dataset for explainable temporal reasoning, called ExpTime. The dataset contains 26k examples derived from temporal knowledge graph datasets. Each example includes a context with multiple events, a future event to predict, and an explanation for the prediction in the form of temporal reasoning over the events.
To generate the dataset, we propose a novel knowledge-graph-instructed-generation strategy. The dataset supports the comprehensive evaluation of large language models on complex temporal reasoning, future event prediction, and explainability.
Based on ExpTime, we develop TimeLlaMA, a series of LLM models fine-tuned for explainable temporal reasoning. TimeLlaMA builds on the foundation LLM LLaMA-2 and utilizes instruction tuning to follow prompts for making explanations.
1from transformers import LlamaConfig, LlamaTokenizer, LlamaForCausalLM
2# Model names: "chrisyuan45/TimeLlama-7b-chat", "chrisyuan45/TimeLlama-13b-chat"
3model = LlamaForCausalLM.from_pretrained(
4 model_name,
5 return_dict=True,
6 load_in_8bit=quantization,
7 device_map="auto",
8 low_cpu_mem_usage=True)
9tokenizer = LlamaTokenizer.from_pretrained(model_name)
Please check our repository for the detailed finetuning method.