Lune

ICLR2025Top-tier venue

Steering Large Language Models between Code Execution and Textual Reasoning

Yongchao Chen, Harsh Jhamtani, Srinagesh Sharma, Chuchu Fan, Chi Wang

Abstract

While a lot of recent research focuses on enhancing the textual reasoning capabilities of Large Language Models (LLMs) by optimizing the multi-agent framework or reasoning chains, several benchmark tasks can be solved with 100% success through direct coding, which is more scalable and avoids the computational overhead associated with textual iterating and searching. Textual reasoning has inherent limitations in solving tasks with challenges in math, logics, optimization, and searching, which is unlikely to be solved by simply scaling up the model and data size. The recently released OpenAI GPT Code Interpreter and multi-agent frameworks such as AutoGen have demonstrated remarkable proficiency of integrating code generation and execution to solve complex tasks using LLMs. However, based on our experiments on 7 existing popular methods for steering code/text generation in both single- and multi-turn settings with 14 tasks and 6 types of LLMs (including the new O1-preview), currently there is no optimal method to correctly steer LLMs to write code when needed. We discover some interesting patterns on when models use code vs. textual reasoning with the evolution to task complexity and model sizes, which even result in an astonishingly inverse scaling behavior. We also discover that results from LLM written code are not always better than using textual reasoning, even if the task could be solved through code. To mitigate the above issues, we propose three methods to better steer LLM code/text generation and achieve a notable improvement. The costs of token lengths and runtime are thoroughly discussed for all the methods. We believe the problem of steering LLM code/text generation is critical for future research and has much space for further improvement. Project Page, Datasets, and Codes are available at https://yongchao98.github.io/CodeSteer/.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

10 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Towards More Accurate Static Analysis for Taint-Style Bug Detection in Linux Kernel cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • Towards More Accurate Static Analysis for Taint-Style Bug Detection in Linux Kernel cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Self-Refine: Iterative Refinement with Self-Feedback
  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Language Models are Few-Shot Learners
  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society cites Language Models are Few-Shot Learners
  • CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Self-Refine: Iterative Refinement with Self-Feedback cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture cites CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society
  • TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture cites Self-Refine: Iterative Refinement with Self-Feedback
  • TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Exploring Diverse Generation Paths via Inference-time Stiefel Activation Steering cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning cites Self-Refine: Iterative Refinement with Self-Feedback
  • R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers10

  1. TUMIX: Multi-Agent Test-Time Scaling with Tool-Use MixtureYongchao Chen, Jiefeng Chen, Rui Meng, Ji Yin et al.ICLR 2026 · 13 citations
  2. OWL : Geometry-Aware Spatial Reasoning for Audio Large Language ModelsSubrata Biswas, Mohammad Nur Hossain Khan, Bashima IslamICLR 2026 · 9 citations
  3. R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement LearningYongchao Chen, Yueying Liu, Junwei Zhou, Yilun Hao et al.ICLR 2026 · 6 citations
  4. Towards More Accurate Static Analysis for Taint-Style Bug Detection in Linux KernelHaonan Li, Hang Zhang, Kexin Pei, Zhiyun QianASE 2025 · 5 citations
  5. Exploring Diverse Generation Paths via Inference-time Stiefel Activation SteeringDongxuan Zhu, Ly Tran Ho Khanh, Andy Yat-Ming Cheung, Man-Chung Yue et al.ICLR 2026 · 4 citations

Builds on28

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
  3. Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran et al.NeurIPS 2023 · 5,068 citations
  4. Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan et al.NeurIPS 2023 · 4,972 citations
  5. CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model SocietyGuohao Li, Hasan Hammoud, Hani Itani, Dmitrii Khizbullin et al.NeurIPS 2023 · 1,975 citations

Related papers

  1. CodeSteer: Symbolic-Augmented Language Models via Code/Text GuidanceYongchao Chen, Yilun Hao, Yueying Liu, Yang Zhang et al.ICML 2025
  2. CodePlan: Unlocking Reasoning Potential in Large Language Models by Scaling Code-form PlanningJiaxin Wen, Jian Guan, Hongning Wang, Wei Wu et al.ICLR 2025
  3. OPT-Engine: Benchmarking the Limits of LLMs in Optimization Modeling via Complexity ScalingYitian Chen, Cheng Cheng, Yinan Sun, Zi Ling et al.ICML 2026 · 3 citations
  4. ReSearch: Learning to Reason with Search for LLMs via Reinforcement LearningMingyang Chen, Linzhuang Sun, Tianpeng Li, Haoze Sun et al.NeurIPS 2025 · 125 citations
  5. BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex InstructionsTerry Yue Zhuo, Minh Chien Vu, Jenny Chim, Han Hu et al.ICLR 2025
Dusk over the sea between two cliffs drawn in fine vertical lines