paperbot · PL 论文追踪

全部论文 待读 收藏

P2 AI Coders Are among Us: Rethinking Programming Language Grammar towards Efficient Code Generation

AI 程序员就在我们身边:面向高效代码生成重新思考编程语言文法
ISSTA Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis2024匹配度 4/10 · 论文提出面向AI的编程语言文法SimPy,通过修改Python文法降低LLM代码生成的token开销,属于PL与AI交叉的语言设计。但用户核心方向是静态分析在ML/Agentic程序中的应用及LLM改进静态分析,该文未涉及静态分析、浮点或贝叶斯程序分析,且研究目标偏向提升LLM自身效率。引用 13 inbox
Zhensu Sun, Xiaoning Du, Zhou Yang, Li Li, David Lo
crossref: 2026-09-12

AI 速览

一句话:提出面向 AI 的编程语言文法概念,实现保持 AST 等价的 Python 方言 SimPy,减少 LLM 代码生成 token 用量 10% 以上。

随着 LLM 成为编程语言的新受众,现有文法与排版主要为人类可读性设计,含大量语法与格式 token,给模型推理带来额外计算开销。论文提出面向 AI 的文法概念,主张用最少 token 表达代码语义。作者以启发式规则改写 Python 文法,实现首个面向 AI 的 Python 方言 Simple Python(SimPy):它与标准 Python 保持相同 AST,既可用修改后的 AST 解析器执行,也可与 Python 无缝互转,支持人类与 LLM 协作;论文还探索帮助现有 LLM 理解 SimPy 的方法。实验表明,在相同代码任务上,CodeLlama 与 GPT-4 使用 SimPy 后 token 用量分别减少 13.5% 和 10.4%,性能保持甚至提升。作者呼吁社区进一步研究 AI 导向的编程语言文法。

问题
现有编程语言文法与排版面向人类可读性设计,包含大量语法与格式 token,为 LLM 进行代码生成和推理带来不必要的计算开销。
方法
提出 AI-oriented grammar 概念,并通过启发式规则改写 Python 文法,实现保持 AST 等价的 SimPy;同时支持修改后的 AST 解析执行、Python/SimPy 双向转换,并探索帮助现有 LLM 理解与使用 SimPy 的方法。
评估
在相同代码相关任务上比较 Python 与 SimPy,使用 CodeLlama 和 GPT-4 测量 token 用量与任务性能。结果显示 token 用量分别减少 13.5% 和 10.4%,且模型性能保持甚至提升。
原文摘要(Abstract)

Artificial Intelligence (AI) models have emerged as another important audience for programming languages alongside humans and machines, as we enter the era of large language models (LLMs). LLMs can now perform well in coding competitions and even write programs like developers to solve various tasks, including mathematical problems. However, the grammar and layout of current programs are designed to cater the needs of human developers -- with many grammar tokens and formatting tokens being used to make the code easier for humans to read. While this is helpful, such a design adds unnecessary computational work for LLMs, as each token they either use or produce consumes computational resources. To improve inference efficiency and reduce computational costs, we propose the concept of AI-oriented grammar.This aims to represent code in a way that better suits the working mechanism of AI models. Code written with AI-oriented grammar discards formats and uses a minimum number of tokens to convey code semantics effectively. To demonstrate the feasibility of this concept, we explore and implement the first AI-oriented grammar for Python, named Simple Python (SimPy). SimPy is crafted by revising the original Python grammar through a series of heuristic rules. Programs written in SimPy maintain identical Abstract Syntax Tree (AST) structures to those in standard Python. This allows for not only execution via a modified AST parser, but also seamless transformation between programs written in Python and SimPy, enabling human developers and LLMs to use Python and SimPy, respectively, when they need to collaborate. We also look into methods to help existing LLMs understand and use SimPy effectively. In the experiments, compared with Python, SimPy enables a reduction in token usage by 13.5% and 10.4% for CodeLlama and GPT-4, respectively, when completing the same set of code-related tasks. Additionally, these models can maintain or even improve their performance when using SimPy instead of Python for these tasks. With these promising results, we call for further contributions to the development of AI-oriented program grammar within our community.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot8524,
  title = {AI Coders Are among Us: Rethinking Programming Language Grammar towards Efficient Code Generation},
  author = {Zhensu Sun and Xiaoning Du and Zhou Yang and Li Li and David Lo},
  booktitle = {ISSTA},
  year = {2024},
  doi = {10.1145/3650212.3680347}
}