Instruct or Interact? Exploring and Eliciting LLMs' Capability in Code Snippet Adaptation Through Prompt Engineering
Tanghaoran Zhang, Yue Yu, Xinjun Mao, Shangwen Wang, Kang Yang, Yao, Lu, Zhang Zhang, Yuxin Zhao

TL;DR
This paper investigates the ability of large language models to adapt code snippets, identifies their limitations, and proposes an interactive prompting method that significantly improves their adaptation performance in software development tasks.
Contribution
It provides an empirical evaluation of LLMs' code adaptation capabilities and introduces an interactive prompting approach to enhance their performance in context-dependent code modification tasks.
Findings
LLMs perform worse on code adaptation than generation, with about 15% decrease in pass@1.
Manual analysis reveals issues like unclear requirements and context misapplication as causes of poor adaptation.
Interactive prompting significantly improves LLMs' adaptation success rate, with over 40% increase in pass@1 and pass@5.
Abstract
Code snippet adaptation is a fundamental activity in the software development process. Unlike code generation, code snippet adaptation is not a "free creation", which requires developers to tailor a given code snippet in order to fit specific requirements and the code context. Recently, large language models (LLMs) have confirmed their effectiveness in the code generation task with promising results. However, their performance on adaptation, a reuse-oriented and context-dependent code change prediction task, is still unclear. To bridge this gap, we conduct an empirical study to investigate the performance and issues of LLMs on the adaptation task. We first evaluate the adaptation performances of three popular LLMs and compare them to the code generation task. Our result indicates that their adaptation ability is weaker than generation, with a nearly 15% decrease on pass@1 and more…
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.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Data Storage Technologies · Scientific Computing and Data Management
