Source-linked AI summary
Hierarchy-Aware Semantic Losses for Knowledge Graph Link Prediction
Filip Kronström, Ross D. King
TL;DR
Link prediction methods often underuse ontology-derived class hierarchies, motivating evaluation of hierarchy-aware semantic losses beyond biological regression. The paper combines GNN encoders with box-based hierarchy constraints and finds consistent gains over baselines and subclass-edge variants across AIFB, CoDEx, and BioKG, while noting that stronger conclusions about hierarchy characteristics require more datasets.
Problem
Many link prediction methods do not explicitly enforce ontological hierarchies, and the effectiveness of hierarchy-aware semantic losses for this task had not been investigated.
Method
The paper combines GNN encoders with box-embedding semantic losses that encourage ontology-derived subclass containment during joint downstream-task training.
Results
Hierarchy-aware semantic losses significantly outperform baseline models and variants that add subclass relations as graph edges across all three benchmark datasets.
Takeaways & Limitations
The results support ontology-derived class hierarchies as complementary to graph structure and semantic losses as a parameter-efficient way to incorporate them.
Takeaways & Limitations
Only three datasets were considered, limiting strong conclusions about which hierarchy characteristics matter most.
Abstract
from arXiv · showhide
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 often include ontological class hierarchies, but link prediction methods typically do not explicitly enforce their semantic constraints. This paper evaluates hierarchy-aware GNN semantic losses for link prediction across three benchmark datasets.
- Many link prediction methods learn from observed graph structure without explicitly enforcing ontological class inclusion relationships.Such representations may violate known hierarchical relationships even when ontology information is available.
- Geometric hierarchical embeddings capture structural patterns but do not directly incorporate ontology-derived concepts or logical axioms.
- Box embeddings represent concepts as axis-aligned hyperrectangles, making subsumption correspond naturally to geometric containment.
- Semantic losses incorporate symbolic knowledge by penalising predictions that violate logical constraints during neural-model training.
- The evaluated framework combines GNN message passing with box-embedding semantic losses and was previously applied to biological gene deletion fitness prediction.The present study tests whether it generalises to knowledge graph link prediction.
- The evaluation spans AIFB, CoDEx, and BioKG, covering different domains, scales, and degrees of ontological structure.
2. Hierarchy-aware GNNs
The hierarchy-aware GNN jointly trains graph representations and a downstream decoder while adding box-based semantic losses for ontology-derived subclass containment. These losses encourage, but do not guarantee, exact hierarchical consistency.
- The approach jointly optimises a GNN encoder, hierarchy-derived semantic losses, and a task-specific decoder for downstream prediction.The architecture is illustrated in Figure 1.
- Concepts are represented as axis-aligned hyperrectangles whose lower and upper coordinates define each box along every latent dimension.Boxes can alternatively be represented by centerpoints and offsets.
- For C ⊑D, the child concept box is encouraged to lie inside the parent concept box through a distance-based semantic loss.The loss is based on signed element-wise distances between boxes.
- The inclusion loss penalises subclass-containment violations and becomes zero when the child box is fully contained within the parent box.Penalties increase with the extent of the containment violation.
- At each GNN layer, node embeddings are transformed into boxes and the inclusion loss is evaluated over ontology-derived subclass relations.The framework is architecture-agnostic and supports arbitrary downstream objectives, including link prediction.
- Because the semantic loss is jointly optimised with link prediction, hierarchy constraints are encouraged rather than guaranteed to hold exactly.The coefficient α controls the semantic loss contribution.
3. Experimental setup
The experiments compare hierarchy-aware semantic losses with baseline and subclass-edge configurations across three heterogeneous knowledge graph benchmarks. Models use GNN encoders and link prediction decoders selected according to dataset performance.
- Datasets and hierarchies: The evaluation covers AIFB, CoDEx, and BioKG, which differ substantially in scale, domain, and available hierarchical information.
- Datasets and hierarchies: AIFB provides explicit subClassOf relations from a single ontology, while CoDEx hierarchy information is constructed from Wikidata instanceOf and subClassOf properties.
- Datasets and hierarchies: BioKG contains five biomedical domains, each associated with a domain-specific hierarchy, enabling evaluation across multiple ontology-derived information sources.
- Models: R-GCN is used for AIFB, whereas GraphSAGE is used for CoDEx and BioKG based on preliminary encoder comparisons.
- Models: ComplEx performs best on AIFB, while a neural-network decoder is more effective on CoDEx and BioKG.The reported models use the strongest encoder and decoder for each dataset.
- Hierarchy configurations: The hierarchy comparison includes the original-graph baseline, SC-Edges with subclass relations added as graph edges, and semantic-loss models that constrain the embedding space.Semantic losses preserve the original graph topology.
- Training and evaluation: Evaluation uses BCE training with sampled negatives and reports MRR under benchmark-specific negative-ranking procedures.
4. Results
Across AIFB, CoDEx, and BioKG, hierarchy-aware semantic-loss models achieved the strongest link-prediction performance and outperformed both baseline and SC-Edges variants. The losses decreased during BioKG training, while exploratory analyses related performance gains to hierarchy characteristics.
- Across all three datasets, semantic-loss models significantly outperformed corresponding baseline and SC-Edges variants.Results used 10 training runs and Welch’s two-sided t-test with p < 0.05.
- 15% relative improvement: BioKG MRR increased from 0.723 to 0.835 with semantic losses.
- Semantic losses achieved stronger BioKG performance than SC-Edges while reducing parameters from 53.41M to 50.62M.BioKG MRR increased from 0.764 to 0.835; semantic losses incorporate hierarchy through the loss function rather than graph augmentation.
- Semantic losses decreased throughout training across BioKG ontology domains and GNN layers, indicating increasing satisfaction of hierarchy constraints.Complete satisfaction was not guaranteed because the semantic loss was jointly optimized with the link-prediction objective.
- The largest semantic-loss reductions occurred for the function, protein, and drug hierarchies.
- Exploratory analysis associated larger performance gains with greater hierarchy availability and lower hierarchy density across the three datasets.Hierarchy density measures subclass axioms per hierarchy entity, while availability measures hierarchy entities per hierarchy-covered graph entity; only three datasets were available.
5. Discussion
Hierarchy-aware semantic losses improve link prediction across diverse knowledge graphs and outperform adding subclass relations as graph edges. The gains appear related to the availability and quality of hierarchical information, although only three datasets limit stronger conclusions.
- Semantic losses significantly outperform baseline models and SC-Edges variants across three knowledge graph datasets.They achieve stronger predictive performance while remaining more parameter-efficient than corresponding SC-Edges variants.
- Explicitly constraining embeddings preserves the original graph topology and is more effective than relying on message passing alone to propagate taxonomic information.SC-Edges add subclass relations as message-passing edges, whereas semantic losses directly enforce hierarchical relations in the embedding space.
- Semantic losses decrease during training across all five BioKG domains, indicating increasingly satisfied ontology-derived hierarchy constraints.The side-effect hierarchy starts with lower losses and shows smaller decreases, suggesting its constraints are initially better satisfied.
- Performance gains are associated with higher hierarchy availability and lower hierarchy density, with BioKG showing both the greatest availability and largest improvements.These trends are exploratory because only three datasets are available.
- Hierarchy density and availability are coarse measures because hierarchy construction and semantic quality differ across ontology sources.The paper suggests that both the quantity and quality of hierarchical information influence effectiveness.
- Only three datasets were evaluated, limiting strong conclusions about which hierarchy characteristics matter most.The paper calls for broader evaluation across knowledge graphs and ontology sources.
- Class hierarchies provide information complementary to relational graph structure, supporting representations that reflect connectivity and conceptual organisation.The reported improvements extend the hierarchy-aware approach beyond biological regression to knowledge graph link prediction.
Appendix A. Negative loss
The negative semantic loss models disjointness or separation between concepts, but the paper omits it because sampled negatives can impose unsupported constraints and provide little additional benefit for link prediction.
- The negative semantic loss penalises overlap between boxes for concepts assumed to be distinct.It can represent disjointness axioms or use randomly sampled negative examples.
- The overall objective combines task-specific loss, positive semantic inclusion loss, and a weighted negative semantic loss.The parameter β controls the negative examples’ contribution relative to positive hierarchy examples.
- Because the datasets lack explicit disjointness axioms, random negative class pairs may be related and impose unsupported separation constraints.Such sampling can penalise embeddings that correctly place related concepts close together.
- The link prediction objective already supplies a strong discriminative signal, potentially reducing the negative loss’s additional information while retaining its incorrect constraints.This makes the negative loss less clearly useful in the evaluated setting.
- Preliminary experiments found no benefit from the negative loss, and some cases slightly improved when it was omitted.All reported experiments therefore use only the positive semantic inclusion loss.
Appendix B. Hyperparameters
The experiments use validation-based model selection and dataset-specific training schedules, regularisation, negative sampling, and embedding dimensions. Table 4 summarises the dataset-specific architectural hyperparameters.
- Hyperparameters were selected using validation performance, with Adam, L2 regularisation weight 10^-3, and semantic loss weight α = 10^-1.
- AIFB, CoDEx, and BioKG were trained for 120, 150, and 250 epochs, respectively, with dataset-specific learning-rate schedules.The best-validation model was retained for test evaluation.
- Negative triples were uniformly sampled at ratios of 1000:1 for AIFB, 150:1 for CoDEx, and 100:1 for BioKG.Each dataset also used a dataset-specific positive class weight selected through validation.
- Dataset-specific architectural hyperparameters are summarised in Table 4.
- ComplEx used learning rate 10^-3, validation-based early stopping with patience 20, and embedding dimensions 256 for AIFB and CoDEx and 512 for BioKG.
Appendix C. Hits@K
Appendix C reports link prediction performance using Hits@K, with results aggregated over 10 runs and significance markers identifying tested comparisons.
- Hits@K results are reported as mean ± standard deviation over 10 runs.
- The § marker denotes significant improvement from semantic-loss training over all baseline models.
- The † and ‡ markers denote significant improvements over ComplEx and ComplEx with subClassOf-edges, respectively.
- The * marker denotes significant improvement over the GNN baseline.
- Significance is assessed with Welch’s two-sided t-test using p < 0.05.