Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion

Wei Cheng, Yuhan Wu, Wei Hu
5/30/2024
cs.SEcs.CL

No official code found. Best implementation: nju-websoft/DraCo (34 stars, GPL-3.0, last commit 2025-03-24).

Abstract

Recent years have witnessed the deployment of code language models (LMs) in various code intelligence tasks such as code completion. Yet, it is challenging for pre-trained LMs to generate correct completions in private repositories. Previous studies retrieve cross-file context based on import relations or text similarity, which is insufficiently relevant to completion targets. In this paper, we propose a dataflow-guided retrieval augmentation approach, called DraCo, for repository-level code completion. DraCo parses a private repository into code entities and establishes their relations through an extended dataflow analysis, forming a repo-specific context graph. Whenever triggering code completion, DraCo precisely retrieves relevant background knowledge from the repo-specific context graph and generates well-formed prompts to query code LMs. Furthermore, we construct a large Python dataset, ReccEval, with more diverse completion targets. Our experiments demonstrate the superior accuracy and applicable efficiency of DraCo, improving code exact match by 3.43% and identifier F1-score by 3.27% on average compared to the state-of-the-art approach.

View on arXivView PDF

Code Implementations(1)

nju-websoft/DraCoCommunity100%
GPL-3.0

Dataflow-guided retrieval augmentation for repository-level code completion, ACL 2024 (main)

346PythonMay 28, 20241 years agoGPL-3.0
code-completionllm4coderag

Similar Papers

Cite this paper

@article{cheng2024dataflowguided,
  title  = {Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion},
  author = {Wei Cheng and Yuhan Wu and Wei Hu},
  year   = {2024},
  eprint = {2405.19782},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2405.19782v1}
}

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/2405.19782.svg)](https://codeofpaper.com/paper/2405.19782)

Discussion