# Research of Personalized Recommendation Technology Based on Knowledge Graphs
## 4 Movie Recommendation Model Based on Knowledge Graph Representation Learning
### TransE Algorithm Improvement
#### 4.1.3 Training Process Improvement  
We introduce the idea of network feature structure learning into the TransE algorithm. We use the method of hybrid feature learning. Furthermore, we use the feature struc \begin{table}
\begin{tabular}{c c c} \hline \hline
**Relation Type** & **Condition** & **Extraction Method** \\ \hline One to many & \(M1\geq 1.5\) and \(M2<1.5\) & The negative triple generated by replacing the tail entity is more likely to be a positive example, so the head entity is replaced with a greater probability P. The tail entity is replaced with a smaller probability \(1-P\). \\ Many to one & \(M1<1.5\) and \(M2\geq 1.5\) & The negative triple generated by replacing the head entity is more likely to be a positive example, so replace the tail entity with a greater probability \(P\). The head entity is replaced with a smaller probability \(1-P\). \\ Many to many & \(M1\geq 1.5\) and \(M2\geq 1.5\) & Consider the number of head entities and tail entities. Replace position entities with a small number. \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Sampling methods for different relation mapping types. ture information of entities in the knowledge graphs to improve the overall effect of the TransE model. First, we build a three-layer neural network. The input of the neural network is the neighbor entity set and relation set of a specific entity. Through the middle projection layer, we sum the input information and output our target entity. The specific model structure of the neural network is shown in Figure 8.  
Among them, the input (\(h1\), \(r1\)) (\(h2\), \(r2\)) (\(h3\), \(r3\))... are all entities and relations connected to a specific entity. The summation formula of the projection layer is shown in Formula (4). The intermediate vector \(X_{t}\) generated by the projection layer is used as the representation vector of the adjacency structure we have learned. \[X_{t}=\sum_{(h,r)\in N(t)}V(h)+V(r) \tag{4}\]  
The feature learning of the neighbor structure takes the prediction probability as the learning objective. The loss function is shown in Formula (5), where \(E\) represents the set of entities in the knowledge graphs, and \(N(t)\) represents the adjacent structure information of the specific entity node \(t\), that is, the input data of the neural network. \[L_{t}=\sum_{t\in E}\log p(t\mid N(t)) \tag{5}\]  
We use softmax to calculate the probability in the loss function. The calculation formula is shown in Formula (6). Among them, \(y(t)\) represents the un-normalized probability value of the entity \(t\), as shown in Formula (7). \(b\) and \(U\) are the parameters of softmax, which are constantly changing during the training of the model. \[p(t\mid N(t))=\frac{e^{y(t)}}{\sum_{e\in E}e^{y(e)}} \tag{6}\]  
\[y(t)=b+UX_{t} \tag{7}\]  
We mainly study the first-order neighbor information of each entity, that is, context information with a step length of 1. Then, on the basis of the TransE algorithm, we use the adjacent structure information of each entity as a supplement. We use a hybrid feature learning method to improve our model. The improved loss function is shown in Formula (8). Figure 8: Neural network model structure diagram. \[L=L_{1}+L_{TransE} \tag{8}\]  
Among them, \(L_{1}\) is the loss function of the above-mentioned neighbor structure feature learning. \(L_{TransE}\) is the loss function of the TransE model, as shown in Formula (9). \[L=\sum_{(h,r,l)\in S}\log p(t\mid N(t))+\sum_{(h,r,l)\in S(h^{\prime},r^{ \prime},l^{\prime})\in S^{\prime}(h,r,l)}\sum\max(0,f_{r}(h,t)+\gamma-f_{r}(h^ {\prime},l^{\prime})) \tag{9}\]  
Through the loss function, we can see that the improved algorithm has two parts. The first part uses the nearest neighbor vector to predict the target entity so that representation learning can make full use of the structural information in the knowledge graphs. The second part is the training process of the TransE algorithm. In order to allow them to share the representation vector, we adopt a cross-training mechanism of information sharing.