From Misuse to Mastery: Enhancing Code Generation with Knowledge-Driven AI Chaining
Xiaoxue Ren, Xinyuan Ye, Dehai Zhao, Zhenchang Xing, Xiaohu Yang

TL;DR
This paper introduces KPC, a knowledge-driven prompt chaining method that significantly improves the quality and reliability of code generated by LLMs, especially in exception handling, through iterative check-rewrite steps.
Contribution
It proposes a novel knowledge-driven prompt chaining approach for enhancing code generation, addressing exception handling challenges in LLMs with empirical validation.
Findings
Achieves 109.86% and 578.57% improvements in static evaluation metrics.
Reduces 18 runtime bugs in sampled code.
Demonstrates effectiveness in managing exceptions in generated code.
Abstract
Large Language Models (LLMs) have shown promising results in automatic code generation by improving coding efficiency to a certain extent. However, generating high-quality and reliable code remains a formidable task because of LLMs' lack of good programming practice, especially in exception handling. In this paper, we first conduct an empirical study and summarise three crucial challenges of LLMs in exception handling, i.e., incomplete exception handling, incorrect exception handling and abuse of try-catch. We then try prompts with different granularities to address such challenges, finding fine-grained knowledge-driven prompts works best. Based on our empirical study, we propose a novel Knowledge-driven Prompt Chaining-based code generation approach, name KPC, which decomposes code generation into an AI chain with iterative check-rewrite steps and chains fine-grained knowledge-driven…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Topic Modeling · Natural Language Processing Techniques
