paperbot · PL 论文追踪

全部论文 待读 收藏

P2 CodeGrid: A Grid Representation of Code

CodeGrid:代码的网格表示
ISSTA Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis2023匹配度 2/10 · 该论文属于 ML×PL 中的代码表示方向,但目标是改进神经网络的下游任务(分类、克隆检测、漏洞检测、补全)的表示,而非静态分析、形式化验证或 Agentic 程序分析;也不涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户画像的核心问题几乎没有交叉。引用 4 inbox
Abdoul Kader Kaboré, Earl T. Barr, Jacques Klein, Tegawendé F. Bissyandé
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 CodeGrid,将代码 token 嵌入保留布局的网格,为下游任务提供空间信号。

现有代码表示多依赖通用 NLP 或抽象语法树(AST),但 AST 忽略了控制流与数据流等代码结构,而纯图像表示性能接近 AST 表示,暗示空间信号尚未被充分利用。本文提出 CodeGrid,一种将代码 token 嵌入网格并保留代码布局的表示,且与下游任务无关,可同时服务生成与分类任务,并为 CNN、PixelCNN 等空间感知模型提供空间信号。作者在代码分类、克隆检测、漏洞检测和代码补全等任务上展开实验,并通过改变网格保留程度验证“代码是空间的”假设。结果显示 CodeGrid 能增强现有模型,在克隆检测中将 ASTNN 的 F1 提升 3.3%。

问题
现有代码表示主要基于通用 NLP 或 AST,未能充分利用代码的控制流、数据流和空间布局等结构信息。
方法
提出 CodeGrid,将 token 嵌入保留代码布局的网格,形成任务无关表示,可与 CNN、PixelCNN 等空间感知模型结合。
评估
在代码分类、克隆检测、漏洞检测与代码补全任务上评估,并通过改变网格保留程度验证空间假设;克隆检测中使 ASTNN 的 F1 提升 3.3%。
原文摘要(Abstract)

Code representation is a key step in the application of AI in software engineering. Generic NLP representations are effective but do not exploit all the rich structure inherent to code. Recent work has focused on extracting abstract syntax trees (AST) and integrating their structural information into code representations.These AST-enhanced representations advanced the state of the art and accelerated new applications of AI to software engineering. ASTs, however, neglect important aspects of code structure, notably control and data flow, leaving some potentially relevant code signal unexploited. For example, purely image-based representations perform nearly as well as AST-based representations, despite the fact that they must learn to even recognize tokens, let alone their semantics. This result, from prior work, is strong evidence that these new code representations can still be improved; it also raises the question of just what signal image-based approaches are exploiting. We answer this question. We show that code is spatial and exploit this fact to propose , a new representation that embeds tokens into a grid that preserves code layout. Unlike some of the existing state of the art, is agnostic to the downstream task: whether that task is generation or classification, can complement the learning algorithm with spatial signal. For example, we show that CNNs, which are inherently spatially-aware models, can exploit outputs to effectively tackle fundamental software engineering tasks, such as code classification, code clone detection and vulnerability detection. PixelCNN leverages ’s grid representations to achieve code completion. Through extensive experiments, we validate our spatial code hypothesis, quantifying model performance as we vary the degree to which the representation preserves the grid. To demonstrate its generality, we show that augments models, improving their performance on a range of tasks, On clone detection, improves ASTNN’s performance by 3.3% F1 score.

链接与引用

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

BibTeX
@inproceedings{KaboreBKB23,
  title = {CodeGrid: A Grid Representation of Code},
  author = {Abdoul Kader Kaboré and Earl T. Barr and Jacques Klein and Tegawendé F. Bissyandé},
  booktitle = {ISSTA},
  year = {2023},
  doi = {10.1145/3597926.3598141}
}