Crafting effective prompts for code generation or editing with Large Language Models (LLMs) is not an easy task. Particularly, the absence of immediate, stable feedback during prompt crafting hinders effective interaction, as users are left to mentally imagine possible outcomes until the code is generated. In response, we introduce Language-Oriented Code Sketching, an interactive approach that provides instant, incremental feedback in the form of code sketches (i.e., incomplete code outlines) during prompt crafting. This approach converts a prompt into a code sketch by leveraging the inherent linguistic structures within the prompt and applying classic natural language processing techniques. The sketch then serves as an intermediate placeholder that not only previews the intended code structure but also guides the LLM towards the desired code, thereby enhancing human-LLM interaction. We conclude by discussing the approach's applicability and future plans.
翻译:摘要:使用大型语言模型(LLM)进行代码生成或编辑时,编写有效提示并非易事。特别是在提示编写过程中缺乏即时、稳定的反馈,这阻碍了有效交互,因为用户只能在大脑中想象可能的结果,直到代码生成完毕。为此,我们提出面向语言的代码草图方法,这是一种交互式方法,可在提示编写过程中以代码草图(即不完整的代码轮廓)的形式提供即时、增量式反馈。该方法通过利用提示中固有的语言结构并应用经典自然语言处理技术,将提示转换为代码草图。该草图随后充当中间占位符,不仅预览预期的代码结构,还能引导LLM生成所需代码,从而增强人机交互效果。最后,我们讨论了该方法的适用性和未来规划。