一句话:提出DSrepair,用知识图谱RAG增强LLM修复数据科学代码缺陷,显著提升修复率并减少token消耗。
本文针对 LLM 生成的数据科学代码常含缺陷、现有修复方法缺乏领域知识的问题,提出知识增强修复方法 DSrepair。它利用知识图谱 RAG 检索 API 知识并增强缺陷知识,构建 DS-KG;同时用 AST 在节点级定位错误,为 LLM 生成修复提示。作者在 DS-1000 上以四个 LLM 和五个最优修复基线评测。结果表明,DSrepair 优于全部基线;相比次优基线,对四个 LLM 分别多修复 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 approach designed to repair the buggy code generated by LLMs in the data science domain. DSrepair uses knowledge graph based RAG for API knowledge retrieval and 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. We evaluate DSrepair's effectiveness against five state-of-the-art LLM-based repair baselines using four advanced LLMs on the DS-1000 dataset. The results show that DSrepair outperforms all five baselines. Specifically, when compared to the second-best baseline, DSrepair achieves substantial 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.
DOI 原文 ·
@inproceedings{paperbot8746,
title = {Knowledge-Enhanced Program Repair for Data Science Code},
author = {Shuyin Ouyang and Jie M. Zhang and Zeyu Sun and Albert Merono Penuela},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00246}
}