{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/arxiv-2509-16112","title":"CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion","arxiv_id":"2509.16112","date":"2025-09-19","proceeding":"EMNLP","authors":["Sheng Zhang","Yifan Ding","Shuquan Lian","Shun Song","Hui Li"],"abstract":"Repository-level code completion automatically predicts the unfinished code based on the broader information from the repository. Recent strides in Code Large Language Models (code LLMs) have spurred the development of repository-level code completion methods, yielding promising results. Nevertheless, they suffer from issues such as inappropriate query construction, single-path code retrieval, and misalignment between code retriever and code LLM. To address these problems, we introduce CodeRAG, a framework tailored to identify relevant and necessary knowledge for retrieval-augmented repository-level code completion. Its core components include log probability guided query construction, multi-path code retrieval, and preference-aligned BestFit reranking. Extensive experiments on benchmarks ReccEval and CCEval demonstrate that CodeRAG significantly and consistently outperforms state-of-the-art methods. The implementation of CodeRAG is available at https://github.com/KDEGroup/CodeRAG.","url_abs":"https://arxiv.org/abs/2509.16112","url_pdf":"https://arxiv.org/pdf/2509.16112","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2509.16112","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2509.16112"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/KDEGroup/CodeRAG","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":12},"by_repo_kind":{"found_in_text":{"samples":12,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"5cc7e713a361b98f","entry":"ask_llm_tgi","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/inference/tgi.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/inference/tgi.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5cc7e713a361b98f"}},{"code_sha256_prefix":"be289ff17cce3aa9","entry":"build_query_by_last_k_lines","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/build_query/build_query.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/build_query/build_query.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"be289ff17cce3aa9"}},{"code_sha256_prefix":"e63c0b38c54cd391","entry":"compute_EM","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/evaluation/metrics.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/evaluation/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e63c0b38c54cd391"}},{"code_sha256_prefix":"c1a55b16a582d56f","entry":"count_tokens","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/build_prompt/merge_retrieval.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/build_prompt/merge_retrieval.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c1a55b16a582d56f"}},{"code_sha256_prefix":"ee811882800fd4ae","entry":"get_client","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/inference/limited_async_openai.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/inference/limited_async_openai.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ee811882800fd4ae"}},{"code_sha256_prefix":"86216a5e81faff6f","entry":"get_tokenizer","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/build_prompt/merge_retrieval.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/build_prompt/merge_retrieval.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"86216a5e81faff6f"}},{"code_sha256_prefix":"e3a7eba104f010a8","entry":"hit","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/evaluation/metrics.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/evaluation/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e3a7eba104f010a8"}},{"code_sha256_prefix":"6d4fa6a5220b6843","entry":"iterate_repos","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/benchmark/common.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/benchmark/common.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6d4fa6a5220b6843"}},{"code_sha256_prefix":"2678b36e09057618","entry":"iterate_repository","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/benchmark/common.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/benchmark/common.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2678b36e09057618"}},{"code_sha256_prefix":"08e488a1ef10ab01","entry":"load_jsonl","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/benchmark/common.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/benchmark/common.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"08e488a1ef10ab01"}},{"code_sha256_prefix":"3329eb864079863b","entry":"process_one_file_sync","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/build_query/build_query.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/build_query/build_query.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3329eb864079863b"}},{"code_sha256_prefix":"b15d840bae43ef19","entry":"truncate_content_to_fit_token_limit","repo":"KDEGroup/CodeRAG","repo_kind":"found_in_text","path":"coderag/build_prompt/merge_retrieval.py","file_url":"https://github.com/KDEGroup/CodeRAG/blob/HEAD/coderag/build_prompt/merge_retrieval.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b15d840bae43ef19"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CL","source":"arxiv_api"},"syntology_extracted_results":null}