# Knowledge Graph Double Interaction Graph Neural Network for Recommendation Algorithm
## 3 Definition of Recommended Questions  
In a typical recommendation scenario, we have a set of M users \(U=\{u_{1},u_{2},\ldots,u_{M}\}\) and a set of N items \(V=\{v_{1},v_{2},\ldots,v_{N}\}\). Existing user-item interaction matrix \(Y\in R^{M*N}\). The matrix is defined according to the implicit feedback information of the user, and \(y_{uv}=1\) indicates that user \(u\) interacted with item \(v\), such as scoring or purchasing. This recommendation method extracts user features based on their historical behavioral data, so it requires implicit feedback datasets.  
\[Y=\{y_{uv}|u\in U,v\in V\},y_{uv}=\left\{\begin{array}{l}1,u\text{ and }v\text{ have interacted}\\ 0,u\text{ and }v\text{ have not interacted}\end{array}\right., \tag{1}\]  
Existing knowledge graph \(G\) is a directed graph in the form of a triple \((h,r,t)\), where \(h,t\in E\), and \(r\in R\) denote the head entity, tail entity, and relation, where \(E\) and \(R\) are the set of entities and relations in the knowledge graph, respectively. For example, the triple (_Farewell My Concubine_, Director, [PERSON]) means that the director of _Farewell My Concubine_ is [PERSON]. In many recommendation scenarios, each item \(v\in V\) corresponds to some entity \(e\in E\) on the knowledge graph, but not all entities \(e\) have items \(v\) corresponding to them, so the set of items \(V\) can be seen as a subset of the set of entities \(E\), i.e., \(V\subseteq E\).  
Since the number of directly adjacent entities of each entity in the actual knowledge graph is unequal, in order to ensure that the computational dimension of each batch is fixed, we randomly sample a fixed-size number of neighbors for each entity.  
The sampling process is from the inside out, as shown in Figure 2, where small circles represent entities, the central entity denotes the item whose features are to be extracted, the black entities represent entities that are sampled, the white entities represent entities that are not sampled, and \(h\) represents the depth of traversal on the knowledge graph, and the sampling steps are as follows:  
(1) Randomly select a central node \(v\);  
(2) Find the entity set \(N(v)\) directly connected to the central node \(v\), and count the number \(n(v)\) of entities in \(N(v)\). Compare with the size of \(n(v)\) and the number of samples \(K\): if \(n(v)<K\), select k entities in \(N(v)\) (neighbors can be repeated) to form a sampled entity set \(S(v)\); if \(n(v)\geq K\), select an entity without replacement in \(N(v)\) to form a sampling set.  
Based on the existing user-item interaction matrix \(Y\),with the knowledge graph \(G\) used as auxiliary information, the model aims to predict whether user \(u\) has potential interest in item \(v\) that they have not interacted with before. The ultimate goal to learn the prediction function is  
\[\hat{y}_{uv}=F(u,v|\theta,Y,G),\]  
Figure 2: The process of graph sampling.  
where \(\hat{y}_{uv}\) denotes the probability of user \(u\) engage in item \(v\), and \(F\) denotes the model parameters of the function, which mainly include entity embedding, relation embedding, weight matrix used for aggregation, and offset vector.