TL;DR
This paper introduces THINK-AND-EXECUTE, a novel framework that significantly improves Large Language Models' (LLMs) algorithmic reasoning abilities. By first discovering a task-level logic expressed in pseudocode and then simulating its execution, the approach outperforms existing methods and demonstrates the power of structured, task-general logic over instance-specific solutions.
What Problem Does This Paper Address?
Algorithmic reasoning—the ability to break down complex problems into sequential steps—is a known challenge for LLMs, despite their impressive performance in other areas. Existing methods like Chain-of-Thought (CoT) and Program-of-Thought (PoT) often generate reasoning steps or code on-the-fly for each specific instance. This approach is inefficient, as it doesn't leverage common logic across similar problems, and can be restrictive for LLMs. The paper aims to address this by developing a method that first identifies and formalizes the underlying logic of an entire task, making it reusable and more robust for LLMs.
Methods
The proposed framework, THINK-AND-EXECUTE, operates in two main phases:
- THINK: An "Instructor LM" is prompted to analyze a given task using a few examples. It then generates a task-level pseudocode prompt that captures the shared reasoning logic for that task. This pseudocode is designed to be general and reusable across all instances of the task, unlike instance-specific code.
- EXECUTE: A "Reasoner LM" takes the generated task-level pseudocode and tailors it to a specific instance. It then simulates the execution of this pseudocode, generating intermediate reasoning steps (similar to CoT) and ultimately producing the final answer. This simulation helps the LLM track state and logic more effectively.
The key novelty lies in the explicit separation of discovering task-level logic (THINK) from applying it to individual instances (EXECUTE), and the use of pseudocode as a structured, yet flexible, intermediate representation.
Datasets
The experiments were conducted on seven algorithmic reasoning tasks from the Big-Bench Hard dataset. These tasks are specifically designed to test step-by-step reasoning capabilities and include:
- Dyck Languages
- Geometric Shapes
- Navigate
- Reasoning about Colored Objects
- Temporal Sequences
- Tracking Shuffled Objectives
- Web of Lies
The models were evaluated in a zero-shot setting.
Key Insights and Ideas
- Task-level logic is more powerful than instance-specific logic: Discovering and applying a general logic for a task significantly boosts reasoning performance compared to generating code or reasoning steps for each individual problem.
- Pseudocode excels as an intermediate representation: Pseudocode, with its structured syntax and ability to express logic concisely (e.g., using loops and conditionals), proves more effective than natural language for guiding LLM reasoning.
- Simulating execution aids reasoning: The act of simulating pseudocode execution helps LLMs maintain state and follow complex logic, leading to better accuracy.
- Transferability to smaller models: The task-level pseudocode prompts generated by powerful LLMs can be effectively used to improve the reasoning capabilities of smaller language models (SLMs).
Key Results
THINK-AND-EXECUTE consistently outperformed strong baselines like Zero-shot CoT and Program-of-Thought (PoT) across all seven Big-Bench Hard tasks. For instance, with GPT-3.5-Turbo, THINK-AND-EXECUTE achieved an average accuracy of 60.4%, significantly higher than PoT (32.4%) and Zero-shot CoT (48.0%). The framework also showed impressive results when applied to smaller models like CodeLlama-13B, achieving 36.3% accuracy, which is comparable to GPT-3.5-Turbo with PoT. Furthermore, the pseudocode generated by LLMs was found to be comparable to, and in some cases superior to, human-written pseudocode.
Limitations and Future Work
The authors acknowledge that their approach is currently focused on algorithmic reasoning. However, they suggest that THINK-AND-EXECUTE could be extended to other domains requiring complex, multi-step reasoning, such as multi-hop reasoning and symbolic reasoning. Future work could also explore further optimizations in the pseudocode generation and execution simulation processes.
Summary updated