# Research of Personalized Recommendation Technology Based on Knowledge Graphs
## 4 Movie Recommendation Model Based on Knowledge Graph Representation Learning
### KG-BPR Recommend Model  
This paper proposes a movie recommendation algorithm that combines knowledge graphs and Bayesian Personalized Ranking (BPR), referred to as KG-BPR. BPR is a personalized recommendation model based on ranking learning [33, 34, 35]. It is an improvement of the matrix factorization algorithm. It mainly models the relative preference ranking of two different items, and obtains the user feature matrix and item feature matrix through the user-item ranking data. The flow chart of the KG-BPR model is shown in Figure 9. First, we use the improved TransE representation learning method to obtain the entity vector and relation vector corresponding to the knowledge graphs. Then, we integrate the movie entity vector matrix into the BPR model, that is, by introducing the external hidden information of the movie to assist the generation of feature matrix based on user-behavior data. Finally, we can get the model parameters based on the maximum posterior estimation, that is, the user feature matrix and the movie feature matrix. After the model training is completed, the user's preference value for the movie is obtained through the two generated matrices and the movie entity vector matrix. The movie recommendation list is generated according to the value, and each user can get the recommended movies. We use \(V\) to represent the embedding vector matrix obtained by the representation learning model. The size of \(V\) is \(n*k\), where \(n\) is the number of movies and \(k\) is the dimension of the embedding vector. First, we construct a set of \((u,i,j)\) triples, which means that for user \(u\), their interest in movie \(i\) is greater than their interest in movie \(j\). These sets of triples are the data sets required for KG-BPR model training, and are denoted by \(D\) in the following. In addition, we need to make two assumptions about these data. First, each user's preference behavior is independent of each other, that is, whether user \(u\) likes movie \(i\) or movie \(j\) has nothing to do with other users. Second, the partial order of the same user for different movies is independent of each other, that is, whether user \(u\) likes movie \(i\) or movie \(j\) has nothing to do with other movies. After that, the KG-BPR model uses the idea of matrix decomposition to decompose the user-movie prediction ranking matrix \(X\) generated by the above steps. Furthermore, it combines the movie entity vector \(V\) to obtain the user feature matrix \(P\) and the movie feature matrix \(Q\). Among them, the embedding dimensions of these matrices are consistent. We assume that there are \(m\) users and \(n\) movies in the data set, and the dimension of the feature matrix is \(k\). Then, the size of the user feature matrix is \(m*k\). The size of the movie feature matrix is \(n*k\), as is shown in Formula (14). \[X=P_{m*k}(Q_{n*k}+V_{n*k})^{T} \tag{14}\]  
At the same time, the preference of user \(u\) for movie \(i\) is calculated as shown in Formula (15). \[x_{ui}=p_{u}\bullet(q_{i}+v_{i})=\sum_{f=1}^{k}p_{uf}(q_{if}+v_{if}) \tag{15}\]  
Among them, \(p_{u}\) represents the \(u\)-th row of the user feature matrix \(P\), that is, the potential feature vector of user \(u\). \(q_{i}\) represents the \(i\)-th row of the movie feature matrix \(Q\), that is, the potential feature vector of movie \(i\). \(v_{i}\) represents the entity vector of movie \(i\) generated by the improved TransE model. The KG-BPR model uses the maximum posterior estimation to solve the model parameters, namely the matrix \(P\) and the matrix \(Q\). For convenience, we use \(\theta\) to represent  
Figure 9: KG-BPR model recommendation flowchart. parameters \(P\) and \(Q\). According to Bayesian formula, the model optimization goal is shown in Formula (16).