用大模型直接编译代码,探索其可行性与优化路径。
Exploring the Feasibility of End-to-End Large Language Model as a Compiler
- 构建专用数据集和评估框架,测试大模型编译能力。
- 当前编译成功率低,但通过提示优化和模型扩展可显著提升质量。
- 适合对编译器革新感兴趣的开发者与研究者。
近年来,端到端大语言模型(LLM)在多个领域展现出显著优势。作为关键系统软件的编译器负责将源代码转换为目标代码。尽管已有研究利用大模型辅助编译器开发与维护,但将其作为端到端编译器的潜力仍待探索。本文探讨了大模型作为编译器(LaaC)的可行性及未来方向。我们设计了CompilerEval数据集与评估框架,专门用于评估主流大模型在源代码理解与汇编代码生成方面的能力。实验中分析了各类错误,探索了多种提升生成代码质量的方法,并评估了跨平台编译能力。结果表明,大模型具备基本编译能力,但当前编译成功率较低。通过优化提示、扩大模型规模及引入推理方法,生成的汇编代码质量可显著提升。基于此,我们对LaaC持乐观态度,提出实用架构设计与未来研究方向。我们认为,经过针对性训练、知识丰富提示与专用基础设施支持,LaaC有望生成高质量汇编代码,推动编译领域范式变革。
原文摘要 · Abstract (English)
In recent years, end-to-end Large Language Model (LLM) technology has shown substantial advantages across various domains. As critical system software and infrastructure, compilers are responsible for transforming source code into target code. While LLMs have been leveraged to assist in compiler development and maintenance, their potential as an end-to-end compiler remains largely unexplored. This paper explores the feasibility of LLM as a Compiler (LaaC) and its future directions. We designed the CompilerEval dataset and framework specifically to evaluate the capabilities of mainstream LLMs in source code comprehension and assembly code generation. In the evaluation, we analyzed various errors, explored multiple methods to improve LLM-generated code, and evaluated cross-platform compilation capabilities. Experimental results demonstrate that LLMs exhibit basic capabilities as compilers but currently achieve low compilation success rates. By optimizing prompts, scaling up the model, and incorporating reasoning methods, the quality of assembly code generated by LLMs can be significantly enhanced. Based on these findings, we maintain an optimistic outlook for LaaC and propose practical architectural designs and future research directions. We believe that with targeted training, knowledge-rich prompts, and specialized infrastructure, LaaC has the potential to generate high-quality assembly code and drive a paradigm shift in the field of compilation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。