CodeRAG-Bench: Can Retrieval Augment Code Generation?

Zora Zhiruo Wang, Akari Asai, Xinyan Velocity Yu, Frank F. Xu, Yiqing Xie +2 more
6/20/2024
cs.SEcs.CL

No official code found. Best implementation: code-rag-bench/code-rag-bench (173 stars, last commit 2024-11-15).

Abstract

While language models (LMs) have proven remarkably adept at generating code, many programs are challenging for LMs to generate using their parametric knowledge alone. Providing external contexts such as library documentation can facilitate generating accurate and functional code. Despite the success of retrieval-augmented generation (RAG) in various text-oriented tasks, its potential for improving code generation remains under-explored. In this work, we conduct a systematic, large-scale analysis by asking: in what scenarios can retrieval benefit code generation models? and what challenges remain? We first curate a comprehensive evaluation benchmark, CodeRAG-Bench, encompassing three categories of code generation tasks, including basic programming, open-domain, and repository-level problems. We aggregate documents from five sources for models to retrieve contexts: competition solutions, online tutorials, library documentation, StackOverflow posts, and GitHub repositories. We examine top-performing models on CodeRAG-Bench by providing contexts retrieved from one or multiple sources. While notable gains are made in final code generation by retrieving high-quality contexts across various settings, our analysis reveals room for improvement -- current retrievers still struggle to fetch useful contexts especially with limited lexical overlap, and generators fail to improve with limited context lengths or abilities to integrate additional contexts. We hope CodeRAG-Bench serves as an effective testbed to encourage further development of advanced code-oriented RAG methods.

View on arXivView PDF

Code Implementations(1)

CodeRAG-Bench: Can Retrieval Augment Code Generation?

17319HTML, ShellJun 12, 20241 years ago
code-generationexecution-based-evaluationretrieval-augmented-generation

Similar Papers

Cite this paper

@article{wang2024coderagbench,
  title  = {CodeRAG-Bench: Can Retrieval Augment Code Generation?},
  author = {Zora Zhiruo Wang and Akari Asai and Xinyan Velocity Yu and Frank F. Xu and Yiqing Xie and Graham Neubig and Daniel Fried},
  year   = {2024},
  eprint = {2406.14497},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2406.14497v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2406.14497.svg)](https://codeofpaper.com/paper/2406.14497)

Discussion