图基自适应搜索方法 GraphAHA 改进代码生成效果
GraphAHA: Graph-Based Adaptive Search with Heterogeneous Actions for Test-Time Code Generation
这个方法挺有意思,用图结构来优化代码生成,能更高效地利用计算预算,提升生成质量。
提出图基自适应搜索方法 GraphAHA,通过构建有向无环图组织测试时代码生成过程,将等价程序合并为单一代码节点,实现搜索统计复用。在 LiveCodeBench 和 CodeContests 两个基准上,使用 Qwen2.5-Coder 和 DeepSeek-Coder 模型进行测试,GraphAHA 在 18/20 案例中取得最佳成绩,Pass@1 平均提升 4.1 个百分点。
GraphAHA: Graph-Based Adaptive Search with Heterogeneous Actions for Test-Time Code Generation
Test-time scaling improves code generation by spending additional inference budget (e.g., calls or tokens) on direct sampling, feedback-conditioned repair, and reasoning-guided implementation. Search-based methods can allocate this budget adaptively, but two challenges remain. First, tree-structured search treats each generation history as a separate state even when trajectories converge to the same program, duplicating evaluation and preventing statistics from being shared. Second, sampling, repair, and reasoning have complementary and state-dependent payoffs, making online allocation among them difficult under a finite budget. To address these challenges, we propose an adaptive graph search method with heterogeneous actions (GraphAHA). GraphAHA organizes the test-time code generation in a typed directed acyclic graph. Equivalent programs are merged into a single code node, allowing their downstream search statistics to be reused across all discovery paths. Hierarchical Thompson sampling then selects whether to generate a new state or follow an existing successor and, for generation, chooses among the type-valid sampling, reasoning, implementation, and repair operations. Evaluated on LiveCodeBench and CodeContests with Qwen2.5-Coder and DeepSeek-Coder, GraphAHA achieves the best score in 18 of 20 cases. For Pass@1 measured using visible tests, it outperforms the strongest baseline for both models on both benchmarks by 4.1 percentage points on average, demonstrating more effective use of a fixed inference budget.