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

面向数据科学代码的知识增强程序修复

Knowledge-Enhanced Program Repair for Data Science Code

Shuyin Ouyang, Jie M. Zhang, Zeyu Sun, Albert Merono Penuela

AI总结:

针对数据科学领域LLM生成的缺陷代码,本文提出知识增强修复方法DSrepair,结合知识图谱RAG与AST错误定位,在DS-1000数据集上显著优于现有基线,同时提升修复效率。

摘要:

本文提出DSrepair,一种知识增强型程序修复方法,旨在修复大语言模型(LLM)在数据科学领域生成的存在缺陷的代码。DSrepair采用基于知识图谱的检索增强生成(RAG)进行API知识检索与缺陷知识增强,以此构建供LLM使用的修复提示词。具体而言,为实现基于知识图谱的API检索,我们针对常用数据科学库构建了DS-KG(数据科学知识图谱);在缺陷知识增强方面,我们利用抽象语法树(AST)在AST节点层级定位错误。我们在DS-1000数据集上,使用4种先进LLM将DSrepair与5种当前最优的基于LLM的修复基线方法进行对比,以评估其有效性。结果显示,DSrepair的表现优于全部5种基线方法:具体来看,与排名第二的基线方法相比,针对4种评估所用的LLM,DSrepair修复的缺陷代码片段数量分别多出44.4%、14.2%、20.6%和32.1%,提升效果显著;此外,它的效率更高,每个代码任务所需的token数分别减少17.49%、34.24%、24.71%和17.59%。

英文摘要:

This paper introduces DSrepair, a knowledge-enhanced program repair method designed to repair the buggy code generated by LLMs in the data science domain. DSrepair uses knowledge graph based RAG for API knowledge retrieval as well as bug knowledge enrichment to construct repair prompts for LLMs. Specifically, to enable knowledge graph based API retrieval, we construct DS-KG (Data Science Knowledge Graph) for widely used data science libraries. For bug knowledge enrichment, we employ an abstract syntax tree (AST) to localize errors at the AST node level. DSrepair's effectiveness is evaluated against five state-of-the-art LLM-based repair baselines using four advanced LLMs on the DS-1000 dataset. The results show that DSrepair surpasses all five baselines. Specifically, when compared to the second-best baseline, DSrepair demonstrates significant improvements, fixing 44.4%, 14.2%, 20.6%, and 32.1% more buggy code snippets for each of the four evaluated LLMs, respectively. Additionally, it achieves greater efficiency, reducing the number of tokens required per code task by 17.49%, 34.24%, 24.71%, and 17.59%, respectively.

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

↑