Transformer是高效的编译器:可证明的
Transformers are Efficient Compilers, Provably
AI总结:
本文从表达能力角度首次正式研究Transformer作为编译器的性能,证明在输入深度有界时其所需参数仅与序列长度对数相关,并通过领域特定语言Cybertron生成形式化证明,揭示了Transformer与RNN之间的指数级分离。
摘要:
基于Transformer的大语言模型(LLM)在广泛的语言相关任务中展现出了惊人的稳健性能,包括编程语言的理解与生成。本文从表达能力的角度出发,首次对将Transformer用作编译器进行正式研究。为此,我们引入了一种具有代表性的编程语言Mini-Husky,它封装了现代类C语言的关键特性。我们证明,如果输入代码序列在抽象语法树(AST)和类型推断中的深度都是有界的(这是基于整洁代码原则的合理假设),那么Transformer处理编译任务(如AST构建、符号解析和类型分析)所需的参数数量仅取决于输入序列长度的对数。一个重大的技术挑战源于Transformer在低层级运行的事实,其中每一层将输入序列作为原始向量处理,而没有将它们与预定义的结构或含义显式关联。相比之下,高层级的编译器任务需要管理复杂的关系和结构化的程序信息。我们的主要技术贡献是开发了一种领域特定语言Cybertron,它生成了关于Transformer表达能力的正式证明,并扩展以解决编译器任务。我们进一步证明,循环神经网络(RNN)相对于输入序列至少需要线性数量的参数,这导致Transformer和RNN之间产生了指数级的分离。最后,我们通过在Mini-Husky中的编译器任务上比较Transformer和RNN,实证验证了我们的理论结果。
英文摘要:
Transformer-based large language models (LLMs) have demonstrated surprisingly robust performance across a wide range of language-related tasks, including programming language understanding and generation. In this paper, we take the first steps towards a formal investigation of using transformers as compilers from an expressive power perspective. To this end, we introduce a representative programming language, Mini-Husky, which encapsulates key features of modern C-like languages. We show that if the input code sequence has a bounded depth in both the Abstract Syntax Tree (AST) and type inference (reasonable assumptions based on the clean code principle), then the number of parameters required by transformers depends only on the logarithm of the input sequence length to handle compilation tasks, such as AST construction, symbol resolution, and type analysis. A significant technical challenge stems from the fact that transformers operate at a low level, where each layer processes the input sequence as raw vectors without explicitly associating them with predefined structure or meaning. In contrast, high-level compiler tasks necessitate managing intricate relationships and structured program information. Our primary technical contribution is the development of a domain-specific language, Cybertron, which generates formal proofs of the transformer's expressive power, scaling to address compiler tasks. We further establish that recurrent neural networks (RNNs) require at least a linear number of parameters relative to the input sequence, leading to an exponential separation between transformers and RNNs. Finally, we empirically validate our theoretical results by comparing transformers and RNNs on compiler tasks within Mini-Husky.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。