## 4 Methodology
### Heterogenous Graph Multi-Level View Encoder Network
#### 4.1.1 Local-Level View Encoder  
Local-level mainly captures the collaborative information and semantic information of nodes through two complementary views. We use different encoding methods to embed the interaction view and semantic view individually to ensure that the embedded representation contains the complete content.  
**Interaction view Encoder.** Interaction view is mainly designed to capture collaborative information in the user behavior record graph, using the historical interaction connections between users and recipes as the basis for modeling. For the interaction view, the relationship of interaction behaviors is relatively single, and we consider an effective and efficient aggregation method for message aggregation and delivery. We choose the message propagation strategy of Light-GCN [16] for encoding, and its effective lightweight architecture can be well applied with user-recipe collaborative information collection. The specific form is as follows:  
\[\mathbf{x}_{u}^{(l+1)}=\sum_{r\in N_{u}}\frac{\mathbf{x}_{r}^{(l)}}{\sqrt{|N_{u}||N_{ r}|}};\mathbf{x}_{r}^{(l+1)}=\sum_{u\in N_{r}}\frac{\mathbf{x}_{u}^{(l)}}{\sqrt{|N_{r}| |N_{u}|}} \tag{2}\]  
where \(\mathbf{x}_{u}^{l}\) and \(\mathbf{x}_{r}^{l}\) are the embedding representations of user \(u\) and recipe \(r\) at layer \(l\). \(N_{u}\) and \(N_{r}\) denote the set of recipes \(r\) that interact with user \(u\) and the set of users connected to recipe \(r\), respectively. After that, we sum the embedded expressions for different layers as the output of the interaction view, as follows:  
\[e_{u}^{i}=x_{u}^{(0)}+\cdots+x_{u}^{(l)};e_{r}^{i}=x_{r}^{(0)}+\cdots+x_{r}^{(l )} \tag{3}\]  
where \(e_{u}^{i}\) and \(e_{r}^{i}\) are the node embedding containing the collaboration information after encoding by the interaction view.  
**Semantic View Encoder.** Semantic view is mainly designed to capture the semantic information between recipes and properties. The properties corresponding to recipes in recipe recommendations often contain nodes with multiple relationship types, such as: ingredients, tastes, cooking methods, etc. Inspired by the graph attention mechanism [7; 17], we use a relation-aware embedding layer to encode the semantic view as follows:  
\[x_{r}^{s}=\sigma\Bigg{(}\sum_{e\in N_{r}^{e}}\alpha_{e,r}\cdot x_{e}\Bigg{)} \tag{4}\]  
\[\alpha_{e,r}=\frac{\exp(\text{LeakyReLU}(\mathbf{\mathrm{a}}_{\mathbf{\gamma}}\cdot[ x_{e}\parallel x_{r}]))}{\sum_{e\in N_{r}^{e}}\exp(\text{LeakyReLU}(\mathbf{\mathrm{a}}_{\mathbf{ \gamma}}\cdot[x_{e}\parallel x_{r}]))} \tag{5}\]where \(\sigma\) is the nonlinear activation function, \(x_{e}\) is the entity embedding, and \(\alpha_{e,r}\) denotes the attention relevance of entities and relationships under different relationships. Additionally, \(\mathbf{a}_{\gamma}\) denotes the relation-aware attention vector, and \(N_{r}^{e}\) is the entity neighbor of different relationships connected to the recipe \(r\). In this manner we encode the semantic information that the recipe nodes contain multiple relationship entity types, which is important for us to determine the user's preferences for the recipes. After that we define the importance score \(w_{r,a}\) of the relationship to the node and normalize it as follows:  
\[\begin{split} w_{r,a}=\frac{1}{|V_{a}|}\sum\limits_{r\in V_{a}}q^ {\top}\cdot\tanh(\mathbf{W}_{s}x_{r}^{s}+\mathbf{b}_{s})\\ \beta_{r,a}=\frac{\exp(w_{r,a})}{\sum_{r=1}^{S}\exp(w_{r,a})} \end{split} \tag{6}\]  
where \(V_{a}\) denotes the set of nodes associated with relation a and \(q\) denotes the relational level attention vector. The matrix \(\mathbf{W}_{s}\) and the bias \(\mathbf{b}_{s}\) are parameters that can be learned. \(\beta_{r,a}\) can be regarded as the degree of contribution of the relation \(a\) to the recipe nodes, and \(S\) denotes the number of recipe vectors. Ultimately, we aggregate the recipe embedding of different relationships in the semantic view as follows:  
\[e_{r}^{S}=\sum\limits_{m=1}^{S}\beta_{r,a}\cdot x_{r}^{s} \tag{7}\]