[論文レビュー] What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?
本稿では、大規模言語モデル(LLMs)を用いたコードインテリジェンスタスクにおける効果的なコンテキスト内デモの設計法について調査する。3つのタスク—コード要約、バグ修正、プログラム合成—において、デモ選択、順序付け、例の数の影響を体系的に評価し、最適化されたデモを用いることで、標準的手法に比べてF1スコアで最大175.96%の向上を達成することを示している。
Pre-trained models of source code have gained widespread popularity in many code intelligence tasks. Recently, with the scaling of the model and corpus size, large language models have shown the ability of in-context learning (ICL). ICL employs task instructions and a few examples as demonstrations, and then inputs the demonstrations to the language models for making predictions. This new learning paradigm is training-free and has shown impressive performance in various natural language processing and code intelligence tasks. However, the performance of ICL heavily relies on the quality of demonstrations, e.g., the selected examples. It is important to systematically investigate how to construct a good demonstration for code-related tasks. In this paper, we empirically explore the impact of three key factors on the performance of ICL in code intelligence tasks: the selection, order, and number of demonstration examples. We conduct extensive experiments on three code intelligence tasks including code summarization, bug fixing, and program synthesis. Our experimental results demonstrate that all the above three factors dramatically impact the performance of ICL in code intelligence tasks. Additionally, we summarize our findings and provide takeaway suggestions on how to construct effective demonstrations, taking into account these three perspectives. We also show that a carefully-designed demonstration based on our findings can lead to substantial improvements over widely-used demonstration construction methods, e.g., improving BLEU-4, EM, and EM by at least 9.90%, 175.96%, and 50.81% on code summarization, bug fixing, and program synthesis, respectively
研究の動機と目的
- 大規模言語モデル(LLMs)を用いたコードインテリジェンスタスクにおける、高品質なコンテキスト内デモ(ICL)を構築する方法に関する理解の欠落を埋めるため。
- デモ選択、順序付け、例の数が、コード関連タスクにおけるICLパフォーマンスに与える影響を調査するため。
- コード要約、バグ修正、プログラム合成におけるICL効果を向上させるための、実行可能で根拠に基づいたガイドラインを研究者および実務家に提供するため。
- 最適化されたデモが、特にリソースが限られた状況下でも、ランダムまたはヒューリスティックベースのベースラインを著しく上回ることを示すため。
- 複数のLLMおよびコードデータセットにわたる一般化可能性を検証するとともに、現在の評価範囲における制限を同定するため。
提案手法
- 3つのコードインテリジェンスタスク(コード要約、バグ修正、プログラム合成)を対象に、3つのLLMを用いて広範な実験を実施した。
- ランダム選択、類似度ベースの検索(BM-25および意味的埋め込みを用い)、多様性ベースの選択を含む、複数のデモ選択戦略を評価した。
- ランダム、類似度ベース(降順)、逆類似度(昇順)の順序付け戦略を比較した。
- 例の数(1~10例)を変化させ、タスク全体におけるモデルパフォーマンスへの影響を評価した。
- 標準的な指標(BLEU-4、正確一致(EM)、F1)を用いてパフォーマンスを評価し、統計的有意性の検定も実施した。
- 実証的発見に基づき、選択、順序付け、例の数最適化を統合した、体系的なデモ設計フレームワークを提案した。

実験結果
リサーチクエスチョン
- RQ1コードインテリジェンスタスクにおけるコンテキスト内デモの設計において、どの選択手法が最も効果的か?
- RQ2デモ例の順序付けが、コード関連タスクにおけるICLパフォーマンスにどのように影響するか?
- RQ3デモ例の数が、コードインテリジェンスタスクにおけるICLパフォーマンスにどのように影響するか?
- RQ4得られた知見は、異なるLLMおよびプログラミング言語にわたって一般化可能か?
主な発見
- 意味的埋め込み(例:SBERT)を用いた類似度ベースの選択が、ランダム選択やBM-25ベースの検索に比べ、デモ選択において顕著に優れている。
- 入力クエリとの類似度が高い順にデモを並べることでパフォーマンスが向上し、逆類似度順序(類似度が低い順)はしばしば劣る。
- 最適なデモ例の数はタスクによって異なり、一般的には5~8例がピークパフォーマンスを示すが、6~8例を超えるとパフォーマンスは頭打ちになる。
- 最適な選択、類似度ベースの順序付け、適切な例の数を統合した、洗練されたデモ戦略により、バグ修正タスクでEMが175.96%、プログラム合成で50.81%、コード要約で9.90%向上した。
- 最適化されたデモによるパフォーマンス向上は、複数のLLMにわたって一貫しており、知見の一般化可能性が強いことが示された。
- 本研究では、ICLパフォーマンスがデモ設計に極めて敏感であり、単純な選択やランダムな順序付けでは、大規模モデルであっても最適でない結果が得られることを明らかにした。

より良い研究を、今すぐ始めましょう
論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。