arXiv:2510.24749cs.SEcs.AI2025-10EMNLP被引 2

让代码检索理解整个仓库的修改意图,提升精准度。

Beyond Function-Level Search: Repository-Aware Dual-Encoder Code Retrieval with Adversarial Verification

  • 用双塔结构+大模型反思,动态融合语法、依赖和语义信息
  • 在52000个实例上,顶5准确率提升12.2%,召回率提升7.1%
  • 适合需要理解上下文变更需求的开发者与工具构建者

现代代码库复杂度不断提升,亟需能理解跨组件修改意图的检索系统,而传统函数级搜索无法满足这一需求。尽管近期研究提升了自然语言查询与代码片段的对齐能力,但针对具体变更请求的上下文相关代码检索仍缺乏探索。为此,我们提出RepoAlign-Bench,首个面向变更驱动场景的仓库级代码检索基准,包含52,000个标注样本,推动检索范式从函数中心转向全局仓库级推理。同时,我们提出ReflectCode,一种基于对抗性反思增强的双编码器架构,具备解耦的代码编码器与文档编码器。该模型通过大语言模型引导的反思机制,动态整合语法模式、函数依赖与语义扩展意图。大量实验表明,ReflectCode在顶5准确率上比现有最佳基线提升12.2%,召回率提升7.1%,为上下文感知代码检索开辟新方向。

原文摘要 · Abstract (English)

The escalating complexity of modern codebases has intensified the need for retrieval systems capable of interpreting cross-component change intents, a capability fundamentally absent in conventional function-level search paradigms. While recent studies have improved the alignment between natural language queries and code snippets, retrieving contextually relevant code for specific change requests remains largely underexplored. To address this gap, we introduce RepoAlign-Bench, the first benchmark specifically designed to evaluate repository-level code retrieval under change request driven scenarios, encompassing 52k annotated instances. This benchmark shifts the retrieval paradigm from function-centric matching to holistic repository-level reasoning. Furthermore, we propose ReflectCode, an adversarial reflection augmented dual-tower architecture featuring disentangled code_encoder and doc_encoder components. ReflectCode dynamically integrates syntactic patterns, function dependencies, and semantic expansion intents through large language model guided reflection. Comprehensive experiments demonstrate that ReflectCode achieves 12.2% improvement in Top-5 Accuracy and 7.1% in Recall over state-of-the-art baselines, establishing a new direction for context-aware code retrieval.

代码检索大模型仓库级

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