# OntoKGE: A Framework for Injecting Ontology Rules into Knowledge Graph Embedding Training

Luisa Sophie Werner, Pierre Genevès, Nabil Layaïda

<figure><img src="image_1.png" /></figure>

To cite this version:

Luisa Sophie Werner, Pierre Genevès, Nabil Layaïda. OntoKGE: A Framework for Injecting Ontology Rules into Knowledge Graph Embedding Training. 2025. hal-05075151

HAL Id: hal-05075151

https://inria.hal.science/hal-05075151v1

Preprint submitted on 20 May 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# OntoKGE: A Framework for Injecting Ontology Rules into Knowledge Graph Embedding Training

Luisa Werner and Pierre Genevès Nabil Layaïda

Univ. Grenoble Alpes, CNRS, INRIA, Grenoble INP, LIG, 655 Av. Europe, 38330 Montbonnot Saint Martin, France, https://www.inria.fr/tyrex {firstname.name}@inria.fr

**Abstract.** Link prediction is a key task in knowledge graphs that involves inferring new links between entities based on existing ones. Knowledge graph embedding models address this task by representing entities and relations as points in a geometric space and using distance or similarity functions to predict missing links. However, traditional knowledge graph embedding models are trained only on assertional facts and ignore semantic information, encoded for example in the ontology. We aim to improve the quality of knowledge graph embedding models for link prediction by leveraging prior knowledge. To this end, we propose *OntoKGE*, an embedding-agnostic framework that integrates a reasoning module into the training process of knowledge graph embedding models. This module is based on Datalog and derives additional training facts, enriching the training set and enhancing the learned embeddings. Experiments on multiple benchmarks show that OntoKGE improves link prediction performance across multiple knowledge graph embedding models.

**Keywords:** knowledge graph embeddings · neuro-symbolic integration · link prediction.

## 1 Introduction

Knowledge graphs are a rich source of information that have recently attracted significant attention from both academia and industry [15, 17, 23]. Based on a set of entities and a set of relations, they consist of assertional facts represented as triples (subject, predicate, object), such as (`Paris`, `isCapitalOf`, `France`). This structure provides a flexible and extensible format to express relationships. Knowledge graphs are often augmented with an ontology [1, 18]. Ontologies encode general rules and background knowledge, typically formalized in Description Logics [4], about the facts in the graph. They describe the semantics of the components in a knowledge graph by formalising conventions about what entities and relations mean in a certain domain [15]. For example, an ontology might encode that the relations `buys` and `isBoughtBy` are inverse. From this follows, that if (`userA`, `buys`, `productB`) is a true fact, then (`productB`, `isBoughtBy`, `userA`) should also be a true fact.
Link prediction is the task of inferring new relationships between entities in a graph, which has a wide range of applications such as knowledge base completion [8], recommender systems [30], social network analysis [22], and biomedical discovery [35]. Knowledge graph embedding models [25, 3, 31] represent the entities and relations of a knowledge graph in the continuous vector space with the intention of capturing its regularities geometrically. Link prediction is performed by assigning scores (typically based on distance or similarity functions) to candidate triples. During training, the model learns with gradient descent to assign higher scores to true (positive) facts and lower scores to false (negative) facts in order to effectively distinguish between positive and negative facts. Prominent examples of knowledge graph embedding models are TransE [8], DistMult [33], BoxE [2], RotatE [27] or RGCN [26].

While knowledge graph embedding models have some important advantages such as scalability and robustness to noisy data [28], they are also subject to some major limitations. First, the informative value of the embedding vectors depends on the one hand on the expressiveness and inductive capacity of the chosen knowledge graph embedding model [2], but also on the quality of the training data. Patterns not observed in the training data may be missed by the model and thus not retained during inference.

Furthermore, knowledge graphs are often incomplete [32, 12]. This can happen unintentionally due to flaws in the data extraction [34, 5]. Beyond this, for performance reasons, many implicit facts are not stored explicitly because they can be inferred from other facts and the ontology, and would therefore be redundant [12]. Regardless of that, most knowledge graph embedding models focus solely on the assertional, explicit facts. The prior knowledge about the facts, for example from the ontology, is often neglected by knowledge graph embedding model. As a result, the predictions in the vector space are not necessarily consistent with this knowledge. Furthermore, ontologies can be of great benefit to improve embedding training, especially in the presence of incomplete data. The objective of this work is to learn more meaningful embeddings on knowledge graphs while exploiting prior knowledge.

**Contribution.** We propose the neuro-symbolic method OntoKGE for training knowledge graph embedding models with the support of logic rules. OntoKGE combines knowledge graph embedding training with a reasoning module based on Datalog [29]. The reasoning module iteratively infers new facts using existing facts and the prior knowledge, and uses them to augment the training data. In this way, knowledge in the form of additional facts is introduced at the training stage which allows the model to learn patterns that can be useful at inference. OntoKGE is agnostic to the choice of knowledge graph embedding model. Experimental results across multiple link prediction benchmarks and Datalog programs demonstrate its effectiveness in enhancing link prediction performance.
<figure><img src="image_3.png" /><figcaption>Fig. 1. Illustration of incomplete knowledge graphs.</figcaption></figure>

## 2 Notations and Problem Formulation

We focus on the task of *link prediction* in *knowledge graphs*. To formalize the problem, we introduce the following notations and definitions.

**Definition 1 (Knowledge Graph).** A knowledge graph is denoted as a tuple $\mathcal{K} = (\mathcal{E}, \mathcal{R}, \mathcal{F})$, where $\mathcal{E}$ is a finite set of entities, $\mathcal{R}$ is a finite set of relations and $\mathcal{F}$ is a finite set of facts formulated as triples. A fact is denoted as $(e_h, r, e_t)$ where $e_h \in \mathcal{E}$ and $e_t \in \mathcal{E}$ are called head entity and tail entity.

**Definition 2 (Incomplete Knowledge Graph).** Let us assume a world $\mathcal{W}$ with complete knowledge about positive facts $\mathcal{W}^+$ and negative facts $\mathcal{W}^-$, where $\mathcal{W} = \mathcal{W}^+ \cup \mathcal{W}^- = \mathcal{E} \times \mathcal{R} \times \mathcal{E}$. We define the following subsets of $\mathcal{W}$:

- $\mathcal{F}^+ \in \mathcal{W}^+$ is the set of explicit positive facts,

- $\mathcal{F}^{(+)} \in \mathcal{W}^+$ is the set of implicit positive facts,

- $\mathcal{W}^+ \setminus \mathcal{F}^+ \cup \mathcal{F}^{(+)}$ is the set of positive facts that are neither explicit nor implicit and need to be predicted.

The concepts in Definition 2 are visualized in Figure 1. $\mathcal{F}^{(+)}$ is not fully contained in $\mathcal{F}^+$ but can be derived through reasoning from the facts in $\mathcal{F}^+$ and the prior knowledge.

**Definition 3 (Link Prediction).** Given a knowledge graph $\mathcal{K}$, the task of link prediction is to infer new positive facts $\mathcal{W}^+ \setminus \mathcal{F}^+$ by predicting the plausibility of triples $(e_h, r, e_t) \in \mathcal{E} \times \mathcal{R} \times \mathcal{E}$ that are not in the set of known facts $\mathcal{F}$.

