Skip to main content
QUICK REVIEW

[논문 리뷰] Repoformer: Selective Retrieval for Repository-Level Code Completion

Di Wu, Wasi Uddin Ahmad|arXiv (Cornell University)|2024. 03. 15.
Web Data Mining and AnalysisComputer Science인용 수 3
한 줄 요약

이 논문은 자기지도 학습된 코드 언어 모델을 사용해 검색이 필요한 시점에 동적으로 결정하는 선택적 검색 프레임워크인 Repoformer를 제안한다. 이는 정확도와 추론 효율성을 모두 향상시킨다. 불필요한 검색을 피함으로써 성능을 유손하지 않고도 추론 속도를 최대 70% 향상시킨다. 다양한 벤치마크에서 일정한 검색 기반 보조 모델보다 뛰어난 성능을 발휘한다.

ABSTRACT

Recent advances in retrieval-augmented generation (RAG) have initiated a new era in repository-level code completion. However, the invariable use of retrieval in existing methods exposes issues in both efficiency and robustness, with a large proportion of the retrieved contexts proving unhelpful or harmful to code language models (code LMs). In this paper, we propose a selective RAG framework to avoid retrieval when unnecessary. To power this framework, we design a self-supervised learning approach to enable a code LM to accurately self-evaluate whether retrieval can improve its output quality and robustly leverage the potentially noisy retrieved contexts. Using this LM as both the selective RAG policy and the generation model, our framework achieves state-of-the-art repository-level code completion performance on diverse benchmarks including RepoEval, CrossCodeEval, and CrossCodeLongEval, a new long-form code completion benchmark. Meanwhile, our analyses show that selectively retrieving brings as much as 70% inference speedup in the online serving setting without harming the performance. We further demonstrate that our framework is able to accommodate different generation models, retrievers, and programming languages. These advancements position our framework as an important step towards more accurate and efficient repository-level code completion.

연구 동기 및 목표

  • 코드 레파지토리 수준의 코드 완성에 대해 검색 보조 생성(RAG)을 항상 수행할 경우 발생하는 비효율성과 낮은 견고성 문제를 해결하기 위해.
  • 모델 성능을 떨어뜨리는 관련 없거나 노이즈가 많은 파일 간 컨텍스트를 검색하는 데 발생하는 계산 자원 낭비를 줄이기 위해.
  • 검색이 완성 품질을 향상시킬지 자가 평가할 수 있는 자기 평가 기반 코드 언어 모델을 개발하기 위해.
  • 다양한 코드 LMs, 검색기, 프로그래밍 언어, 완성 정밀도 수준에 걸쳐 일반화할 수 있도록 하기 위해.
  • 실제 코딩 환경에서 정확도와 지연 시간을 동시에 향상시키는 즉시 사용 가능한 선택적 검색 정책을 구현하기 위해.

제안 방법

  • 코드 조각과 검색된 파일 간 컨텍스트를 쌍으로 묶어 학습 데이터를 생성하기 위해 자기지도 학습 기반 RAG 시뮬레이션 절차를 설계한다.
  • 코드 생성과 선택적 검색 결정을 동시에 최적화하는 다중 태스크 목표를 사용해 코드 LM(Repoformer)를 훈련한다.
  • 모델이 컨텍스트의 관련성에 따라 검색을 호출할지 여부를 결정하기 위해 예측하는 검색 트리거 토큰(<cc>)을 통합한다.
  • 검색이 출력 품질을 향상시킬지 평가할 수 있도록 모델을 교육하기 위해 자가 평가 손실($\mathcal{L}_{eval}$)을 사용한다.
  • 내부 신뢰도에 따라 검색 결정이 이루어지도록, 파일 내 완성과 검색 보조 생성의 조합으로 모델을 피지컬 트레이닝한다.
  • 선택적 검색 정책과 코드 생성기를 동일한 모델로 사용함으로써 별도의 정책 네트워크를 제거해 파이프라인을 단순화한다.
Figure 1 : (a) An overview of the proposed selective RAG framework. Given the current file context, a policy first assesses whether retrieval is required and triggers the retriever selectively. Then, the code LM makes a hypothesis with the optional retrieved context. With Repoformer , the two stages
Figure 1 : (a) An overview of the proposed selective RAG framework. Given the current file context, a policy first assesses whether retrieval is required and triggers the retriever selectively. Then, the code LM makes a hypothesis with the optional retrieved context. With Repoformer , the two stages

실험 결과

연구 질문

  • RQ1코드 언어 모델을 훈련시켜 검색이 완성 품질을 향상시킬지 자가 평가할 수 있는가?
  • RQ2항상 검색하는 것과 비교해 선택적 검색은 성능 저하 없이 추론 지연 시간을 줄일 수 있는가?
  • RQ3검색이 활성화되었을 때, 노이즈가 많거나 관련 없는 검색된 컨텍스트에 대해 모델의 견고성은 어느 정도인가?
  • RQ4동일한 선택적 검색 정책이 다양한 코드 LMs, 프로그래밍 언어, 검색 방법에 걸쳐 일반화 가능한가?
  • RQ5이미 답을 알고 있거나 파일 간 컨텍스트가 불필요할 경우, 모델이 검색을 생략하도록 훈련시킬 수 있는가?

주요 결과

  • Repoformer는 불필요한 검색을 피함으로써 성능 저하 없이 추론 속도를 70% 향상시켰다.
  • RepoEval과 CrossCodeEval에서, Repoformer는 조각 완성 및 함수 완성 작업 모두에서 일정한 검색 기반 기준 모델을 능가했다.
  • Ablation 연구 결과, A2($\mathcal{L}_{eval}$가 포함된 버전)는 손실 불균형으로 인해 기본적으로 검색을 수행하는 A1보다 더 나은 선택적 결정을 내렸다.
  • A3는 훈련 중 $CC$를 제거했기 때문에 RAG 성능이 열악해졌으며, 이는 검색된 컨텍스트로 훈련하는 것이 견고성 확보에 필수적임을 증명한다.
  • A4는 $CC$를 인페일링 스팸 내부에 위치시켰기 때문에 함수 완성에서 성능이 열악했으며, 이는 사전 훈련된 '빈칸 메꾸기' 의미를 파괴함을 시사한다.
  • Repoformer는 다양한 프로그래밍 언어와 완성 정밀도 수준에서 뛰어난 성능 유지를 보이며 일반화 능력을 입증했다.
Figure 2 : A comparison between fill-in-the-middle and self-selective RAG. We mark the end of the current file with a new token <eof> , which triggers the LM’s self-evaluation. $\rightarrow$ denotes the invocation of the LM. LM-generated parts are colored in red. fim_p , fim_s , and fim_m refer to t
Figure 2 : A comparison between fill-in-the-middle and self-selective RAG. We mark the end of the current file with a new token <eof> , which triggers the LM’s self-evaluation. $\rightarrow$ denotes the invocation of the LM. LM-generated parts are colored in red. fim_p , fim_s , and fim_m refer to t

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.