# Code2LoRA：超网络生成适配器助力代码语言模型应对软件演化

- 来源：HuggingFace Daily Papers（社区热门论文）
- 发布时间：2026-06-04 08:00
- AIHOT 分数：68
- AIHOT 链接：https://aihot.virxact.com/items/cmq13ksuq0c4xsltr8146vbja
- 原文链接：https://arxiv.org/abs/2606.06492

## AI 摘要

Code2LoRA 是一种超网络框架，可生成仓库专属的 LoRA 适配器，在推理时零 token 开销注入仓库知识。它支持两种模式：Code2LoRA-Static 将单一仓库快照转为适配器，适合稳定代码库；Code2LoRA-Evo 通过 GRU 隐藏状态随代码 diff 更新适配器，适合演化中的活跃开发。团队构建了含 604 个 Python 仓库的 RepoPeftBench 基准。静态任务中，Code2LoRA-Static 跨仓库 exact match 达 63.8%，仓库内达 66.2%，持平逐仓库 LoRA 上界；演化任务中，Code2LoRA-Evo 跨仓库 exact match 达 60.3%，比单一共享 LoRA 高 5.2 个百分点。代码和数据集已开源。

## 正文

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.
