The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of Code
On the map: LLM reasoning → Causal reasoning in LLMs
Abstract (arXiv)
Causal reasoning, the ability to identify cause-and-effect relationship, is crucial in human thinking. Although large language models (LLMs) succeed in many NLP tasks, it is still challenging for them to conduct complex causal reasoning like abductive reasoning and counterfactual reasoning. Given the fact that programming code may express causal relations more often and explicitly with conditional statements like ``if``, we want to explore whether Code-LLMs acquire better causal reasoning abilities. Our experiments show that compared to text-only LLMs, Code-LLMs with code prompts are significantly better in causal reasoning. We further intervene on the prompts from different aspects, and discover that the programming structure is crucial in code prompt design, while Code-LLMs are robust towards format perturbations.
Key facts. Cited by 21 papers in the map (data through 7 Oct 2026). Placed in Causal reasoning in LLMs, one of 17 directions in LLM reasoning. Builds on 13 of its 38 references that are in the map. First posted on arXiv 30 May 2023.
Builds on
13 of 38 references.
References · 13
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,057
- 2022Diffusion-LM Improves Controllable Text Generationcited by 1,006
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023StarCoder: may the source be with you!cited by 790
- 2022PAL: Program-aided Language Modelscited by 635
- 2022Autoformalization with Large Language Modelscited by 252
- 2022Language Models of Code are Few-Shot Commonsense Learnerscited by 160
- 2022COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamicscited by 159
- 2021Towards Zero-Label Language Learningcited by 76
- 2022Code4Struct: Code Generation for Few-Shot Event Structure Predictioncited by 70
Built on by
Citing papers per year: 2023: 3; 2024: 10; 2025: 5; 2026: 3.
21 papers.
Sort:
By area:
- 2024Are LLMs Capable of Data-based Statistical and Causal Reasoning? Benchmarking Advanced Quantitative Reasoning with Datacited by 61
- 2024LLaRA: Supercharging Robot Learning Data for Vision-Language Policycited by 51
- 2024Large Language Models and Causal Inference in Collaboration: A Surveycited by 26
- 2024Understanding Long Videos with Multimodal Language Modelscited by 25
- 2024Cause and Effect: Can Large Language Models Truly Understand Causality?cited by 23
- 2023When Do Program-of-Thoughts Work for Reasoning?cited by 19
- 2025Large language models for artificial general intelligence (AGI): A survey of foundational principles and approachescited by 18
- 2024Counterfactual Token Generation in Large Language Modelscited by 14
- 2024A Critical Review of Causal Reasoning Benchmarks for Large Language Modelscited by 13
- 2023Event Causality Is Key to Computational Story Understandingcited by 11
- 2024MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Datasetcited by 11
- 2023Applying Large Language Models for Causal Structure Learning in Non Small Cell Lung Cancercited by 8
9 more
- 2024Can LLMs Correct Physicians, Yet? Investigating Effective Interaction Methods in the Medical Domaincited by 7
- 2025Code Execution as Grounded Supervision for LLM Reasoningcited by 5
- 2026Wiring the 'Why': A Unified Taxonomy and Survey of Abductive Reasoning in LLMscited by 5
- 2024Do LLMs Have the Generalization Ability in Conducting Causal Inference?cited by 2
- 2025Do Large Language Models Show Biases in Causal Learning? Insights from Contingency Judgmentcited by 1
- 2025Representation in large language modelscited by 0
- 2025If Probable, Then Acceptable? Understanding Conditional Acceptability Judgments in Large Language Modelscited by 0
- 2026Retell, Reward, Repeat: Reinforcement Learning for Narrative Theory-Informed Story Retellingcited by 0
- 2026Contextual Causality with Large Language Models: A Surveycited by 0
- 2026Contextual Causality with Large Language Models: A Survey18 Sep 2026
- 2026Wiring the 'Why': A Unified Taxonomy and Survey of Abductive Reasoning in LLMs9 Apr 2026
- 2026Retell, Reward, Repeat: Reinforcement Learning for Narrative Theory-Informed Story Retelling23 Jan 2026
- 2025Do Large Language Models Show Biases in Causal Learning? Insights from Contingency Judgment15 Oct 2025
- 2025If Probable, Then Acceptable? Understanding Conditional Acceptability Judgments in Large Language Models9 Oct 2025
- 2025Code Execution as Grounded Supervision for LLM Reasoning12 Jun 2025
- 2025Large language models for artificial general intelligence (AGI): A survey of foundational principles and approaches6 Jan 2025
- 2025Representation in large language models1 Jan 2025
- 2024Do LLMs Have the Generalization Ability in Conducting Causal Inference?15 Oct 2024
- 2024Counterfactual Token Generation in Large Language Models25 Sep 2024
- 2024A Critical Review of Causal Reasoning Benchmarks for Large Language Models10 Jul 2024
- 2024LLaRA: Supercharging Robot Learning Data for Vision-Language Policy28 Jun 2024
9 more
- 2024MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Dataset4 Jun 2024
- 2024Can LLMs Correct Physicians, Yet? Investigating Effective Interaction Methods in the Medical Domain29 Mar 2024
- 2024Understanding Long Videos with Multimodal Language Models25 Mar 2024
- 2024Large Language Models and Causal Inference in Collaboration: A Survey14 Mar 2024
- 2024Cause and Effect: Can Large Language Models Truly Understand Causality?28 Feb 2024
- 2024Are LLMs Capable of Data-based Statistical and Causal Reasoning? Benchmarking Advanced Quantitative Reasoning with Data27 Feb 2024
- 2023Event Causality Is Key to Computational Story Understanding16 Nov 2023
- 2023Applying Large Language Models for Causal Structure Learning in Non Small Cell Lung Cancer13 Nov 2023
- 2023When Do Program-of-Thoughts Work for Reasoning?29 Aug 2023
- 2024Are LLMs Capable of Data-based Statistical and Causal Reasoning? Benchmarking Advanced Quantitative Reasoning with Datacited by 61
- 2023When Do Program-of-Thoughts Work for Reasoning?cited by 19
- 2024A Critical Review of Causal Reasoning Benchmarks for Large Language Modelscited by 13
- 2024MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Datasetcited by 11
- 2025Code Execution as Grounded Supervision for LLM Reasoningcited by 5
- 2026Wiring the 'Why': A Unified Taxonomy and Survey of Abductive Reasoning in LLMscited by 5
- 2026Wiring the 'Why': A Unified Taxonomy and Survey of Abductive Reasoning in LLMs9 Apr 2026
- 2025Code Execution as Grounded Supervision for LLM Reasoning12 Jun 2025
- 2024A Critical Review of Causal Reasoning Benchmarks for Large Language Models10 Jul 2024
- 2024MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Dataset4 Jun 2024
- 2024Are LLMs Capable of Data-based Statistical and Causal Reasoning? Benchmarking Advanced Quantitative Reasoning with Data27 Feb 2024
- 2023When Do Program-of-Thoughts Work for Reasoning?29 Aug 2023
- 2024Large Language Models and Causal Inference in Collaboration: A Surveycited by 26
- 2024Cause and Effect: Can Large Language Models Truly Understand Causality?cited by 23
- 2024Counterfactual Token Generation in Large Language Modelscited by 14
- 2023Event Causality Is Key to Computational Story Understandingcited by 11
- 2023Applying Large Language Models for Causal Structure Learning in Non Small Cell Lung Cancercited by 8
- 2024Can LLMs Correct Physicians, Yet? Investigating Effective Interaction Methods in the Medical Domaincited by 7
- 2024Do LLMs Have the Generalization Ability in Conducting Causal Inference?cited by 2
- 2025Do Large Language Models Show Biases in Causal Learning? Insights from Contingency Judgmentcited by 1
- 2025Representation in large language modelscited by 0
- 2025If Probable, Then Acceptable? Understanding Conditional Acceptability Judgments in Large Language Modelscited by 0
- 2026Contextual Causality with Large Language Models: A Surveycited by 0
- 2026Contextual Causality with Large Language Models: A Survey18 Sep 2026
- 2025Do Large Language Models Show Biases in Causal Learning? Insights from Contingency Judgment15 Oct 2025
- 2025If Probable, Then Acceptable? Understanding Conditional Acceptability Judgments in Large Language Models9 Oct 2025
- 2025Representation in large language models1 Jan 2025
- 2024Do LLMs Have the Generalization Ability in Conducting Causal Inference?15 Oct 2024
- 2024Counterfactual Token Generation in Large Language Models25 Sep 2024
- 2024Can LLMs Correct Physicians, Yet? Investigating Effective Interaction Methods in the Medical Domain29 Mar 2024
- 2024Large Language Models and Causal Inference in Collaboration: A Survey14 Mar 2024
- 2024Cause and Effect: Can Large Language Models Truly Understand Causality?28 Feb 2024
- 2023Event Causality Is Key to Computational Story Understanding16 Nov 2023
- 2023Applying Large Language Models for Causal Structure Learning in Non Small Cell Lung Cancer13 Nov 2023
Similar, not cited
Close in wording, no citation either way
- 2024Code Prompting Elicits Conditional Reasoning Abilities in Text+Code LLMs
- 2025Unveiling Causal Reasoning in Large Language Models: Reality or Mirage?
- 2025Unveiling the Magic of Code Reasoning through Hypothesis Decomposition and Amendment
- 2025A Survey on Enhancing Causal Reasoning Ability of Large Language Models
- 2025On Code-Induced Reasoning in LLMs
- 2024Eliciting Causal Abilities in Large Language Models for Reasoning Tasks
- 2023Causal Reasoning and Large Language Models: Opening a New Frontier for Causality
- 2023CLadder: Assessing Causal Reasoning in Language Models