**Definition 4 (Knowledge Graph Embedding Model).** A knowledge graph embedding model is a tuple $(\mathbf{e}, \mathbf{r}, f_{score}, \Theta, \mathbb{K})$ where:

- $\mathbb{K}$ is the embedding space (typically $\mathbb{R}^d$, $\mathbb{C}^d$, or $\mathbb{H}^d$)

- $\mathbf{e}: \mathcal{E} \to \mathbb{K}^d$ maps each entity to a vector in $\mathbb{K}$,

- $\mathbf{r}: \mathcal{R} \to \mathbb{K}^{d'}$ maps each relation to a vector or structured object in $\mathbb{K}$,

- $\Theta$ is a set of parameters (embeddings and model-specific parameters),

- $f_{score}: (\mathcal{E} \times \mathcal{R} \times \mathcal{E}) \times \Theta \to \mathbb{R}$ is a score function assigning a plausibility to a fact.
Knowledge graph embedding models are a class of methods for link prediction. Given a set of facts $\mathcal{F}^+$, the goal is to find representations of entities and relations in the graph. A knowledge graph embedding model maps entities and relations into a continuous vector space over a chosen algebraic structure using a set of learnable parameters $\Theta$. The goal is to learn a set of parameters $\Theta^*$ to distinguish between positive and negative facts at inference. Therefore, a differentiable loss function $\mathbf{L}$ that measures the distances of scores and labels is minimized. The parameters $\Theta$ receive gradient updates $\frac{\partial \mathbf{L}}{\partial \Theta}$ and represent the resulting embedding vectors for entities and relations. At inference, the score function is used to infer missing facts and conduct link prediction.

Knowledge graphs contain only positive facts. However, negative facts are essential during training to avoid overgeneralization to the positive facts. For this reason, negative facts are commonly generated through *uniform negative sampling* under the closed world assumption [8, 3]. Assuming that the unobserved facts are negative, a set of negative facts $\mathcal{N}$ is created by randomly replacing the head or tail entity of a positive fact with another entity in the graph [8].

# 3 Challenges in Current Approaches

The process of knowledge graph embedding training has some major drawbacks when assuming the existence of a set of implicit positive facts $\mathcal{F}^{(+)}$. First, implicit positive facts could be mistakenly sampled during uniform negative sampling to create the set of negative facts $\mathcal{N}$. This may introduce bias during training and impact the quality of link prediction. Second, most knowledge graph embedding models are only trained on the explicit facts in the training dataset. If certain patterns are not present in the training data due to redundancy with the ontology, the model cannot learn them and is likely to miss related links at inference.

# 4 Method

We propose *OntoKGE*, a neuro-symbolic method that combines a reasoning engine with *ontology axioms* and a *knowledge graph embedding model* to learn embeddings for incomplete knowledge graphs. The aim is to leverage explicit positive facts and prior knowledge, coming for example from an ontology, to augment the training graph. OntoKGE takes as input a set of explicit positive facts and a set of rules written in Datalog. These rules encode semantics about the facts in a graph. While the positive facts in the graph represent the grounded atoms in the program, the rules express knowledge about the facts in the domain. In other words, they describe patterns that the facts in the knowledge graph should respect. By *iterative forward chaining* during training, implicit positive facts are inferred, forming an *augmented graph* of positive facts. This augmented graph is used for the training of the knowledge graph embedding model.
## 4.1 Datalog Reasoning Module

We adopt Datalog as a general framework for representing the knowledge used by the reasoning module. Datalog offers a flexible and expressive rule-based formalism that can capture a wide range of knowledge types, including ontologies, commonsense knowledge, hand-crafted rules, and automatically mined patterns [13]. Although ontologies are often formalized in Description Logics, they can typically be translated into equivalent Datalog programs, enabling seamless integration with other rule-based knowledge [16, 20, 9].

The reasoning module takes as input a set of rules $\Sigma$ and a set of facts $\mathcal{F}^+$, which together form the Datalog program. $\mathcal{F}[r] = \{(e_h, e_t)^1, \dots, (e_h, e_t)^n\}$ describes a set of $n$ facts under the relation $r \in \mathcal{R}$ with head and tail entities $e_h, e_t \in \mathcal{E}$.

**Rules.** The rules are formulated in the logical language $\mathcal{L} = \{C, \mathcal{P}, \mathcal{V}\}$, which consists of finite sets of constants $C$, variables $\mathcal{V}$ and predicates $\mathcal{P}$ with arity in $\{1, 2\}$, namely unary and binary predicates. Binary predicates $P(x, y)$ indicate relations between two variables $x$ and $y$. Unary predicates are denoted as $P(\_, y)$ and $P(x, \_)$ and refer to the variable $x$ or $y$. An atom is a predicate applied to a set of variables, and a grounded atom is an atom where all variables are replaced by constants. The operators negation $\neg$, conjunction $\wedge$, disjunction $\vee$ and implication $\leftarrow$ allow forming logical expressions of predicates. A rule $\phi$ is formulated as Horn rule in $\mathcal{L}$, consisting of a head $\eta$ and a body $B$:

$$ \phi : \eta \leftarrow \beta. \qquad (1) $$

The body $B$ contains a predicate or a conjunction of predicates, while the head is a single atom. The rules are read from the right to the left as If-Then rules. The variables that occur in the head must occur at in at least one atom in the body. A finite set of rules is denoted as $\Sigma = \{\phi_0, \dots, \phi_n\}$.

**Facts.** The explicit positive facts $\mathcal{F}^+$ are considered as grounded atoms in the logic program. The facts must be consistent with the rules in $\Sigma$. In other words, the facts in program have to be a *model* of the rules. A *batch graph* $\mathcal{B}^+$ is a subset of explicit positive facts $\mathcal{B}^+ \subseteq \mathcal{F}^+$ of size $b$. Given the language $\mathcal{L}$, the facts in $\mathcal{B}^+$ represent grounded predicates. The set of binary predicates in $\mathcal{L}$ is a subset of the relations $\mathcal{R}$ in the graph. Given a set of rules, the facts are distinguished into *extensional* and *intensional* facts, depending on the relation $\mathcal{F}^+[r]$ associated with them. An extensional relation is a relation that occurs only in the body of a rule, while an intensional relation is a relation that occurs in the head of a rule.

**Reasoning with rules and Facts.** The evaluation of a rule $\phi \in \Sigma$ on a set of facts $\mathcal{B}^+$ involves the following steps. First, the body expression $B$ of the rule is evaluated. Second, the corresponding head atom $\eta$ is inferred. Third, the inferred positive fact is concatenated with the explicit positive facts. Thus, the reasoner
implement a function from a set of explicit positive facts and the rules to an
updated set of positive facts containing explicit and implicit positive facts.

A fact $f'$ is an *immediate consequence* of $\Sigma$ and $\mathcal{B}^+$ if $f'$ is in $F^+[r]$ for some extensional relation $r \in \mathcal{R}$ or if $f' \leftarrow f_1, \dots, f_n$ is an instantiation of a rule $\phi \in \Sigma$ and $f_1, \dots, f_n \in \mathcal{B}^+$. The function $T$ defines a set of immediate consequences $\mathcal{B}_{i+1}^+$ for the rules $\Sigma$ and explicit positive facts $\mathcal{B}_i^+$:

$$T: \Sigma^+, \mathcal{B}_i^+ \mapsto \mathcal{B}_{i+1}^+ \qquad (2)$$

For a batch graph of explicit positive facts $\mathcal{B}^+$, the output of $T(\Sigma, \mathcal{B}^+)$ consists of all facts $f \in \mathcal{W}^+$ that are immediate consequences of $\mathcal{B}^+$ and $\Sigma^+$. The operator $T$ is monotone, so that $\mathcal{B}^+ \subseteq T(\mathcal{B}^+)$. While new facts can be added, once inferred facts cannot be removed. The function $T$ can be applied several times to the set of facts: $T^2(\Sigma, \mathcal{B}^+) = T(T(\Sigma, \mathcal{B}^+)), T^3(\Sigma, \mathcal{B}^+) = T(T(T(\Sigma, \mathcal{B}^+)))$ and $T^n(\Sigma, \mathcal{B}^+) = T(\dots T(T(\Sigma, \mathcal{B}^+)))$. It follows

$$\mathcal{B}^+ \subseteq T(\Sigma, \mathcal{B}^+) \subseteq T^2(\Sigma, \mathcal{B}^+) \subseteq \dots \subseteq T^n(\Sigma, \mathcal{B}^+). \qquad (3)$$

Starting from the explicit positive facts $\mathcal{B}^+$, this process is repeated until a fixpoint is reached. Formally, a fixpoint is reached when no more additional facts can be inferred with the rules and the extensional facts. A fixpoint is reached at step $N$ for all $J > N$ if $T^N(\Sigma^+, \mathcal{B}^+) = T^J(\Sigma, \mathcal{B}^+)$. The least fixpoint operator $\text{lfp}^\circ(T)$ is defined as

$$\text{lfp}^\circ(T) = T \circ \dots \circ T = T^N \qquad (4)$$

if there exists a minimum $N > 0$ such that $T^N(\mathcal{B}^+) \cong T^{N+1}(\mathcal{B}^+)$.

Overall, the reasoning module corresponds to the least fixpoint operator

$$\text{lfp}^{\oplus}(T): \mathcal{B}^+, \Sigma \mapsto \mathcal{B}^{\oplus}. \qquad (5)$$

The set of facts generated at the fixpoint is $\mathcal{B}^{\oplus} = T^N(\Sigma, \mathcal{B}^+)$. The output fact set of the reasoning module $\mathcal{B}^{\oplus}$ is defined as the disjunction of the fact sets for all relations in the graph at the fixpoint:

$$\mathcal{B}^{\oplus} = \bigcup_{\forall r \in \mathcal{R}} \mathcal{F}[r]^{\oplus}. \qquad (6)$$

The number of inferred implicit positive facts is $\Delta^+ = |\mathcal{B}^{\oplus}| - |\mathcal{B}^+|$.

**Example 1 (Reasoning with Rules and Facts).** The rules $\Sigma$ and the explicit positive facts $\mathcal{B}^+$ are used to infer implicit positive facts with the least fixpoint operator in Equation 5. This Example is illustrated in Figure 2 (left) and below. The explicit positive facts $\mathcal{B}^+ = \{ \text{mother} = [(\text{"b"}, "e")], (\text{"b"}, "d")], \text{father} = [(\text{"a"}, "d")] \}$ are extensional facts for rule 1. In step $N = 1$, the inferred facts $\{ \text{parent} = [(\text{"b"}, "e")], (\text{"b"}, "d")], (\text{"a"}, "d")] \}$ are added to the set of positive facts. In step $N = 2$, the facts $\{ \text{parent} = [(\text{"b"}, "e")], (\text{"b"}, "d")] \}$ are extensional facts for rule 2 and allow inferring $\{ \text{Sibling} = [(\text{"d"}, "e")] \}$. A fixpoint is reached for $N = 2$, since no more implicit facts are inferred by reapplying the rules to the fact set. The set of facts $\mathcal{B}^{\oplus}$ returned by the reasoner consists of all facts derived at $N = 2$.
<figure><img src="image_4.png" /><figcaption>Fig. 2. Left: Illustration of Example 1. Right: Reasoning with intermediate concepts</figcaption></figure>

