arXiv:2512.02567cs.SEcs.AI2025-12被引 1

研究大模型代码翻译中反馈循环与代码扰动的影响,提升C转Rust的可靠性。

Feedback Loops and Code Perturbations in LLM-based Software Engineering: A Case Study on a C-to-Rust Translation System

  • 采用生成-验证反馈循环修复生成错误代码。
  • 引入代码扰动后系统成功率提升,模型差异显著缩小。
  • 适合关注AI辅助编程可靠性的工业开发者参考。

生成式AI对代码修复、测试生成和语言翻译等软件工程任务产生重大影响。尽管GitHub Copilot已在交互场景广泛应用,但自动化工具仍需更高可靠性才能投入工业实践。本文聚焦三个直接影响结果质量的因素:自动化反馈循环、大语言模型(LLM)选择,以及行为保持的代码扰动。以基于生成-验证模式的C到Rust自动翻译系统为案例,该系统通过编译检查和行为等价性验证,对LLM生成的Rust代码进行评估,并在失败时通过反馈循环重新提示以修复输出。实验表明,无反馈循环时,模型选择对翻译成功率影响显著;而启用反馈循环后,不同模型间的差异大幅缩小,系统平均性能和抗扰动鲁棒性均提升。此外,代码扰动带来的多样性甚至能进一步提高系统表现。

原文摘要 · Abstract (English)

The advent of strong generative AI has a considerable impact on various software engineering tasks such as code repair, test generation, or language translation. While tools like GitHub Copilot are already in widespread use in interactive settings, automated approaches require a higher level of reliability before being usable in industrial practice. In this paper, we focus on three aspects that directly influence the quality of the results: a) the effect of automated feedback loops, b) the choice of Large Language Model (LLM), and c) the influence of behavior-preserving code changes. We study the effect of these three variables on an automated C-to-Rust translation system. Code translation from C to Rust is an attractive use case in industry due to Rust's safety guarantees. The translation system is based on a generate-and-check pattern, in which Rust code generated by the LLM is automatically checked for compilability and behavioral equivalence with the original C code. For negative checking results, the LLM is re-prompted in a feedback loop to repair its output. These checks also allow us to evaluate and compare the respective success rates of the translation system when varying the three variables. Our results show that without feedback loops LLM selection has a large effect on translation success. However, when the translation system uses feedback loops the differences across models diminish. We observe this for the average performance of the system as well as its robustness under code perturbations. Finally, we also identify that diversity provided by code perturbations can even result in improved system performance.

代码生成大模型反馈循环C转Rust

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。