arXiv:2606.06492cs.SEcs.AI2026-06被引 2

用超网络生成代码适配器,零开销注入项目上下文,支持静态和动态演化场景。

Code2LoRA: Hypernetwork-Generated Adapters for Code Language Models under Software Evolution

论文配图:Code2LoRA: Hypernetwork-Generated Adapters for Code Language Models under Software Evolution
图 1 · 摘自论文原文
  • 通过超网络动态生成项目专属LoRA适配器,避免长输入或重复微调。
  • 静态任务中达66.2%准确率,逼近全量微调上限;演化任务中比共享适配器高5.2个百分点。
  • 适合需要实时更新的开发环境,也适用于稳定项目的代码理解。

代码语言模型需依赖仓库级上下文以解析导入、API 和项目规范。现有方法通过长输入(如RAG或依赖分析)或按仓库微调、LoRA实现,但成本高且对代码演化敏感。本文提出Code2LoRA,一种超网络框架,可生成仓库级特定的LoRA适配器,实现零推理时令牌开销的知识注入。支持两种场景:Code2LoRA-Static将单个仓库快照转为适配器,适用于稳定代码库;Code2LoRA-Evo基于GRU隐状态随代码变更更新适配器,适用于活跃开发。为评估,构建RepoPeftBench基准,包含604个Python仓库,分静态与演化两轨:静态轨含4万训练、1.2万测试断言补全任务;演化轨含21.5万提交衍生训练、8.7万提交衍生测试任务。静态轨上,Code2LoRA-Static达成63.8%跨仓库与66.2%本仓库精确匹配,接近每仓库微调上限;演化轨上,Code2LoRA-Evo达60.3%跨仓库精确匹配,较单一共享LoRA提升5.2个百分点。代码见https://anonymous.4open.science/r/code2lora-6857;模型与数据集见https://huggingface.co/code2lora。

原文摘要 · Abstract (English)

Code language models need repository-level context to resolve imports, APIs, and project conventions. Existing methods inject this knowledge as long inputs (retrieved through RAG or dependency analysis) or through per-repository fine-tuning and LoRA -- costly at repository scale and brittle to evolving codebases. We introduce Code2LoRA, a hypernetwork framework that generates repository-specific LoRA adapters, effectively injecting repository knowledge with zero inference-time token overhead. Code2LoRA supports two usage scenarios: Code2LoRA-Static converts a single repository snapshot into an adapter, suitable for comprehension of stable codebases; while Code2LoRA-Evo maintains an adapter backed by a GRU hidden state updated per code diff, suitable for active development of evolving codebases. To evaluate Code2LoRA against parameter-efficient fine-tuning baselines, we build RepoPeftBench, a benchmark of 604 Python repositories with two tracks: a static track with 40K training and 12K test assertion-completion tasks, and an evolution track with 215K commit-derived training and 87K commit-derived test tasks. On the static track, Code2LoRA-Static achieves 63.8% cross-repo and 66.2% in-repo exact match, matching the per-repository LoRA upper bound; on the evolution track, Code2LoRA-Evo achieves 60.3% cross-repo exact match (+5.2 pp over a single shared LoRA). Code2LoRA's code can be found at https://anonymous.4open.science/r/code2lora-6857; the model checkpoints and RepoPeftBench datasets can be found at https://huggingface.co/code2lora.

代码生成LoRA超网络软件演化

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