The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of Code

Xiao Liu, Da Yin, Chen Zhang, Yansong Feng, Dongyan Zhao
5/30/2023
cs.CL

No official code found. Best implementation: xxxiaol/magic-if (31 stars, MIT, last commit 2023-06-04).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

xxxiaol/magic-ifCommunity100%
MIT

Source code and data for The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of Code (Findings of ACL 2023)

313PythonMay 14, 20233 years agoMIT

Similar Papers

Cite this paper

@article{liu2023magic,
  title  = {The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of Code},
  author = {Xiao Liu and Da Yin and Chen Zhang and Yansong Feng and Dongyan Zhao},
  year   = {2023},
  eprint = {2305.19213},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2305.19213v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2305.19213.svg)](https://codeofpaper.com/paper/2305.19213)

Discussion