TransformCode: A Contrastive Learning Framework for Code Embedding via Subtree Transformation

要約

人工知能 (AI) は、ソフトウェア開発効率を向上させることでソフトウェア エンジニアリング (SE) に革命をもたらしました。
転移学習を活用した事前トレーニング済みモデル (PTM) の出現により、SE 向けの AI が大幅に進歩しました。
ただし、個々のコード トークンで動作する既存の PTM にはいくつかの制限があります。トレーニングと微調整にコストがかかります。
また、タスク固有のデータセットを微調整するためにラベル付きデータに大きく依存しています。
この論文では、対照的な学習方法でコードの埋め込みを学習する新しいフレームワークである TransformCode を紹介します。
私たちのフレームワークはエンコーダーや言語に依存せず、あらゆるエンコーダー モデルを活用し、あらゆるプログラミング言語を処理できることを意味します。
また、抽象構文ツリー (AST) 変換と呼ばれる新しいデータ拡張手法も提案します。これは、元のコード スニペットに構文的および意味的変換を適用して、対比学習用のより多様で堅牢なサンプルを生成します。
私たちのフレームワークには、既存の方法に比べていくつかの利点があります。(1) コード表現を必要とする他の下流タスク (コード クローンの検出や分類など) に簡単に拡張できるため、柔軟性と適応性があります。
(2) 大規模なモデルや大量のトレーニング データを必要とせず、あらゆるプログラミング言語をサポートできるため、効率的でスケーラブルです。
(3) 教師なし学習に限定されず、タスク固有のラベルや目標を組み込むことで一部の教師あり学習タスクにも適用できます。
(4) コンピューティング リソースに基づいてエンコーダ パラメータの数を調整することもできます。
私たちはいくつかのコード関連のタスクでフレームワークを評価し、SourcererCC、Code2vec、InferCode などの最先端のメソッドに対するその有効性と優位性を実証します。

要約(オリジナル)

Artificial intelligence (AI) has revolutionized software engineering (SE) by enhancing software development efficiency. The advent of pre-trained models (PTMs) leveraging transfer learning has significantly advanced AI for SE. However, existing PTMs that operate on individual code tokens suffer from several limitations: They are costly to train and fine-tune; and they rely heavily on labeled data for fine-tuning on task-specific datasets. In this paper, we present TransformCode, a novel framework that learns code embeddings in a contrastive learning manner. Our framework is encoder-agnostic and language-agnostic, which means that it can leverage any encoder model and handle any programming language. We also propose a novel data-augmentation technique called abstract syntax tree (AST) transformation, which applies syntactic and semantic transformations to the original code snippets, to generate more diverse and robust samples for contrastive learning. Our framework has several advantages over existing methods: (1) It is flexible and adaptable, because it can easily be extended to other downstream tasks that require code representation (such as code-clone detection and classification); (2) it is efficient and scalable, because it does not require a large model or a large amount of training data, and it can support any programming language; (3) it is not limited to unsupervised learning, but can also be applied to some supervised learning tasks by incorporating task-specific labels or objectives; and (4) it can also adjust the number of encoder parameters based on computing resources. We evaluate our framework on several code-related tasks, and demonstrate its effectiveness and superiority over the state-of-the-art methods such as SourcererCC, Code2vec, and InferCode.

arxiv情報

著者 Zixiang Xian,Rubing Huang,Dave Towey,Chunrong Fang,Zhenyu Chen
発行日 2024-04-24 03:08:29+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.SE パーマリンク