paperbot · PL 论文追踪

全部论文 待读 收藏

P2 AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models

AST-Probe:从预训练语言模型的隐藏表示中恢复抽象语法树
ASE Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering2022匹配度 3/10 · 论文研究从代码预训练语言模型隐藏表示中探针恢复完整AST,属于代码模型可解释性与语法表示分析,与用户关注的“静态分析×LLM/Agent”核心问题(用静态分析分析 Agentic 程序,或用 LLM/Agent 改进静态分析与形式化验证)无直接交集;AST 只是被分析的内部表示内容,未涉及程序分析工具、形式化验证或工业落地。引用 20 inbox
José Antonio Hernández López, Martin Weyssow, Jesús Sánchez Cuadrado, Houari Sahraoui
crossref: 2026-09-12

AI 速览

一句话:提出 AST-Probe 探针,从预训练代码语言模型隐藏表示中恢复完整抽象语法树,并证明句法子空间存在且维度较低。

预训练语言模型已广泛用于代码建模,但此前探针研究只揭示简单语言属性,未验证模型是否编码完整编程语言语法结构。本文证明模型隐藏表示中存在包含语法信息的句法子空间,提出 AST-Probe 探针方法,从表示中提取该子空间并恢复输入代码片段的完整抽象语法树。在五个 SOTA 预训练语言模型上的实验表明,该句法子空间普遍存在;中间层编码最多 AST 信息;其最优维度远低于模型表示空间维度,说明模型仅用一小部分表示空间编码编程语言语法信息。

问题
预训练语言模型是否在隐藏表示中编码编程语言的完整语法结构,此前尚未得到验证。
方法
证明隐藏表示中存在句法子空间,并提出 AST-Probe 探针从表示中提取该子空间以恢复完整抽象语法树。
评估
在五个 SOTA 预训练语言模型上进行探测实验,分析 AST 信息在不同模型中的存在性、层间分布以及最优子空间维度。
原文摘要(Abstract)

The objective of pre-trained language models is to learn contextual representations of textual data. Pre-trained language models have become mainstream in natural language processing and code modeling. Using probes, a technique to study the linguistic properties of hidden vector spaces, previous works have shown that these pre-trained language models encode simple linguistic properties in their hidden representations. However, none of the previous work assessed whether these models encode the whole grammatical structure of a programming language. In this paper, we prove the existence of a syntactic subspace, lying in the hidden representations of pre-trained language models, which contain the syntactic information of the programming language. We show that this subspace can be extracted from the models’ representations and define a novel probing method, the AST-Probe, that enables recovering the whole abstract syntax tree (AST) of an input code snippet. In our experimentations, we show that this syntactic subspace exists in five state-of-the-art pre-trained language models. In addition, we highlight that the middle layers of the models are the ones that encode most of the AST information. Finally, we estimate the optimal size of this syntactic subspace and show that its dimension is substantially lower than those of the models’ representation spaces. This suggests that pre-trained language models use a small part of their representation spaces to encode syntactic information of the programming languages.

链接与引用

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

BibTeX
@inproceedings{paperbot7261,
  title = {AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models},
  author = {José Antonio Hernández López and Martin Weyssow and Jesús Sánchez Cuadrado and Houari Sahraoui},
  booktitle = {ASE},
  year = {2022},
  doi = {10.1145/3551349.3556900}
}