arXiv:2505.20356cs.PLcs.AI2025-05被引 2

用可组合翻译提升大模型编译能力,突破长程序处理瓶颈

LEGO-Compiler: Enhancing Neural Compilation Through Translation Composability

  • 将程序拆解为小块,分步验证生成汇编代码
  • 在ExeBench上准确率达99%以上,AnsiBench达97.9%
  • 支持接近十倍规模的代码编译,适合系统级应用

大型语言模型(LLMs)有望彻底改变编译器与代码转换工具的设计方式。然而,现有模型难以处理长且复杂的程序。我们提出LEGO-Compiler,一种基于大模型的神经编译系统,可将高级语言翻译为汇编代码。其核心创新包括:基于可组合性的模块化翻译方法;将复杂编译流程分解为多个可验证的小步骤,通过外部测试构建可验证的LLM工作流;以及自纠正反馈机制。在形式化证明支持下,LEGO-Compiler在多个数据集上表现优异,于ExeBench上准确率超99%,AnsiBench达97.9%。此外,其可编译代码规模提升近一个数量级。该研究为大模型应用于系统级任务开辟新路径,补充传统编译技术。

原文摘要 · Abstract (English)

Large language models (LLMs) have the potential to revolutionize how we design and implement compilers and code translation tools. However, existing LLMs struggle to handle long and complex programs. We introduce LEGO-Compiler, a novel neural compilation system that leverages LLMs to translate high-level languages into assembly code. Our approach centers on three key innovations: LEGO translation, which decomposes the input program into manageable blocks; breaking down the complex compilation process into smaller, simpler verifiable steps by organizing it as a verifiable LLM workflow by external tests; and a feedback mechanism for self-correction. Supported by formal proofs of translation composability, LEGO-Compiler demonstrates high accuracy on multiple datasets, including over 99% on ExeBench and 97.9% on industrial-grade AnsiBench. Additionally, LEGO-Compiler has also acheived near one order-of-magnitude improvement on compilable code size scalability. This work opens new avenues for applying LLMs to system-level tasks, complementing traditional compiler technologies.

神经编译大模型代码生成可组合性

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