Code generation remains a challenging task that requires precise and structured reasoning. Existing Test Time Scaling (TTS) methods, including structured tree search, have made progress in exploring reasoning paths but still face two major challenges: (1) underthinking, where reasoning chains tend to be shallow and fail to capture the full complexity of problems; and (2) overthinking, where overly verbose reasoning leads to inefficiency and increased computational costs. To address these issues, we propose LogitsCoder, a novel framework that enhances chain-of-thought reasoning through lightweight, logit-level control mechanisms for code generation. LogitsCoder iteratively generates and refines reasoning steps by first steering token selection toward statistically preferred patterns via Logits Preference Decoding, then selecting and aggregating diverse reasoning paths using Logits Rank Based Path Selection and Thoughts Aggregation. This results in coherent and effective reasoning chains that balance depth and efficiency. Extensive experiments demonstrate that LogitsCoder produces more efficient and higher-quality reasoning chains, leading to superior code generation performance compared to baseline methods.
翻译:代码生成仍然是一项需要精确且结构化推理的挑战性任务。现有的测试时间扩展方法,包括结构化树搜索,在探索推理路径方面已取得进展,但仍面临两大挑战:(1)欠思考,即推理链往往较浅,未能捕捉问题的全部复杂性;(2)过思考,即过于冗长的推理导致效率低下和计算成本增加。为解决这些问题,我们提出了LogitsCoder,一个通过轻量级、logit级别的控制机制来增强代码生成中思维链推理的新框架。LogitsCoder通过Logits偏好解码首先引导token选择朝向统计上偏好的模式,然后利用基于Logits排序的路径选择和思维聚合来筛选与整合多样化的推理路径,从而迭代地生成并优化推理步骤。这产生了在深度与效率之间取得平衡的连贯且有效的推理链。大量实验表明,与基线方法相比,LogitsCoder能生成更高效、更高质量的推理链,从而实现更优的代码生成性能。