[論文レビュー] Code Generation Tools (Almost) for Free? A Study of Few-Shot, Pre-Trained Language Models on Code
本論文は Codex に基づく few-shot ツールを三つのコード生成タスクで評価し、手動で構築したツールと比較しています。モデルベースのツールは従来のツールを補完・同等以上・上回る可能性があり、開発労力は著しく少なくて済むことを示しています。
Few-shot learning with large-scale, pre-trained language models is a powerful way to answer questions about code, e.g., how to complete a given code example, or even generate code snippets from scratch. The success of these models raises the question whether they could serve as a basis for building a wide range code generation tools. Traditionally, such tools are built manually and separately for each task. Instead, few-shot learning may allow to obtain different tools from a single pre-trained language model by simply providing a few examples or a natural language description of the expected tool behavior. This paper studies to what extent a state-of-the-art, pre-trained language model of code, Codex, may serve this purpose. We consider three code manipulation and code generation tasks targeted by a range of traditional tools: (i) code mutation; (ii) test oracle generation from natural language documentation; and (iii) test case generation. For each task, we compare few-shot learning to a manually built tool. Our results show that the model-based tools complement (code mutation), are on par (test oracle generation), or even outperform their respective traditionally built tool (test case generation), while imposing far less effort to develop them. By comparing the effectiveness of different variants of the model-based tools, we provide insights on how to design an appropriate input ("prompt") to the model and what influence the size of the model has. For example, we find that providing a small natural language description of the code generation task is an easy way to improve predictions. Overall, we conclude that few-shot language models are surprisingly effective, yet there is still more work to be done, such as exploring more diverse ways of prompting and tackling even more involved tasks.
研究の動機と目的
- 事前学習済み言語モデルを few-shot で用いて、さまざまなカテゴリに跨るコード生成タスクの一般的なツールとして機能し得るかを評価する。
- コード変異、自然言語からのテストオラクル生成、テストケース生成において、モデルベースのツールと手動で作成したツールを比較する。
- プロンプト設計とモデルサイズがこれらのツールの有効性に与える影響を分析する。
提案手法
- 最先端のコード言語モデル(Codex)を三つのタスクに適用する:コード変異、自然言語ドキュメントからのテストオラクル生成、およびテストケース生成。
- few-shot プロンプトと軽量な自然言語記述を用いてツールの挙動を試作する。
- 有効性と開発労力の観点から、モデルベースのツールと従来の手動構築ツールを比較する。
- プロンプト設計の変化とモデルサイズが性能に与える影響を調査する。
実験結果
リサーチクエスチョン
- RQ1Codex ベースの few-shot のツールは、コード変異、テストオラクル生成、およびテストケース生成において、従来のツールと同等かそれを上回ることができるか?
- RQ2NL 説明を含むプロンプト設計が、タスクを跨るモデル生成コードの品質に与える影響は何か?
- RQ3モデルサイズは few-shot のコード生成ツールの有効性にどう影響するか?
主な発見
- モデルベースのツールは従来のコード変異ツールを補完する。
- 自然言語ドキュメントからのテストオラクル生成において、モデルベースのツールは従来ツールと同等である。
- テストケース生成において、モデルベースのツールは従来ツールを上回る可能性があり、開発労力は大幅に少なくて済む。
- タスクの小さな自然言語記述を提供すると予測性能が向上する。
- 異なるプロンプト変種とモデルサイズは有効性に影響を与え、プロンプトの最適化やより大きい/小さいモデルの探索の余地があることを示唆する。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。