<figure><img src="image_5.png" /></figure>

## 4.2 Training and Reasoning.

The architecture of OntoKGE is shown in Figure 3. The training is performed with *mini-batch gradient descent*. The set $\mathcal{F}^+$ is split into $S$ batches $\{\mathcal{B}_1^+, \dots, \mathcal{B}_S^+\}$ of size $b$ with $S = \lfloor \frac{|\mathcal{F}^+|}{b} \rfloor$.<fnref n="1" /> The loss and the parameters are updated per batch. The reasoning module in OntoKGE modifies the training loop. Given a set of rules, reasoning is applied to the set of explicit positive facts before the loss is calculated. The reasoning process is illustrated in the lines 4-8 of Algorithm 1. Consider a batch of explicit positive facts $\mathcal{B}_i^+$ of size $b$, where $i \in [1, S]$. For the sake of readability, the index of the batch is omitted. The least fixpoint operator of Equation 5 is used to derive $\mathcal{B}^\oplus$, given the batch of explicit positive facts $\mathcal{B}^+$ and the set of rules $\Sigma$. Implicit positive facts are inferred, increasing the batch size to $|\mathcal{B}^\oplus| = b + \Delta_+$. Labels with value one are added to the inferred implicit positive facts, since they are logical consequences of $\mathcal{B}^+$ and $\Sigma$.

<footnote n="1">¹ In this notation, the last batch with less than $b$ facts is discarded.</footnote>
<caption>**Algorithm 1** OntoKGE. Forward Pass with Reasoning</caption>

**Input**
Training facts $\mathcal{F}^+$, Set of rules $\Sigma$
Parameters batch size $b$, ratio $\rho$, score function $f_{\text{score}}^{\Theta}$, set of parameters $\Theta$

1: Split $\mathcal{F}^+$ into $n$ batches $\mathbf{B} = \{\mathcal{B}_1^+, \dots, \mathcal{B}_n^+\}$ of size $b$.
2: **for** $\mathcal{B}^+ \in \mathbf{B}$ **do**
3: &nbsp;&nbsp;&nbsp;&nbsp;Initialize DatalogReasoner($\Sigma$)
4: &nbsp;&nbsp;&nbsp;&nbsp;**if** $\text{len}(\Sigma) > 0$ **then**
5: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{B}^\oplus$ $\leftarrow$ positive reasoning ($\mathcal{B}^+$, $\Sigma$)
6: &nbsp;&nbsp;&nbsp;&nbsp;**else**
7: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{B}^\oplus$ $\leftarrow$ $\mathcal{B}^+$
8: &nbsp;&nbsp;&nbsp;&nbsp;**end if**
9: &nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{B}^\ominus$ $\leftarrow$ $\mathcal{N}$
10: &nbsp;&nbsp;&nbsp;&nbsp;positive labels $\leftarrow \{1\}^{\text{len}(\mathcal{B}^\oplus)}$
11: &nbsp;&nbsp;&nbsp;&nbsp;negative labels $\leftarrow \{0\}^{\text{len}(\mathcal{B}^\ominus)}$
12: &nbsp;&nbsp;&nbsp;&nbsp;labels $\leftarrow$ concat[positive labels, negative labels]
13: &nbsp;&nbsp;&nbsp;&nbsp;facts $\leftarrow$ concat[$\mathcal{B}^\oplus$, $\mathcal{B}^\ominus$]
14: &nbsp;&nbsp;&nbsp;&nbsp;loss $f_{\text{score}}^{\Theta}$(facts, labels)
15: &nbsp;&nbsp;&nbsp;&nbsp;$\Theta$ $\leftarrow$ $\frac{\delta\text{Loss}}{\delta\Theta}$ gradient update
16: **end for**

