ContextModule: Improving Code Completion via Repository-level Contextual Information

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Guan, Zhanming, Liu, Junlin, Liu, Jierui, Peng, Chao, Liu, Dexin, Sun, Ningyuan, Jiang, Bo, Li, Wenchao, Liu, Jie, Zhu, Hang
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913607511441408
author Guan, Zhanming
Liu, Junlin
Liu, Jierui
Peng, Chao
Liu, Dexin
Sun, Ningyuan
Jiang, Bo
Li, Wenchao
Liu, Jie
Zhu, Hang
author_facet Guan, Zhanming
Liu, Junlin
Liu, Jierui
Peng, Chao
Liu, Dexin
Sun, Ningyuan
Jiang, Bo
Li, Wenchao
Liu, Jie
Zhu, Hang
contents Large Language Models (LLMs) have demonstrated impressive capabilities in code completion tasks, where they assist developers by predicting and generating new code in real-time. However, existing LLM-based code completion systems primarily rely on the immediate context of the file being edited, often missing valuable repository-level information, user behaviour and edit history that could improve suggestion accuracy. Additionally, challenges such as efficiently retrieving relevant code snippets from large repositories, incorporating user behavior, and balancing accuracy with low-latency requirements in production environments remain unresolved. In this paper, we propose ContextModule, a framework designed to enhance LLM-based code completion by retrieving and integrating three types of contextual information from the repository: user behavior-based code, similar code snippets, and critical symbol definitions. By capturing user interactions across files and leveraging repository-wide static analysis, ContextModule improves the relevance and precision of generated code. We implement performance optimizations, such as index caching, to ensure the system meets the latency constraints of real-world coding environments. Experimental results and industrial practise demonstrate that ContextModule significantly improves code completion accuracy and user acceptance rates.
format Preprint
id arxiv_https___arxiv_org_abs_2412_08063
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle ContextModule: Improving Code Completion via Repository-level Contextual Information
Guan, Zhanming
Liu, Junlin
Liu, Jierui
Peng, Chao
Liu, Dexin
Sun, Ningyuan
Jiang, Bo
Li, Wenchao
Liu, Jie
Zhu, Hang
Software Engineering
Artificial Intelligence
Large Language Models (LLMs) have demonstrated impressive capabilities in code completion tasks, where they assist developers by predicting and generating new code in real-time. However, existing LLM-based code completion systems primarily rely on the immediate context of the file being edited, often missing valuable repository-level information, user behaviour and edit history that could improve suggestion accuracy. Additionally, challenges such as efficiently retrieving relevant code snippets from large repositories, incorporating user behavior, and balancing accuracy with low-latency requirements in production environments remain unresolved. In this paper, we propose ContextModule, a framework designed to enhance LLM-based code completion by retrieving and integrating three types of contextual information from the repository: user behavior-based code, similar code snippets, and critical symbol definitions. By capturing user interactions across files and leveraging repository-wide static analysis, ContextModule improves the relevance and precision of generated code. We implement performance optimizations, such as index caching, to ensure the system meets the latency constraints of real-world coding environments. Experimental results and industrial practise demonstrate that ContextModule significantly improves code completion accuracy and user acceptance rates.
title ContextModule: Improving Code Completion via Repository-level Contextual Information
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2412.08063