arXiv:2603.15159cs.SEcs.AI2026-03被引 3

教大模型用私有库接口写代码,效果提升超20%。

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

  • 用自动合成数据训练模型,模拟私有库调用场景。
  • 在多个测试中提升代码生成通过率超20%。
  • 适合需要对接私有代码库的开发者使用。

大型语言模型(LLMs)在代码生成方面表现强劲,但在依赖私有库接口的场景下仍存在局限。现有方法依赖推理时检索并注入私有库API文档,但研究发现即使知识准确,模型仍难以有效调用接口。为此,我们提出PriCoder,通过自动合成数据来训练模型掌握私有库调用。具体地,将数据合成建模为图结构,交替使用两种图操作:(1) 渐进式图演化,从基础样本逐步生成更多样化的训练数据;(2) 多维图剪枝,通过严格过滤流程提升数据质量。为支持严谨评估,我们基于近期发布的、模型未接触过的库构建了两个新基准。在三款主流LLM上的实验表明,PriCoder显著提升了私有库导向的代码生成能力,多个场景下pass@1提升超过20%,同时对通用代码生成能力影响极小。代码与基准已公开于https://github.com/eniacode/PriCoder。

原文摘要 · Abstract (English)

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. Our code and benchmarks are publicly available at https://github.com/eniacode/PriCoder.

代码生成私有库大模型训练

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