$\triangleright$ uniform negative sampling

# 5 Experimental Evaluation

Experiments are conducted to address the following research questions:

**R1** Does OntoKGE enhance link prediction results?

**R2** Does OntoKGE allow learning unseen zero-shot relations?

**R3** Does OntoKGE with intermediate concepts improve link prediction?

**R4** How does the reasoning module in OntoKGE affect the training set?

The source code of OntoKGE is publicly available<fnref n="2" />. Additional experimental details can be found in the supplementary material.

**Datasets.** We consider the following link prediction tasks on the datasets Word-Net [24], Family [19] and Freebase [6] to investigate the research questions. A summary of the datasets is given in Tab. A.4 in the supplementary material.

The **Family dataset** [19] encodes kinship relationships between individuals. The individuals represent the entities in the graph and the relations indicate kinship relationships between them. For example, the fact *Person x is the aunt of person y* is written as triple (x, aunt, y) or as Datalog predicate *Aunt(x,y)*. The initial version of the dataset consists of 12 relations [14]. We use an extended version of the dataset with 16 relations [21]. The following Datalog programs grouped into symmetry, inversion and hierarchy patterns, are used on this task. They are handcrafted based on common sense knowledge.

<footnote n="2">² https://anonymous.4open.science/r/OntoKGE-E29C</footnote>
<figure><img src="image_6.png" /><figcaption>Fig. 3. Overview of the training loop of OntoKGE with positive and negative reasoning.</figcaption></figure>

1 % symmetry
2 sibling(x,y) ← sibling(y,x)
3 partner(x,y) ← partner(y,x)

1 % inversion
2 parent(x,y) ← child(y,x)
3 child(x,y) ← parent(y,x)
4 wife(x,y) ← husband(y,x)
5 husband(x,y) ← wife(y,x)

1 % hierarchy
2 parent(x,y) ← father(x,y)
3 parent(x,y) ← mother(x,y)
4 parent(x,y) ← son(x,y)
5 parent(x,y) ← daughter(x,y)
6 sibling(x,y) ← sister(x,y)
7 sibling(x,y) ← brother(x,y)
8 partner(x,y) ← wife(x,y)
9 partner(x,y) ← husband(x,y)
10 child(x,y) ← daughter(x,y)
11 child(x,y) ← son(x,y)

Wordnet [24] is a lexical knowledge base of English that groups words into synsets. We use the WN18RR dataset [7]. It contains 18 distinct relations. We use the following Datalog programs for Wordnet:

1 % Symmetry
2 also_see(x, y) ← also_see(y, x)
3 similar_to(x, y) ← similar_to(y, x)

1 % Inversion
2 part_of(x,y) ← has_part(y,x)
3 hypernym(x,y) ← hyponym(y,x)
4 instance_hypernym(x,y) ← instance_hyponym(y,x)
5 member_holonym(x,y) ← member_meronym(y,x)
6 member_of_domain_region(x, y) ← synset_domain_region_of(y,x)
7 member_of_domain_topic(x,y) ← synset_domain_topic_of(y,x)
8 member_of_domain_usage(x,y) ← synset_domain_usage_of(y,x)

Freebase [6] contains data about entities and their relationships, spanning domains like people, places, films, and organizations. In this work the FB15k-237 [8] dataset is used. For Freebase, the Datalog program contains automatically extracted rules with AMIE [13] proposed in [11]. Each rule has a confidence score in [0, 1]. We consider Datalog programs with rules with a confidence $\le 0.75$ and $\le 0.95$. The Datalog programs for Freebase are given in Section A.1 of the supplementary material.
## 5.1 Link Prediction (R1)

In order to evaluate if OntoKGE enhances link prediction, we train knowledge graph embedding models with OntoKGE on the benchmarks Wordnet, Freebase and Family and evaluate the trained models on the test set. The rank-based metrics Hits@k with $k = \{1, 5, 10\}$ are used. We compare different knowledge graph embedding models from the state-of-the-art namely BoxE [2], RotatE [27], TransE [8], Distmult [33] and RGCN [26]. To evaluate if OntoKGE leads to significant improvements compared to the knowledge graph embedding models without OntoKGE, we conduct 30 runs with different random seeds. We perform a one-sided t-test with $H_0: OntoKGE \le$ knowledge graph embedding model (KGE) and $H_1: OntoKGE >$ KGE with significance level $p = 0.05$. As an ablation study we randomly discard 25% of the training facts to model an incomplete knowledge graph.

The results of these experiments are given in Tab. 1, 2 and 3. We report the average metrics over the runs. An asterisk (*) indicates that OntoKGE achieves significantly higher Hits@k scores than the corresponding knowledge graph embedding model. The results are also visualized in Fig. A.2-A.2 of the supplementary material.

