Skip to main content
QUICK REVIEW

[論文レビュー] Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learning

Mingyang Geng, Shangwen Wang|arXiv (Cornell University)|Apr 22, 2023
Software Engineering ResearchComputer Science被引用数 9
ひとこと要約

この論文は大規模言語モデル(Codex)が文脈から学習して複数の意図を持つコードコメントを生成できることを示し、10件のデモと検索ベースのデモ選択戦略+再ランク付けを用いると強い改善が得られる。

ABSTRACT

Code comment generation aims at generating natural language descriptions for a code snippet to facilitate developers' program comprehension activities. Despite being studied for a long time, a bottleneck for existing approaches is that given a code snippet, they can only generate one comment while developers usually need to know information from diverse perspectives such as what is the functionality of this code snippet and how to use it. To tackle this limitation, this study empirically investigates the feasibility of utilizing large language models (LLMs) to generate comments that can fulfill developers' diverse intents. Our intuition is based on the facts that (1) the code and its pairwise comment are used during the pre-training process of LLMs to build the semantic connection between the natural language and programming language, and (2) comments in the real-world projects, which are collected for the pre-training, usually contain different developers' intents. We thus postulate that the LLMs can already understand the code from different perspectives after the pre-training. Indeed, experiments on two large-scale datasets demonstrate the rationale of our insights: by adopting the in-context learning paradigm and giving adequate prompts to the LLM (e.g., providing it with ten or more examples), the LLM can significantly outperform a state-of-the-art supervised learning approach on generating comments with multiple intents. Results also show that customized strategies for constructing the prompts and post-processing strategies for reranking the results can both boost the LLM's performances, which shed light on future research directions for using LLMs to achieve comment generation.

研究の動機と目的

  • 多様な開発者の意図を反映するための多意図コードコメント生成の動機づけ。
  • ファインチューニングなしで、文脈学習を用いた事前学習済みLLMが複数視点のコメントを生成できるかを調査。
  • デモンストレーションの量、検索ベースデモ選択、ポストホック再ランク付けを評価して性能を最大化。
  • 大規模なJavaコードコメントデータセット Funcomと TLC で、DOME という最先端の supervised アプローチと比較。

提案手法

  • 多意図コードコメント生成のために OpenAI Codex を LLMとして利用し、文脈学習を実施。
  • 言語指示、意図カテゴリ、対応するコメントを含むコードデモのセットを含むプロンプトテンプレートを提供。
  • ターゲットコードに類似するデモを選択するため、トークンベースと意味表現ベースの2つのデ Retrieval 戦略を設計。
  • 最も類似した取得コードの参照コメントを用いた再ランク付け戦略を適用し、トークンベースおよび意味的類似性を計算。
  • FuncomおよびTLCのJavaデータセットで BLEU、ROUGE-L、METEOR を指標として評価。
  • ゼロショット/ワンショットの設定におけるランダム性を考慮して複数回実施(100回)し平均を報告;再ランク評価も最適解を推定するために100回実施。
Figure 1 . Multi-intent code summarization prompt template.
Figure 1 . Multi-intent code summarization prompt template.

実験結果

リサーチクエスチョン

  • RQ1RQ1: DOMEと比較して、ゼロショット・ワンショット・少数ショット学習下で Codex は複数意図コメント生成でどれくらい効果的か?
  • RQ2RQ2: 検索ベースのデモ選択は Codex の性能を向上させるか?
  • RQ3RQ3: 生成コメントの再ランク付けは Codex の結果をさらに改善できるか?

主な発見

  • デモを増やすと Codex が改善する;10-shot プロンプトは平均的に DOME を上回る BLEU、ROUGE-L、METEOR。
  • ターゲットコードへの類似性によるデモ選択は性能を大幅に向上させる(Funcomで BLEU が 97%、TLC で 131% の改善、ランダム選択と比較)。
  • 類似コードの参照コメントを用いた再ランク付けで追加の利得(Funcom で BLEU ~9.9%、TLC ~9.6%)。
  • ゼロショット・ワンショットは DOME に劣るが、5-shot Codex は ROUGE-L と METEOR で競合可能、10-shot は二つのデータセットすべての指標で一貫して DOME を上回る。
  • 意図をまたいだ場合でも、10-shot プロンプトで得られる Codex の最適結果はゼロ/少数ショットのベースラインに大きく上回り、LLM による複数意図コードコメント生成の潜在力を示す。
  • prompting設計、デモ選択、ポスト処理の有望な方向性を示唆する。
Figure 2 . Overview of our in-context learning-based code summarization.
Figure 2 . Overview of our in-context learning-based code summarization.

この論文を読む

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

Nubintでこの論文を読む

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