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

当LLM落后时:来自演进API的代码生成中的知识冲突

When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generation

University of Manitoba(曼尼托巴大学);Concordia University(康考迪亚大学);University of Windsor(温莎大学);Queen’s University(女王大学)

Ahmed Nusayer Ashik, Shaowei Wang, Tse-Hsun Chen, Muhammad Asaduzzaman, Yuan Tian

AI总结:

本文研究了API演变对LLM代码生成的影响,发现缺乏全面文档时LLM难以优先处理外部上下文,执行率仅42.55%,而结构化文档和大模型规模可提升至66.36%,但推理策略如Self-Reflection可进一步提升11%。

摘要:

软件库的快速演变给大型语言模型(LLM)带来了重大挑战,因其静态参数化知识在训练后往往过时。虽然检索增强生成(RAG)常用于提供最新的API规范,但当外部指令与模型内部参数化知识冲突时会出现'上下文-记忆冲突'。本文通过构建包含270个真实世界更新的基准测试,评估了四个LLM家族的11个模型。结果表明,在缺乏全面文档的情况下,LLM难以优先处理外部上下文,生成的代码示例中仅有42.55%可在目标环境中执行。虽然结构化文档和更大模型规模可提高LLM更新采用能力,但执行问题仍存在,执行率仅为66.36%。此外,基于推理的策略(如Self-Reflection)显著提升了LLM的性能,执行率提高了11%。我们的发现突显了即使在提供API更新规范的情况下,LLM中仍然存在过时模式的持续存在,并强调了需要演进意识的基准测试和技术。

英文摘要:

The rapid evolution of software libraries creates a significant challenge for Large Language Models (LLMs), whose static parametric knowledge often becomes stale post-training. While retrieval-augmented generation (RAG) is commonly used to provide up-to-date API specifications, "context-memory conflict" arises when external instructions contradict a model's internal parametric knowledge. This paper presents a systematic empirical study of LLM code generation under API evolution (e.g., API deprecation, API modification, and API addition), by constructing a benchmark of 270 real-world updates from eight Python libraries. We evaluate four LLM families of 11 models. Our results show that without comprehensive documentation, LLMs struggle to prioritize external context, averaging only 42.55% of generated code examples are executable in the target environment. While structured documentation and larger model scales improve LLMs' ability to update adoption, they do not fully resolve executability issues with a low 66.36% executable rate. In addition, reasoning-based strategies (e.g., Self-Reflection) significantly boost LLMs' performance with 11% improvement on executable rate. Our findings highlight the persistence of outdated patterns from LLMs, even when API update specifications are provided, and emphasize the need for evolution-aware benchmarks and techniques.

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

↑