Repository-Level Prompt Generation for Large Language Models of Code

Disha Shrivastava,Hugo Larochelle,Daniel Tarlow
2023-06-06
Abstract: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{<a class="link-external link-https" href="https://github.com/shrivastavadisha/repo_level_prompt_generation" rel="external noopener nofollow">this https URL</a>}.
Machine Learning,Artificial Intelligence,Programming Languages,Software Engineering
What problem does this paper attempt to address?
The paper attempts to address the problem of how to generate more effective prompts in large language models (LLMs), particularly in the task of code autocompletion. Specifically, the authors propose a framework called the Repo-Level Prompt Generator (RLPG), which can automatically generate prompts for specific examples based on the overall structure of the code repository and the content of related files. This not only improves the accuracy of code autocompletion but also does not require access to the weights of the LLM, making this approach applicable even with only black-box access. The paper demonstrates through experiments that, compared to existing code assistants (such as Codex), using their proposed prompt generation method can significantly improve the performance of single-line code autocompletion.