Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Cheng, Wei, Wu, Yuhan, Hu, Wei
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866910464316801024
author Cheng, Wei
Wu, Yuhan
Hu, Wei
author_facet Cheng, Wei
Wu, Yuhan
Hu, Wei
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2405_19782
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion
Cheng, Wei
Wu, Yuhan
Hu, Wei
Software Engineering
Computation and Language
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.
title Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completion
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2405.19782