Manuscript Offprint

arXiv:2608.27813

Representation of syntax in LLMs through the lens of linear distance and similarity-aware entropy

Juan Pablo Vigneaux, Mary Kennedy, Khalil Iskarous, Robert Frank, Matilde Marcolli

Abstract

Structural probes were introduced by Hewitt and Manning to reconstruct syntactic trees from a neural language model's latent representations. They are evaluated by calculating the proportion of syntactic tree edges correctly reconstructed over an annotated corpus (as measured by undirected unlabeled attachment score). Here, we disaggregate this measure, considering undirected attachment score by label (UASL), which assesses the reconstruction accuracy of each syntactic relation separately, establishing important differences among relations that overlap linguistic distinctions. Moreover, we identify two factors that predict most of UASL's variability across relations: (i) the mean and dispersion of the linear distance (on a log scale) between the related words, and (ii) the diversity (similarity-aware entropy) of the syntactic relation's head. These results, which hold across a range of model sizes and architectures, shed light on the degree of abstraction of the representation of syntax in language models and the dependence of such representation on geometric properties of the embedding space.

1 Introduction

Probing vector representations has been widely used as a means for extracting insights into the inner workings of neural language models (Alain and Bengio, 2017; Conneau et al., 2018). Since the seminal work of Hewitt and Manning (2019) found that dependency trees could be recovered with probes with a reasonable degree of success, there has been a proliferation of syntactic probing methodologies (Chi et al., 2020; Davis et al., 2022; Tucker et al., 2022; Eisape et al., 2022; Arps et al., 2022; Diego-Simón et al., 2024). We would like to leverage these results to identify to what extent and through which mechanisms the algebraic

Figure

Figure 1: Held-out UASL against the similarity-corrected entropy of the relation’s head HheadsimH_{head}^{sim}, for the optimal structural probe trained on BERT-base embeddings of the PTB. Both axes are residuals with respect to the other two predictors in the weighted linear regression of §6. Each point is one relation, with area proportional to the number of edges used to measure its UASL; the ten largest are labelled.

structure of syntax is encoded and processed by LLMs in the geometry of their latent spaces. This includes not just the question of whether syntactic relations and hierarchical structures are detectable, but more precisely whether linguistic differences among dependency relations correspond to quantitative differences in performance and whether these differences can be traced back to distinct computational mechanisms.

The work we present in this paper represents the first steps in such an investigation. It shows that individual syntactic relations behave differently with respect to probe performance, quantifying in precise mathematical terms certain significant “limitations of abstraction” in the representation of syntactic dependencies.

Firstly, we show that the accuracy at reconstructing a given dependency relation varies widely

*Corresponding author: jpvigneaux@northwestern.edu Code and data: github.com/jpvigneaux/structural-probes-labelwise-analysis among relations. In §4 we study this variability across multiple relations and looking at representations at different model depths. We then consider possible underlying explanatory variables derived from linguistic theory: nature of the syntactic-role, frequency of the relation, linear distance between head and dependent, and similarity-aware entropy of the head or dependent.

Secondly, by performing a more detailed analysis of the UASL dependence on distance, based both on a log-linear decay model ( §5.1§5.1) and on a model-free comparison between the UASL-vs-distance curves ( §5.2§5.2), we find that dependency relations with similar properties from the perspective of syntactic theory exhibit similar behaviors. Therefore, linguistic distinctions provide useful cues for the identification of likely distinct mechanisms that underlie the model’s processing of these relations.

Thirdly, we uncover another variable that modulates UASL performance across relations, largely independent of the linear distance descriptors: the similarity-aware entropy of a relation’s heads. The similarity in question is derived from neural word embeddings; we see these embeddings as an instance of a geometrically-structured semantic space (Shepard, 2024; Piantadosi et al., 2024; Grindrod, 2025), partly shared between models (Huh et al., 2024; Jha et al., 2025) and somewhat comparable with human conceptualization—see, e.g. (Reif et al., 2019; Garí Soler and Apidianaki, 2021; Gupta et al., 2022; Trott and Bergen, 2023).

