Skip to main content
QUICK REVIEW

[論文レビュー] A parallel corpus of Python functions and documentation strings for automated code documentation and code generation

Antonio Valerio Miceli Barone, Rico Sennrich|arXiv (Cornell University)|Jul 7, 2017
Natural Language Processing Techniques参考文献 14被引用数 57
ひとこと要約

この論文は GitHub からスクレイピングした docstrings が付与された Python 関数の大規模並列コーパスと、ニューラル機械翻訳とデータ拡張を用いたコード文書化およびコード生成のベースラインを提供し、研究用リソースを公開します。

ABSTRACT

Automated documentation of programming source code and automated code generation from natural language are challenging tasks of both practical and scientific interest. Progress in these areas has been limited by the low availability of parallel corpora of code and natural language descriptions, which tend to be small and constrained to specific domains. In this work we introduce a large and diverse parallel corpus of a hundred thousands Python functions with their documentation strings ("docstrings") generated by scraping open source repositories on GitHub. We describe baseline results for the code documentation and code generation tasks obtained by neural machine translation. We also experiment with data augmentation techniques to further increase the amount of training data. We release our datasets and processing scripts in order to stimulate research in these areas.

研究の動機と目的

  • 自動コード文書化と生成を進展させるために、大規模で現実的なコード-言語コーパスの必要性を動機づける。
  • GitHub からの docstring を伴う Python 関数の多様な並列コーパスと付随するメタデータを作成する。
  • コーパス上で code-to-docstring および docstring-to-code タスクのベースラインニューラル機械翻訳結果を提供する。
  • 訓練データを強化するための合成 docstring を用いたデータ拡張を探る。
  • 研究コミュニティに対してデータセット、前処理スクリプト、ベースライン設定を公開する。

提案手法

  • GitHub をスクレイプして Python 2.7 のコードを抽出し、関数宣言・docstrings・本体に分割する。
  • 並列コーパスを作成するためにフィルタリングと前処理を行い、合成 docstrings を含むコードのみコーパスを別個作成する。
  • Moses でトークン化し、スパース性を低減するために Byte-Pair Encoding を適用する。
  • 特定のハイパーパラメータを用いて Nematus でコード→docstring および docstring→コードの両方向のニューラル機械翻訳モデルを訓練する。
  • コードのみデータに対して合成 docstring を生成してバックトランスレーションを適用し、再訓練する。

実験結果

リサーチクエスチョン

  • RQ1大規模で多様な Python 関数-ドキュストリングコーパスは、コード文書化とコード生成タスクの効果的な学習を支援できるか?
  • RQ2このデータに対するコード→docstring および docstring→コードタスクでニューラルMTのベースラインはどのように機能するか?
  • RQ3バックトランスレーションと合成 docstring のデータ拡張は性能を改善するか?
  • RQ4このコーパスにおけるタスク難易度を示すベースラインBLEUスコアは何か?

主な発見

システムBLEU有効テスト
コード→ドックストリング14.0313.84
ドックストリング→コード (ベース)10.3210.24
ドックストリング→コード(バックトランス)10.8510.90
  • 主な並列コーパスは 150,370 件の関数宣言、docstrings、本文を含み、訓練 109,108 件、検証 2,000 件、テスト 2,000 件の例を含む。
  • Code-to-docstring ベースライン BLEU: 14.03 (valid) and 13.84 (test).
  • Docstring-to-code (base) ベースライン BLEU: 10.32 (valid) and 10.24 (test).
  • Docstring-to-code with backtranslation BLEU: 10.85 (valid) and 10.90 (test).
  • バックトランスレーションは、ベースの docstring-to-code モデルと比較して約 0.5–0.6 BLEUポイントの中程度の改善を提供する。
  • このデータセットは、他のデータセットでのBLEUスコアが60–85の範囲である等、これまでに公表された Python コーパスよりも難易度が高く、現実的な複雑さを示す。

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

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

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

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