Syntactic multilingual probing of pre-trained language models of code
Pre-trained language models (PLMs) have demonstrated remarkable abilities in coding tasks, establishing themselves as a state-of-the-art technique in machine learning for code. However, due to their deep neural network-based structure, PLMs function as black-box systems, making it crucial to understand the types of information they actually learn. Recent studies indicate that PLMs possess cross-lingual capabilities, allowing them to generalize to unseen programming languages and outperform monolingual models when trained in a multilingual setting. Nonetheless, the reasons behind these cross-lingual abilities remain largely uncharted and remain open questions. In this paper, we explore this phenomenon through a syntactic perspective. Specifically, we build on our prior work, the AST-Probe, a probing methodology that evaluates whether a PLM encodes the complete grammatical structure of a programming language. This probe identifies a syntactic subspace within the PLM’s vector representations, which is then used to reconstruct ASTs. We extend this approach in two ways. First, we conducted experiments on eight programming languages and eight PLMs and found that: (1) this syntactic structure can be extracted in all cases, (2) CodeBERT and GraphCodeBERT excel at encoding ASTs, and (3) syntactic knowledge resides in the middle layers of all PLMs, with a distribution that is independent of the programming language. Secondly, we mathematically adapt the AST-Probe to a multilingual setting and apply it to CodeBERT. Our findings provide evidence that CodeBERT learns cross-lingual representations of programming languages syntax.
Authors
- José Antonio Hernández López (ORCID: https://orcid.org/0000-0003-2439-2136)
- Houari A. Sahraoui (ORCID: https://orcid.org/0000-0001-6304-9926)
- Jesús Sánchez Cuadrado (ORCID: https://orcid.org/0000-0001-9755-5616)
- Martin Weyssow (ORCID: https://orcid.org/0000-0002-5987-850X)
Publication Details
- Journal
- Journal of Systems and Software
- Published
- 2025-09-03
- DOI
- https://doi.org/10.1016/j.jss.2025.112604
- Primary Topic
- Topic Modeling
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Ministerio de Ciencia, Innovación y Universidades
- Federación Española de Enfermedades Raras