Skip to main content
QUICK REVIEW

[論文レビュー] ToolCoder: Teach Code Generation Models to use API search tools

Kechi Zhang, Zhang, Huangzhao|arXiv (Cornell University)|May 6, 2023
Software Engineering Research被引用数 10
ひとこと要約

ToolCoderはAPI検索ツールを事前学習済みコード生成モデルに統合し、コード生成中のAPI選択の自動ツール利用を可能にし、公開ライブラリと私的ライブラリのベンチマークで一貫した利得を生み出します。ChatGPTベースのデータ注釈とLoRAベースのファインチューニングを用いて、ツール対応デコードを効率的に実現します。

ABSTRACT

Automatically generating source code from natural language descriptions has been a growing field of research in recent years. However, current large-scale code generation models often encounter difficulties when selecting appropriate APIs for specific contexts. These models may generate APIs that do not meet requirements or refer to non-existent APIs in third-party libraries, especially for lesser-known or private libraries. Inspired by the process of human developers using tools to search APIs, we propose ToolCoder, a novel approach that integrates API search tools with existing models to assist in code generation and API selection. To teach our model to use tools, we introduce an automated data annotation method using ChatGPT to add tool usage information into the source code data and fine-tune code generation models. During inference, we integrate API search tools into the generation process so that our model can automatically use the search tool to get suggestions when selecting an API. Our experimental results demonstrate that ToolCoder exhibits excellent performance and generalization across five public and private library code generation benchmarks, with at least 6.21\% improvement on average pass@1 metrics and 9.64\% improvement on average pass@10 metrics compared to state-of-the-art methods. Furthermore, we show that our relatively small ToolCoder model is comparable to one of the current best models, GPT-3.5, highlighting the potential of incorporating programming tools into the code generation process.

研究の動機と目的

  • 広大かつ私的ライブラリの存在によるコード生成モデルのAPI選択の課題を動機づけ、対応する。
  • API検索ツールの使用をモデルに教えるツール強化データパイプラインを導入。
  • デコード時のツール使用を可能にする効率的なファインチューニング手法を提案。
  • ToolCoderを公開ライブラリと私的ライブラリのベンチマークで一般化させることを示す。

提案手法

  • ツール使用の呼び出しをソースコードデータに挿入するよう、ChatGPTを用いてツール強化データセットを自動的にアノテート。
  • パラメータ効率的なチューニング(LoRA)でAPI検索ツールの使用を対象とした事前学習済みコード生成モデルをファインチューニング。
  • 推論時にデコードプロセスへAPI検索ツールを統合し、モデル出力がツール呼び出しトークンを発する場合にツール呼び出しをトリガー。
  • オンラインのDuckDuckGo + 私的ライブラリ用のインドゥバムBM25ベースのリトリーバルを統合し、特別なトークンとしてAPI検索呼び出しに統一。
  • ToolCoderを5つのベンチマークで評価(3つの公開:NumpyEval, PandasEval, TorchDataEval; 2つの私的:MonkeyEval, BeatNumEval)をpass@k指標(k=1,10)で。
  • 一般的なコード生成ベースラインとAPI指向ベースラインと比較し、GPT-3.5を強力な参照として含む。

実験結果

リサーチクエスチョン

  • RQ1RQ1: ToolCoderは公開ライブラリベンチマークでSOTAベースラインに対してどうなるか?
  • RQ2RQ2: ToolCoderは私的ライブラリベンチマークでどうか?
  • RQ3RQ3: データセット、訓練、および推論コンポーネントの貢献(アブレーション)は?
  • RQ4RQ4: ToolCoder生成ソリューションのコード品質と失敗モードは?

主な発見

モデルパラ.NumpyEval pass@1NumpyEval pass@10PandasEval pass@1PandasEval pass@10TorchDataEval pass@1TorchDataEval pass@10
CodeT5220M00.10000
PyCodeGPT110M18.0438.6112.7537.623.8014.00
CodeGen350M350M18.5143.5616.7329.704.6014.00
CodeGen2B2B29.1053.4630.6942.577.0018.00
GPT3.5-58.4166.2130.0933.166.0024.00
CERT-numpy220M31.4746.4216.0327.722.2014.00
CERT-pandas220M18.8133.6628.4248.042.806.00
CodeGenAPI350M16.5529.4813.5834.957.1916.93
CodeGenAPI-retrieval475M12.6727.3211.2528.6110.4123.50
CodeGen-retrieval475M18.3035.129.5429.027.5216.36
ToolCoder-OnlineTool350M35.6450.5022.7737.627.4020.00
ToolCoder-OnlineTool-2B2B41.5855.4431.6847.5211.8024.00
  • ToolCoderは公開ベンチマークでSOTAベースラインと比較して、pass@1で平均6.21%、pass@10で平均9.64%の改善を達成。
  • ToolCoder-OnlineToolバリアントはオンラインツールを搭載して強力な結果を出し、API選択エラーを減少。
  • 私的ライブラリでは、文書検索または私的文書ツールを用いたToolCoderが安定した改善と良好な一般化を示す。
  • 5つのベンチマーク全体で、ToolCoderは設定次第で平均pass@1の改善が6.21–19.00%を示し、いくつかの公開ベンチマークで大規模モデルに近づくか追いつく。
  • LoRAベースのファインチューニングはパラメータ効率的な学習を可能にし、CodeGen-350MとCodeGen-2Bでそれぞれ訓練されたパラメータは0.18–0.09%のみ。
  • アブレーション研究はデータ注釈、訓練、および推論設計の効果を確認。

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

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

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

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