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

看清并非掌握:教LLM使用私有库进行代码生成

To See is Not to Master: Teaching LLMs to Use Private Libraries for Code Generation

College of AI, Tsinghua University(清华大学人工智能学院);Proxseer Inc.(Proxseer公司);School of Computer Science, Nanjing University(南京大学计算机科学与技术学院);Software Institute, Nanjing University(南京大学软件学院);School of Computer Science and Technology, Beijing Institute of Technology(北京理工大学计算机科学与技术学院);School of Computer Science and Engineering, Beihang University(北京航空航天大学计算机科学与工程学院)

Yitong Zhang, Chengze Li, Ruize Chen, Guowei Yang, Xiaoran Jia, Yijie Ren, Jia Li

AI总结:

本文提出PriCoder方法,通过自动生成数据教LLM有效调用私有库API,提升私有库代码生成能力,实验显示在多种设置下pass@1指标提升超20%。

摘要:

大型语言模型(LLMs)在代码生成方面展现出强大潜力,但其在面向私有库的代码生成中仍存在局限,目标是使用私有库的API生成代码。现有方法主要依赖检索私有库API文档并在推理时注入相关知识。然而,我们的研究显示这不足:即使给定准确的所需知识,LLMs仍难以有效调用私有库API。为解决这一限制,我们提出了PriCoder,一种通过自动生成数据教LLM调用私有库API的方法。具体而言,PriCoder将私有库数据合成视为图的构建,并交替使用两种图操作:(1)渐进图演化,通过逐步合成更多样化的训练样本提高数据多样性;(2)多维图修剪,通过严格过滤流程提高数据质量。为支持严格评估,我们构建了两个基于最近发布的库的新基准,这些库对测试模型而言是陌生的。在三个主流LLM上的实验表明,PriCoder显著提升了面向私有库的代码生成能力,在许多设置中pass@1指标提升超过20%,同时对通用代码生成能力影响 negligible。我们的代码和基准已公开在https://github.com/eniacode/PriCoder。

英文摘要:

Large Language Models (LLMs) have shown strong potential for code generation, yet they remain limited in private-library-oriented code generation, where the goal is to generate code using APIs from private libraries. Existing approaches mainly rely on retrieving private-library API documentation and injecting relevant knowledge into the context at inference time. However, our study shows that this is insufficient: even given accurate required knowledge, LLMs still struggle to invoke private-library APIs effectively. To address this limitation, we propose PriCoder, an approach that teaches LLMs to invoke private-library APIs through automatically synthesized data. Specifically, PriCoder models private-library data synthesis as the construction of a graph, and alternates between two graph operators: (1) Progressive Graph Evolution, which improves data diversity by progressively synthesizing more diverse training samples from basic ones, and (2) Multidimensional Graph Pruning, which improves data quality through a rigorous filtering pipeline. To support rigorous evaluation, we construct two new benchmarks based on recently released libraries that are unfamiliar to the tested models. Experiments on three mainstream LLMs show that PriCoder substantially improves private-library-oriented code generation, yielding gains of over 20% in pass@1 in many settings, while causing negligible impact on general code generation capability.

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

↑