<table><caption>**Table 1.** Avg Hits@(k) on Family (inversion, hierarchy, and symmetry programs).</caption><thead><tr><th rowspan="2">Model</th><th colspan="2">Hits@1</th><th colspan="2">Hits@5</th><th colspan="2">Hits@10</th></tr><tr><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th></tr></thead><tbody><tr><td colspan="7" style="text-align: center; font-weight: bold;">Inversion</td></tr><tr><td>TransE</td><td>0.0000</td><td>0.0000</td><td>0.0432</td><td>0.0758</td><td>*</td><td>0.0683</td><td>0.0987</td><td>*</td></tr><tr><td>RotatE</td><td>0.0141</td><td>0.0827</td><td>*</td><td>0.0444</td><td>0.1587</td><td>*</td><td>0.0663</td><td>0.1977</td><td>*</td></tr><tr><td>RGCN</td><td>0.0031</td><td>0.0041</td><td>*</td><td>0.0143</td><td>0.0181</td><td>*</td><td>0.0270</td><td>0.0327</td><td>*</td></tr><tr><td>DistMult</td><td>0.0955</td><td>0.1333</td><td>*</td><td>0.2145</td><td>0.2631</td><td>*</td><td>0.2792</td><td>0.3255</td><td>*</td></tr><tr><td>BoxE</td><td>0.0940</td><td>0.1069</td><td>*</td><td>0.2667</td><td>0.2729</td><td>*</td><td>0.3859</td><td>0.3974</td><td>*</td></tr><tr><td colspan="7" style="text-align: center; font-weight: bold;">Hierarchy</td></tr><tr><td>TransE</td><td>0.0000</td><td>0.0000</td><td>0.0431</td><td>0.0643</td><td>*</td><td>0.0682</td><td>0.0895</td><td>*</td></tr><tr><td>RotatE</td><td>0.0141</td><td>0.0737</td><td>*</td><td>0.0445</td><td>0.1767</td><td>*</td><td>0.0664</td><td>0.2270</td><td>*</td></tr><tr><td>RGCN</td><td>0.0031</td><td>0.0046</td><td>*</td><td>0.0141</td><td>0.0203</td><td>*</td><td>0.0268</td><td>0.0368</td><td>*</td></tr><tr><td>DistMult</td><td>0.0953</td><td>0.1313</td><td>*</td><td>0.2148</td><td>0.2679</td><td>*</td><td>0.2795</td><td>0.3308</td><td>*</td></tr><tr><td>BoxE</td><td>0.0936</td><td>0.1011</td><td>*</td><td>0.2670</td><td>0.2748</td><td>*</td><td>0.3869</td><td>0.3994</td><td>*</td></tr><tr><td colspan="7" style="text-align: center; font-weight: bold;">Symmetry</td></tr><tr><td>TransE</td><td>0.0000</td><td>0.0000</td><td>0.0435</td><td>0.0778</td><td>*</td><td>0.0687</td><td>0.1039</td><td>*</td></tr><tr><td>RotatE</td><td>0.0142</td><td>0.0708</td><td>*</td><td>0.0447</td><td>0.1622</td><td>*</td><td>0.0667</td><td>0.2079</td><td>*</td></tr><tr><td>RGCN</td><td>0.0031</td><td>0.0038</td><td>*</td><td>0.0141</td><td>0.0166</td><td>*</td><td>0.0268</td><td>0.0307</td><td>*</td></tr><tr><td>DistMult</td><td>0.0950</td><td>0.0973</td><td>*</td><td>0.2142</td><td>0.2221</td><td>*</td><td>0.2785</td><td>0.2861</td><td></td></tr><tr><td>BoxE</td><td>0.0937</td><td>0.1003</td><td>*</td><td>0.2672</td><td>0.2742</td><td>*</td><td>0.3870</td><td>0.3983</td><td>*</td></tr></tbody></table>
Regarding the **Family** dataset (see Tab. 1), significant improvements can be found for all knowledge graph embedding models and all metrics for the hierarchy and inversion program, except of Hits@1 for TransE. Also, on the symmetry program, significant advantages of OntoKGE can be found with the exception of Hits@1 and Hits@10 for DistMult. However, the mean delta between OntoKGE and KGE is still positive. The results for TransE may be due to the fact that TransE is not well-suited for the Family dataset and returns a Hits@1 of 0.0 for all considered programs. BoxE is the model that leads to the best link prediction results on Family (with and without OntoKGE). Overall, OntoKGE leads to significantly better link prediction results on the Family dataset.

On **Wordnet** (see Tab. 2), significant improvements of OntoKGE over KGE are found for the majority of knowledge graph embedding models with the inversion program, except for Hits@10 with BoxE, Hits@1 on RGCN and Hits@5 on RotatE. However, for the symmetry program, no significant improvements of OntoKGE are reported. The model that leads to the best link prediction results on Wordnet (with and without OntoKGE) is RotatE.

<table><caption>**Table 2.** Avg. Hits@(k) on the inversion and symmetry programs on WordNet.</caption><thead><tr><th rowspan="2">Model</th><th colspan="2">Hits@1</th><th colspan="2">Hits@5</th><th colspan="2">Hits@10</th></tr><tr><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th></tr></thead><tbody><tr><td colspan="7" style="text-align: center; font-weight: bold;">Inversion</td></tr><tr><td>TransE</td><td>0.0000</td><td>0.0001 *</td><td>0.4792</td><td>0.5047 *</td><td>0.5395</td><td>0.5601 *</td></tr><tr><td>RotatE</td><td>0.5707</td><td>0.5733 *</td><td>0.6888</td><td>0.6908</td><td>0.7111</td><td>0.7134 *</td></tr><tr><td>RGCN</td><td>0.2092</td><td>0.2093</td><td>0.4038</td><td>0.4095 *</td><td>0.4904</td><td>0.4995 *</td></tr><tr><td>DistMult</td><td>0.3092</td><td>0.3789 *</td><td>0.6289</td><td>0.6501 *</td><td>0.6738</td><td>0.6804 *</td></tr><tr><td>BoxE</td><td>0.4804</td><td>0.5147 *</td><td>0.6799</td><td>0.6832 *</td><td>0.7121</td><td>0.7120</td></tr><tr><td colspan="7" style="text-align: center; font-weight: bold;">Symmetry</td></tr><tr><td>TransE</td><td>0.0000</td><td>0.0000</td><td>0.4806</td><td>0.4804</td><td>0.5410</td><td>0.5412</td></tr><tr><td>RotatE</td><td>0.5726</td><td>0.5744</td><td>0.6894</td><td>0.6915</td><td>0.7125</td><td>0.7139</td></tr><tr><td>RGCN</td><td>0.2093</td><td>0.2060</td><td>0.4042</td><td>0.4019</td><td>0.4914</td><td>0.4895</td></tr><tr><td>DistMult</td><td>0.3120</td><td>0.3059</td><td>0.6288</td><td>0.6213</td><td>0.6738</td><td>0.6706</td></tr><tr><td>BoxE</td><td>0.4796</td><td>0.4787</td><td>0.6799</td><td>0.6780</td><td>0.7123</td><td>0.7100</td></tr></tbody></table>

On **Freebase** (see Tab. 3), with the 0.95 confidence program, no significant improvements can be observed for all knowledge graph embedding models. With the 0.75 confidence program, significant improvements are observed for DistMult. This may be due to the fact that the 0.75 confidence program contains more rules and is more useful for reasoning. Overall, OntoKGE is shown to be less useful on Freebase, where automatically generated rules are used, than on the other benchmarks. These observations suggest that OntoKGE is in general more promising when the rules come from an ontology or are known rather than automatically extracted.
<table><caption>**Table 3.** Avg. Hits@(k) for programs with rule confidence ≥ 0.75 & ≥ 0.95 on Freebase.</caption><thead><tr><th rowspan="2">Model</th><th colspan="2">Hits@1</th><th colspan="2">Hits@5</th><th colspan="2">Hits@10</th></tr><tr><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th><th>KGE</th><th>OntoKGE</th></tr></thead><tbody><tr><td colspan="7" style="text-align: center; font-weight: bold;">Confidence ≥ 0.95</td></tr><tr><td>TransE</td><td>0.0225</td><td>0.0223</td><td>0.1655</td><td>0.1656</td><td>0.2443</td><td>0.2446</td></tr><tr><td>RotatE</td><td>0.1234</td><td>0.1229</td><td>0.2776</td><td>0.2769</td><td>0.3654</td><td>0.3649</td></tr><tr><td>DistMult</td><td>0.0754</td><td>0.0752</td><td>0.1999</td><td>0.1995</td><td>0.2817</td><td>0.2815</td></tr><tr><td>BoxE</td><td>0.1115</td><td>0.1114</td><td>0.2528</td><td>0.2532</td><td>0.3403</td><td>0.3404</td></tr><tr><td colspan="7" style="text-align: center; font-weight: bold;">Confidence ≥ 0.75</td></tr><tr><td>TransE</td><td>0.0225</td><td>0.0225</td><td>0.1655</td><td>0.1650</td><td>0.2440</td><td>0.2433</td></tr><tr><td>RotatE</td><td>0.1232</td><td>0.1235</td><td>0.2774</td><td>0.2775</td><td>0.3651</td><td>0.3652</td></tr><tr><td>DistMult</td><td>0.0753</td><td>0.0766</td><td>* 0.1998</td><td>0.2010</td><td>0.2817</td><td>0.2838</td></tr><tr><td>BoxE</td><td>0.1116</td><td>0.1115</td><td>0.2528</td><td>0.2536</td><td>0.3403</td><td>0.3407</td></tr></tbody></table>

