Skip to main content
QUICK REVIEW

[論文レビュー] GraphSearchNet: Enhancing GNNs via Capturing Global Dependencies for Semantic Code Search

Shangqing Liu, Xiaofei Xie|arXiv (Cornell University)|Nov 4, 2021
Software Engineering Research参考文献 36被引用数 4
ひとこと要約

GraphSearchNetは、双方向GNN(BiGGNN)とマルチヘッドアテンションを用いて、ソースコードと自然言語クエリの両方の構造的・グローバルな依存関係を同時に捉えることで、GNNを拡張するグラフベースのディーブラーニングフレームワークを提案する。このモデルは、JavaおよびPython用のCodeSearchNetベンチマークにおいて、最先端の性能を達成し、従来の手法を顕著に上回る。

ABSTRACT

Code search aims to retrieve accurate code snippets based on a natural language query to improve software productivity and quality. With the massive amount of available programs such as (on GitHub or Stack Overflow), identifying and localizing the precise code is critical for the software developers. In addition, Deep learning has recently been widely applied to different code-related scenarios, e.g., vulnerability detection, source code summarization. However, automated deep code search is still challenging since it requires a high-level semantic mapping between code and natural language queries. Most existing deep learning-based approaches for code search rely on the sequential text i.e., feeding the program and the query as a flat sequence of tokens to learn the program semantics while the structural information is not fully considered. Furthermore, the widely adopted Graph Neural Networks (GNNs) have proved their effectiveness in learning program semantics, however, they also suffer the problem of capturing the global dependencies in the constructed graph, which limits the model learning capacity. To address these challenges, in this paper, we design a novel neural network framework, named GraphSearchNet, to enable an effective and accurate source code search by jointly learning the rich semantics of both source code and natural language queries. Specifically, we propose to construct graphs for the source code and queries with bidirectional GGNN (BiGGNN) to capture the local structural information of the source code and queries. Furthermore, we enhance BiGGNN by utilizing the multi-head attention module to supplement the global dependencies that BiGGNN missed to improve the model learning capacity. The extensive experiments on Java and Python programming language from the public benchmark CodeSearchNet confirm that GraphSearchNet outperforms current state-of-the-art works.

研究の動機と目的

  • 『ビッグコード』時代におけるコード再利用に依存する開発者のニーズに応えるため、意味的コード検索の課題に取り組む。
  • 従来の順序付きモデルや標準的なGNNが、コードとクエリの両方における構造的およびグローバルな依存関係を十分に捉えられていないという限界を克服する。
  • グラフニューラルネットワークを用いて、ソースコードと自然言語クエリの表現を統合的にモデル化することで、意味的マッピングを向上させる。
  • 従来のGNNが見逃すグローバルな依存関係を回復するために、マルチヘッドアテンションを統合することでGNNを強化する。

提案手法

  • コードとクエリのシーケンスから局所的な構造的情報を学ぶために、双方向ゲーテッドグラフニューラルネットワーク(BiGGNN)を用いてプログラムおよびクエリのグラフを構築する。
  • 長距離およびグローバルな依存関係をグラフ内のノード間で捉えるために、マルチヘッド自己アテンション機構をBiGGNNに統合する。
  • 強化されたグラフネットワークを用いて、ソースコードと自然言語クエリを統一されたベクトル表現に同時にエンコードする。
  • 類似度スコアを計算するために、コサイン類似度を用いてコードとクエリの埋め込み表現の間の意味的類似度を算出する。
  • 関連するコード-クエリペアを整列させるために、対照学習の目的関数を用いてCodeSearchNetデータセット上でエンドツーエンドでモデルを学習する。
  • ASTベースのエッジとトークンレベルの接続性を含む、構文的および意味的構造を保持するグラフ構築技術を適用する。

実験結果

リサーチクエスチョン

  • RQ1グラフベースのディーブラーニングフレームワークは、コードと自然言語クエリの両方における局所的構造的およびグローバルな依存関係を効果的にモデル化できるか?
  • RQ2BiGGNNにマルチヘッドアテンションを統合することで、コード検索におけるGNNの表現学習能力はどのように向上するか?
  • RQ3GraphSearchNetは、標準ベンチマーク上での既存の最先端モデルと比較して、どの程度優れた性能を示すか?
  • RQ4コードとクエリのグラフを統合的にモデル化することで、順序付きまたは単一モodalなアプローチと比較して、より良い意味的整合性が得られるか?

主な発見

  • GraphSearchNetは、JavaおよびPythonの両言語において、CodeSearchNetベンチマークで最先端の性能を達成した。
  • 平均平均精度(mAP)および上位k件の再現率という指標において、従来の最先端手法(MMANやCode2Seqを含む)を顕著に上回った。
  • マルチヘッドアテンションをBiGGNNに統合することで、特に長距離の構造的関係において、グローバルな依存関係を捉える能力が明確に向上した。
  • アブレーションスタディの結果、BiGGNNおよびマルチヘッドアテンションの両方のコンponentsが不可欠であり、最終的な性能向上にそれぞれ顕著な寄与をしていることが確認された。
  • 異なるプログラミング言語にわたる汎用性の高さが示され、言語特有のパターンにとらわれない有効性が裏付けられた。

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

論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。

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

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