Introduction
While Large Language Models (LLMs) are often viewed as the "wizards" of the artificial intelligence era, their true potential is unlocked by a specific "wand": code. This survey explores how training LLMs on code transcends mere programming proficiency, fundamentally enhancing their logical reasoning, tool manipulation, and capacity to function as autonomous Intelligent Agents (IAs).
The Limitation of Pure Text
Traditional LLMs, primarily trained on vast web-scaled natural language corpora, excel at conversation but frequently falter when tasks require rigorous multi-step planning or interaction with external environments. These models often suffer from "hallucinations" and a lack of grounding in physical or digital reality. The core question addressed is: why does code training bridge this gap? The transition from traditional text-based models to modern code-empowered agents allows for scientific research, complex gaming, and autonomous driving.
A Taxonomy of Code Empowerment
The research categorizes the impact of code into a structured framework that defines how structured, executable language transforms a model's internal processing and external capabilities.
1. Boosting Performance and Reasoning
Code training inherently improves "Chain-of-Thought" (CoT) reasoning. Because code requires strict syntax and logical flow, models learn to decompose complex natural language problems into modular, logical steps. This is exemplified by the "Program-of-Thought" (PoT) approach, where models solve problems by generating executable scripts rather than just text, offloading computation to an interpreter.
2. Connecting to Functional Ends
Code acts as a universal interface. By utilizing APIs and function calls, LLMs can interact with a diverse array of digital tools (e.g., search engines, calculators) and physical systems (e.g., robotic arms, autonomous vehicles). This code-centric paradigm allows for more precise and flexible tool use than natural language alone.
3. Automated Feedback and Self-Correction
Unlike the subjective nature of human language, code is deterministic. Execution environments provide "hard" feedback—such as error messages or unit test results—allowing LLMs to self-debug and iteratively improve their plans without constant human oversight. This creates a powerful feedback loop for self-improvement.
Key Insights and Results
- Reasoning Jumps: Models like the
code-davinciseries showed dramatic improvements in mathematical reasoning. For instance, on the GSM8k benchmark, accuracy jumped from approximately 12% to over 60% when models were trained on code and used CoT. - Agentic Success: In complex environments like Minecraft (via the Voyager agent), code-based agents can store "skills" as modular snippets, enabling them to solve tasks far beyond the reach of text-only models.
- Structured Knowledge: Code-trained models demonstrate a superior grasp of structured data formats like JSON and HTML, which is critical for web navigation and GUI interaction.
Future Directions and Limitations
Despite these gains, challenges remain. The "causality gap" persists; researchers are still determining exactly which properties of code (modularity vs. logic vs. syntax) drive specific reasoning improvements. Furthermore, as agents rely on long chains of code-based tool calls, the risk of "error accumulation" increases. Future research must balance the precision of code with the explainability required for human-agent collaboration, ensuring that the "wizard's wand" remains controllable and transparent.
Summary updated