## 3 Methodology
### Quaternion for Link Prediction  
The KG consists of a set of entities \(E\) and a set of relations \(R\), which are stored in the database as a series of triples \((h,r,t)\subseteq E\times R\times E\), where \(h\in E\) and \(t\in E\) are the head and tail entities in the triples, respectively, and \(r\in R\) are the relations in the triples. Each triple represents a fact in the KG, indicating that the head entity is connected to the tail entity by the relation, which can be denoted as \(h\xrightarrow{r}t\). To better express the semantic meaning of entities and relations, triples in the graph embedding problem are represented as a combination of three \(d\)-dimensional vectors \((e_{h},e_{r},e_{t})\), where \(e_{h}\in E^{d}\) and \(e_{t}\in E^{d}\) denote the embedding of the head and tail entities, respectively, and \(e_{r}\in R^{d}\) denotes the embedding of the relations. The link prediction task aims to discover the missing links between entities in the KG and is therefore considered to play an important role in KG completion. Each triple is assigned a score, which represents the likelihood that the triple is a true fact. Higher scores indicate that the triple is closer to the true fact. The essence of link prediction is to construct a scoring function that accurately expresses the degree of truth. Given an incomplete triple \((e_{h},e_{r},? )\) or \((?,e_{r},e_{t})\), we need to find the correct head or tail entity. In this paper, we calculate the score as \begin{table}
\begin{tabular}{l l} \hline \hline
**Symbol** & **Description** \\ \hline \(h,r,t\) & Head entity, relation, and tail entity in a KG triple \\ \(e_{h},e_{r},e_{t}\) & Embeddings of \(h,r\), and \(t\), respectively \\ \(e_{s}\) & Embeddings of the source entity in a given incomplete triple \\ \(\ell_{s}^{j}\) & Embeddings of the predicted entity obtained by quaternion transform \\ \(e_{sec},e_{thr},e_{for}\) & Embeddings of the second-hop, third-hop, and fourth-hop neighbors \\ \(e_{fs},e_{fr}\) & Embeddings of the first-hop neighbor’s entity and relation \\ \(CLS_{0},CLS_{1},CLS_{f},CLS_{aut}\) & Different flag vectors \\ \(CLS_{0}^{\prime},CLS_{1}^{\prime},CLS_{f}^{\prime},CLS_{aut}^{\prime}\) & Output of \(CLS_{0},CLS_{1},CLS_{f}\), and \(CLS_{out}\) \\ \(T_{r}\) & A multi-head Transformer for relation instantiation \\ \(T_{n}\) & A multi-head Transformer for quaternion space rotation \\ \(T_{m}\) & A multi-head Transformer for geometric decoding \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notations used in this paper. Figure 1: General architecture of RiQ-KGC, which includes three modules: Relation Instantiation, Quaternion Space Rotation, and Geometric Decoding. \[e_{t}=\operatorname*{arg\,max}_{i\in E}\phi(e_{s},e_{r},e_{i}) \tag{1}\]  
where the known entity in the triple is referred to as the source entity \(e_{s}\) and the entity to be predicted is called the target entity \(e_{t}\). Following [PERSON] [45], we unify the prediction tasks as \((e_{s},e_{r},e_{t})\), where \(e_{s}\) can be either the head entity or the tail entity in the triple, and two different sets of \(e_{r}\) are used to distinguish between the head entity prediction task and the tail entity prediction task. We initialize \(n_{e}\) vectors to represent entities and \(2n_{r}\) vectors to represent relations for the datasets containing \(n_{e}\) entities and \(n_{r}\) relations. In RiQ-KGC, entities are distributed in quaternion space, and relations are represented as transformation patterns of the entities. Quaternion is a hyper-complex system introduced by [PERSON] (Holland, OH, USA). A quaternion \(Q\) consists of a scalar \(q_{0}\) and a set of vectors \(q=(q_{1},q_{2},q_{3})\), which can be represented as \(Q=q_{0}+q=q_{0}+q_{1}i+q_{2}j+q_{3}k\), where \(i\), \(j\), and \(k\) denote the unit vectors on the \(x\)-, \(y\)-, and \(z\)-axis, respectively. They satisfy \(i^{2}=j^{2}=k^{2}=i\cdot j\cdot k=-1\), so that a quaternion can be represented as a quaternion \((q_{0},q_{1},q_{2},q_{3})\).