We investigate how and to what extent hierarchical relations (e.g., Japan ⊂ Eastern Asia ⊂ Asia) are encoded in the internal representations of language models. Building on Linear Relational Concepts, we train linear transformations specific to each hierarchical depth and semantic domain, and characterize representational differences associated with hierarchical relations by comparing these transformations. Going beyond prior work on the representational geometry of hierarchies in LMs, our analysis covers multi-token entities and cross-layer representations. Across multiple domains we learn such transformations and evaluate in-domain generalization to unseen data and cross-domain transfer. Experiments show that, within a domain, hierarchical relations can be linearly recovered from model representations. We then analyze how hierarchical information is encoded in representation space. We find that it is encoded in a relatively low-dimensional subspace and that this subspace tends to be domain-specific. Our main result is that hierarchy representation is highly similar across these domain-specific subspaces. Overall, we find that all models considered in our experiments encode concept hierarchies in the form of highly interpretable linear representations.
Figures & tables
Figure 1: Overview of our main findings. LMs represent hierarchical concepts (left) in domain-specific subspaces of intermediate layer activations (center). The structure of these internal representations is similar across domains (right). The middle and right panels visualize, using PCA, the representations obtained by applying a linear transformation trained on hierarchical data to the hidden-state vectors corresponding to each concept in intermediate layers of Llama 3.1 8B. See App. F for details.
Figure 2: Overview of Linear Hierarchical Encoding (LHE). Given a hierarchical relation, LHE learns depth-specific and domain-specific linear transformations that map a child concept representation to the representation of its parent concept in LM intermediate layers.
Depth
Locations
Research Topic
Persons
Organizations
Organisms
0 (Root)
1
1
1
1
1
1
5
4
6
6
6
2
22
25
35
21
87
3
263
219
224
235
461
4
27971
4464
–
–
–
Table 1: Number of examples by hierarchical depth across domains
Accuracy
Causality
Method
Loc.
Topic
Pers.
Org.
Orgm.
Loc.
Topic
Pers.
Org.
Orgm.
Input averaging
0.41
0.29
0.47
0.35
0.44
0.42
0.05
0.10
0.07
0.18
SVM
0.55
0.36
0.63
0.72
0.55
0.58
0.20
0.32
0.35
0.28
LHE
0.68
0.52
0.89
0.93
0.72
0.67
0.35
0.65
0.57
0.57
Table 2: Comparison of LHE and baselines in terms of Accuracy and Causality across domains for Llama 3.1 8B. Scores are averaged across hierarchical levels. Results for all models are reported in Table 10 and scores by depth in Figure 8 .
Accuracy (LHE)
Causality (LHE)
Model
Loc.
Topic
Pers.
Org.
Orgm.
Loc.
Topic
Pers.
Org.
Orgm.
Llama 3.2 3B
0.76
0.69
0.92
0.96
0.90
0.63
0.14
0.69
0.75
0.65
Llama 3.1 8B
0.70
0.53
0.88
0.96
0.75
0.65
0.12
0.64
0.52
0.53
Qwen3 8B
0.77
0.62
0.92
0.98
0.81
0.55
0.19
0.46
0.52
0.35
Qwen3 14B
0.76
0.58
0.85
0.90
0.80
0.55
0.12
0.25
0.46
0.12
Table 3: Comparison of model performance using LHE in terms of Accuracy and Causality by domain. The results are computed on child-parent examples shared by all four models after LM-based word-prediction filtering. Scores are averaged across hierarchical levels.
[Location] Cairo All correct Pred: Cairo ⊂ Egypt ✓ ⊂ Northern Africa ✓ ⊂ Africa ✓ Gold: Cairo ⊂ Egypt ⊂ Northern Africa ⊂ Africa
[Person] Lionel Messi All correct Pred: Lionel Messi ⊂ Soccer player ✓ ⊂ Athlete ✓ Gold: Lionel Messi ⊂ Soccer player ⊂ Athlete
[Location] Leping Bottom ✗, Top ✓ Pred: Leping ⊂ India ✗ ⊂ Eastern Asia ✓ ⊂ Asia ✓ Gold: Leping ⊂ China ⊂ Eastern Asia ⊂ Asia
[Organism] Dolphin Bottom ✓, Top ✗ Pred: Dolphin ⊂ Cetacea ✓ ⊂ Fish ✗ Gold: Dolphin ⊂ Cetacea ⊂ Mammal
[Organization] The New York Times Company Bottom ✗, Top ✓ Pred: The New York Times Company ⊂ Consumer goods company ✗ ⊂ Company ✓ Gold: The New York Times Company ⊂ Media company ⊂ Company
Table 4: Examples for accuracy using Llama 3.1 8B. Each row shows an entity and its predicted parent chain ( Pred ) with step-wise correctness (✓/✗) against the gold chain ( Gold ). Correct and incorrect predicted parents are highlighted in green and red, respectively, and ⊂ / ⊂ indicate inclusion vs. non-inclusion relations between consecutive depths. We group cases by whether errors occur earlier vs. later along the evaluated depth sequence; this table shows representative instances of All correct , Bottom ✗, Top ✓ , and Bottom ✓, Top ✗ . Additional examples are provided in Appendix Table 9 .
Table 5: Causality success and failure cases obtained with Llama 3.1 8B. Before : the LM’s original prediction. Target : the intended prediction after intervention. After : the actual prediction after adding the concept vector difference.
Figure 3: Results of sweeping the rank of the pseudo-inverse matrix Wr† for Llama 3.1 8B. Scores are averaged across all domains. The vertical dotted line indicates the point at which the average of Accuracy and Causality is maximized. The results for all models are reported in App. E , confirming that the same trend is consistently observed across models.
Figure 4: Cross-domain evaluation of hierarchical-structure directions in Llama 3.1 8B. We train a linear transformation on a domain (x-axis) and evaluate it on test domains (y-axis). Left: Accuracy. Right: Causality (intervention success). Causality drops sharply under domain shift, while Accuracy remains relatively stable. Results for all models in Fig. 12 .
Figure 5: Subspace similarity of subject representations for Llama 3.1 8B. We decompose the learned linear transformation matrix W via a low-rank SVD, W≈Udiag(s)V⊤ , and quantify the overlap between the subspaces spanned by the right singular vectors V as overlap(A,B)=r1∥VA⊤VB∥F2 , where r denotes the rank and A,B are the two conditions being compared. Results for all models in Fig. 16 .
Figure 6: PCA of concept vectors for Llama 3.1 8B in the Location and Organism domains. Concept vectors are obtained by applying a low-rank pseudo-inverse of the learned transformation to parent representations and averaging over examples grouped by parent concept.
Figure 7: Similarity matrix of LM representations based on persistent homology for Llama 3.1 8B. Each entry shows the Wasserstein distance, computed on persistence diagrams derived from concept vector point clouds, between a pair of domains or datasets. Smaller values indicate more similar representational structure. Results for all models in Fig. 18 .
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
Depth
Locations
Research Topic
Persons
Organizations
Organisms
Model: Llama 3.2 3B
0 (Root)
1
1
1
1
1
1
5
3
6
5
6
2
21
12
31
14
40
3
151
79
188
157
354
4
20820
1302
–
–
–
Appendix
Table 6: Number of LM-filtered examples by hierarchical depth across domains and models, where parent-child relations are retained only when the model correctly predicts the parent category
Models
Hidden dim.
#Layer
#Head
Llama 3.2 3B
3072
28
24
Llama 3.1 8B
4096
32
32
Qwen3 8B
4096
36
32
Qwen3 14B
5120
40
40
Appendix
Table 7: Hyperparameters of each model’s architecture.
Figure 8: Accuracy and Causality at each hierarchy depth for all models. The Accuracy reported in this figure is chance-corrected to account for the depth-specific chance rate and to enable fair comparison across depths.
Figure 9: Examples of data representing the hierarchical structure of concepts.
Figure 10: Prompt format used for both data filtering and the main experiments.
Figure 11: Few-shot prompts in the template-based format. The is-a template is used for the Person, Organization, Organism, and Research Topic domains, whereas the part-of template is used for the Location domain. Results obtained with these prompts are shown in Tbl. 11 .
Model
Subject Layer
Object Layer
Rank
Llama 3.2 3B
12
15
128
Llama 3.1 8B
12
21
160
Qwen3 8B Base
20
27
192
Qwen3 14B Base
25
28
256
Appendix
Table 8: Hyperparameters used for LRC training and inference for each model.
[Organization] Toyota All correct Pred: Toyota ⊂ Automotive company ✓ ⊂ Company ✓ Gold: Toyota ⊂ Automotive company ⊂ Company
[Research Topic] Information Retrieval and Search Behavior Bottom ✓, Top ✗ Pred: Information Retrieval and Search Behavior ⊂ Information Systems ✓ ⊂ Computer Science ✓ ⊂ Social Sciences ✗ Gold: Information Retrieval and Search Behavior ⊂ Information Systems ⊂ Computer Science ⊂ Physical Sciences
Appendix
Table 9: Qualitative examples for accuracy using Llama 3.1 8B. Each row shows an entity and its predicted parent chain ( Pred ) with step-wise correctness (✓/✗) against the gold chain ( Gold ). Correct and incorrect predicted parents are highlighted in green and red, respectively, and ⊂ / ⊂ indicate inclusion vs. non-inclusion relations between consecutive depths. We group cases by whether errors occur earlier vs. later along the evaluated depth sequence; this table shows representative instances of All correct , Bottom ✗, Top ✓ , and Bottom ✓, Top ✗ .
Figure 12: Cross-domain evaluation of hierarchical-structure directions for all models.
Figure 13: Results of sweeping the rank of the pseudo-inverse matrix Wr† for all models. Scores are averaged across all domains. The vertical dotted line indicates the point at which the average of Accuracy and Causality is maximized.
Figure 14: Accuracy and Causality obtained by sweeping the subject layer while keeping the object layer fixed.
Figure 15: Accuracy and Causality obtained by sweeping the object layer while keeping the subject layer fixed.
Figure 16: Subspace similarity of subject representations for all models.
Figure 17: PCA visualizations of the concept vectors for Llama 3.1 8B.
Figure 18: Similarity matrices of LM representations for all models, based on persistent homology. Each entry shows the Wasserstein distance (computed on persistence diagrams derived from the concept vector point clouds; log1p scale) between a pair of domains/datasets. Smaller values indicate more similar representational structure.