[논문 리뷰] RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation
RepoCoder는 저장소 수준 코드 완성을 위해 저장소 컨텍스트와 반복 프롬프트를 활용하는 반복 검색-생성 프레임워크를 도입하여 여러 모델에서 파일 내 baselines보다 완성 정확도를 향상시킵니다. 또한 RepoEval을 제시하는 벤치마크로, 단위 테스트를 사용하는 라인, API 호출, 함수 본문 완성을 포함합니다.
The task of repository-level code completion is to continue writing the unfinished code based on a broader context of the repository. While for automated code completion tools, it is difficult to utilize the useful information scattered in different files. We propose RepoCoder, a simple, generic, and effective framework to address the challenge. It streamlines the repository-level code completion process by incorporating a similarity-based retriever and a pre-trained code language model in an iterative retrieval-generation pipeline. RepoCoder makes effective utilization of repository-level information for code completion and has the ability to generate code at various levels of granularity. Moreover, we propose a new benchmark RepoEval, which consists of the latest and high-quality real-world repositories covering line, API invocation, and function body completion scenarios. Experimental results indicate that RepoCoder significantly improves the In-File completion baseline by over 10% in all settings and consistently outperforms the vanilla retrieval-augmented code completion approach. Furthermore, we validate the effectiveness of RepoCoder through comprehensive analysis, providing valuable insights for future research. Our source code and benchmark are publicly available: https://github.com/microsoft/CodeT/tree/main/RepoCoder
연구 동기 및 목표
- 코드베이스 내에서 파일 간 컨텍스트를 활용하도록 저장소 수준 코드 완성을 동기화한다.
- 저장소 수준 정보를 통합하기 위한 일반적 검색 보강 생성 프레임워크를 제안한다.
- 검색 컨텍스트와 대상 완성 간 격차를 메우기 위한 반복 검색을 보여준다.
- 저장소 평가 RepoEval을 도입하여 단위 테스트와 함께 라인, API 호출, 함수 본문 완성을 평가한다.
제안 방법
- 파일에 대한 슬라이딩 윈도우를 사용하여 검색 컬렉션을 구축하여 저장소 코드 코퍼스를 구성한다.
- 미완성 코드 X를 질의로 사용하여 저장소에서 관련 스니펫을 검색하는 검색기를 사용한다(C_repo, X).
- 모든 파라미터를 고정하지 않고 각 생성 Y^{i-1}를 사용하여 Y^{i}의 검색을 다듬는 반복 방식 적용.
- 검색된 스니펫 C_ret와 미완성 코드 X를 결합한 프롬프트 설계로 사전 학습된 언어 모델의 생성을 안내한다.
- 희박한(Jaccard 기반)과 조밀한(UniXcoder 기반) 검색기 및 여러 생성 모델(GPT-3.5-Turbo, CodeGen 변형)을 활용한다.
- RepoEval로 벤치마크: 세 가지 세분화(라인, API 호출, 함수 본문)와 단위 테스트 기반 평가.
실험 결과
연구 질문
- RQ1저장소 수준 컨텍스트가 파일 내 컨텍스트를 넘어 코드 완성을 개선할 수 있는가?
- RQ2RepoCoder의 반복 검색-생성(반복적 검색-생성)이 서로 다른 모델 전반에 걸쳐 단일 패스 RAG 및 파일 내 baselines를 능가하는가?
- RQ3저장소 수준 코드 완성에서 검색 품질이 완성도에 어떤 영향을 미치는가?
- RQ4반복 횟수가 성능에 미치는 영향과 언제 반복을 중지해야 하는가?
- RQ5RepoEval이 단위 테스트를 포함한 실제 저장소 수준 완성 시나리오를 어떻게 포착하는가?
주요 결과
- RepoCoder는 데이터세트와 모델 전반에서 파일 내 완성을 EM 및 ES에서 10% 이상 지속적으로 향상시킨다.
- RepoCoder의 두 번 이상의 반복은 라인 및 API 완성 작업에서 일반 RAG보다 신뢰성 있게 우수하다.
- 350M 매개변수를 가진 CodeGen 모델이 RepoCoder 설정에서 GPT-3.5-Turbo와 비슷한 성능을 달성한다.
- Dense 검색기가 RepoCoder 프레임워크에서 희박한 검색기와 유사한 성능을 보이며, 검색 선택에 대한 강건성을 시사한다.
- 둘의 반복이 있는 RepoCoder은 ground-truth API 호출에 대해 더 높은 재현율(recall)을 보여주므로 생성에 대한 더 나은 검색 가이드를 제공한다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.