Higher values of the similarity-aware entropy of a relation head (i.e. greater diversity in heads' embeddings) hinder probe performance. We conjecture that this measures difficulties that the attention heads encounter in encoding, geometrically, the connections between dependents and heads and hence the relation as an abstract construct. It is suggestive that the majority of the “syntactic” attention heads identified by Clark et al. (2019) are such that the dependent attends predominantly to its head; this makes us think that the problem of reconstructing the relation might be recast by the models as identifying the head given the dependent, which is more complex if the attention mechanism has to point into independent or even conflicting directions. This is the kind of understanding that we would like to motivate with this study.

Our results are stable across a range of models, which differ both in parameter counts and architecture: BERT-base, DeBERTa-v3-base, ModernBERT-base, GPT-2-base, and GPT-J-6B. This points to some underlying structure present in the language itself, or at least to the way transformers can capture that structure.

References (41)

  • Javier Ferrando, Gabriele Sarti, Arianna Bisazza, and Marta R. Costa-jussà. 2024. A primer on the inner workings of transformer-based language models. arXiv preprint arXiv:2405.00208. Preprint, arXiv:2405.00208. (opens arXiv in a new tab)
  • RoBERTa: A Robustly Optimized BERT Pretraining Approach
  • Crucially, these include pre-layer or post-layer normalization, and sequential or parallel placement of attention and MLP modules
  • An encoding $z$ of the position is added to these raw embeddings, which yields $x_i^{(1)} = L(x_i^{(0)} + z(i))$ for a post-layer-normalization model and $x_i^{(1)} = x_i^{(0)} + z(i)$ otherwise
  • attention blocks
  • A relation's count is the number of edges the probe evaluation scores under it: edges of the gold dependency tree whose two endpoints are both non-punctuation tokens
  • The probe's reconstruction is $\hat{T}_{s} = (V_{s}, \hat{E}_{s})$, the minimum spanning tree of the projected points $Bx_{\bullet}$ under the Euclidean distance of $\mathbb{R}^{64}$
  • It follows that UUAS is the average of UASL( $\lambda$ ) over relations weighted by their edge counts, which is why those counts appear as the regression weights in §6
  • convention A
  • Remember that layer normalization is given by
  • Of the four operations composing $L$, three can be absorbed by the probe matrix $B$: the shift $\beta$ cancels in the difference $x_i - x_j$ on which the probe is evaluated, the gain $\gamma$ is diagonal, and the centering is the fixed projection $I - \mathbf{1}\mathbf{1}^\top/d$
  • The probes attain a peak development UUAS of 0.7755 at checkpoint 16 under A and 0.7741 at checkpoint 15 under B; across checkpoints the mean difference B – A is -0.0050, exceeding 0.015 in magnitude only at the deepest checkpoints, where residual-stream norms grow sharply under A
  • Remarkably, we can see that the general order is preserved: pcomp is the most reliably parsed dependency relation, and csubj is the least
  • All models report similar performance decay as linear distance increases, further confirming the findings of Diego-Simón et al
  • We find that the median $R^{2}$ across (relation, residual stream checkpoint) pairs is 0.777 for BERT-base, 0.752 for GPT-2-base, 0.692 for ModernBERT-base, 0.648 for GPT-J-6B, and 0.588 for DeBERTa-v3-base
  • Here, we define an additional range component that quantifies the linear distances of dependency relations in the corpus, and a composite distance formula
  • These are computed using the full gold-arc counts
  • Each dendrogram is reported along a symmetric-log scale horizontal axis (below 0.3, the average composite distance is linear; above this, the distance is logarithmic), and 25% of the tallest merge height is marked with a dashed vertical line, after which leaf
  • The colour scale runs from red ( $R^{2} = 0$) through yellow to green ( $R^{2} = 1$)
  • Because this dendrogram uses only linear distances, intermediate-range dependency relations (mark/discourse/rcmod/tmod/nsubj/appos/prep) cluster together as their linear distances can be seen to range from 7–9 in Table C.1
  • $d_{\text{range}}$ is not a metric)
  • For example, cc and csubj both have $\delta_{90} = 11$ but have 3.07 words separation in the Wasserstein-1 metric, while advcl and ccomp both have $\delta_{90} = 17$ but differ by 2.22 words in Wasserstein-1 (see the $\alpha = 0$ panel of Figure C.8)
  • Datapoints are UASL values for one linear distance $\delta$ with at least five gold edges in the test set
  • Rows are as in Figure C.5
  • However, unlike Figure C.7, the range component has been replaced with the Wasserstein-1 distance described in Equation 14
  • The average-linkage dendrograms of the 41 dependency relations, clustered by UASL, as a function of linear distance ( $\alpha = 1$ in the composite distance of Figure C.7), measured over all residual stream checkpoints of the test set
  • More importantly, however, we observe that all models' regression coefficients display the same sign, and that all models have roughly the same magnitude and significance, indicating that our UASL analysis is not unique to BERT alone
  • The predictors are computed once on the Penn Treebank, hence they remain the same for every model, so the rows only differ in the UASL values, and the locations of the same 42 relations just move vertically from row to row
  • The partial view is necessary in the middle column, where $\mathrm{sd}(\log \delta)$ correlates $+0.56$ with mean $(\log \delta)$: the raw scatter of UASL against dispersion slopes downward ($r$ between $-0.24$ and $-0.37$) although the partial effect is positive in every model
  • the slope on the mean distance is consistently negative, that on the dispersion positive everywhere, and that on head similarity-corrected entropy is negative everywhere
  • we used the mean of the log rather than the log of the mean, the standard deviation instead of the variance, and we stopped at the second moment of the log-length distribution
  • The symbol *** denotes $p < .001$, while * denotes $p < .05$
  • Point area is proportional to the relation’s weight in the regression
  • On the other hand, the skewness term $M_{3}$ is in every model not statistically significant, with the adjusted $R^{2}$ dropping in the case of ModernBERT-base and GPT-J-6B, and the AIC worsening in three of the models
  • as well as
  • up to 40 cookies
  • After permutation, aux and auxpass become comparable
  • The shaded bands represent one standard deviation across relations
  • Whereas cc relies on the coordinated head occurring directly before the dependent conjunction, conj shows an additional symmetry which might be preserved through some permutations
  • We considered RoBERTa-Shuffle-n1 (Sinha et al., 2021), the model discussed in §E.1, pre-trained on permuted sentences (maintaining the same probes, alignments, corpus splits, and predictors)
  • The final column repeats the BERT-base coefficient for comparison