mlsanityData to 14 Oct 2026

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

arXiv 2206.11719 ↗First posted 23 Jun 2022cs.CL cs.AI cs.LGcited by 16

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

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2014Adam: A Method for Stochastic Optimizationcited by 37,240
  4. 2020Language Models are Few-Shot Learnerscited by 32,419
  5. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
  6. 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
  7. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  8. 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,918
  9. 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,218
  10. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  11. 2015Aligning Books and Movies: Towards Story-like Visual Explanations by Watching Movies and Reading Bookscited by 1,043
  12. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
24 more
  1. 2021Probing Classifiers: Promises, Shortcomings, and Advancescited by 876
  2. 2020A Primer in BERTology: What we know about how BERT workscited by 815
  3. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
  4. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
  5. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
  6. 2021Recent Advances in Natural Language Processing via Large Pre-Trained Language Models: A Surveycited by 463
  7. 2018What you can cram into a single vector: Probing sentence embeddings for linguistic propertiescited by 457
  8. 2021Unified Pre-training for Program Understanding and Generationcited by 366
  9. 2017A Survey of Machine Learning for Big Code and Naturalnesscited by 221
  10. 2016Fine-grained Analysis of Sentence Embeddings Using Auxiliary Prediction Taskscited by 216
  11. 2017What do Neural Machine Translation Models Learn about Morphology?cited by 166
  12. 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 119
  13. 2020Finding Universal Grammatical Relations in Multilingual BERTcited by 110
  14. 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 50
  15. 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
  16. 2019When Deep Learning Met Code Searchcited by 46
  17. 2020A Tale of a Probe and a Parsercited by 40
  18. 2020Fast and Memory-Efficient Neural Code Completioncited by 38
  19. 2021What do pre-trained code models know about code?cited by 36
  20. 2018Straight to the Tree: Constituency Parsing with Neural Syntactic Distancecited by 32
  21. 2021A Non-Linear Structural Probecited by 31
  22. 2022Probing Pretrained Models of Source Codecited by 26
  23. 2020Introducing Orthogonal Constraint in Structural Probescited by 21
  24. 2022An Exploratory Study on Code Attention in BERTcited by 12

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2023: 9; 2024: 1; 2025: 4; 2026: 2.

16 papers.

Sort:

By area: