{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/large-language-models-can-learn-temporal","title":"Large Language Models Can Learn Temporal Reasoning","arxiv_id":"2401.06853","date":"2024-01-12","proceeding":null,"authors":["Siheng Xiong","Ali Payani","Ramana Kompella","Faramarz Fekri"],"abstract":"While large language models (LLMs) have demonstrated remarkable reasoning capabilities, they are not without their flaws and inaccuracies. Recent studies have introduced various methods to mitigate these limitations. Temporal reasoning (TR), in particular, presents a significant challenge for LLMs due to its reliance on diverse temporal concepts and intricate temporal logic. In this paper, we propose TG-LLM, a novel framework towards language-based TR. Instead of reasoning over the original context, we adopt a latent representation, temporal graph (TG) that enhances the learning of TR. A synthetic dataset (TGQA), which is fully controllable and requires minimal supervision, is constructed for fine-tuning LLMs on this text-to-TG translation task. We confirmed in experiments that the capability of TG translation learned on our dataset can be transferred to other TR tasks and benchmarks. On top of that, we teach LLM to perform deliberate reasoning over the TGs via Chain-of-Thought (CoT) bootstrapping and graph data augmentation. We observed that those strategies, which maintain a balance between usefulness and diversity, bring more reliable CoTs and final results than the vanilla CoT distillation.","url_abs":"https://arxiv.org/abs/2401.06853v6","url_pdf":"https://arxiv.org/pdf/2401.06853v6.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"large-language-models-can-learn-temporal","repo_url":"https://github.com/xiongsiheng/tg-llm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"data-augmentation","task_name":"Data Augmentation"},{"task_slug":"diversity","task_name":"Diversity"},{"task_slug":"text-generation","task_name":"Text Generation"},{"task_slug":"translation","task_name":"Translation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2401.06853","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2401.06853"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/xiongsiheng/tg-llm","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":12,"unverified":15},"by_repo_kind":{"official":{"samples":27,"ran":12,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"2c503ce417d1dcb7","entry":"TG_formating_change","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/utlis.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/utlis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2c503ce417d1dcb7"}},{"code_sha256_prefix":"e60f57957786c21d","entry":"add_brackets","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/utlis.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/utlis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e60f57957786c21d"}},{"code_sha256_prefix":"aafcf7f19d17018f","entry":"calculate_EM","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Evaluation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Evaluation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aafcf7f19d17018f"}},{"code_sha256_prefix":"7bf3b153ae77bf4e","entry":"configure_experiment","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Inference_in_context_learning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Inference_in_context_learning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7bf3b153ae77bf4e"}},{"code_sha256_prefix":"04baeed1a6087e14","entry":"initialize_model","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Inference_in_context_learning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Inference_in_context_learning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"04baeed1a6087e14"}},{"code_sha256_prefix":"59cd476e2da672b1","entry":"my_generate_prompt_CoT_bs","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/prompt_generation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/prompt_generation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"59cd476e2da672b1"}},{"code_sha256_prefix":"728cf1bc1de4ee15","entry":"my_generate_prompt_TG_Reasoning","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/prompt_generation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/prompt_generation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"728cf1bc1de4ee15"}},{"code_sha256_prefix":"0f869ecd0da8b94a","entry":"my_gpt_completion","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Models.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Models.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0f869ecd0da8b94a"}},{"code_sha256_prefix":"b06bb22f061273b7","entry":"parse_generation","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Evaluation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Evaluation.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b06bb22f061273b7"}},{"code_sha256_prefix":"67e14cf8263186c1","entry":"prepare_prompts","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Example_accelerate_inference.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Example_accelerate_inference.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"67e14cf8263186c1"}},{"code_sha256_prefix":"8aaaded627e91fec","entry":"process_CoT","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/utlis.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/utlis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8aaaded627e91fec"}},{"code_sha256_prefix":"5e981e8216935d05","entry":"setup_model","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/CoT_bootstrap.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/CoT_bootstrap.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5e981e8216935d05"}},{"code_sha256_prefix":"cb4f976df70802fa","entry":"calculate_F1","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Evaluation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Evaluation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cb4f976df70802fa"}},{"code_sha256_prefix":"03fb82e648b4f4cb","entry":"initialize_model_and_tokenizer","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Inference_in_context_learning.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Inference_in_context_learning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"03fb82e648b4f4cb"}},{"code_sha256_prefix":"d9e464347efd6ebe","entry":"load_and_prepare_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/CoT_bootstrap.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/CoT_bootstrap.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d9e464347efd6ebe"}},{"code_sha256_prefix":"f5f3d5df55849409","entry":"load_and_prepare_dataset","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_text_to_TG_Trans.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_text_to_TG_Trans.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f5f3d5df55849409"}},{"code_sha256_prefix":"c7264563bb030e10","entry":"load_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Inference_in_context_learning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Inference_in_context_learning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c7264563bb030e10"}},{"code_sha256_prefix":"53c786894bf78ed0","entry":"load_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"53c786894bf78ed0"}},{"code_sha256_prefix":"e9cff349000673db","entry":"load_model_and_tokenizer","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e9cff349000673db"}},{"code_sha256_prefix":"cce7996e68e164e1","entry":"load_test_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Inference_in_context_learning.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Inference_in_context_learning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cce7996e68e164e1"}},{"code_sha256_prefix":"ea5ab833166b0ed2","entry":"my_generate_prompt_ICL","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/prompt_generation.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/prompt_generation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ea5ab833166b0ed2"}},{"code_sha256_prefix":"57830d7473a5dbd2","entry":"obtain_loss_in_batch","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Models.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"57830d7473a5dbd2"}},{"code_sha256_prefix":"485538ab9c196ec3","entry":"prepare_TG_pred","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"485538ab9c196ec3"}},{"code_sha256_prefix":"5c967fee8b9215c7","entry":"prepare_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5c967fee8b9215c7"}},{"code_sha256_prefix":"37999e53da63da2e","entry":"read_data","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"37999e53da63da2e"}},{"code_sha256_prefix":"b0e211cdbd2080be","entry":"run_inference","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/Example_accelerate_inference.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/Example_accelerate_inference.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b0e211cdbd2080be"}},{"code_sha256_prefix":"c676e0c7b2233e53","entry":"setup_directories","repo":"xiongsiheng/tg-llm","repo_kind":"official","path":"src/SFT_TG_Reasoning_ppl.py","file_url":"https://github.com/xiongsiheng/tg-llm/blob/HEAD/src/SFT_TG_Reasoning_ppl.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c676e0c7b2233e53"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}