GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model
Fuente:
arXiv
Saved in:
| Main Authors: | , , , , , , , |
|---|---|
| Format: | Preprint |
| Published: |
2024
|
| Subjects: | |
| Online Access: | |
| Tags: |
Add Tag
No Tags, Be the first to tag this record!
|
| _version_ | 1866914948544724992 |
|---|---|
| author | Liu, Wei Yu, Ailun Zan, Daoguang Shen, Bo Zhang, Wei Zhao, Haiyan Jin, Zhi Wang, Qianxiang |
| author_facet | Liu, Wei Yu, Ailun Zan, Daoguang Shen, Bo Zhang, Wei Zhao, Haiyan Jin, Zhi Wang, Qianxiang |
| contents | The performance of repository-level code completion depends upon the effective leverage of both general and repository-specific knowledge. Despite the impressive capability of code LLMs in general code completion tasks, they often exhibit less satisfactory performance on repository-level completion due to the lack of repository-specific knowledge in these LLMs. To address this problem, we propose GraphCoder, a retrieval-augmented code completion framework that leverages LLMs' general code knowledge and the repository-specific knowledge via a graph-based retrieval-generation process. In particular, GraphCoder captures the context of completion target more accurately through code context graph (CCG) that consists of control-flow, data- and control-dependence between code statements, a more structured way to capture the completion target context than the sequence-based context used in existing retrieval-augmented approaches; based on CCG, GraphCoder further employs a coarse-to-fine retrieval process to locate context-similar code snippets with the completion target from the current repository. Experimental results demonstrate both the effectiveness and efficiency of GraphCoder: Compared to baseline retrieval-augmented methods, GraphCoder achieves higher exact match (EM) on average, with increases of +6.06 in code match and +6.23 in identifier match, while using less time and space. |
| format | Preprint |
| id |
arxiv_https___arxiv_org_abs_2406_07003 |
| institution | arXiv |
| publishDate | 2024 |
| record_format | arxiv |
| spellingShingle | GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model Liu, Wei Yu, Ailun Zan, Daoguang Shen, Bo Zhang, Wei Zhao, Haiyan Jin, Zhi Wang, Qianxiang Software Engineering The performance of repository-level code completion depends upon the effective leverage of both general and repository-specific knowledge. Despite the impressive capability of code LLMs in general code completion tasks, they often exhibit less satisfactory performance on repository-level completion due to the lack of repository-specific knowledge in these LLMs. To address this problem, we propose GraphCoder, a retrieval-augmented code completion framework that leverages LLMs' general code knowledge and the repository-specific knowledge via a graph-based retrieval-generation process. In particular, GraphCoder captures the context of completion target more accurately through code context graph (CCG) that consists of control-flow, data- and control-dependence between code statements, a more structured way to capture the completion target context than the sequence-based context used in existing retrieval-augmented approaches; based on CCG, GraphCoder further employs a coarse-to-fine retrieval process to locate context-similar code snippets with the completion target from the current repository. Experimental results demonstrate both the effectiveness and efficiency of GraphCoder: Compared to baseline retrieval-augmented methods, GraphCoder achieves higher exact match (EM) on average, with increases of +6.06 in code match and +6.23 in identifier match, while using less time and space. |
| title | GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model |
| topic | Software Engineering |
| url | https://arxiv.org/abs/2406.07003 |