KCoEvo: 一种增强知识图谱的进化代码生成框架
KCoEvo: A Knowledge Graph Augmented Framework for Evolutionary Code Generation
AI总结:
KCoEvo通过增强知识图谱的方法提升代码迁移的准确性与可控性
摘要:
在现代软件开发中,代码进化是不可避免的。第三方API的更改经常破坏现有代码并使维护复杂化,给开发者带来了实际挑战。尽管大型语言模型(LLMs)在代码生成方面表现出色,但它们在没有结构化表示这些演变关系的情况下难以推理,往往导致生成过时的API或无效输出。在本工作中,我们提出了一种增强知识图谱的框架,将迁移任务分解为两个协同阶段:进化路径检索和路径引导的代码生成。我们的方法构建了静态和动态API图,以建模版本内的结构和跨版本转换,从而在API进化上实现结构化推理。两个模块均使用从真实世界API差异自动衍生的合成监督进行训练,确保可扩展性和最小的人力投入。在单包和多包基准上的广泛实验表明,我们的框架在迁移准确性、可控性和执行成功率方面显著优于标准LLM基线。源代码和数据集可在:https://github.com/kangjz1203/KCoEvo获取。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。