AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 16 papers in the map (data through 14 Oct 2026). Builds on 36 of its 47 references that are in the map. First posted on arXiv 23 Jun 2022.
Builds on
36 of 47 references.
References · 36
- 2017Attention Is All You Needcited by 60,361
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,918
- 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,218
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2015Aligning Books and Movies: Towards Story-like Visual Explanations by Watching Movies and Reading Bookscited by 1,043
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
24 more
- 2021Probing Classifiers: Promises, Shortcomings, and Advancescited by 876
- 2020A Primer in BERTology: What we know about how BERT workscited by 815
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
- 2021Recent Advances in Natural Language Processing via Large Pre-Trained Language Models: A Surveycited by 463
- 2018What you can cram into a single vector: Probing sentence embeddings for linguistic propertiescited by 457
- 2021Unified Pre-training for Program Understanding and Generationcited by 366
- 2017A Survey of Machine Learning for Big Code and Naturalnesscited by 221
- 2016Fine-grained Analysis of Sentence Embeddings Using Auxiliary Prediction Taskscited by 216
- 2017What do Neural Machine Translation Models Learn about Morphology?cited by 166
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 119
- 2020Finding Universal Grammatical Relations in Multilingual BERTcited by 110
- 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 50
- 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
- 2019When Deep Learning Met Code Searchcited by 46
- 2020A Tale of a Probe and a Parsercited by 40
- 2020Fast and Memory-Efficient Neural Code Completioncited by 38
- 2021What do pre-trained code models know about code?cited by 36
- 2018Straight to the Tree: Constituency Parsing with Neural Syntactic Distancecited by 32
- 2021A Non-Linear Structural Probecited by 31
- 2022Probing Pretrained Models of Source Codecited by 26
- 2020Introducing Orthogonal Constraint in Structural Probescited by 21
- 2022An Exploratory Study on Code Attention in BERTcited by 12
Built on by
Citing papers per year: 2023: 9; 2024: 1; 2025: 4; 2026: 2.
16 papers.
Sort:
By area:
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2023Towards Efficient Fine-tuning of Pre-trained Code Models: An Experimental Study and Beyondcited by 20
- 2023Exploring Code Analysis: Zero-Shot Insights on Syntax and Semantics with LLMscited by 19
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14
- 2023Evaluating and Explaining Large Language Models for Code Using Syntactic Structurescited by 9
- 2023The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classificationcited by 5
- 2023Substance or Style: What Does Your Image Embedding Know?cited by 5
- 2024Meta-Models: An Architecture for Decoding LLM Behaviors Through Interpreted Embeddings and Natural Languagecited by 5
- 2023Pop Quiz! Do Pre-trained Code Models Possess Knowledge of Correct API Names?cited by 3
- 2025Where's the Bug? Attention Probing for Scalable Fault Localizationcited by 3
- 2025Hyperdimensional Probe: Decoding LLM Representations via Vector Symbolic Architecturescited by 3
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 2
4 more
- 2026Towards Understanding What State Space Models Learn About Codecited by 1
- 2026Latent Programming Horizons in Coding Agentscited by 1
- 2025How to Select Pre-Trained Code Models for Reuse? A Learning Perspectivecited by 0
- 2025Toward Neurosymbolic Program Comprehensioncited by 0
- 2026Latent Programming Horizons in Coding Agents6 Jul 2026
- 2026Towards Understanding What State Space Models Learn About Code6 Feb 2026
- 2025Hyperdimensional Probe: Decoding LLM Representations via Vector Symbolic Architectures29 Sep 2025
- 2025Where's the Bug? Attention Probing for Scalable Fault Localization19 Feb 2025
- 2025Toward Neurosymbolic Program Comprehension3 Feb 2025
- 2025How to Select Pre-Trained Code Models for Reuse? A Learning Perspective7 Jan 2025
- 2024Meta-Models: An Architecture for Decoding LLM Behaviors Through Interpreted Embeddings and Natural Language3 Oct 2024
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkit30 Dec 2023
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformers8 Dec 2023
- 2023Pop Quiz! Do Pre-trained Code Models Possess Knowledge of Correct API Names?14 Sep 2023
- 2023Evaluating and Explaining Large Language Models for Code Using Syntactic Structures7 Aug 2023
- 2023Substance or Style: What Does Your Image Embedding Know?10 Jul 2023
4 more
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completion1 Jun 2023
- 2023Exploring Code Analysis: Zero-Shot Insights on Syntax and Semantics with LLMs20 May 2023
- 2023The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classification8 May 2023
- 2023Towards Efficient Fine-tuning of Pre-trained Code Models: An Experimental Study and Beyond11 Apr 2023
- 2026Latent Programming Horizons in Coding Agentscited by 1
- 2026Latent Programming Horizons in Coding Agents6 Jul 2026
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2023Towards Efficient Fine-tuning of Pre-trained Code Models: An Experimental Study and Beyondcited by 20
- 2023Exploring Code Analysis: Zero-Shot Insights on Syntax and Semantics with LLMscited by 19
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14
- 2023Evaluating and Explaining Large Language Models for Code Using Syntactic Structurescited by 9
- 2023The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classificationcited by 5
- 2023Substance or Style: What Does Your Image Embedding Know?cited by 5
- 2024Meta-Models: An Architecture for Decoding LLM Behaviors Through Interpreted Embeddings and Natural Languagecited by 5
- 2023Pop Quiz! Do Pre-trained Code Models Possess Knowledge of Correct API Names?cited by 3
- 2025Where's the Bug? Attention Probing for Scalable Fault Localizationcited by 3
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 2
- 2026Towards Understanding What State Space Models Learn About Codecited by 1
12 most cited of 14 All 14 (JSON)
- 2026Towards Understanding What State Space Models Learn About Code6 Feb 2026
- 2025Where's the Bug? Attention Probing for Scalable Fault Localization19 Feb 2025
- 2025Toward Neurosymbolic Program Comprehension3 Feb 2025
- 2025How to Select Pre-Trained Code Models for Reuse? A Learning Perspective7 Jan 2025
- 2024Meta-Models: An Architecture for Decoding LLM Behaviors Through Interpreted Embeddings and Natural Language3 Oct 2024
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkit30 Dec 2023
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformers8 Dec 2023
- 2023Pop Quiz! Do Pre-trained Code Models Possess Knowledge of Correct API Names?14 Sep 2023
- 2023Evaluating and Explaining Large Language Models for Code Using Syntactic Structures7 Aug 2023
- 2023Substance or Style: What Does Your Image Embedding Know?10 Jul 2023
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completion1 Jun 2023
- 2023Exploring Code Analysis: Zero-Shot Insights on Syntax and Semantics with LLMs20 May 2023
12 newest of 14 All 14 (JSON)