Table of Contents
Fetching ...

RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generation

Jicheng Wang, Yifeng He, Hao Chen

TL;DR

This paper proposes RepoGenReflex, a generic, dynamic, effective framework that can dynamically choose the optimal results for repository-level code completion by leveraging the Retrieval-Augmented Generation enhanced with Verbal Reinforcement Learning (VRL).

Abstract

In real-world software engineering tasks, solving a problem often requires understanding and modifying multiple functions, classes, and files across a large codebase. Therefore, on the repository level, it is crucial to extract the relevant information to achieve accurate code completion effectively. Existing code completion tools have achieved some success, but they struggle to optimize the retrieval and generation process dynamically. In this paper, we propose RepoGenReflex, a generic, dynamic, effective framework to address this challenge. By leveraging the Retrieval-Augmented Generation (RAG) enhanced with Verbal Reinforcement Learning (VRL), it can dynamically choose the optimal results for repository-level code completion. RepoGenReflex uses Reflector to give directional feedback to the next loop. RepoGenReflex chooses the optimal results stored in the Experience cache based on the RAG-VRL loop. To validate the framework's generalization ability, we propose a new benchmark RepoGenEval, which consists of the latest, high-quality real-world repositories in line completion scenarios. Our experiments demonstrate that RepoGenReflex achieves significant improvements after optimizing the Reflector component, resulting in enhanced accuracy and relevance of code completions. Additionally, RepoGenReflex consistently demonstrates superior performance and effectiveness across standard code completion tasks, highlighting the robustness and adaptability of our framework.

RepoGenReflex: Enhancing Repository-Level Code Completion with Verbal Reinforcement and Retrieval-Augmented Generation

TL;DR

This paper proposes RepoGenReflex, a generic, dynamic, effective framework that can dynamically choose the optimal results for repository-level code completion by leveraging the Retrieval-Augmented Generation enhanced with Verbal Reinforcement Learning (VRL).

Abstract

In real-world software engineering tasks, solving a problem often requires understanding and modifying multiple functions, classes, and files across a large codebase. Therefore, on the repository level, it is crucial to extract the relevant information to achieve accurate code completion effectively. Existing code completion tools have achieved some success, but they struggle to optimize the retrieval and generation process dynamically. In this paper, we propose RepoGenReflex, a generic, dynamic, effective framework to address this challenge. By leveraging the Retrieval-Augmented Generation (RAG) enhanced with Verbal Reinforcement Learning (VRL), it can dynamically choose the optimal results for repository-level code completion. RepoGenReflex uses Reflector to give directional feedback to the next loop. RepoGenReflex chooses the optimal results stored in the Experience cache based on the RAG-VRL loop. To validate the framework's generalization ability, we propose a new benchmark RepoGenEval, which consists of the latest, high-quality real-world repositories in line completion scenarios. Our experiments demonstrate that RepoGenReflex achieves significant improvements after optimizing the Reflector component, resulting in enhanced accuracy and relevance of code completions. Additionally, RepoGenReflex consistently demonstrates superior performance and effectiveness across standard code completion tasks, highlighting the robustness and adaptability of our framework.
Paper Structure (28 sections, 1 equation, 4 figures, 5 tables, 1 algorithm)

This paper contains 28 sections, 1 equation, 4 figures, 5 tables, 1 algorithm.

Figures (4)

  • Figure 1: An overview of the model design, illustrating the iterative process of Retriever, Actor (Generative LLM), Evaluator, Reflector, and Experience components.
  • Figure 2: A process of the prompt concatenated to the Reflector component
  • Figure 3: An example of detailed feedback from the Reflector, consisting of Evaluation Analysis, Contextual Analysis, and Specific Suggestions
  • Figure 4: The process from Experience to next iteration