arXiv:2603.07581cs.SEcs.CL2026-03中稿 · the DASFAA 2026 In…被引 1

用知识图谱辅助代码迁移,让大模型更懂API变化规律。

KCoEvo: A Knowledge Graph Augmented Framework for Evolutionary Code Generation

  • 构建静态与动态API图,显式建模版本间演变关系。
  • 在单包和多包任务中,迁移准确率显著高于基线模型。
  • 自动从真实API差异生成训练数据,降低人工成本。

现代软件开发中代码演进不可避免,第三方API频繁变更常导致现有代码失效,给维护带来挑战。尽管大语言模型在代码生成方面表现良好,但缺乏对演化关系的结构化理解,常生成过时或无效的API调用。本文提出KCoEvo框架,将迁移任务分解为演进路径检索与路径感知的代码生成两个协同阶段。通过构建静态与动态API图,分别刻画版本内结构与跨版本变迁,实现对API演化的结构化推理。两个模块均使用从真实API差异中自动生成的合成监督信号进行训练,兼顾可扩展性与低人力投入。在单包与多包基准测试上,该框架显著提升迁移准确性、可控性与执行成功率,优于标准LLM基线。代码与数据集已公开于https://github.com/kangjz1203/KCoEvo。

原文摘要 · Abstract (English)

Code evolution is inevitable in modern software development. Changes to third-party APIs frequently break existing code and complicate maintenance, posing practical challenges for developers. While large language models (LLMs) have shown promise in code generation, they struggle to reason without a structured representation of these evolving relationships, often leading them to produce outdated APIs or invalid outputs. In this work, we propose a knowledge graph-augmented framework that decomposes the migration task into two synergistic stages: evolution path retrieval and path-informed code generation. Our approach constructs static and dynamic API graphs to model intra-version structures and cross-version transitions, enabling structured reasoning over API evolution. Both modules are trained with synthetic supervision automatically derived from real-world API diffs, ensuring scalability and minimal human effort. Extensive experiments across single-package and multi-package benchmarks demonstrate that our framework significantly improves migration accuracy, controllability, and execution success over standard LLM baselines. The source code and datasets are available at: https://github.com/kangjz1203/KCoEvo.

代码生成知识图谱API演化

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