## 3 Methodology
### Embedded Learning Model Construction  
Knowledge embedded learning represents entities and relations as low-dimensional real value vectors to efficiently compute the entities, relations and complex semantic associations among them, while KG utilizes triplets (head entity, relation, tail entity), where nodes represent entities and edges represent relations. Building embedded learning model consists of the following steps:  
1. Utilizing Continuous vector Spaces to represent entities and relations, and relations are often regarded as operations in vector Spaces;
2. Defining a score function or loss function to measure the rationality of knowledge;
3. Learning the entities and relations embedded by maximizing the rationality of global observation knowledge.  
The difference between different embedded learning models lies in the setting of score functions and the associations expression between entities and relation. In this paper, three mature embedded learning models including RotatE, DistMult and ComplEx are taken as verification objects for the proposed method. The DistMult model assumes that the relation is symmetric, which reduces the computational complexity and is suitable for large-scale KG completion and construction. ComplEx model introduced complex-valued vectors, and the triplet score was calculated by the complex-valued dot product. The real part of the complex-valued vector was symmetric and the imaginary part was asymmetric, so that it could be used to model the symmetric/antisymmetric relation. The RotatE model is based on the idea of complex valued vectors, modeling relations as rotations in complex vector space, so as to effectively model and infer various complex relation modes such as symmetry/antisymmetry, synthesis and inversion. For example, the DistMult model calculates the product of elements between entities and relational vectors as a score or distance function, expressed as:  
\[d_{r-DistMult}(h,t)=\langle h,r,t\rangle \tag{4}\]  
The ComplEx model takes the conjugation of the inner product of the entity and the relational complex vector as the scoring function:  
\[d_{r-ComplEx}(h,t)=RE(\langle h,r,t\rangle) \tag{5}\]  
RotatE model defines relations as rotations in complex vector space, which focuses on the complex relation completion task. According to the existing literature, three types of relation patterns are very important and widely spread in KGs: symmetry, inversion and composition. The RotatE model calculates the product difference between the two elements as a scoring function:  
\[d_{r-RotatE}(h,t)=\|h\circ r-t\| \tag{6}\]  
By defining each relation as a rotation in the complex vector spaces, RotatE can model and infer all the three types of relation patterns introduced above.  
Loss function is the core of model training, which measures the difference between the predicted value and the actual value so as to guide the algorithm optimization direction. In this paper, knowledge constraints based on logical rules are introduced to guide the model to deduce the optimal result. Taking RotatE model as an example, adding a penalty term on the basis of its existing loss function, the loss function obtained is as follows:  
\[L=-\log\sigma(\gamma-d_{r}(h,t))-\sum_{i=1}^{n}p\big{(}h^{\prime}_{i},r,t^{ \prime}_{i}\big{)}\log\sigma\big{(}d_{r}\big{(}h^{\prime}_{i},t^{\prime}_{i} \big{)}-\gamma\big{)}-P \tag{7}\]where \(\sigma\) is the sigmoid activation function, \(d_{r}(h,t)\) and \(d_{r}(h^{\prime}_{i},t^{\prime}_{i})\) are the distance functions in the positive and negative samples, respectively, \(\gamma\) is the fixed deviation, and P is the constant of the penalty term embedded based on logical rules, usually a larger value.