Skip to main content
QUICK REVIEW

[論文レビュー] Unsupervised Translation of Programming Languages

Marie-Anne Lachaux, Baptiste Rozière|arXiv (Cornell University)|Jun 5, 2020
Software Engineering Research参考文献 48被引用数 62
ひとこと要約

この論文は TransCoder を全て監督なしで訓練し、C++、Java、Python 間の関数をモノ言語コードのみで翻訳するニューラル・トランスコンパイラを開発・評価する。852-function parallel test set を公開し、ユニットテストでルールベースのベースラインより高い性能を示す。

ABSTRACT

A transcompiler, also known as source-to-source translator, is a system that converts source code from a high-level programming language (such as C++ or Python) to another. Transcompilers are primarily used for interoperability, and to port codebases written in an obsolete or deprecated language (e.g. COBOL, Python 2) to a modern one. They typically rely on handcrafted rewrite rules, applied to the source code abstract syntax tree. Unfortunately, the resulting translations often lack readability, fail to respect the target language conventions, and require manual modifications in order to work properly. The overall translation process is timeconsuming and requires expertise in both the source and target languages, making code-translation projects expensive. Although neural models significantly outperform their rule-based counterparts in the context of natural language translation, their applications to transcompilation have been limited due to the scarcity of parallel data in this domain. In this paper, we propose to leverage recent approaches in unsupervised machine translation to train a fully unsupervised neural transcompiler. We train our model on source code from open source GitHub projects, and show that it can translate functions between C++, Java, and Python with high accuracy. Our method relies exclusively on monolingual source code, requires no expertise in the source or target languages, and can easily be generalized to other programming languages. We also build and release a test set composed of 852 parallel functions, along with unit tests to check the correctness of translations. We show that our model outperforms rule-based commercial baselines by a significant margin.

研究の動機と目的

  • 既存のコードベースを言語横断で自動翻訳することを、並列データや専門家ルールなしで実現可能と動機づける。
  • GitHub のコードを用いたクロスリンガル事前学習、デノイズド自己符号化、バック・トランスレーションを用いた完全監督なしのトランスコンパイラを開発する。
  • 監督なしモデルがルールベースおよび商用ベースラインを関数レベルの翻訳で上回ることを示す。
  • 翻訳正確性を評価するための並列関数の検証/テストセットとユニットテストを提供する。

提案手法

  • C++、Java、Python で共有される単一の Transformer ベースのエンコーダ-デコーダモデルを用いる。
  • クロス言語表現を得るためにモノ言語コード上でのクロスリンガル masked language modeling (XLM) による事前訓練を行う。
  • デコーダが有効なシーケンスを生成するようにデノイズド自己符号化を適用し、堅牢な表現を得る。
  • 言語ペア間の pseuro-parallel data を作成するためにバック・トランスレーションを活用する。
  • 翻訳を参照一致と BLEU 指標に加え、ユニットテストによる計算精度で評価する。

実験結果

リサーチクエスチョン

  • RQ1完全に監督なしのニューラル・トランスコンパイラがモノ言語コードのみを用いて C++、Java、Python の翻訳を学習できるか。
  • RQ2関数レベルの翻訳において TransCoder はルールベースおよび商用ベースラインよりどのように性能が出るか。
  • RQ3BLEU や参照重複を超えた機能的正確さを最もよく反映する評価指標は何か。
  • RQ4ビーム探索と入力前処理が翻訳品質に与える影響はどの程度か。
  • RQ5本手法は studied の三言語以外にも他のプログラミング言語へ一般化可能か。

主な発見

Language pairReference MatchBLEUComputational Accuracy
C++ → Java3.1285.4160.91
C++ → Python6.770.1144.49
Java → C++24.6896.9980.9
Java → Python3.6768.1234.99
Python → C++4.9465.3732.19
Python → Java0.8364.6424.74
  • TransCoder は言語間方向全体で計算的正確度がベースラインより高い(例: C++→Java: 60.91%; Java→Python: 34.99%)。
  • 参照一致と BLEU は実際の機能的正確さと強く相関しない、正解の翻訳が参照と正確に一致しなかったり高 BLEU を持たない場合がある。
  • ユニットテスト検証を用いるとビーム探索は計算的正確度を大幅に改善できる(方向によっては最大で 33.7%)。
  • TransCoder は Java→Python のベースラインおよび C++→Java の商用ベースラインより計算的正確度で上回る。
  • ソースコード内のコメントを保持するとアンカーポイントが増え、クロス言語の整合性が向上し性能が向上する。
  • モデルは監督なしで言語固有の構造と標準ライブラリの使用を言語間でマッピングすることを学習する。

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

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

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

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