[논문 리뷰] Unsupervised Translation of Programming Languages
본 논문은 TransCoder라는 완전 무감독 신경 트랜스컴파일러를 활용해 C++, Java, Python 간의 함수를 단일 언어 코드만으로 번역하도록 학습하고, 규칙 기반 기준선에 비해 강한 성능을 보이는 유닛 테스트를 포함한 852-함수 병렬 테스트 세트를 공개한다.
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.
연구 동기 및 목표
- 병렬 데이터나 전문가 규칙 없이도 서로 다른 언어 간 기존 코드베이스의 자동 번역을 촉진한다.
- 교차 언어 사전학습, denoising auto-encoding, 백-번역을 사용하여 GitHub 코드로 학습된 완전 무감독 트랜스컴파일러를 개발한다.
- 무감독 모델이 함수 수준의 번역에서 규칙 기반 및 상용 기준선보다 성능이 우수함을 시연한다.
- 번역 정확도를 평가하기 위한 단위 테스트가 포함된 병렬 함수의 검증/테스트 세트를 제공한다.
제안 방법
- C++, Java, Python에 공통으로 공유되는 단일 Transformer 기반 인코더-디코더 모델을 사용한다.
- 교차 언어 표현을 위한 단일 언어 코드에서 교차 언어 마스킹 언어 모델링(XLM)으로 사전학습한다.
- 디코더가 유효한 시퀀스를 생성하고 강인한 표현을 얻도록 잡음 제거 자동 인코딩을 적용한다.
- 언어 쌍 간의 의사 병렬 데이터를 생성하기 위해 백-번역을 활용한다.
- 유닛 테스트를 통한 계산적 정확도, 참조 일치 및 BLEU 지표와 함께 번역을 평가한다.
실험 결과
연구 질문
- RQ1완전 무감독 신경 트랜스컴파일러가 단일 언어 코드만으로 C++, Java, Python 간 번역을 학습할 수 있는가?
- RQ2함수 수준 번역에서 규칙 기반 및 상용 기준선과 비교해 TransCoder의 성능은 어떠한가?
- RQ3BLEU나 참조 중첩을 넘는 기능적 정확성을 가장 잘 반영하는 평가 지표는 무엇인가?
- RQ4빔 탐색과 입력 전처리가 번역 품질에 미치는 영향은 어느 정도인가?
- RQ5연구된 세 가지 언어를 넘어 다른 프로그래밍 언어로도 이 접근법이 일반화될 수 있는가?
주요 결과
| Language pair | Reference Match | BLEU | Computational Accuracy |
|---|---|---|---|
| C++ → Java | 3.12 | 85.41 | 60.91 |
| C++ → Python | 6.7 | 70.11 | 44.49 |
| Java → C++ | 24.68 | 96.99 | 80.9 |
| Java → Python | 3.67 | 68.12 | 34.99 |
| Python → C++ | 4.94 | 65.37 | 32.19 |
| Python → Java | 0.83 | 64.64 | 24.74 |
- TransCoder는 언어 방향 전반에서 기준선보다 높은 계산적 정확도를 달성한다(예: C++→Java: 60.91%; Java→Python: 34.99%).
- 참조 일치와 BLEU는 실제 기능적 정확성과 잘 상관하지 못한다. 많은 올바른 번역이 참조와 정확히 일치하지 않거나 높은 BLEU를 가지지 않는다.
- 유닛 테스트 검증을 사용할 때 빔 검색은 계산적 정확도를 상당히 향상시키며 일부 방향에서 최대 33.7%까지 향상된다.
- TransCoder는 Java→Python 기준선 및 C++→Java 상용 기준선보다 계산적 정확도가 더 높다.
- 소스 코드 주석을 유지하면 앵커 포인트가 증가하고 언어 간 정렬이 향상되어 성능이 향상된다.
- 모델은 감독 없이도 언어별 구성 및 표준 라이브러리 사용을 서로 매핑하는 법을 학습한다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.