We propose the Adversarial DEep Learning Transpiler (ADELT), a novel approach to source-to-source transpilation between deep learning frameworks. ADELT uniquely decouples code skeleton transpilation and API keyword mapping. For code skeleton transpilation, it uses few-shot prompting on large language models (LLMs), while for API keyword mapping, it uses contextual embeddings from a code-specific BERT. These embeddings are trained in a domain-adversarial setup to generate a keyword translation dictionary. ADELT is trained on an unlabeled web-crawled deep learning corpus, without relying on any hand-crafted rules or parallel data. It outperforms state-of-the-art transpilers, improving pass@1 rate by 17.4 pts and 15.0 pts for PyTorch-Keras and PyTorch-MXNet transpilation pairs respectively. We provide open access to our code at https://github.com/gonglinyuan/adelt.
翻译:我们提出了对抗性深度学习编译器(ADELT),一种用于深度学习框架间源代码到源代码跨语言编译的新方法。ADELT独特地将代码骨架编译与API关键词映射解耦。对于代码骨架编译,它采用大语言模型(LLMs)的少样本提示技术;对于API关键词映射,则使用代码专用BERT的上下文嵌入。这些嵌入在领域对抗性设置下训练,生成关键词翻译词典。ADELT基于无标签的网络爬取深度学习语料库训练,无需依赖任何人工规则或平行数据。它优于现有最先进的编译器,在PyTorch-Keras和PyTorch-MXNet跨语言编译任务上分别将pass@1率提升17.4个和15.0个百分点。我们已在https://github.com/gonglinyuan/adelt 开放代码访问。