With the success of large language models (LLMs) of code and their use as code assistants (e.g. Codex used in GitHub Copilot), techniques for introducing domain-specific knowledge in the prompt design process become important. In this work, we propose a framework called Repo-Level Prompt Generator that learns to generate example-specific prompts using prompt proposals. The prompt proposals take context from the entire repository, thereby incorporating both the structure of the repository and the context from other relevant files (e.g. imports, parent class files). Our technique doesn't require any access to the weights of the LLM, making it applicable in cases where we only have black-box access to the LLM. We conduct experiments on the task of single-line code-autocompletion using code repositories taken from Google Code archives. We demonstrate that an oracle constructed from our prompt proposals gives a remarkably high relative improvement of 36% over Codex, showing the quality of these proposals. Further, we show that when we train a model to predict a prompt proposal, we can achieve significant performance gains over Codex and other baselines. We release our code, data, and trained checkpoints at: \url{https://github.com/shrivastavadisha/repo_level_prompt_generation}.
翻译:随着代码大型语言模型(LLMs)的成功及其作为代码助手(例如GitHub Copilot中使用的Codex)的广泛应用,在提示设计过程中引入领域特定知识的技术变得至关重要。本文提出一个名为"仓库级提示生成器"的框架,该框架通过学习利用提示提议生成示例特定的提示。这些提示提议从整个仓库中提取上下文,从而整合了仓库的结构以及其他相关文件(例如导入文件、父类文件)的上下文信息。我们的技术无需访问LLM的权重参数,因此适用于仅具有黑盒访问权限的场景。我们使用来自Google代码档案的代码仓库,在单行代码自动补全任务上进行了实验。结果表明,基于提示提议构建的"理想提示"相对于Codex实现了高达36%的显著相对改进,充分展示了这些提议的质量。此外,当训练模型预测提示提议时,我们取得了远超Codex及其他基线模型的性能增益。我们在以下地址开源了代码、数据和训练检查点:\url{https://github.com/shrivastavadisha/repo_level_prompt_generation}。