Skip to main content
QUICK REVIEW

[論文レビュー] A Closer Look into Transformer-Based Code Intelligence Through Code Transformation: Challenges and Opportunities

Yaoxian Li, Shiyi Qi|arXiv (Cornell University)|Jul 9, 2022
Software Engineering Research被引用数 8
ひとこと要約

この論文は、意味を保つコード変換に対して、トランスフォーマーに基づくコードインテリジェンスモデルのロバスト性を調査する。JavaおよびPythonにおいて24〜27の変換戦略を実装した結果、挿入/削除および識別子変換が性能を最も著しく低下させることを明らかにした。一方、ASTベースのトランスフォーマーは、シーケンスのみに依存するモデルよりもより高いロバスト性を示した。

ABSTRACT

Transformer-based models have demonstrated state-of-the-art performance in many intelligent coding tasks such as code comment generation and code completion. Previous studies show that deep learning models are sensitive to the input variations, but few studies have systematically studied the robustness of Transformer under perturbed input code. In this work, we empirically study the effect of semantic-preserving code transformation on the performance of Transformer. Specifically, 24 and 27 code transformation strategies are implemented for two popular programming languages, Java and Python, respectively. For facilitating analysis, the strategies are grouped into five categories: block transformation, insertion/deletion transformation, grammatical statement transformation, grammatical token transformation, and identifier transformation. Experiments on three popular code intelligence tasks, including code completion, code summarization and code search, demonstrate insertion/deletion transformation and identifier transformation show the greatest impact on the performance of Transformer. Our results also suggest that Transformer based on abstract syntax trees (ASTs) shows more robust performance than the model based on only code sequence under most code transformations. Besides, the design of positional encoding can impact the robustness of Transformer under code transformation. Based on our findings, we distill some insights about the challenges and opportunities for Transformer-based code intelligence.

研究の動機と目的

  • 意味を保つコード変換に対して、トランスフォーマーに基づくコードインテリジェンスモデルのロバスト性を調査すること。
  • どのコード変換戦略がモデルの性能に最も顕著に影響を与えるかを特定すること。
  • コードの摂動下における、シーケンスベースとASTベースのトランスフォーマーのロバスト性を比較すること。
  • 位置符号化の設計が、コード変換下でのモデルのロバスト性に与える影響を分析すること。

提案手法

  • Python用に27の意味を保つコード変換戦略、Java用に24の戦略を設計および実装した。
  • 変換を5つのカテゴリに分類した:ブロック、挿入/削除、文法的ステートメント、文法的トークン、識別子変換。
  • コード補完、コード要約、コード検索の3つのコードインテリジェンスタスクでモデルのパフォーマンスを評価した。
  • 2種類のトランスフォーマー・アーキテクチャを比較した:1つは生のコードシーケンスを入力として使用し、もう1つは抽象構文木(AST)を入力表現として使用した。
  • 異なる位置符号化設計がコード変換下でのロバスト性に与える影響を分析した。
  • 標準的な指標(例:BLEU、F1、Recall@K)を用いて、変換された入力におけるパフォーマンスの低下を定量的に測定した。

実験結果

リサーチクエスチョン

  • RQ1意味を保つさまざまなコード変換が、トランスフォーマーに基づくコードインテリジェンスモデルのパフォーマンスにどのように影響を与えるか?
  • RQ2どの変換戦略がトランスフォーマーのパフォーマンスに最も顕著に悪影響を与えるか?
  • RQ3抽象構文木(AST)を入力として使用することで、生のコードシーケンスに依存するモデルと比較して、トランスフォーマーのロバスト性が向上するか?
  • RQ4位置符号化の設計が、コード変換下でのトランスフォーマーのロバスト性にどのように影響を与えるか?

主な発見

  • 挿入/削除変換および識別子のリネームは、コード補完、要約、検索のすべてのタスクにおいて、トランスフォーマーのパフォーマンスに最も顕著な悪影響を与える。
  • 抽象構文木(AST)を入力として使用するトランスフォーマーは、ほとんどの変換タイプにおいて、単にコードシーケンスに依存するモデルよりも高いロバスト性を示す。
  • 位置符号化の設計は、モデルのロバスト性に顕著な影響を与え、特定の設定がコード摂動下でもパフォーマンスをよりよく維持する。
  • パフォーマンスの低下は、特にコード要約とコード検索で顕著であり、極端な識別子リネームではBLEUスコアが最大30%低下した。
  • 一般的なリファクタリングパターンによって生成された意味的に同等のコードバージョンでも、モデルの予測が著しく異なることがあり、一般化能力の欠如を示している。
  • 本研究は、現在の最先端のコードインテリジェンスモデルが、意味を保つ構文的変化に対して脆いことを明らかにした。これは、ロバスト性における重要なギャップを示している。

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

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

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

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