# Predicting Dynamic User-Item Interaction with Meta-Path Guided Recursive RNN
## 4 Methodology
### Dynamical Embedding Generation  
In this section, we will introduce how to generate the dynamical embeddings of users and items based on the learned static embeddings learned above. **Recursive RNN. ** As illustrated in the green box of Figure 2, there are two recursive RNN models. One is the UserRNN and the other is ItemRNN. The two components are designed to generate user and item dynamic embeddings according to their historical interaction, and they are shared by users and items to mutually learn dynamic embeddings of users and items. A user/item RNN is composed of RNN layers and the hidden states of the user/item RNN are used to represent user/item embeddings. In the recursive RNN module, the user and item embeddings will be updated by the user RNN module and item RNN module, respectively, when an interaction between a user and an item occurs. To be specific, the user embedding \(u_{t}\) will be updated based on the user embedding \(u_{t-1}\), the item embedding \(i_{t-1}\) and the auxiliary feature vector \(o_{u}\) at the previous timestamp \(t-1\). The item embedding is updated with the item RNN in a similar way to the user RNN. In this way, the user or item embeddings are able to absorb the information hidden in the interaction data. The user and item embeddings can also be encoded into the same latent space. Note that the embeddings of users and items evolve with the dynamic user-item interaction. There are two advantages in the designed recursive RNN model. First, users and items are embedded into the same latent space, and thus the similarity between users and items can be easily obtained through measuring their distance in the same embedding space. For example, if users \(A\) and \(B\) interacted with the items \(C\) and \(D\) respectively, and item \(C\) is similar with item \(D\), we consider the users \(A\) and \(B\) are also similar. Based on this idea, the embeddings of users and items can be updated by the following formula iteratively. \[ \begin{split}& u_{t}=\sigma(W_{1}^{u}u_{t-1}+W_{2}^{u}i_{t-1}+W_{3}^{u }o_{u})\\ & i_{t}=\sigma(W_{1}^{u}u_{t-1}+W_{2}^{u}i_{t-1}+W_{3}^{u}o_{i}) \end{split}  \tag{5}\]  
In Equation (5), \(u_{t}\) and \(u_{i}\) are dynamic embeddings of user \(u\) and item \(i\) at time \(t\). \(o_{u}\) and \(o_{i}\) are auxiliary features. \(\sigma\) is a sigmoid function. \(W_{1}^{u}\),..., \(W_{3}^{u}\) are the parameter matrices of user RNN, and \(W_{1}^{i}\),..., \(W_{3}^{i}\) are the parameter matrices of item RNN. **Shift embedding. ** In order to predict the embedding of the user in the future, we design a shift embedding module that works as an embedding projection operation. The predicted embedding can then be used for downstream tasks, such as link prediction or recommendation. Existing works ignore the importance of temporal information and are not capable of continuously updating the interaction embeddings over time. The embeddings are only updated discretely when new interactions occur. However, we argue that users and items can evolve over time continuously such as the interests of users, attributes of items, and so on. We assume that the user and item embeddings can still change smoothly and continuously over time even there is no new interaction between a user and an item. The part in the box of Figure 2 shows the shift embedding module which is able to capture the temporal dynamics of user embedding by considering the elapsed time information. If the time gap between two successive interactions of one user is large, the user embedding learned from the previous interaction is not appropriate to predict the current and continuously adjust the user embeddings between the time interval of two successively interactions with items. In other words, recent interactions have a greater impact on the user embedding, while interactions too long ago have a weaker impact. Inspired by previous work, the feedback loop of RNN keeps the previous information of hidden states as internal memory.