mlsanityData to 7 Oct 2026

Code Prompting Elicits Conditional Reasoning Abilities in Text+Code LLMs

arXiv 2401.10065 ↗First posted 18 Jan 2024cs.CLcited by 19

On the map: LLM reasoning → Prompting and chain-of-thought reasoning

Abstract (arXiv)

Reasoning is a fundamental component of language understanding. Recent prompting techniques, such as chain of thought, have consistently improved LLMs' performance on various reasoning tasks. Nevertheless, there is still little understanding of what triggers reasoning abilities in LLMs in the inference stage. In this paper, we introduce code prompting, a chain of prompts that transforms a natural language problem into code and directly prompts the LLM using the generated code without resorting to external code execution. We hypothesize that code prompts can elicit certain reasoning capabilities of LLMs trained on text and code and utilize the proposed method to improve conditional reasoning, the ability to infer different conclusions depending on the fulfillment of certain conditions. We find that code prompting exhibits a high-performance boost for multiple LLMs (up to 22.52 percentage points on GPT 3.5, 7.75 on Mixtral, and 16.78 on Mistral) across multiple conditional reasoning datasets. We then conduct comprehensive experiments to understand how code prompts trigger reasoning abilities and which capabilities are elicited in the underlying models. Our analysis of GPT 3.5 reveals that the code formatting of the input problem is essential for performance improvement. Furthermore, code prompts improve sample efficiency of in-context learning and facilitate state tracking of variables or entities.

Key facts. Cited by 19 papers in the map (data through 7 Oct 2026). Placed in Prompting and chain-of-thought reasoning, one of 17 directions in LLM reasoning. Builds on 16 of its 43 references that are in the map. First posted on arXiv 18 Jan 2024.

Builds on

16 of 43 references.

Closest ancestors · 3

Same direction, newest first

  1. 2023Measuring Faithfulness in Chain-of-Thought Reasoning17 Jul
  2. 2023Faithful Chain-of-Thought Reasoning31 Jan
  3. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Them17 Oct

Other references · 13

  1. 2023GPT-4 Technical Reportcited by 18,132
  2. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  4. 2021Training Verifiers to Solve Math Word Problemscited by 9,743
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  6. 2021Program Synthesis with Large Language Modelscited by 3,509
  7. 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
  8. 2023Mistral 7Bcited by 3,065
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  10. 2024Mixtral of Expertscited by 1,785
  11. 2023Textbooks Are All You Needcited by 561
  12. 2023Chain of Code: Reasoning with a Language Model-Augmented Code Emulatorcited by 120
1 more
  1. 2023Towards leveraging LLMs for Conditional QAcited by 2

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 7; 2025: 9; 2026: 3.

19 papers.

Sort:

By area:

  1. 2024A Systematic Survey of Prompt Engineering in Large Language Models: Techniques and Applicationscited by 428
  2. 2024Unlocking the Capabilities of Thought: A Reasoning Boundary Framework to Quantify and Optimize Chain-of-Thoughtcited by 56
  3. 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
  4. 2024Synatra: Turning Indirect Knowledge into Direct Demonstrations for Digital Agents at Scalecited by 43
  5. 2024SMARTCAL: An Approach to Self-Aware Tool-Use Evaluation and Calibrationcited by 13
  6. 2024Fine-Tuning on Diverse Reasoning Chains Drives Within-Inference CoT Refinement in LLMscited by 12
  7. 2024Look Further Ahead: Testing the Limits of GPT-4 in Path Planningcited by 7
  8. 2025From Tools to Teammates: Evaluating LLMs in Multi-Session Coding Interactionscited by 7
  9. 2025Talk to Your Slides: High-Efficiency Slide Editing via Language-Driven Structured Data Manipulationcited by 7
  10. 2025Read it in Two Steps: Translating Extremely Low-Resource Languages with Code-Augmented Grammar Bookscited by 4
  11. 2025LLM-BabyBench: Can Language Models Plan in Worlds They Can Simulate?cited by 2
  12. 2024Chain of Condition: Construct, Verify and Solve Conditions for Conditional Question Answeringcited by 1
7 more
  1. 2025Training with Pseudo-Code for Instruction Followingcited by 1
  2. 2026Using Small Language Models to Reverse-Engineer Machine Learning Pipelines Structurescited by 1
  3. 2025Synthetic Function Demonstrations Improve Generation in Low-Resource Programming Languagescited by 0
  4. 2025From Language to Logic: A Bi-Level Framework for Structured Reasoningcited by 0
  5. 2025PragWorld: A Benchmark Evaluating LLMs' Local World Model under Minimal Linguistic Alterations and Conversational Dynamicscited by 0
  6. 2026CangjieBench: Benchmarking LLMs on a Low-Resource General-Purpose Programming Languagecited by 0
  7. 2026KGCaRe: Explainable Complex Conditional Question Answering using Automatic Knowledge Graph Construction and Context Retrieval with LLMscited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2023The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of Code
  2. 2025Short-Path Prompting in LLMs: Analyzing Reasoning Instability and Solutions for Robust Performance
  3. 2023Code Prompting: a Neural Symbolic Method for Complex Reasoning in Large Language Models
  4. 2025"Well, Keep Thinking": Enhancing LLM Reasoning with Adaptive Injection Decoding
  5. 2025Unveiling the Magic of Code Reasoning through Hypothesis Decomposition and Amendment
  6. 2025Mapping the Minds of LLMs: A Graph-Based Analysis of Reasoning LLM
  7. 2022Towards Understanding Chain-of-Thought Prompting: An Empirical Study of What Matters
  8. 2024Eliciting Causal Abilities in Large Language Models for Reasoning Tasks