RustEvo^2:面向大语言模型Rust代码生成的API演化动态基准
RustEvo^2: An Evolving Benchmark for API Evolution in LLM-based Rust Code Generation
AI总结:
针对大语言模型难以适配Rust快速迭代API的问题,研究提出可自动构建动态基准的RustEvo框架,实验揭示模型在不同API演化场景下的性能差异及知识截止的影响,验证RAG可提升后截止API任务表现。
摘要:
大语言模型(LLM)已成为软件开发中实现代码生成自动化的核心工具。然而,这类模型在为Rust等快速迭代的编程语言生成具备版本感知能力的代码时面临严峻挑战——不同版本间应用程序编程接口(API)的频繁变更会引发兼容性问题与正确性错误。现有基准缺乏对模型如何应对API迭代的系统性评估,依赖人工整理的方式耗时费力,且能提供的版本相关洞见十分有限。\n为填补这一空白,我们提出RustEvo,这是一款用于构建动态基准的新型框架,旨在评估LLM适配不断演化的Rust API的能力。RustEvo可自动化完成数据集构建:它将588项API变更(其中380项来自Rust标准库,208项来自15个第三方crate)合成为贴合真实开发场景的编程任务。这些任务覆盖四类API演化场景:稳定化(Stabilizations)、签名变更(Signature Changes)、行为变更(Behavioral Changes)和弃用(Deprecations),其分布与Rust生态中的实际情况一致。\n针对当前最先进(SOTA)LLM的实验显示,不同模型的表现存在显著差异:模型在稳定化API任务上的平均成功率为65.8%,但在行为变更任务上仅为38.0%,这凸显出模型在无签名改动的情况下检测语义偏移的难度。知识截止日期对模型性能影响极大:模型在截止日期前的API任务上得分为56.1%,而在截止日期后的任务上仅为32.5%。检索增强生成(RAG)可缩小这一差距,对于模型训练后发布的API,其成功率平均提升13.5%。我们的研究结果表明,这类具备演化感知能力的基准对提升LLM在快速迭代的软件生态中的适配性至关重要。该框架与基准已在https://github.com/SYSUSELab/RustEvo公开发布。
英文摘要:
Large Language Models (LLMs) have become pivotal tools for automating code generation in software development. However, these models face significant challenges in producing version-aware code for rapidly evolving languages like Rust, where frequent Application Programming Interfaces (API) changes across versions lead to compatibility issues and correctness errors. Existing benchmarks lack systematic evaluation of how models navigate API transitions, relying on labor-intensive manual curation and offering limited version-specific insights. To address this gap, we present RustEvo, a novel framework for constructing dynamic benchmarks that evaluate the ability of LLMs to adapt to evolving Rust APIs. RustEvo automates dataset creation by synthesizing 588 API changes (380 from Rust standard libraries, 208 from 15 third-party crates) into programming tasks mirroring real-world challenges. These tasks cover four API evolution categories: Stabilizations, Signature Changes, Behavioral Changes, and Deprecations, reflecting their actual distribution in the Rust ecosystem. Experiments on state-of-the-art (SOTA) LLMs reveal significant performance variations: models achieve a 65.8% average success rate on stabilized APIs but only 38.0% on behavioral changes, highlighting difficulties in detecting semantic shifts without signature alterations. Knowledge cutoff dates strongly influence performance, with models scoring 56.1% on before-cutoff APIs versus 32.5% on after-cutoff tasks. Retrieval-Augmented Generation (RAG) mitigates this gap, improving success rates by 13.5% on average for APIs released after model training. Our findings underscore the necessity of our evolution-aware benchmarks to advance the adaptability of LLMs in fast-paced software ecosystems. The framework and the benchmarks are publicly released at https://github.com/SYSUSELab/RustEvo.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。