paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Code Prediction by Feeding Trees to Transformers

将语法树输入 Transformer 进行代码预测
ICSE 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE)2021匹配度 2/10 · 该论文研究基于语法树的 Transformer 代码补全(下一 token 预测),属于 AI 辅助编程的代码预测任务,而非用户关注的静态分析、Agentic 程序、浮点/贝叶斯程序分析等方向,且未涉及 LLM/Agent 与静态分析的交叉。引用 248 inbox
Seohyun Kim, Jinman Zhao, Yuchi Tian, Satish Chandra
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:让 Transformer 感知代码的语法结构,使代码补全的下一 token 预测准确率大幅提升。

代码补全(autocomplete)是现代 IDE 的核心功能,其效果取决于底层模型能否把正确的下一个 token 排在候选列表前列。本文以 Transformer 为基座神经架构,研究如何让这一本质上为序列处理而设计的模型感知代码的语法结构,并给出多种将代码结构信息传递给 Transformer 的方式。作者在标准 Python 数据集以及 Facebook 内部 Python 语料上进行了全面实验,比较了多种替代设计选择,最终在下一 token 预测准确率上超越多个当时最先进的系统,领先幅度为 14% 至 18%。论文承诺开源其代码与数据准备流程。

问题
现代 IDE 中代码补全(下一 token 预测)的排序准确率仍有不足,需要更强的模型把正确的候选 token 排到列表前列。
方法
以 Transformer 为基础架构,通过多种方式把代码的语法树结构信息输入到这一序列模型之中,使模型显式感知代码句法结构。
评估
在标准 Python 数据集与 Facebook 内部 Python 语料上做全面实验,并与若干最先进的下一 token 预测系统比较准确率,以及不同结构编码设计选择。
原文摘要(Abstract)

Code prediction, more specifically autocomplete, has become an essential feature in modern IDEs. Autocomplete is more effective when the desired next token is at (or close to) the top of the list of potential completions offered by the IDE at cursor position. This is where the strength of the underlying machine learning system that produces a ranked order of potential completions comes into play. We advance the state-of-the-art in the accuracy of code prediction (next token prediction) used in autocomplete systems. Our work uses Transformers as the base neural architecture. We show that by making the Transformer architecture aware of the syntactic structure of code, we increase the margin by which a Transformer-based system outperforms previous systems. With this, it outperforms the accuracy of several state-of-the-art next token prediction systems by margins ranging from 14% to 18%. We present in the paper several ways of communicating the code structure to the Transformer, which is fundamentally built for processing sequence data. We provide a comprehensive experimental evaluation of our proposal, along with alternative design choices, on a standard Python dataset, as well as on Facebook internal Python corpus. Our code and data preparation pipeline will be available in open source.

链接与引用

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

BibTeX
@inproceedings{KimZT021,
  title = {Code Prediction by Feeding Trees to Transformers},
  author = {Seohyun Kim and Jinman Zhao and Yuchi Tian and Satish Chandra},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00026}
}