AST-MHSA : Code Summarization using Multi-Head Self-Attention

要約

コードの要約は、ソース コードの簡潔な自然言語記述を生成することを目的としています。
一般的なアプローチでは、トランスフォーマーベースのエンコーダー/デコーダー アーキテクチャが採用されており、ソース コードの抽象構文ツリー (AST) が構造情報のエンコードに利用されます。
ただし、AST は対応するソース コードよりもはるかに長く、既存の方法では、線形化された AST 全体をエンコーダーに直接供給することでこのサイズ制約を無視しています。
この単純化されたアプローチでは、長すぎる入力シーケンスから真に価値のある依存関係を抽出することが困難になり、AST 内のすべてのノードに適用されるセルフアテンションにより、大幅な計算オーバーヘッドが発生します。
この問題に効果的かつ効率的に対処するために、マルチヘッド アテンションを使用して AST から重要な意味情報を抽出するモデル AST-MHSA を紹介します。
モデルは、エンコーダーとデコーダーという 2 つの主要コンポーネントで構成されます。
エンコーダーはコードの抽象構文ツリー (AST) を入力として受け取り、一連の隠れ状態を生成します。
次に、デコーダはこれらの隠れた状態を入力として受け取り、コードの自然言語要約を生成します。
マルチヘッド アテンション メカニズムにより、モデルは入力コードのさまざまな表現を学習でき、それらを組み合わせてより包括的なサマリーを生成できます。
モデルはコードと要約のデータセットでトレーニングされ、生成された要約とグラウンドトゥルース要​​約の間の損失を最小限に抑えるためにモデルのパラメーターが最適化されます。

要約(オリジナル)

Code summarization aims to generate concise natural language descriptions for source code. The prevailing approaches adopt transformer-based encoder-decoder architectures, where the Abstract Syntax Tree (AST) of the source code is utilized for encoding structural information. However, ASTs are much longer than the corresponding source code, and existing methods ignore this size constraint by directly feeding the entire linearized AST into the encoders. This simplistic approach makes it challenging to extract truly valuable dependency relations from the overlong input sequence and leads to significant computational overhead due to self-attention applied to all nodes in the AST. To address this issue effectively and efficiently, we present a model, AST-MHSA that uses multi-head attention to extract the important semantic information from the AST. The model consists of two main components: an encoder and a decoder. The encoder takes as input the abstract syntax tree (AST) of the code and generates a sequence of hidden states. The decoder then takes these hidden states as input and generates a natural language summary of the code. The multi-head attention mechanism allows the model to learn different representations of the input code, which can be combined to generate a more comprehensive summary. The model is trained on a dataset of code and summaries, and the parameters of the model are optimized to minimize the loss between the generated summaries and the ground-truth summaries.

arxiv情報

著者 Yeshwanth Nagaraj,Ujjwal Gupta
発行日 2023-08-10 15:43:46+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.CL, cs.LG, cs.PL, cs.SE パーマリンク