arXiv:2608.22981cs.LGAug 2026

Manuscript Offprint

arXiv:2608.22981

Hierarchy-Aware Semantic Losses for Knowledge Graph Link Prediction

Filip Kronström, Ross D. King

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Knowledge graphs are often accompanied by ontological class hierarchies that encode valuable semantic information, yet many link prediction methods either ignore such hierarchies or incorporate them indirectly through additional graph edges. Recent work introduced hierarchy-aware graph neural networks (GNNs), which use semantic losses derived from box embeddings to encourage satisfaction of subclass relationships during GNN-based representation learning. While this approach has shown promise for biological regression tasks, its effectiveness for knowledge graph link prediction has not been investigated.

In this paper we evaluate hierarchy-aware semantic losses on link prediction across three benchmark datasets: AIFB, CoDEx, and BioKG. We combine graph neural network encoders with box-embedding-based semantic losses that encourage learned representations to better satisfy ontology-derived class hierarchies, and compare this approach to both standard link prediction models and models incorporating subclass relations as graph edges. Across all datasets, hierarchy-aware semantic losses significantly improve mean reciprocal rank (MRR) and consistently outperform models that incorporate hierarchy information through additional subclass edges. Relative to the baseline GNN models, MRR improved by 7.6%, 2.4%, and 15.5% on AIFB, CoDEx, and BioKG, respectively. Furthermore, semantic losses consistently outperform the alternative of augmenting the graph with subclass edges.

These results are consistent with ontology-derived class hierarchies providing complementary information to graph structure, and suggest that encouraging hierarchical consistency through semantic losses is an effective and comparatively parameter-efficient mechanism for improving knowledge graph link prediction.

1. Introduction

Knowledge graphs (KGs) are widely used to represent structured relational knowledge across domains such as biomedicine, recommender systems, and semantic web applications. Many KGs can be enriched with ontological information, where entities are organised into class hierarchies through relations such as subClassOf. These hierarchies encode valuable background knowledge about conceptual similarity and inheritance structure, and can therefore provide useful inductive bias for representation learning.

A common task that motivates knowledge graph representation learning is link prediction: estimating missing relations between entities based on the observed graph structure.

© 2026 F. Kronström & R.D. King.

Contemporary link prediction methods typically learn low-dimensional embeddings of entities and relations by optimising reconstruction objectives over observed triples. Translational methods such as TransE (Bordes et al., 2013) and RotatE (Sun et al., 2019), bilinear models such as DistMult (Yang et al., 2015) and ComplEx (Trouillon et al., 2016), and graph neural network (GNN) approaches such as R-GCNs (Schlichtkrull et al., 2018) have all achieved strong empirical performance on benchmark datasets. However, these methods generally learn representations from the observed graph structure and do not explicitly enforce semantic consistency with ontological hierarchies. As a result, learned embeddings may violate known class inclusion relationships even when such information is available in the data.

Recent work has explored several approaches for incorporating hierarchical information into representation learning. Within knowledge graph embedding, methods such as HAKE (Zhang et al., 2020) and hyperbolic embedding approaches (Nickel and Kiela, 2017) introduce geometric inductive biases that capture hierarchical structure and improve link prediction performance. However, these methods capture hierarchical patterns through geometric properties of the embedding space and do not directly incorporate ontology-derived concepts or logical axioms.

A complementary line of research focuses on embedding ontologies formulated in description logics. Box embeddings (Vilnis et al., 2018) provide a geometric representation in which concepts are modelled as axis-aligned hyperrectangles and subsumption relations correspond naturally to geometric containment. This idea has inspired several ontology embedding methods, including ELEm (Kulmanov et al., 2019), ELBE (Peng et al., 2022), BoxEL (Xiong et al., 2022), and Box 2^{2}EL (Jackermeier et al., 2024), which construct geometric representations that approximate model-theoretic interpretations of ontology axioms. These methods show that ontological constraints can be encoded effectively in continuous vector spaces, particularly for biomedical ontologies formulated in lightweight logics such as EL++\mathcal{EL}^{++}.

More generally, semantic loss functions provide a mechanism for incorporating symbolic knowledge into neural models by penalising predictions that violate logical constraints during training (Xu et al., 2018). The geometric representations described above provide a natural way of expressing such constraints in terms of hierarchical relations between concepts.

Building on these ideas, Kronström et al. (2026) introduced a hierarchy-aware graph neural network framework that combines GNN-based message passing with semantic loss terms derived from ontological class hierarchies. The method represents classes using box embeddings and optimises semantic losses encouraging subclass containment while simultaneously training on a downstream prediction task. Applied to a heterogeneous biological KG describing the yeast Saccharomyces cerevisiae, this approach improved predictive performance on gene deletion fitness prediction and produced embeddings that better reflected the underlying ontology structure.

In this paper, we investigate whether the hierarchy-aware semantic loss framework introduced by Kronström et al. (2026) generalises beyond biological regression to knowledge graph link prediction. Our contribution is a systematic empirical evaluation of this framework across three benchmark datasets, together with an analysis of how hierarchy characteristics relate to the observed performance gains. We evaluate the framework on BioKG

Figure

Figure 1: Overview of the hierarchy-aware GNN architecture. Semantic losses are applied to the GNN encoder to produce embeddings encouraged to better satisfy subsumptions defined in ontologies. This is optimised jointly with a task-specific decoder, e.g., for link prediction.

(Walsh et al., 2020) from the Open Graph Benchmark (OGB) (Hu et al., 2020), CoDEx (Safavi and Koutra, 2020), and AIFB (Bloehdorn and Sure, 2007), spanning different domains, scales, and degrees of ontological structure.

References (25)