arXiv:2504.05759cs.CL2025-04

用代码库提升代码生成效率,小模型也能逼近大模型效果

RETROcode: Leveraging a Code Database for Improved Natural Language to Code Generation

  • 引入外部代码数据库作为记忆增强,替代单纯扩大模型和数据
  • 在小数据集上训练,仍超越同规模传统模型,接近Codex表现
  • 适合资源有限但需高效代码生成的研究者与开发者

随着文本和代码资源的增长,大规模预训练模型在代码生成任务中展现出潜力,通常采用问题描述-程序对进行监督微调。然而,为提升性能而增大模型规模和数据量,也带来了计算开销增加和过拟合风险。为此,我们提出RETROcode,是RETRO架构在序列到序列模型中的新应用,利用大规模代码数据库作为辅助扩展手段。该方法不依赖单纯扩大模型或数据规模,而是通过整合海量代码记忆来提升预测能力。实验表明,RETROcode不仅在测试集上优于同规模传统架构,且在从零开始训练、使用更小数据集的情况下,其效果接近更大的Codex模型。

原文摘要 · Abstract (English)

As text and code resources have expanded, large-scale pre-trained models have shown promising capabilities in code generation tasks, typically employing supervised fine-tuning with problem statement-program pairs. However, increasing model size and data volume for performance gains also raises computational demands and risks of overfitting. Addressing these challenges, we present RETROcode, a novel adaptation of the RETRO architecture \cite{RETRO} for sequence-to-sequence models, utilizing a large code database as an auxiliary scaling method. This approach, diverging from simply enlarging model and dataset sizes, allows RETROcode to leverage a vast code database for prediction, enhancing the model's efficiency by integrating extensive memory. Our findings indicate that RETROcode not only outperforms similar-sized traditional architectures on test sets but also approaches the effectiveness of the much larger Codex model, despite being trained from scratch on a substantially smaller dataset.

代码生成记忆增强高效模型

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