## 5.2 Zero-shot Learning (R2)

We investigate whether OntoKGE is effective in zero-shot learning scenarios. Zero-shot learning is defined as the task of predicting relations that do not occur in the training set [10]. These relations are known to exist, but no single fact under these relations is observed during training. However, the reasoning module may contain knowledge that can be useful in inferring the missing information. Such relations are called *unseen relations*. In contrast, the relations that occur in the training set are called *seen relations*.

In the experiments, all facts for unseen relations are deleted from the training set on the Family dataset to simulate the zero-shot learning scenario. Here, the unseen relations are {parent, sibling, partner, child} and the hierarchy program is used. The results for the zero-shot learning experiments are shown in Tab. 4 (left). The positive reasoning in the zero-shot scenario leads to significant improvements for all models.

<table><caption>**Table 4.** Avg. hits@10 for zero-shot learning (left) and intermediate concepts (right)</caption><thead><tr><th rowspan="2">Model</th><th colspan="3">Zero-shot</th><th colspan="3">Intermediate Concept</th></tr><tr><th>OntoKGE</th><th>KGE</th><th>Δ</th><th>OntoKGE</th><th>KGE</th><th>Δ</th></tr></thead><tbody><tr><td>TransE</td><td>0.0949</td><td>0.0208</td><td>0.0741</td><td>* 0.0737</td><td>0.0479</td><td>0.0258</td></tr><tr><td>RotatE</td><td>0.4091</td><td>0.0630</td><td>0.3461</td><td>* 0.3894</td><td>0.0663</td><td>0.3231</td></tr><tr><td>BoxE</td><td>0.4650</td><td>0.3935</td><td>0.0714</td><td>* 0.4232</td><td>0.3974</td><td>0.0259</td></tr><tr><td>DistMult</td><td>0.2289</td><td>0.0604</td><td>0.1684</td><td>* 0.1812</td><td>0.1160</td><td>0.0652</td></tr><tr><td>RGCN</td><td>0.0510</td><td>0.0295</td><td>0.0215</td><td>* 0.0772</td><td>0.0733</td><td>0.0039</td></tr></tbody></table>
## 5.3 Reasoning with Intermediate Concepts (R3)

An intermediate concept is a relation $r \notin \mathcal{R}$ that does not belong to the initial set of relations, but can be extracted through reasoning and help to infer facts under known relations in $\mathcal{R}$. The relations of an *intermediate concept* do not exist explicitly in the training or test graph.

*Example 2 (Intermediate Concepts)*. This Example is visualized in Fig. 2 (right). Given the rule `mother(x,y) ← child(x,y)`, the fact `mother(a,b)` is observed. From this, it can only be inferred that **b** must be the child of **a**, but it is unclear whether **b** is the son or the daughter of **a**. However, the intermediate concept of gender `female` and `male` is introduced. The gender is inferred by rules like `female(x) ← sister(x,_)`. If **x** is the sister of any other entity, then **x** must be `female`.

The research question **R3** investigates the use of intermediate concepts in OntoKGE on the Family dataset with the following program:

```
1 %intermediate concepts
2 female(x) ← daughter(x,_) or sister(x,_) or mother(x,_) or aunt(x,_) or wife(x,_,)
3 male(x) ← son(x,_) or brother(x,_) or father(x,_) or uncle(x,_) or husband(x,_,)
4 %hierarchy
5 aunt(y,x) ← niece(x,y) and female(y)
6 aunt(y,x) ← nephew(x,y) and female(y)
7 uncle(y,x) ← niece(x,y) and male(y)
8 uncle(y,x) ← nephew(x,y) and male(y)
9 mother(y,x) ← child(x,y) and female(y)
10 father(y,x) ← child(x,y) and male(y)
11 daughter(y,x) ← parent(x,y) and female(y)
12 son(y,x) ← parent(x,y) and male(y)
13 sister(y,x) ← sibling(x,y) and female(y)
14 brother(y,x) ← sibling(x,y) and male(y)
```

The concepts `female` and `male` are intermediate concepts, while the other relations are apparent in the graph. As ablation study, a proportion of the training facts $\gamma \in \{10\%, 25\%, 50\%\}$ are randomly dropped to simulate the incompleteness of the training graph. The results for OntoKGE with intermediate concepts are presented in Tab 4 (right). Reasoning with intermediate gender concepts on the Family dataset yields significant improvements across all levels of missing data for TransE, RotatE, BoxE, and DistMult. For RGCN, significant gains are observed when 10% and 50% of the facts are missing.

## 5.4 Analysis of the Reasoner (R4)

For **R4** the reasoning process in OntoKGE on batch graphs is analysed in isolation from the knowledge graph embedding training to evaluate, how OntoKGE reacts to different parameter choices. The experiments for **R4** are conducted on the Family dataset.

*Reasoning time.* As described in Fig. 4 for the inversion program, the reasoning time increases linearly with the number of facts in the input batch. In line with this observation, the number of inferred facts increases linearly with the batch size.
<figure><img src="image_7.png" /><figcaption>**Fig. 4.** *Left:* Reasoning Time vs. batch size. *Right:* Number of inferred facts vs. batch size for the inversion rule set.</figcaption></figure>

*Relation Frequency.* Furthermore, the relation of the facts to be inferred depends on the predicates that occur in the head atom of the rule. Therefore, the reasoning module increases the frequency of facts corresponding to the head atoms. This is shown in Fig. 5 for the hierarchy, inversion and symmetry programs.

<figure><img src="image_8.png" /><figcaption>**Fig. 5.** Number of facts added per relation type vs. batch size for the hierarchy (left), inversion (right) programs on Family.</figcaption></figure>

*Fact duplication and leakage.* It may happen that the reasoner infers a fact that is already contained in another batch of the training set. In this case, the inferred fact would not be an implicit fact, but an explicit fact in another batch. Across all batches, this fact would contribute to the loss calculation several times, thus increasing the importance of the fact for the gradient updates.

Potentially, the reasoner could infer facts that are in the test set and violate the disjointness of the training, validation, and test sets. In this case, the reasoner would *leak* test data at the training stage. The magnitude of this problem is investigated in Fig. 6. It can be seen that the number of redundant facts in the train set decreases with increasing batch size, which is expected. If the reasoner
considers the entire training graph, it cannot reason about facts in other batches. The number of leaked facts of the train and the test set increases with the batch size, because more facts are inferred for a larger batch size. However, in this observed case the problem is minor (~50 leaked test facts per 2,000 facts). An approach to address this is to filter inferred test facts at training from the test set.

<figure><img src="image_9.png" /><figcaption>**Fig. 6.** Number of redundant facts vs. percentage of missing facts for batch size 512 for the train, valid and test set (left) and number of redundant facts vs. batch size for the train, valid and test set (right) for the inversion rule set.</figcaption></figure>

