Skip to main content
QUICK REVIEW

[論文レビュー] STALL+: Boosting LLM-based Repository-level Code Completion with Static Analysis

Junwei Liu, Yixuan Chen|arXiv (Cornell University)|Jun 14, 2024
Natural Language Processing TechniquesComputer Science被引用数 3
ひとこと要約

本稿では、LLMを用いたリポジトリレベルのコード補完における精度向上と幻覚の低減を目的として、静的解析を複数段階にわたり統合するフレームワーク「STALL+」を提案する。静的解析をプロンプト段階に統合した場合が特に優れた性能を示し、Javaのような静的型付け言語において顕著である。一方、静的解析とRAGを組み合わせることで、相乗効果が得られ、コスト効率も向上する。

ABSTRACT

Repository-level code completion is challenging as it involves complicated contexts from multiple files in the repository. To date, researchers have proposed two technical categories to enhance LLM-based repository-level code completion, i.e., retrieval-augmented generation (RAG) and static analysis integration. This work performs the first study on the static analysis integration in LLM-based repository-level code completion by investigating both the effectiveness and efficiency of static analysis integration strategies across different phases of code completion. We first implement a framework STALL+, which supports an extendable and customizable integration of multiple static analysis strategies into the complete pipeline of LLM-based repository-level code completion; and based on STALL+, we perform extensive experiments by including different code LLMs on the latest repository-level code completion benchmark CrossCodeEval. Our findings show that integrating file-level dependencies in prompting phase performs the best while the integration in post-processing phase performs the worse. Additionally, we observe different improvements from static analysis between dynamic languages and static languages, i.e., the best combination is prompting-phase with decoding-phase integration for Java while the best combination is prompting-phase with post-processing-phase integration for Python given the limitations of statically analyzing dynamic languages. Additionally, we find the complementarity between RAG and static analysis integration as well as their cost-effectiveness after combination.

研究の動機と目的

  • ローカルリポジトリの文脈に関する知識が限られることが原因で生じるLLMベースのリポジトリレベルコード補完における幻覚問題に対処すること。
  • コード補完パイプラインの異なる段階における静的解析統合の有効性と効率性を調査すること。
  • 静的解析とリtrieーブ・オーバーラップ・ジェネレーション(RAG)の相乗効果が、コード補完の正確性向上に与える影響を評価すること。
  • 多様な静的解析戦略の統合を可能にするカスタマイズ可能で拡張可能なフレームワークを提供すること。

提案手法

  • プロンプト、デコード、後処理の3段階のパイプラインステージで、複数の静的解析戦略を統合可能なモジュラーなフレームワーク「STALL+」を設計する。
  • 静的解析ツール(例:依存関係抽出器、型チェックャ)の拡張可能でカスタマイズ可能な統合をLLM推論パイプラインに可能にする。
  • プロンプト段階での静的解析統合として、他のファイルからの関連コード依存関係を抽出し、入力プロンプトに埋め込む。
  • デコード段階での静的解析統合として、解析結果に基づいてトークンの確率を修正し、より正確な生成を誘導する。
  • 後処理段階での静的解析統合として、型チェックや制御フローアナリシスを用いて生成されたコードの検証または修正を実施する。
  • RAG技術との互換性を確保するため、取得したコードスニペットと静的解析結果を同時に入力に組み込むことを可能にする。
Figure 1. Overview of the STALL + static analysis integration framework
Figure 1. Overview of the STALL + static analysis integration framework

実験結果

リサーチクエスチョン

  • RQ1LLMベースのコード補完パイプラインにおける異なる段階(プロンプト、デコード、後処理)に静的解析を統合した場合、その有効性はどの程度か?
  • RQ2動的型付け言語(例:Python)と静的型付け言語(例:Java)において、静的解析統合のパフォーマンスにどのような差が生じるか?
  • RQ3リポジトリレベルのコード補完において、静的解析とリtrieーブ・オーバーラップ・ジェネレーション(RAG)を組み合わせた場合の相対的な有効性と効率性はどの程度か?
  • RQ4異なる段階における静的解析戦略の組み合わせの中で、コード補完の正確性向上に最も寄与するのはどれか?

主な発見

  • ファイルレベルの依存関係を静的解析によってプロンプト段階に統合した場合が、デコード段階や後処理段階の統合を上回る最高のパフォーマンス向上を達成する。
  • 後処理段階での静的解析統合は最も成績が悪く、最終的なコードの最適化に限られた有用性しか示さない。
  • Java(静的型付け言語)においては、プロンプト段階とデコード段階での静的解析統合を組み合わせた場合が最良のパフォーマンスを示す。
  • Python(動的型付け言語)においては、静的解析の正確性に動的機能の制限があることから、プロンプト段階と後処理段階での統合が最良のパフォーマンスをもたらす。
  • 静的解析とRAG技術は相乗効果を示す:両者を組み合わせることで、単独での利用よりも高い正確性が得られ、コスト効率も向上する。
  • フレームワーク「STALL+」は、コード補完パイプライン全体にわたり、効果的でカスタマイズ可能な静的解析統合を可能にし、今後の研究やツール開発を支援する。
Figure 2. Comparison case of three strategies
Figure 2. Comparison case of three strategies

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。