Skip to main content
QUICK REVIEW

[論文レビュー] Exploring and Unleashing the Power of Large Language Models in Automated Code Translation

Zhen Yang, Fang Liu|arXiv (Cornell University)|Apr 23, 2024
Natural Language Processing TechniquesComputer Science被引用数 3
ひとこと要約

本稿では、テストケース生成、実行ベースの増強、反復的修復を活用することで、大規模言語モデル(LLMs)の自動コード翻訳性能を向上させる統合フレームワークUniTransを提案する。Python、Java、C++の翻訳において評価された結果、GPT-3.5 や LLaMAバージョンなど多様なLLMsにおいて、微調整を必要とせずに計算精度および正確一致精度が顕著に向上した。

ABSTRACT

Code translation tools (transpilers) are developed for automatic source-to-source translation. Although learning-based transpilers have shown impressive enhancement against rule-based counterparts, owing to their task-specific pre-training on extensive monolingual corpora. Their current performance still remains unsatisfactory for practical deployment, and the associated training resources are also prohibitively expensive. LLMs pre-trained on huge amounts of human-written code/text have shown remarkable performance in many code intelligence tasks due to their powerful generality, even without task-specific training. Thus, LLMs can potentially circumvent the above limitations, but they have not been exhaustively explored yet. This paper investigates diverse LLMs and learning-based transpilers for automated code translation tasks, finding that: although certain LLMs have outperformed current transpilers, they still have some accuracy issues, where most of the failures are induced by a lack of comprehension of source programs, missing clear instructions on I/O types in translation, and ignoring discrepancies between source and target programs. Enlightened by the above findings, we further propose UniTrans, a Unified code Translation framework, applicable to various LLMs, for unleashing their power in this field. Specifically, UniTrans first crafts a series of test cases for target programs with the assistance of source programs. Next, it harnesses the above auto-generated test cases to augment the code translation and then evaluate their correctness via execution. Afterward, UniTrans further (iteratively) repairs incorrectly translated programs prompted by test case execution results. Extensive experiments are conducted on six settings of translation datasets between Python, Java, and C++. Three recent LLMs of diverse sizes are tested with UniTrans, and all achieve substantial improvements.

研究の動機と目的

  • 大規模言語モデル(LLMs)を学習ベースのトランスパイラーの代替手段として、自動コード翻訳に用いる可能性を検討すること。
  • 特に理解、入出力仕様、構造的不一致の処理において、LLMベースのコード翻訳の失敗原因を特定・分析すること。
  • 微調整を必要とせず、LLMのコード翻訳性能を向上させる統合的でプロンプトベースのフレームワーク—UniTransを設計すること。
  • 複数のLLMsおよび翻訳設定においてフレームワークを評価し、汎用性と実用的価値を示すこと。

提案手法

  • UniTransは、ソースコードを用いてターゲットプログラムの入出力要件およびプログラム動作を符号化することで、ターゲットプログラム用のテストケースを生成する。
  • テストケース情報をプロンプトに組み込むことで、コード翻訳を増強し、LLMが必要な入出力型およびプログラム意味をより正確に理解できるようにする。
  • 生成されたテストケースの自動実行により、翻訳コードの正しさを評価する。
  • テストケース実行の失敗を分析することで、誤った翻訳を修復し、必要に応じて反復的修復ループを実行して改善を図る。
  • フレームワークはモデルに依存しない設計であり、GPT-3.5、LLaMA-7B/13B/33B、CodeGen-6B などの多様なLLMsをサポートする。
  • プロンプト工学と実行フィードバックによって駆動される三段階パイプライン(テストケース生成、翻訳増強、翻訳修復)を採用する。
Figure 1. Frequencies of Failed Cases in Each Translation Dataset
Figure 1. Frequencies of Failed Cases in Each Translation Dataset

実験結果

リサーチクエスチョン

  • RQ1最先端のLLMsが自動コード翻訳タスクで示す主な失敗モードは何か?
  • RQ2タスク固有の微調整を要せず、LLMsが既存の学習ベースのトランスパイラーを上回る性能を発揮できるか?
  • RQ3テストケースと実行フィードバックを効果的に活用することで、LLMベースのコード翻訳をどのように改善できるか?
  • RQ4統合的でプロンプトベースのフレームワークは、複数のプログラミング言語ペアにおいて多様なLLMsをどれほど効果的に向上できるか?
  • RQ5LLMsを用いた汎用的で微調整不要なコード翻訳システムを構築するにあたり、どのような主要設計原則が必要か?

主な発見

  • GPT-3.5 などのLLMsは現在の学習ベースのトランスパイラーを上回るコード翻訳精度を示すが、依然として顕著な失敗率を示す。
  • LLMsの主な失敗原因は以下の通りである:ソースプログラムの理解不足(38.51%)、入出力型の指示不足(14.94%)、構造的不一致の無視(41.38%)。
  • UniTransは、すべてのテスト対象LLMsおよび翻訳設定において、計算精度および正確一致精度を向上させ、GPT-3.5 や LLaMA モデルにおいて顕著な向上が確認された。
  • モデルの微調整を一切必要とせず一貫した性能向上を達成しており、実用性とスケーラビリティの両面で有効性を示している。
  • UniTransの反復的修復メカニズムにより、特に複雑な翻訳シナリオにおいて翻訳の正確性がさらに向上した。
  • フレームワークは、オープンソース(LLaMA)およびクローズドソース(GPT-3.5)の多様なLLMファミリーおよびサイズに対し効果を示し、普遍性を実証した。
Figure 2. UniTrans
Figure 2. UniTrans

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。