arXiv:2502.17139cs.AIcs.SE2025-02中稿 · ASE 2025被引 4

FastCoder通过高效检索与验证,加速代码生成且不牺牲质量。

FastCoder: Accelerating Repository-level Code Generation via Efficient Retrieval and Verification

  • 构建多源知识库,动态检索高质量代码草稿。
  • 比自回归生成快2.54倍,较现有方法提速最高88%。
  • 适合需要快速生成代码的开发场景,兼容现有纠错方法。

代码生成是延迟敏感的任务,要求高时效性。然而,随着对仓库级代码生成兴趣的增长及其内在难度,大多数现有研究侧重提升生成代码的正确性,而忽视了推理效率,后者受大模型生成过程中的开销显著影响。尽管已有加速大模型推理的工作,但这些方法未针对代码生成的特点进行设计,将代码视同自然语言序列,忽略了其独特的语法和语义特征,这些特征对提升效率同样关键。因此,这些方法在复杂度较高的仓库级任务中效果有限。为此,我们提出 FastCoder,一种基于草稿-验证范式的高效推理加速方法,专为代码生成设计,不牺牲输出质量。FastCoder 构建多源数据存储,提供通用与项目特定知识,支持高质量草稿序列的检索;同时通过控制检索时机、并行检索及上下文与大模型偏好感知缓存降低检索开销。实验表明,FastCoder 在仓库级和独立代码生成任务中分别达到 2.53x 和 2.54x 的加速比,优于最先进推理加速方法高达 88%。FastCoder 可与现有以正确性为导向的代码生成方法集成,实现超过 2.6x 的加速。

原文摘要 · Abstract (English)

Code generation is a latency-sensitive task that demands high timeliness. However, with the growing interest and inherent difficulty in repository-level code generation, most existing code generation studies focus on improving the correctness of generated code while overlooking the inference efficiency, which is substantially affected by the overhead during LLM generation. Although there has been work on accelerating LLM inference, these approaches are not tailored to the specific characteristics of code generation; instead, they treat code the same as natural language sequences and ignore its unique syntax and semantic characteristics, which are also crucial for improving efficiency. Consequently, these approaches exhibit limited effectiveness in code generation tasks, particularly for repository-level scenarios with considerable complexity and difficulty. To alleviate this issue, following draft-verification paradigm, we propose FastCoder, a simple yet highly efficient inference acceleration approach specifically designed for code generation, without compromising the quality of the output. FastCoder constructs a multi-source datastore, providing access to both general and project-specific knowledge, facilitating the retrieval of high-quality draft sequences. Moreover, FastCoder reduces the retrieval cost by controlling retrieval timing, and enhances efficiency through parallel retrieval and a context- and LLM preference-aware cache. Experimental results show that FastCoder can reach up to 2.53x and 2.54x speedup compared to autoregressive decoding in repository-level and standalone code generation tasks, respectively, outperforming state-of-the-art inference acceleration approaches by up to 88%. FastCoder can also be integrated with existing correctness-focused code generation approaches to accelerate the LLM generation process, and reach a speedup exceeding 2.6x.

代码生成推理加速大模型优化

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