# 6 Conclusion

We introduce the neuro-symbolic method OntoKGE, which combines knowledge graph embedding training with a symbolic reasoning component based on Datalog. Given an incomplete knowledge graph, OntoKGE allows to dynamically infer new positive facts during training and to incorporate them into the loss computation and gradient updates. In this way, implicit facts that are encoded as prior knowledge or in an ontology, are made explicit and injected into the knowledge graph embeddings training. Experiments on different benchmarks and with multiple Datalog programs show that OntoKGE can be helpful in learning more meaningful knowledge graph embedding models for link prediction across different embedding models. Some interesting future work involves adapting OntoKGE to graphs that contain noise.

**Supplemental Material Statement.** The source code of the experiments and OntoKGE is publicly available as anonymous GitHub (see Section 5). The supplementary material contains additional experimental details such as the hyperparameters, the Datalog programs for the Freebase experiments, statistics of the datasets, hardware details and a visualization of the link prediction results.
References

1. Web ontology language (owl). https://www.w3.org/OWL/, accessed: 2023-03-20

2. Abboud, R., Ceylan, I., Lukasiewicz, T., Salvatori, T.: Boxe: A box embedding model for knowledge base completion. In: Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., Lin, H. (eds.) Advances in Neural Information Processing Systems. vol. 33, pp. 9649–9661. Curran Associates, Inc. (2020), https://proceedings.neurips.cc/paper_files/paper/2020/file/6dbbe6abe5f14af882ff977fc3f35501-Paper.pdf

3. Ali, M., Berrendorf, M., Hoyt, C.T., Vermue, L., Galkin, M., Sharifzadeh, S., Fischer, A., Tresp, V., Lehmann, J.: Bringing light into the dark: A large-scale evaluation of knowledge graph embedding models under a unified framework. IEEE Transactions on Pattern Analysis and Machine Intelligence 44(12), 8825–8845 (Dec 2022). https://doi.org/10.1109/tpami.2021.3124805, http://dx.doi.org/10.1109/TPAMI.2021.3124805

4. Baader, F., Horrocks, I., Lutz, C., Sattler, U.: An Introduction to Description Logic. Cambridge University Press (2017). https://doi.org/10.1017/9781139025355

5. Biega, J., Kuzey, E., Suchanek, F.: Inside yago2s: a transparent information extraction architecture. pp. 325–328 (05 2013)

6. Bollacker, K., Evans, C., Paritosh, P., Sturge, T., Taylor, J.: Freebase: A collaboratively created graph database for structuring human knowledge. In: Proceedings of the 2008 ACM SIGMOD International Conference on Management of Data. p. 1247–1250. SIGMOD ’08, Association for Computing Machinery, New York, NY, USA (2008). https://doi.org/10.1145/1376616.1376746, https://doi.org/10.1145/1376616.1376746

7. Bordes, A., Glorot, X., Weston, J., Bengio, Y.: A semantic matching energy function for learning with multi-relational data. Machine Learning (2013), to appear

8. Bordes, A., Usunier, N., Garcia-Duran, A., Weston, J., Yakhnenko, O.: Translating embeddings for modeling multi-relational data. In: Burges, C., Bottou, L., Welling, M., Ghahramani, Z., Weinberger, K. (eds.) Advances in Neural Information Processing Systems. vol. 26. Curran Associates, Inc. (2013), https://proceedings.neurips.cc/paper_files/paper/2013/file/1cecc7a77928ca8133fa24680a88d2f9-Paper.pdf

9. Cadoli, M., Palopoli, L., Lenzerini, M.: Datalog and description logics: Expressive power. In: Proceedings of the 6th International Workshop on Database Programming Languages. p. 281–298. DBLP-6, Springer-Verlag, Berlin, Heidelberg (1997)

10. Chen, J., Geng, Y., Chen, Z., Horrocks, I., Z. Pan, J., Chen, H.: Knowledge-aware zero-shot learning: Survey and perspective. In: Zhou, Z.H. (ed.) Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, IJCAI-21. pp. 4366–4373. International Joint Conferences on Artificial Intelligence Organization (8 2021). https://doi.org/10.24963/ijcai.2021/597, https://doi.org/10.24963/ijcai.2021/597, survey Track

11. Cheng, K., Yang, Z., Zhang, M., Sun, Y.: UniKER: A unified framework for combining embedding and definite horn rule reasoning for knowledge graph inference. In: Moens, M.F., Huang, X., Specia, L., Yih, S.W.t. (eds.) Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing. pp. 9753–9771. Association for Computational Linguistics, Online and Punta Cana, Dominican Republic (Nov 2021). https://doi.org/10.18653/v1/2021.emnlp-main.769, https://aclanthology.org/2021.emnlp-main.769
12. Cimiano, P., Paulheim, H.: Knowledge graph refinement: A survey of approaches and evaluation methods. Semant. Web 8(3), 489–508 (jan 2017). https://doi.org/10.3233/SW-160218, https://doi.org/10.3233/SW-160218

13. Galarraga, L.A., Teflioudi, C., Hose, K., Suchanek, F.: Amie: association rule mining under incomplete evidence in ontological knowledge bases. In: Proceedings of the 22nd International Conference on World Wide Web. p. 413–422. WWW ’13, Association for Computing Machinery, New York, NY, USA (2013). https://doi.org/10.1145/2488388.2488425, https://doi.org/10.1145/2488388.2488425

14. Han, C., He, Q., Yu, C., Du, X., Tong, H., Ji, H.: Logical entity representation in knowledge-graphs for differentiable rule learning (2023)

15. Hogan, A., Blomqvist, E., Cochez, M., D'amato, C., Melo, G.D., Gutierrez, C., Kirrane, S., Gayo, J.E.L., Navigli, R., Neumaier, S., Ngomo, A.C.N., Polleres, A., Rashid, S.M., Rula, A., Schmelzeisen, L., Sequeda, J., Staab, S., Zimmermann, A.: Knowledge graphs. ACM Computing Surveys 54(4), 1–37 (Jul 2021). https://doi.org/10.1145/3447772, http://dx.doi.org/10.1145/3447772

16. Hustadt, U., Motik, B., Sattler, U.: Reasoning in description logics by a reduction to disjunctive datalog. Journal of Automated Reasoning 39(3), 351–384 (2007). https://doi.org/10.1007/s10817-007-9080-3, https://doi.org/10.1007/s10817-007-9080-3

17. Ji, S., Pan, S., Cambria, E., Marttinen, P., Yu, P.S.: A survey on knowledge graphs: Representation, acquisition, and applications. IEEE Transactions on Neural Networks and Learning Systems 33(2), 494–514 (Feb 2022). https://doi.org/10.1109/tnnls.2021.3070843, http://dx.doi.org/10.1109/TNNLS.2021.3070843

18. Klyne, G., Carroll, J.J.: Resource description framework (rdf): Concepts and abstract syntax. W3C Recommendation (2004), http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/

19. Kok, S., Domingos, P.: Statistical predicate invention. In: Proceedings of the 24th International Conference on Machine Learning. p. 433–440. ICML ’07, Association for Computing Machinery, New York, NY, USA (2007). https://doi.org/10.1145/1273496.1273551, https://doi.org/10.1145/1273496.1273551

