Skip to main content
archive
Search Submit Donate Log in
Press Enter to search · Advanced search

Computer Science > Programming Languages

arXiv:2410.14706 (cs)
[Submitted on 7 Oct 2024 (v1), last revised 25 Jan 2025 (this version, v2)]

Title:Transformers are Efficient Compilers, Provably

Authors:Xiyu Zhai, Runlong Zhou, Liao Zhang, Simon Shaolei Du
View a PDF of the paper titled Transformers are Efficient Compilers, Provably, by Xiyu Zhai and 3 other authors
View PDF HTML (experimental)
Abstract: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.
Comments: 65 pages
Subjects: Programming Languages (cs.PL); Machine Learning (cs.LG)
MSC classes: 68T07 (Primary)
Cite as: arXiv:2410.14706 [cs.PL]
  (or arXiv:2410.14706v2 [cs.PL] for this version)
  https://doi.org/10.48550/arXiv.2410.14706
arXiv-issued DOI via DataCite

Submission history

From: Xiyu Zhai [view email]
[v1] Mon, 7 Oct 2024 20:31:13 UTC (381 KB)
[v2] Sat, 25 Jan 2025 04:05:56 UTC (1,141 KB)
Full-text links:

Access Paper:

    View a PDF of the paper titled Transformers are Efficient Compilers, Provably, by Xiyu Zhai and 3 other authors
  • View PDF
  • HTML (experimental)
  • TeX Source
view license

Current browse context:

cs.PL
< prev   |   next >
new | recent | 2024-10
Change to browse by:
cs
cs.LG

References & Citations

  • NASA ADS
  • Google Scholar
  • Semantic Scholar
Loading...

BibTeX formatted citation

Data provided by:

Bookmark

BibSonomy Reddit

Bibliographic and Citation Tools

Bibliographic Explorer (What is the Explorer?)
Connected Papers (What is Connected Papers?)
Litmaps (What is Litmaps?)
scite Smart Citations (What are Smart Citations?)

Code, Data and Media Associated with this Article

alphaXiv (What is alphaXiv?)
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub (What is DagsHub?)
Gotit.pub (What is GotitPub?)
Hugging Face (What is Huggingface?)
ScienceCast (What is ScienceCast?)

Demos

Replicate (What is Replicate?)
Hugging Face Spaces (What is Spaces?)
TXYZ.AI (What is TXYZ.AI?)

Recommenders and Search Tools

Influence Flower (What are Influence Flowers?)
CORE Recommender (What is CORE?)
  • Author
  • Venue
  • Institution
  • Topic

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

Which authors of this paper are endorsers? | Disable MathJax (What is MathJax?)
We gratefully acknowledge support from our major funders, member institutions, , and all contributors.
About · Help · Contact · Subscribe · Copyright · Privacy · Accessibility · Operational Status (opens in new tab)
Major funding support from
Simons Foundation Simons Foundation International Schmidt Sciences