We propose Adversarial DEep Learning Transpiler (ADELT) for source-to-source transpilation between deep learning frameworks. Unlike prior approaches, we decouple the transpilation of code skeletons and the mapping of API keywords (an API function name or a parameter name). ADELT transpile code skeletons using few-shot prompting on big language models. Based on contextual embeddings extracted by a BERT for code, we train aligned API embeddings in a domain-adversarial setup, upon which we generate a dictionary for keyword translation. The model is trained on our unlabeled DL corpus from web crawl data, without using any hand-crafted rules and parallel data. Our method outperforms state-of-the-art transpilers on multiple transpilation pairs including PyTorch-Keras and PyTorch-MXNet by 15.9pts and 12.0pts in exact match scores respectively.
翻译:我们提出对抗性深度学习转译器(ADELT),用于深度学习框架间的源到源代码转换。与先前方法不同,我们解耦了代码骨架的转译与API关键词(API函数名或参数名)的映射。ADELT利用大语言模型的少样本提示进行代码骨架转译。基于BERT代码理解模型生成的上下文嵌入,我们在领域对抗设置中训练对齐的API嵌入,并据此生成关键词翻译词典。该模型使用从网络爬取数据中获取的无标签深度学习语料库进行训练,无需任何手工规则或平行数据。在包括PyTorch-Keras和PyTorch-MXNet在内的多个转换对中,我们的方法在精确匹配分数上分别超越现有最优转译器15.9个点和12.0个点。