arXiv:2510.00324cs.SEcs.IR2025-10中稿 · as a full paper at…

用大模型当裁判,找最适合代码检索的编程语言和模型组合。

Which Programming Language and Model Work Best With LLM-as-a-Judge For Code Retrieval?

  • 用大模型评估代码检索结果,对比不同语言与模型的匹配效果。
  • 发现代码语言与检索模型存在协同效应,影响人机判断一致性。
  • 提出用编译器生成跨语言数据集,提升代码搜索基准可扩展性。

代码搜索是重要的信息检索应用,提升搜索效率有助于加速开发者上手、降低维护成本并更好理解大型代码库。尽管搜索算法和评测基准不断进步,代码搜索领域仍相对滞后,主要原因是人工标注成本高——代码标注需熟悉编程语言及软件工程知识。本文研究利用大语言模型(LLM)进行函数级代码检索,并生成代码搜索结果的标注。在多个主流语言(C、Java、JavaScript、Go、Python)中,基于实现常见数据结构的仓库,比较稀疏表示与语义表示、编程语言、以及不同LLM对人类标注的一致性影响。结果表明,检索模型与编程语言之间存在显著协同效应,影响人机相关性判断的一致性;同时不同语言在表示方式上的差异也会影响对齐效果。本文提出通过编译器转换构建跨语言可扩展的代码搜索数据集,并在案例研究中证明,人机相关性一致率接近(最坏情况下的)人与人之间的标注一致性。实验代码已公开于GitHub。

原文摘要 · Abstract (English)

Code search is an important information retrieval application. Benefits of better code search include faster new developer on-boarding, reduced software maintenance, and ease of understanding for large repositories. Despite improvements in search algorithms and search benchmarks, the domain of code search has lagged behind. One reason is the high cost of human annotation for code queries and answers. While humans may annotate search results in general text QA systems, code annotations require specialized knowledge of a programming language (PL), as well as domain specific software engineering knowledge. In this work we study the use of Large Language Models (LLMs) to retrieve code at the level of functions and to generate annotations for code search results. We compare the impact of the retriever representation (sparse vs. semantic), programming language, and LLM by comparing human annotations across several popular languages (C, Java, Javascript, Go, and Python). We focus on repositories that implement common data structures likely to be implemented in any PLs. For the same human annotations, we compare several LLM-as-a-Judge models to evaluate programming language and other affinities between LLMs. We find that the chosen retriever and PL exhibit affinities that can be leveraged to improve alignment of human and AI relevance determinations, with significant performance implications. We also find differences in representation (sparse vs. semantic) across PLs that impact alignment of human and AI relevance determinations. We propose using transpilers to bootstrap scalable code search benchmark datasets in other PLs and in a case study demonstrate that human-AI relevance agreement rates largely match the (worst case) human-human agreement under study. The application code used in this work is available at \href{https://github.com/rlucas7/code-searcher/}{this github repo}.

代码检索大模型评估编程语言人机对齐

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