[Paper Review] RAMBO: Enhancing RAG-based Repository-Level Method Body Completion
Rambo is a RAG-based approach for repository-level method body completion that enhances code LLMs by retrieving essential repository-specific code elements—such as classes, methods, and fields—and their relevant usages, rather than relying on similarity-based retrieval of entire method bodies. It achieves state-of-the-art performance, improving Exact Match by up to 12% over RepoCoder Oracle and boosting CodeBLEU by 57% and Compilation Rate by 36%.
Code completion is essential in software development, helping developers by predicting code snippets based on context. Among completion tasks, Method Body Completion (MBC) is particularly challenging as it involves generating complete method bodies based on their signatures and context. This task becomes significantly harder in large repositories, where method bodies must integrate repositoryspecific elements such as custom APIs, inter-module dependencies, and project-specific conventions. In this paper, we introduce RAMBO, a novel RAG-based approach for repository-level MBC. Instead of retrieving similar method bodies, RAMBO identifies essential repository-specific elements, such as classes, methods, and variables/fields, and their relevant usages. By incorporating these elements and their relevant usages into the code generation process, RAMBO ensures more accurate and contextually relevant method bodies. Our experimental results with leading code LLMs across 40 Java projects show that RAMBO significantly outperformed the state-of-the-art repository-level MBC approaches, with the improvements of up to 46% in BLEU, 57% in CodeBLEU, 36% in Compilation Rate, and up to 3X in Exact Match. Notably, RAMBO surpassed RepoCoder Oracle method by up to 12% in Exact Match, setting a new benchmark for repository-level MBC.
Motivation & Objective
- To address the limitations of similarity-based retrieval in repository-level method body completion, where retrieved code snippets are often irrelevant or non-existent.
- To improve code LLM performance in generating accurate, contextually relevant method bodies by focusing on essential repository-specific code elements and their usages.
- To eliminate reliance on fine-tuning or retraining code LLMs while achieving superior performance over existing RAG-based and oracle-based methods.
- To develop a retrieval strategy that identifies functionally relevant code elements based on a sketch of the target method’s structure, reducing noise and improving precision.
Proposed method
- Rambo generates a sketch body for the target method to infer its functional structure and identify potentially essential code elements.
- It extracts candidate code elements—classes, methods, fields, and variables—from the sketch and uses them to query the repository for relevant declarations and usages.
- The retrieval process focuses on finding syntactically and semantically relevant usages of these elements, treating them as 'recipes' for constructing the method body.
- These retrieved elements and their usages are injected as context into the code LLM, guiding accurate and repository-consistent code generation.
- The approach avoids learning-based retrieval or model fine-tuning, relying instead on structural and semantic analysis of the sketch and codebase.
- The method is evaluated using standard metrics including BLEU, CodeBLEU, Compilation Rate, Exact Match, and pass@k across 40 Java repositories.

Experimental results
Research questions
- RQ1Can a retrieval strategy based on essential code elements and their usages outperform similarity-based retrieval in repository-level method body completion?
- RQ2How does the performance of Rambo compare to state-of-the-art methods like RepoCoder and RepoCoder Oracle across multiple evaluation metrics?
- RQ3To what extent does sketch-based element extraction improve retrieval precision and reduce noise in code retrieval for code generation?
- RQ4Can a retrieval-augmented generation approach achieve SOTA results without fine-tuning or modifying the underlying code LLM?
Key findings
- Rambo improved CodeBLEU by up to 57% compared to the baseline, demonstrating significant gains in structural and semantic alignment of generated code.
- It achieved a 36% improvement in Compilation Rate, indicating that generated method bodies are more syntactically correct and production-ready.
- Rambo surpassed RepoCoder Oracle by up to 12% in Exact Match, setting a new SOTA benchmark for repository-level MBC.
- The approach achieved up to 46% improvement in BLEU and up to 3X improvement in Exact Match, highlighting its effectiveness in generating accurate and complete method bodies.
- The sketch-based retrieval mechanism reduced noise and irrelevant context, leading to more reliable and functionally accurate code generation.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.