Skip to main content
QUICK REVIEW

[論文レビュー] RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation

Fengji Zhang, Bei Chen|arXiv (Cornell University)|Mar 22, 2023
Software Engineering Research被引用数 8
ひとこと要約

tldr: RepoCoder は、リポジトリ全体の文脈と反復的プロンプトを活用して、複数モデルに渡る In-File ベースラインを上回る完成度を達成する、リポジトリレベルのコード補完の反復取得生成フレームワークを導入します。さらに、単体テストを用いた行・API 呼び出し・関数本体の補完を評価する RepoEval ベンチマークを提示します。

ABSTRACT

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 呼び出し・関数本体補完を評価する。

提案手法

  • ファイル上をスライディングウィンドウでリポジトリコードコーパスを構築し、取得コレクションを作成する。
  • unfinished コード X をクエリとして用い、リポジトリから関連スニペットを取得するリトリーバーを使用する(C_repo, X)。
  • 各世代 Y^{i-1} を用いて取得を洗練させる反復スキームを適用し、モデルパラメータを変更せずに Y^{i} を生成する。
  • 取得したスニペット C_ret を unfinished コード X と組み合わせて、事前学習済み言語モデルによる生成を誘導するプロンプト設計を行う。
  • 疎結合(Jaccard ベース)と密結合(UniXcoder ベース)の両方のリトリーバーを使用し、複数の生成モデル(GPT-3.5-Turbo、CodeGen 系列)を併用する。
  • RepoEval によりベンチマークする:三つの粒度(行、API 呼び出し、関数本体)と単体テストベースの評価。

実験結果

リサーチクエスチョン

  • RQ1リポジトリレベルの文脈は、ファイル内の文脈を超えたコード補完を改善できるか?
  • RQ2反復取得生成(RepoCoder)は、単一パスの RAG や In-File ベースラインよりも異なるモデル間で優位か?
  • RQ3取得の品質はリポジトリレベルのコード補完の性能にどう影響するか?
  • RQ4反復回数が性能へ与える影響はどの程度で、いつ反復を停止すべきか?
  • RQ5RepoEval は単体テストを含む実世界のリポジトリレベルの補完シナリオをどう捉えるか?

主な発見

  • RepoCoder は、データセットとモデル全体で In-File 補完を EM および ES で一貫して 10% 以上改善する。
  • RepoCoder の2回以上の反復は、行補完および API 補完タスクで vanilla RAG を信頼性高く上回る。
  • 350M パラメータの CodeGen モデルは、RepoCoder 設定で GPT-3.5-Turbo と同等の性能を達成する。
  • 密結合リトリーバーは、RepoCoder のフレームワーク内で疎結合リトリーバーと同様の性能を示し、リトリーバー選択の堅牢性を示唆する。
  • 2 回の反復を用いた RepoCoder は、真の API 呼び出しのリコールを高め、生成の取得ガイダンスが改善されることを示す。

より良い研究を、今すぐ始めましょう

論文設計から論文執筆まで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。