Progressively Mitigating API Hallucination in LLM-Generated Code via Knowledge Graph Reasoning
Large Language Models (LLMs) are prone to producing bugs when generating code. For instance, LLMs often misuse APIs from libraries they are not familiar with. Incorrect API usage can severely impact the functionality of the generated code. However, existing error detection and program repair methods lack the targeted handling of API hallucinations and are often unsuitable when faced with data scarcity, such as private libraries. Therefore, a lightweight and transferable method for detecting and repairing API misuses is needed. This paper introduces the StepwiseGraphFix framework, which detects API misuses in LLM-generated code by retrieving and comparing relevant subgraphs from the code library’s knowledge graph. It then applies a stepwise refinement strategy to complete the repair. We constructed the UnifiedFixEval dataset for program repair in unseen libraries by integrating five existing code generation datasets, and validated our method against several other baselines on this dataset. Experimental results show that our approach outperforms current state-of-the-art methods, increasing the proportion of successful repair tasks by 8.1%, with average improvements of 4.0% in test pass rate. Ablation studies further confirm each component’s contribution to overall performance, and the multi-round repair mechanism improves repair quality.
Thu 19 MarDisplayed time zone: Athens change
14:00 - 15:30 | Session 5A - Robustness and Reliability of LLM Code GenerationShort Papers and Posters Track / Research Track / Tool Demo Track / Early Research Achievement (ERA) Track at Panorama Chair(s): Mugdha Khedkar Heinz Nixdorf Institute, Paderborn University | ||
14:00 7mTalk | Failure-Aware Enhancements for Large Language Model (LLM) Code Generation: An Empirical study on Decision Framework Short Papers and Posters Track Jianru Shen University of Montana, Zedong Peng University of Montana, Lucy Owen University of Montana | ||
14:07 15mTalk | Progressively Mitigating API Hallucination in LLM-Generated Code via Knowledge Graph Reasoning Research Track Yuxuan Li Peking University, Zexiong Ma Peking University, Yanzhen Zou Peking University, Yue Wang Peking University, Lihan Yang Peking University, Bing Xie Peking University | ||
14:22 15mTalk | Programming Language Confusion: When Code LLMs Can't Keep their Languages Straight Research Track Micheline Bénédicte MOUMOULA University of Luxembourg, NIKIEMA Beninwende Serge Lionel University of Luxembourg, Abdoul Kader Kaboré University of Luxembourg, Jacques Klein University of Luxembourg, Tegawendé F. Bissyandé University of Luxembourg | ||
14:37 15mTalk | Can LLMs Keep Up with Library Changes? An Exploratory Study on LLM-Generated Code Research Track Xiangrong Lin Zhejiang University, Jiakun Liu Harbin Institute of Technology, Lingfeng Bao Zhejiang University | ||
14:52 15mTalk | Leveraging Enhanced Test-Driven Development for Accurate Code Generation in LLMs Research Track Rui Zhang School of Artificial Intelligence, China University of Geosciences (Beijing), Weijie Shan School of Artificial Intelligence, China University of Geosciences (Beijing), Teng Long School of Artificial Intelligence, China University of Geosciences (Beijing), Ce Fu School of Artificial Intelligence, China University of Geosciences(Beijing) | ||
15:07 7mTalk | When RAG Lies: Link-Injection Knowledge-Base Poisoning in Code Generation Short Papers and Posters Track Nguyen Trung Hieu Hanoi University of Science and Technology, Trung-Hieu Nguyen Hanoi University of Science and Technology, Hanoi, Vietnam, Trong-Nghia Be University of Engineering and Technology, Bao-Huy Hoang Hanoi University of Science and Technology,, Anh M. T. Bui Hanoi University of Science and Technology | ||
15:14 7mTalk | Grounding Generative AI in Software Engineering: Are We There Yet? Early Research Achievement (ERA) Track Mootez Saad Dalhousie University, José Antonio Hernández López Department of Computer Science and Systems, University of Murcia, Boqi Chen McGill University, Neil Ernst University of Victoria, Daniel Varro Linköping University / McGill University, Tushar Sharma Dalhousie University Pre-print | ||
15:21 7mTalk | MutEval: NL-PL Prompt Mutation Framework for Robustness Evaluation of Code LLMs Tool Demo Track Pre-print Media Attached | ||