arXiv:2504.20434cs.SEcs.AI2025-04被引 12

无需微调,通过迭代检索-生成-修复提升代码生成准确率

ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement

  • 先检索上下文再生成代码,利用执行反馈不断修正
  • 在HumanEval上达87.2% pass@1,优于CodeAgent的82.3%
  • 适合追求高可靠性且不想微调模型的开发者

我们提出无监督微调的智能检索增强代码合成系统ARCS。该系统基于冻结模型,采用预算受限的合成-执行-修复循环:生成前检索相关代码上下文,提出候选代码,通过测试执行并根据反馈修复。这种先检索后生成的设计有效减少幻觉并加速收敛。我们将ARCS形式化为状态-动作过程,具备终止保证、单调改进和成本有界等理论性质。分层控制器(小/中/大)可预测地权衡延迟与精度。在HumanEval上,使用Llama-3.1-405B模型达到87.2% pass@1,超越CodeAgent(82.3%),且控制逻辑比树搜索更简单。在TransCoder上,多数翻译对准确率≥90%。在LANL科学语料上,相比基线RAG,CodeBLEU提升+0.115。ARCS提供了一种使用现有LLM检查点实现可靠代码合成的实用、可复现方案。

原文摘要 · Abstract (English)

We present Agentic Retrieval-Augmented Code Synthesis (ARCS), a system that improves LLM-based code generation without fine-tuning. ARCS operates through a budgeted synthesize-execute-repair loop over a frozen model: it retrieves relevant code context before generation, proposes candidates, executes them against tests, and repairs based on execution feedback. This retrieval-before-generation design reduces hallucination and accelerates convergence. We formalize ARCS as a state-action process with provable guarantees on termination, monotonic improvement, and bounded cost. A tiered controller (Small/Medium/Large) trades latency for accuracy predictably. On HumanEval, ARCS achieves up to 87.2% pass@1 with Llama-3.1-405B, surpassing CodeAgent (82.3%) while using simpler control than tree-search methods. On TransCoder, it achieves >= 90% accuracy on most translation pairs. On a LANL scientific corpus, it improves CodeBLEU by +0.115 over baseline RAG. ARCS provides a practical, reproducible approach to reliable code synthesis using existing LLM checkpoints.

代码生成检索增强迭代修复零样本

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。