arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.00810cs.CL
收藏

Z1:基于代码的高效测试时扩展

Z1: Efficient Test-time Scaling with Code

Tsinghua University(清华大学);Yale University(耶鲁大学)

Zhaojian Yu, Yinghao Wu, Yilun Zhao, Arman Cohan, Xiao-Ping Zhang

AI总结:

本文提出高效测试时扩展方法,通过在代码推理轨迹上训练模型并引入 Shifted Thinking Window 限制多余思考 token,使 Z1-7B 在保持与 R1-Distill-Qwen-7B 相当性能的同时大幅降低 token 消耗,并具备跨任务泛化能力。

摘要:

大型语言模型(LLMs)可以通过测试时计算扩展来增强复杂问题求解能力,但这通常需要更长的上下文和大量的推理 token 成本。在本文中,我们提出了一种高效的测试时扩展方法,该方法在代码相关的推理轨迹上训练 LLMs,促使其在保持性能的同时减少多余的思考 token。首先,我们创建了 Z1-Code-Reasoning-107K,这是一个经过精心筛选的数据集,包含简单和复杂的编程问题,并配有相应的短和长解答轨迹。其次,我们提出了一种新颖的 Shifted Thinking Window,通过移除上下文定界标签(例如,)并限制推理 token 数量,来缓解过度思考的开销。我们的模型 Z1-7B 使用长短轨迹数据进行训练,并配备了 Shifted Thinking Window,展现出根据问题复杂度调整推理级别的能力,并在不同推理任务中表现出高效的测试时扩展能力,其性能与 R1-Distill-Qwen-7B 相当,但平均仅使用其约 30% 的思考 token。值得注意的是,仅使用代码轨迹进行微调的 Z1-7B 展现出了向更广泛推理任务的泛化能力(在 GPQA Diamond 上达到 47.5%)。我们对高效推理激发的分析也为未来研究提供了有价值的见解。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