paperbot · PL 论文追踪

全部论文 待读 收藏

P2 TransMap: Pinpointing Mistakes in Neural Code Translation

TransMap:精确定位神经代码翻译中的错误
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 4/10 · 论文关注神经代码翻译的语义错误定位,属于利用程序分析调试 AI 生成代码,与用户“PL→AI(在 ML/Agent 系统中应用静态分析)”有一定关联,但并非核心方向,且未涉及浮点、贝叶斯或 LLM 改进静态分析等具体兴趣点。引用 15 inbox
Bo Wang, Ruishi Li, Mingkai Li, Prateek Saxena
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出首个自动定位神经代码翻译后语义错误的方法,实现 Python 到 JavaScript 的 TransMap 工具。

神经代码翻译可减少学习新语言或迁移代码的人工成本,Codex 等模型在翻译任务上表现有效,但生成代码常含语义错误。由于神经翻译器是黑盒,难以解释和控制,这些错误难以从翻译器本身消除。本文提出首个自动定位神经代码翻译后语义错误的方法,并实现原型工具 TransMap,用于 Python 到 JavaScript 翻译。它旨在指出需要修复的正确位置,通常仅高亮 1–2 行供用户检查。在包含 648 个语义错误的 Python 微基准上,TransMap 对 87.96% 的错误准确定位修复位置;作者还翻译了 5 个最多 1k 行的 Python 库,初步用户研究显示,相比使用带调试器的标准 IDE,修复语义错误的时间减少约 70%。

问题
神经代码翻译器(如 Codex)常产生语义错误,但翻译器是黑盒,难以解释或控制,因此这些错误难以从翻译器本身消除;目标是在翻译后代码中自动定位这些语义错误。
方法
提出一种自动定位神经代码翻译后语义错误的方法,并实现原型工具 TransMap,用于 Python 到 JavaScript 翻译;该方法指出需要修复的正确位置,通常每处错误仅高亮 1–2 行供用户检查。
评估
在包含 648 个语义错误的 Python 微基准上,TransMap 对 87.96% 的错误准确定位修复位置;作者还翻译了 5 个最多 1k 行的 Python 库,初步用户研究表明,相比带调试器的标准 IDE,修复语义错误的时间减少约 70%。
原文摘要(Abstract)

Automated code translation between programming languages can greatly reduce the human effort needed in learning new languages or in migrating code. Recent neural machine translation models, such as Codex, have been shown to be effective on many code generation tasks including translation. However, code produced by neural translators often has semantic mistakes. These mistakes are difficult to eliminate from the neural translator itself because the translator is a black box, which is difficult to interpret or control compared to rule-based transpilers. We propose the first automated approach to pinpoint semantic mistakes in code obtained after neural code translation. Our techniques are implemented in a prototype tool called TransMap which translates Python to JavaScript, both of which are popular scripting languages. On our created micro-benchmarks of Python programs with 648 semantic mistakes in total, TransMap accurately pinpoints the correct location for a fix for 87.96%, often highlighting 1-2 lines for the user to inspect per mistake. We report on our experience in translating 5 Python libraries with up to 1k lines of code with TransMap. Our preliminary user study suggests that TransMap can reduce the time for fixing semantic mistakes by around 70% compared to using a standard IDE with debuggers.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@inproceedings{WangLLS23,
  title = {TransMap: Pinpointing Mistakes in Neural Code Translation},
  author = {Bo Wang and Ruishi Li and Mingkai Li and Prateek Saxena},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616322}
}