# CKGAT: Collaborative Knowledge-Aware Graph Attention Network for Top-N Recommendation
## 4 Proposed CKGAT Method
### Knowledge-Aware GAT-Based Attentive Embedding Layer  
As aforementioned, to generate the ripple set embeddings, the RippleNet framework [23] adopts the user preference propagation module, whereas the CKAN method [4] adopts the attentive network. However, these methods ignore the complex relations between entities in the multi-hop ripple sets, leading to inaccurate ripple set embeddings. This will affect the accuracy of the user/item embedding, and ultimately will affect the accuracy of the captured user's potential interest. In order to more accurately capture the user's potential interest, CKGAT adopts a knowledge-aware graph attention network to generate the ripple set embeddings. More specifically, on the basis of the graph attention network [35], we construct the knowledge-aware graph attention network by additionally exploiting the embeddings of the relations between entities. As shown in Figure 1, the knowledge-aware GAT-based attentive embedding layer uses the knowledge-aware graph attention network to capture the topological proximity structures of the entities in the multi-hop ripple sets and learn the high-order entity representations, thereby generating the ripple set embeddings. More specifically, this layer consists of the following four steps. The first step is to obtain multiple neighboring head entities of the tail entity in each triple from the user's or the item's multi-hop ripple sets, thereby forming the neighboring entity sets. Assuming that the input of the knowledge-aware graph attention network is the ripple set \(\mathcal{S}_{o}^{l},l=1,2,\ldots,L\), where the unified placeholder \(o\) represents the user \(u\) or the item \(v\), and the corresponding extended entity set of \(\mathcal{S}_{o}^{l}\) is \(\mathcal{E}_{o}^{l}\). The knowledge-aware graph attention network acquires the \(K\) neighboring head entities of each tail entity \(t_{o}\in\mathcal{E}_{o}^{l}\) of each triple in \(\mathcal{S}_{o}^{l}\) to form the neighboring entity set \(\mathcal{N}(t_{o})\), with the hyperparameter \(K=|\mathcal{N}(t_{o})|\). The neighboring entity set is defined in Equation (6). \[\mathcal{N}(t_{o})=\Big{\{}h_{o}^{k}\ |\ h_{o}^{k}\in\mathcal{E}_{o}^{l-1}\ \text{and}\ \Big{(}h_{o}^{k},r_{o}^{k},t_{o}\Big{)}\in\mathcal{S}_{o}^{l}\Big{\}},k=1,2, \ldots,K \tag{6}\]  
The second step is to learn the neighborhood representation of the tail entity \(t_{o}\in\mathcal{E}_{o}^{l}\) based on the obtained neighboring entity set. As shown in Figure 2, let the embedding of each neighboring head entity \(h_{o}^{k}\in\mathcal{N}(t_{o})\) be \(\mathbf{e}_{h_{o}^{k}},k=1,2,\ldots,K\). The knowledge-aware graph attention network first uses the triple \(\Big{(}h_{o}^{k},r_{o}^{k},t_{o}\Big{)}\in\mathcal{S}_{o}^{l}\) to learn a score \(\pi^{k}\), and normalize the score to obtain the weight \(\tilde{\pi}^{k}\). Then, the network performs weighted aggregation on the embedding \(\mathbf{e}_{h_{o}^{k}}\) of each neighboring head entity to obtain the neighborhood representation \(\mathbf{e}_{\mathcal{N}(t_{o})}\) of the entity \(t_{o}\). The above process is defined in Equation (7). \[ \begin{split}\pi^{k}&=\text{LeakyReLU}\Big{(}\mathbf{ w}_{1}^{\top}\Big{[}\mathbf{W}_{1}\mathbf{e}_{h_{o}^{k}}||\mathbf{W}_{1} \mathbf{e}_{o}||\mathbf{W}_{1}\mathbf{e}_{t_{o}}\Big{]}\Big{)}\\ \pi^{k}&=\frac{\exp\Big{(}\pi^{k}\Big{)}}{\sum_{h_{o} ^{k}\in\mathcal{N}(t_{o})}\exp\big{(}\pi^{k^{\prime}}\big{)}}\\ &\mathbf{e}_{\mathcal{N}(t_{o})}=\sum_{k=1}^{K}\tilde{\pi}^{k} \mathbf{e}_{h_{o}^{k}}\end{split}  \tag{7}\]  
where LeakyReLU is a type of activation function based on a ReLU; this activation function can assign a non-zero slope to all negative values. The parameters \(\mathbf{w}_{1}\in\mathbb{R}^{3d}\) and \(\mathbf{W}_{1}\in\mathbb{R}^{d\times d}\) are a weight vector and a weight matrix, respectively, that are determined through parameter learning.