arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.05199cs.CL
收藏

CodeLutra:通过偏好引导的优化提升LLM代码生成

CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinement

University of Wisconsin-Madison(威斯康星大学麦迪逊分校);Adobe Research(Adobe研究)

Leitian Tao, Xiang Chen, Tong Yu, Tung Mai, Ryan Rossi, Yixuan Li, Saayan Mitra

AI总结:

本文提出CodeLutra框架,通过利用正确与错误代码尝试进行基于偏好的迭代优化,有效提升小型开源LLM的代码生成性能,缩小与大型模型的差距。

摘要:

大型语言模型(LLMs)彻底改变了代码生成,但需要大量资源且经常过度泛化,限制了其特定任务的效率。微调较小的开源LLMs提供了一种经济高效的替代方案。然而,标准的监督方法仅依赖正确示例,错失了从失败中获得的宝贵见解。我们引入了CodeLutra,这是一个利用正确和错误代码尝试的框架。CodeLutra不使用仅正确的解决方案,而是应用基于偏好的迭代优化,通过比较成功和失败的输出来更好地逼近预期结果。这种方法缩小了与最先进大型模型的性能差距,而无需海量数据集或辅助模型。例如,在具有挑战性的数据科学编程任务中,仅使用500个样本就将Llama-3-8B的准确率从28.2%提高到48.6%,接近GPT-4的水平。通过从成功和错误中学习,CodeLutra为高质量代码生成提供了一条可扩展且高效的路径,使较小的开源模型在与领先的闭源替代方案的竞争中更具优势。

英文摘要:

Large Language Models (LLMs) have revolutionized code generation but require significant resources and often over-generalize, limiting their task-specific efficiency. Fine-tuning smaller, open-source LLMs provides a cost-effective alternative. However, standard supervised approaches rely only on correct examples, missing valuable insights from failures. We introduce CodeLutra, a framework that leverages both correct and incorrect code attempts. Instead of using only correct solutions, CodeLutra applies iterative preference-based refinement, comparing successful and failed outputs to better approximate desired results. This approach narrows the performance gap with state-of-the-art larger models without requiring massive datasets or auxiliary models. For instance, on a challenging data science coding task, using only 500 samples improved Llama-3-8B's accuracy from 28.2% to 48.6%, approaching GPT-4's level. By learning from both successes and mistakes, CodeLutra provides a scalable and efficient path to high-quality code generation, making smaller open-source models more competitive with leading closed-source alternatives.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