2025-03-10 · 进阶 · 数据科学 · 机器学习 · 计算机视觉

LoRACode: LoRA Adapters for Code Embeddings

该论文提出了一种基于低秩适应(LoRA)的参数高效微调方法,用于构建特定于任务的代码检索适配器,显著提高了代码检索的准确性和效率。

更新于 2026-01-21。作者:Saumya Chaturvedi、Aman Chadha、Laurent Bindschaedler。

中文摘要

代码嵌入对于语义代码搜索至关重要;然而,当前的方法往往难以捕捉代码中固有的精确的语法和上下文细微差别。开源模型如CodeBERT和UniXcoder在可扩展性和效率方面存在局限性,而高性能的专有系统则带来巨大的计算成本。我们介绍了一种基于低秩适应(LoRA)的参数高效微调方法,用于构建针对代码检索的任务特定适配器。我们的方法将可训练参数的数量减少到基础模型的不到2%,使得在大量的代码语料库上进行快速微调成为可能(在两个H100 GPU上,25分钟内处理200万个样本)。实验表明,对于Code2Code搜索,平均倒数排名(MRR)提高了高达9.1%,对于跨多种编程语言的Text2Code搜索任务,提高了高达86.69%。在任务和语言方面的区分有助于探索代码检索对语法和语言变化的敏感性。

英文摘要

Code embeddings are essential for semantic code search; however, current approaches often struggle to capture the precise syntactic and contextual nuances inherent in code. Open-source models such as CodeBERT and UniXcoder exhibit limitations in scalability and efficiency, while high-performing proprietary systems impose substantial computational costs. We introduce a parameter-efficient fine-tuning method based on Low-Rank Adaptation (LoRA) to construct task-specific adapters for code retrieval. Our approach reduces the number of trainable parameters to less than two percent of the base model, enabling rapid fine-tuning on extensive code corpora (2 million samples in 25 minutes on two H100 GPUs). Experiments demonstrate an increase of up to 9.1% in Mean Reciprocal Rank (MRR) for Code2Code search, and up to 86.69% for Text2Code search tasks across multiple programming languages. Distinction in task-wise and language-wise adaptation helps explore the sensitivity of code retrieval for syntactical and linguistic variations.

解读

一句话总结

该论文提出了一种基于低秩适应(LoRA)的参数高效微调方法,用于构建特定于任务的代码检索适配器,显著提高了代码检索的准确性和效率。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源