20. Krötzsch, M., Rudolph, S., Schmitt, P.H.: A closer look at the semantic relationship between datalog and description logics. Semantic Web 6(1), 63–79 (2015). https://doi.org/10.3233/SW-130126, https://doi.org/10.3233/SW-130126

21. Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S., Scarcello, F.: The DLV system for knowledge representation and reasoning. ACM Transactions on Computational Logic 7(3), 499–562 (jul 2006). https://doi.org/10.1145/1149114.1149117, https://doi.org/10.1145/2F1149114.1149117

22. Liben-Nowell, D., Kleinberg, J.: The link prediction problem for social networks. In: Proceedings of the Twelfth International Conference on Information and Knowledge Management. p. 556–559. CIKM ’03, Association for Computing Machinery, New York, NY, USA (2003). https://doi.org/10.1145/956863.956972, https://doi.org/10.1145/956863.956972

23. Meij, E.: Understanding news using the bloomberg knowledge graph. invited talk at the big data innovators gathering (thewebconf). https://www.linkedin.com/blog/engineering/knowledge/building-the-linkedin-knowledge-graph (2019)
24. Miller, G.A.: Wordnet: A lexical database for english. Commun. ACM 38(11), 39-41 (nov 1995). https://doi.org/10.1145/219717.219748, https://doi.org/10.1145/219717.219748

25. Rossi, A., Barbosa, D., Firmani, D., Matinata, A., Merialdo, P.: Knowledge graph embedding for link prediction: A comparative analysis. ACM Transactions on Knowledge Discovery from Data 15(2), 1-49 (Jan 2021). https://doi.org/10.1145/3424672, http://dx.doi.org/10.1145/3424672

26. Schlichtkrull, M., Kipf, T.N., Bloem, P., van den Berg, R., Titov, I., Welling, M.: Modeling relational data with graph convolutional networks. In: Gangemi, A., Navigli, R., Vidal, M.E., Hitzler, P., Troncy, R., Hollink, L., Tordai, A., Alam, M. (eds.) The Semantic Web. pp. 593-607. Springer International Publishing, Cham (2018)

27. Sun, Z., Deng, Z.H., Nie, J.Y., Tang, J.: Rotate: Knowledge graph embedding by relational rotation in complex space (2019)

28. Teach, Y.C., Ruffinelli, D., Broscheit, S., Gemulla, R.: You can teach an old dog new tricks! on training knowledge graph embeddings. In: International Conference on Learning Representations (2020), https://api.semanticscholar.org/CorpusID: 211241737

29. Ullman, J.D.: Principles of Database and Knowledge-Base Systems, Volume I. Computer Science Press, Rockville, MD (1980)

30. Wang, H., Zhang, F., Xie, X., Guo, M.: Knowledge graph convolutional networks for recommender systems. In: Proceedings of the 28th International Conference on World Wide Web. pp. 3307-3313. ACM (2019)

31. Wang, Q., Mao, Z., Wang, B., Guo, L.: Knowledge graph embedding: A survey of approaches and applications. IEEE Transactions on Knowledge and Data Engineering 29(12), 2724-2743 (2017). https://doi.org/10.1109/TKDE.2017.2754499

32. West, R., Gabrilovich, E., Murphy, K., Sun, S., Gupta, R., Lin, D.: Knowledge base completion via search-based question answering. In: Proceedings of the 23rd International Conference on World Wide Web. p. 515-526. WWW '14, Association for Computing Machinery, New York, NY, USA (2014). https://doi.org/10.1145/2566486.2568032, https://doi.org/10.1145/2566486.2568032

33. Yang, B., tau Yih, W., He, X., Gao, J., Deng, L.: Embedding entities and relations for learning and inference in knowledge bases (2015)

34. Zeng, Z., Cheng, Q., Si, Y.: Logical rule-based knowledge graph reasoning: A comprehensive survey. Mathematics 11(21) (2023). https://doi.org/10.3390/math11214486, https://www.mdpi.com/2227-7390/11/21/4486

35. Zitnik, M., Agrawal, M., Leskovec, J.: Modeling polypharmacy side effects with graph convolutional networks. Bioinformatics 34(13), i457-i466 (2018)
# A Additional Experimental Details

## A.1 Datalog Programs

The Datalog programs used in the experiments on Freebase for **Q1** are defined as follows:

<figure><img src="image_10.png" /></figure>

## A.2 Link Prediction Results

The results obtained on the link prediction task **Q1** and visualized for Wordnet (inversion) in Fig. A.2, Wordnet (symmetry) in Fig. A.2, Family (symmetry) in Fig. A.2, Family (inversion) in Fig. A.2 and Family (hierarchy) in Fig A.2.

<figure><img src="image_11.png" /><figcaption>Fig. 7. Link prediction results on Wordnet (inversion)</figcaption></figure>
<figure><img src="image_12.png" /><figcaption>Fig. 8. Link prediction results on Wordnet (symmetry)</figcaption></figure>

<figure><img src="image_13.png" /><figcaption>Fig. 9. Link prediction results on Family (symmetry)</figcaption></figure>
<figure><img src="image_14.png" /><figcaption>**Fig. 10.** Link prediction results on Family (inversion)</figcaption></figure>

<figure><img src="image_15.png" /><figcaption>**Fig. 11.** Link prediction results on Family (hierarchy)</figcaption></figure>

## A.3 Hardware

All experiments are conducted on a machine running an Ubuntu 20.4 equipped with an Intel(R) Xeon(R) Silver 4114 CPU 2.20GHz processor, 192G of RAM and two Nvidia Quadro P5000 GPUs.
## A.4 Hyperparameters and Dataset Details

Tab. A.4 gives an overview of the datasets used in the experiments with On-toKGE. Tab. 6 contains the hyperparameters.

<table><caption>**Table 5.** Overview of the Datasets</caption><thead><tr><th>Dataset</th><th>Entities</th><th>Relations</th><th>Train</th><th>Valid</th><th>Test</th></tr></thead><tbody><tr><td>FB15k-237</td><td>14,541</td><td>237</td><td>272,115</td><td>17,535</td><td>20,466</td></tr><tr><td>Family</td><td>3,007</td><td>12</td><td>5,868</td><td>2,038</td><td>2,838</td></tr><tr><td>WN18RR</td><td>40,943</td><td>18</td><td>141,442</td><td>5,000</td><td>5,000</td></tr></tbody></table>

<table><caption>**Table 6.** Training hyperparameters for R1</caption><thead><tr><th>Hyperparameter</th><th>Value</th></tr></thead><tbody><tr><td>Batch size</td><td>1024</td></tr><tr><td>Embedding dimension</td><td>200</td></tr><tr><td>Epochs</td><td>300</td></tr><tr><td>Early stopping</td><td>Yes</td></tr><tr><td>Early stopping delta</td><td>0</td></tr><tr><td>Early stopping patience</td><td>50</td></tr><tr><td>Learning rate</td><td>0.001</td></tr><tr><td>Optimizer</td><td>Adam</td></tr><tr><td>Triples dropped</td><td>0.25</td></tr><tr><td>Loss function (DistMult, RGCN)</td><td>BCEWithLogitsLoss</td></tr><tr><td>Loss function (others)</td><td>MarginRankingLoss</td></tr></tbody></table>