## 3 Methodology
### Quaternion for Link Prediction
In RiQ-KGC, both the entity embedding \(e_{s}=(e_{s0},e_{s1},e_{s2},e_{s3})\) and the relation embedding \(e_{r}=(e_{r0},e_{r1},e_{r2},e_{r3})\) consist of four parts. The dimension of each part is \(d/4\), while the embedding of entities and relations is still represented using \(d\)-dimensional vectors. Quaternions can express ideal parametric smooth rotations that are robust to noise and perturbations. Additionally, a quaternion is able to represent simultaneous rotations on three axes, unlike Eulerian rotation which rotates in a fixed order and can potentially lead to gimbal lock. [PERSON] [23] demonstrated the advantages of using a quaternion in link prediction, as it possesses similar properties to complex rotations, including the ability to model symmetry, anti-symmetry, and inversion. Furthermore, compared to complex rotation, which only allows a single plane of rotation, a quaternion has two planes and thus provides more degrees of freedom. In the traditional embedding method using quaternion, the relation is represented as a quaternion that describes a rotation pattern. Meanwhile, a source entity can be rotated by the relation using the Hamilton product (quaternion multiplication) as  
\[ \begin{split} e_{s}^{\prime}&=e_{s}\otimes e_{r}\\ &=(e_{s0}e_{r0}-e_{s1}e_{r1}-e_{s2}e_{r2}-e_{s3}e_{r3})\\ &+(e_{s0}e_{r1}+e_{s1}e_{r0}+e_{s2}e_{r3}-e_{s3}e_{r2})i\\ &+(e_{s0}e_{r2}-e_{s1}e_{r3}+e_{s2}e_{r0}+e_{s3}e_{r1})j\\ &+(e_{s0}e_{r3}+e_{s1}e_{r2}-e_{s2}e_{r1}+e_{s3}e_{r0})k\end{split}  \tag{2}\]  
This method enables interactions between different parts of the quaternion, leading to richer expressive power. For link prediction, the similarity between the resulting vector \(e_{s}^{\prime}\) obtained after rotating \(e_{s}\) and the target entity \(e_{t}\) is commonly used as a scoring function to evaluate the validity of a triple. The similarity between the two entities can be measured by computing the inner product of the corresponding quaternions as  
\[ \begin{split}\phi(e_{s},e_{r},e_{s}^{\prime})&=e_{s }^{\prime}\cdot e_{t}\\ &=\langle e_{s0}^{\prime},e_{t0}\rangle+\langle e_{s1}^{\prime}, e_{t1}\rangle+\langle e_{s2}^{\prime},e_{t2}\rangle+\langle e_{s3}^{\prime},e_{t3} \rangle\end{split}  \tag{3}\]  
The traditional method of quaternion embedding imposes a strict constraint on the embedding of entities. Specifically, it expects \(e_{s}^{\prime}\) to be equal to the \(e_{t}\) in the triple, which maximizes the objective function \(\phi(e_{s},e_{r},e_{s}^{\prime})\). Nevertheless, in reality, each entity might be rotated by numerous other entities through different relations, and the constraint imposed by numerous neighboring entities can lead to a Pareto optimal scenario for the final embedding position of the entity. In such a scenario, the objective is to ensure that each true triple containing a score is as high as possible, rather than aiming to make each of them achieve the highest score. However, this constraint can have a significant impact on the model performance, particularly when the entities are more densely distributed. Figure 2 shows how RiQ-KGC leverages a large number of parameters to establish a mapping relation between \(e_{s}^{\prime}\) and \(e_{t}\), enabling the deep learning network to capitalize on its powerful fitting ability, while still retaining the interpretability advantages of the geometric approach. Additionally, we utilize Transformer to incorporate contextual information and enable the model to more accurately capture the entity's information with the increase in knowledge.