Z1: Efficient Test-time Scaling with Code

Zhaojian Yu, Yinghao Wu, Yilun Zhao, Arman Cohan, Xiao-Ping Zhang
4/1/2025
cs.CL

No official code found. Best implementation: efficientscaling/Z1 (69 stars, last commit 2025-04-11).

Abstract

Large Language Models (LLMs) can achieve enhanced complex problem-solving through test-time computing scaling, yet this often entails longer contexts and numerous reasoning token costs. In this paper, we propose an efficient test-time scaling method that trains LLMs on code-related reasoning trajectories, facilitating their reduction of excess thinking tokens while maintaining performance. First, we create Z1-Code-Reasoning-107K, a curated dataset of simple and complex coding problems paired with their short and long solution trajectories. Second, we present a novel Shifted Thinking Window to mitigate overthinking overhead by removing context-delimiting tags (e.g., <think>. . . </think>) and capping reasoning tokens. Trained with long and short trajectory data and equipped with Shifted Thinking Window, our model, Z1-7B, demonstrates the ability to adjust its reasoning level as the complexity of problems and exhibits efficient test-time scaling across different reasoning tasks that matches R1-Distill-Qwen-7B performance with about 30% of its average thinking tokens. Notably, fine-tuned with only code trajectories, Z1-7B demonstrates generalization to broader reasoning tasks (47.5% on GPQA Diamond). Our analysis of efficient reasoning elicitation also provides valuable insights for future research.

View on arXivView PDF

Code Implementations(1)

efficientscaling/Z1Community100%

[EMNLP'25 Industry] Repo for "Z1: Efficient Test-time Scaling with Code"

692Shell, PythonMar 25, 20251 years ago
codellmsllmllm-servingreasoning

Cite this paper

@article{yu2025efficient,
  title  = {Z1: Efficient Test-time Scaling with Code},
  author = {Zhaojian Yu and Yinghao Wu and Yilun Zhao and Arman Cohan and Xiao-Ping Zhang},
  year   = {2025},
  eprint = {2504.00810},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.00810v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.00810.svg)](https://codeofpaper.com/paper/2504.00810)

Discussion