Replacing thinking with tool usage enables reasoning in small language models

Corrado Rainone, Tim Bakker, Roland Memisevic

TL;DR

Large reasoning models scale inference compute using free-form, natural-language "chains of thought" (CoT), but this approach breaks down for small language models (<10B parameters). This paper proposes replacing natural language thoughts with a Chain-of-Edits (CoE)—a structured, multi-turn interaction trace with an external code editor via a minimal domain-specific language (DSL). On Python code-repair tasks, this constrained action space and execution feedback allow models as small as 1B to effectively use test-time compute, outperforming both direct answering and traditional CoT reasoning while training on a single 16GB GPU.

What Problem Does This Paper Address?

Recent advances in test-time scaling—such as DeepSeek-R1—train models via Reinforcement Learning with Verifiable Rewards (RLVR) to generate lengthy reasoning tokens before answering. However, this recipe fails when applied to Small Language Models (SLMs) with fewer than 10B parameters.

Small models face two primary roadblocks in natural language reasoning:

  1. An enormous action space: Exploring free-form natural language requires a strong pre-trained prior that SLMs lack, often leading to degenerate repetitions or formatting failures.
  2. Sparse reward signals: In standard RLVR, the model only receives a reward after generating an entire chain of thought and a final answer, making credit assignment difficult.

The authors ask: Can we enable test-time compute in small models by swapping free-form thinking for structured tool interaction?

Methods

The authors introduce Chain-of-Edits (CoE), reframing reasoning as an interactive loop between an LM agent and a stateful text editor equipped with a unit-test verifier:

  • Stateful Scratchpad & DSL: Instead of managing state internally, the environment presents the current code (with line numbers) and unit test execution feedback (stack traces or test failures). The model interacts purely through five atomic DSL commands:
  • ADDL #L >>><code_line> (add line)
  • REPL #L >>><code_line> (replace line)
  • REPW >>><old> >>><new> #L (replace token in line)
  • DELL #L (delete line)
  • EXIT (terminate trace when tests pass)
  • Two-Stage Training via LoRA:
  • Supervised Fine-Tuning (SFT): The model is taught the DSL and editing logic via synthetic demonstrations where valid code snippets are sequentially corrupted (1–5 edits) and then restored in reverse order.
  • Multi-Turn RLVR (Adapted GRPO): The model is trained on realistic broken code using an adapted version of Group Relative Policy Optimization (GRPO). Crucially, the authors normalize advantages per turn across active trajectories rather than over full trajectories, providing a variance-reducing baseline suited for multi-turn tasks. The reward function combines a binary task reward (OnlyWhenSolved) with a penalty for invalid DSL syntax or failing to exit after resolution.

Datasets

  • Synthetic CoE Demonstrations (SFT): Constructed from the Mostly Basic Python Problems (MBPP) dataset by applying random, reversible corruptions (adding typos, inserting/deleting lines). Yields 35,223 training prompts and 889 evaluation prompts.
  • Code Repair Benchmark (RLVR & Evaluation): A newly generated benchmark following the protocol of Ni et al. (2024). Llama-3.1-8B was prompted to generate solutions for MBPP problems; failing solutions were curated to form realistic repair tasks (4,500 training prompts, 180 validation, 1,317 test). These problems have a much higher average edit distance (135.6 characters) to the ground truth compared to the synthetic data (39.9 characters).
  • Baseline Reasoning Dataset: The s1K dataset (1,000 reasoning problems with high-quality natural language CoTs) was used to fine-tune baseline models for comparison.

Key Insights and Ideas

  • Externalizing state eliminates working-memory overhead: In CoE, the model never needs to predict the next code state or hallucinate execution traces; the editor handles state transitions and provides ground-truth interpreter feedback at every step.
  • Small models collapse on natural language CoT: When fine-tuned on s1K, 1B and 3B models repeatedly fall into degenerate loops (repeating line numbers, echoing prompt sentences, or hallucinating test outputs), actually performing worse than direct answering.
  • A distinct scaling threshold around 8B: While 1B and 3B models benefit dramatically from tool-constrained CoE, the trend reverses for Llama-3.1-8B. The 8B model performs best with unconstrained direct answering or natural language CoT, indicating that higher-capacity models can leverage internal knowledge more effectively without being restricted to rigid DSL steps.

Key Results

Experiments evaluated Llama models across three parameter scales under pass@1 (greedy) and pass@4 (sampled, $T=0.2$):

Model Setup pass@1 pass@4
Llama-3.2-1B Direct Answer (3-shot) 1.30% 3.10%
SFT on s1K (Natural CoT) 0.15% 0.53%
Ours (CoE + RLVR) 7.82% 11.00%
Llama-3.2-3B Direct Answer (3-shot) 6.90% 12.00%
SFT on s1K (Natural CoT) 1.44% 5.24%
Ours (CoE + RLVR) 13.80% 19.00%
Llama-3.1-8B-Instruct Direct Answer (3-shot) 33.40% 42.90%
SFT on s1K (Natural CoT) 23.30% 46.20%
Ours (CoE + RLVR) 21.70% 32.70%
  • Hardware Footprint: The full 1B pipeline trained on a single consumer GPU with only 16GB of VRAM using rank-16 LoRA.

Limitations and Future Work

  • Task Scope: The approach was evaluated exclusively on Python code repair derived from MBPP; it remains unproven on broader reasoning domains (such as competitive mathematics or symbolic logic) or richer codebases like CodeContests.
  • DSL Rigidity: The DSL is intentionally simplistic and restricted to atomic edits; synthetic demonstrations do not guarantee minimal-length edit trajectories.
  • Negative Transfer at Scale: The CoE constraint actively hindered the 8B model relative to direct prompting, suggesting that tool-constrained thinking is an inductive bias primarily beneficial when model parameter capacity is severely constrained.

Summary updated

BibTeX
@inproceedings{rainone2025replacing,
  author = {Corrado Rainone and Tim Bakker and Roland Memisevic},
  title = {{Replacing thinking with tool usage enables reasoning in small language models}},
  booktitle = {WCUA @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=Ge8yEHk35m},
}
Figure