Skip to main content
QUICK REVIEW

[論文レビュー] GraphCodeBERT: Pre-training Code Representations with Data Flow

Daya Guo, Shuo Ren|arXiv (Cornell University)|Sep 17, 2020
Software Engineering Research参考文献 41被引用数 152
ひとこと要約

GraphCodeBERT はデータフロー構造を組み込むことでコード表現を事前学習し、二つの構造認識タスクを導入し、四つのコード関連の下流タスクで最先端の成果を達成する。

ABSTRACT

Pre-trained models for programming language have achieved dramatic empirical improvements on a variety of code-related tasks such as code search, code completion, code summarization, etc. However, existing pre-trained models regard a code snippet as a sequence of tokens, while ignoring the inherent structure of code, which provides crucial code semantics and would enhance the code understanding process. We present GraphCodeBERT, a pre-trained model for programming language that considers the inherent structure of code. Instead of taking syntactic-level structure of code like abstract syntax tree (AST), we use data flow in the pre-training stage, which is a semantic-level structure of code that encodes the relation of "where-the-value-comes-from" between variables. Such a semantic-level structure is neat and does not bring an unnecessarily deep hierarchy of AST, the property of which makes the model more efficient. We develop GraphCodeBERT based on Transformer. In addition to using the task of masked language modeling, we introduce two structure-aware pre-training tasks. One is to predict code structure edges, and the other is to align representations between source code and code structure. We implement the model in an efficient way with a graph-guided masked attention function to incorporate the code structure. We evaluate our model on four tasks, including code search, clone detection, code translation, and code refinement. Results show that code structure and newly introduced pre-training tasks can improve GraphCodeBERT and achieves state-of-the-art performance on the four downstream tasks. We further show that the model prefers structure-level attentions over token-level attentions in the task of code search.

研究の動機と目的

  • トークン列を超えるコード構造を活用して、コード理解を向上させる動機付け。
  • プログラミング言語の意味構造を意識した事前学習フレームワークを提案する。
  • データフローをコード意味をエンコードするためのASTの拡張可能な代替手段として調査する。
  • 複数のコード関連タスクに対する構造認識型事前学習の利点を示す。

提案手法

  • データフローをグラフ入力として組み込むよう強化したTransformerベースでコードを表現する。
  • データフロー ノードとコードトークンへ選択的に注意を払うグラフ誘導型マスク付きアテンションを導入する。
  • データフローエッジ予測とコードとデータフロー間のノードアライメントという、二つの構造認識型事前学習タスクを追加する。
  • これらを標準のマスクド言語モデリングと組み合わせて、コードと構造の表現を結合して学習する。
  • CodeSearchNetでGraphCodeBERTを事前学習し、四つの下流タスクで評価する。

実験結果

リサーチクエスチョン

  • RQ1データフローを意味的なコード構造として組み込むことは、トークン列を超えた学習表現を改善するのか?
  • RQ2二つの構造認識型事前学習タスク(エッジ予測とノードアライメント)は、タスクを横断してコード理解を高められるか?
  • RQ3コード検索、クローン検出、翻訳、洗練化において、GraphCodeBERTはトークンのみの事前学習モデルとどう比較されるか?
  • RQ4実践的には、モデルは生のコードトークンよりデータフローノードに注意を向ける傾向が強いのか?

主な発見

  • GraphCodeBERTは四つの下流タスク、コード検索、クローン検出、コード翻訳、コード洗練化で最先端の性能を達成した。
  • アブレーション研究では、データフローまたは二つの構造認識タスクを除くと性能が低下し、その有用性を裏付けている。
  • アテンション分析は、コード検索においてモデルが純粋なトークンレベルのアテンションより構造レベル(データフロー)アテンションを好むことを示している。
  • ケーススタディは、データフローが変数の意味の曖昧さを解消し、コード理解を向上させることを示している。
  • タスクを跨いで、コード構造を活用することは、CodeBERT や RoBERTa 系列を含むベースラインより改善する。

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

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

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

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