用自动提示优化和强化学习,让大模型更准地合成复杂API。
APRIL: API Synthesis with Automatic Prompt Optimization and Reinforcement Learning
- 结合自动提示优化与可验证奖励强化学习,提升代码生成准确率。
- 在81个真实科学库API上测试,显著优于依赖专家提示的现成大模型。
- 适合需要高可靠API自动生成的研究者与开发者使用。
API是现代软件开发的核心,但从大型库中组合新API面临指数级搜索空间,传统基于组件的合成依赖昂贵探索和手工规范。尽管大语言模型(LLMs)能从自然语言生成代码,但幻觉和缺乏最新上下文信息常导致错误。本文提出APRIL,融合LLM合成、自动提示优化(APO)与基于可验证奖励的强化学习(RLVR):APO迭代优化冻结模型的提示,而RLVR通过策略微调实现功能正确性,构建高效合成流水线。在81个广泛使用的科学Python库的真实API上评估,相较于由专家提示引导的指令微调但未微调的LLM,APRIL表现显著提升。结果表明,集成APO与RLVR为大规模库中的组件化API合成提供了稳健且可扩展的路径。
原文摘要 · Abstract (English)
APIs are central to modern software development, yet composing new APIs from large libraries is difficult due to the exponential search space; traditional component-based synthesis relies on costly exploration and hand-crafted specifications. While large language models (LLMs) can generate implementations from natural language, hallucinations and limited access to up-to-date contextual information often yield incorrect code. In this paper, we present APRIL, an approach that combines LLM-based synthesis with Automatic Prompt Optimization (APO) and Reinforcement Learning from Verifiable Rewards (RLVR): APO iteratively refines prompts for a frozen model, while RLVR fine-tunes the policy toward functional correctness, producing an efficient synthesis pipeline. Evaluated on 81 real-world APIs from widely used scientific Python libraries and benchmarked against instruction-tuned but unfine-tuned LLMs guided by expert prompts, APRIL achieves substantial improvements. These results indicate that integrating APO and RLVR provides a robust, scalable path for component-based API synthesis in large libraries.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。