超越更多上下文:粒度与顺序如何驱动代码补全质量
Beyond More Context: How Granularity and Order Drive Code Completion Quality
AI总结:
本研究针对代码补全中的上下文构建问题,通过文件级与块级检索实验,发现上下文数量与顺序显著影响性能,并提出基于静态分析的块级检索,在Python上较无上下文基线提升16%。
摘要:
上下文在代码补全质量中扮演着重要角色,因为大型语言模型(LLMs)需要充分且相关的信息来协助开发者完成代码生成任务。然而,在大型代码库中,为代码补全构建相关上下文面临诸多挑战:首先,LLMs有限的上下文长度使得包含所有仓库文件变得不切实际。其次,生成代码的质量对噪声或无关上下文高度敏感。在本文中,我们介绍了针对ASE 2025上下文收集挑战赛的方法。该挑战要求通过设计有效的检索和上下文收集策略来超越JetBrains的基线。我们开发并评估了一系列实验,涉及文件级和块级两种检索策略。我们的初步实验聚焦于考察上下文大小和文件顺序对LLM性能的影响。结果表明,上下文的数量和顺序能显著影响模型性能。我们引入了基于静态分析的块级检索,在竞赛初始阶段,针对Python,该方法相比我们最佳的文件级检索策略提升了6%,相比无上下文基线提升了16%。我们的结果强调了检索粒度、顺序以及混合策略在开发面向真实开发场景的有效上下文收集流程中的重要性。
英文摘要:
Context plays an important role in the quality of code completion, as Large Language Models (LLMs) require sufficient and relevant information to assist developers in code generation tasks. However, composing a relevant context for code completion poses challenges in large repositories: First, the limited context length of LLMs makes it impractical to include all repository files. Second, the quality of generated code is highly sensitive to noisy or irrelevant context. In this paper, we present our approach for the ASE 2025 Context Collection Challenge. The challenge entails outperforming JetBrains baselines by designing effective retrieval and context collection strategies. We develop and evaluate a series of experiments that involve retrieval strategies at both the file and chunk levels. We focus our initial experiments on examining the impact of context size and file ordering on LLM performance. Our results show that the amount and order of context can significantly influence the performance of the models. We introduce chunk-based retrieval using static analysis, achieving a 6% improvement over our best file-retrieval strategy and a 16% improvement over the no-context baseline for Python in the initial phase of the competition. Our results highlight the importance of retrieval granularity, ordering and hybrid strategies in developing effective context collection pipelines for real-world development scenarios.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。