## 2 Methodology
### Decoding Process  
To answer the query and sub-query, the conditional distributions of predicted objects \(p(\delta_{t}|s,r)\) and relations \(p(\tilde{r}_{t}|s)\) are modeled by two linear functions. The formulas are presented as Formula (11) and (12)  
\[p(\tilde{o}|s,r,t) =[H_{s^{\prime}}^{t}e_{s};e_{r}]W_{o}^{\top}+b_{o} \tag{11}\] \[p(\tilde{r}|s,t) =[H_{s^{\prime}}^{t}e_{s}]W_{r}^{\top}+b_{r} \tag{12}\]  
As the entities prediction task is considered as a multi-classification task, cross-entropy loss is selected as the loss function. For simplicity of expression, we omit the notations of prediction in Formula (13). The loss function is as follows:  
\[L=-\sum_{(s,r,o)_{t}\in G_{t}}log(o|s,r,t)+\lambda logp(r|s,t) \tag{13}\]  
Here, \(\lambda\) is a hyper-parameter to balance the importance between two parts. In entity prediction tasks, we aim to predict objects depending on relevant subjects and their linked relations.  
We summarize the whole training process as shown in Algorithm 1. Our training approach is divided into two steps. In the first step, during the preset maximum number of iterations _epochs_, we generate the graph embedding from the global unit and save the optimal results for the next step. It is noticed that we choose 2-norm as the loss function in the global model to fit the temporal distribution of all subject entities \(D_{s,t}\). In the second step, we use the local learning unit to estimate the conditional probability distribution of object entities \(\hat{p}(o|s,r,t)\) and answer the queries. It is worth noting that, at the preset maximum iteration number _epochs_, we regard the model with the best \(MRR\) ratio as the best situation of our model.  
```
Step 1: Obtain the graph embedding via the Global Unit; Input: observed TKGs: \(\{G_{t}\}\); temporal distribution of all subject entities \(D_{s,t}\);  maximized iteration number: epochs Output: An estimation of subjects temporal distribution \(\tilde{D}_{s,t}\); graph embedding \(T_{t}\)
1\(L_{min}=\infty\);
2\(epoch=0\);
3 whileepoch\(>=\)epochsdo
4 Obtain all semantic representations via two layers of ERGCN block \(\{h_{s,t}\}\gets ERGCN(G_{t})\);
5 Generate current graph state \(g_{t}\gets f_{max}(h_{s,t})\);
6 Search historical state of the current graph \(g_{m}(t)=\{g_{t-1},\cdots,g_{t-m+1}\}\);
7 Estimate the graph embedding \(\hat{T}_{t}\gets GRU(g_{m}(t))\);
8 Predict the distribution of subjects \(\tilde{D}_{s,t}\leftarrow\hat{T}_{t}W_{d}^{\top}+b\);
9 Calculate the loss score \(L^{*}=\frac{1}{n}\sum||D_{s,t}-\tilde{D}_{s,t}||_{2}\);
10 if\(L^{*}<L_{min}\)then
11\(L_{min}\gets L^{*}\);
12\(T_{t}\leftarrow\hat{T}_{t}\)
13 end if
14\(epoch\pm 1\)
15
16
17 end while
18 Step 2: Predict conditional distributions of entities in the local learning unit; Input: the query set \(\{(s,r,t)\}\); observed TKGs: \(\{G_{t}\}\); graph embedding \(T_{t}\);  maximized iteration number: epochs
19
20 Output: An estimation of conditional probability distribution of object entities: \(\hat{p}(o|s,r,t)\)
21\(MRR_{best}=0\);
22 whileepoch\(>=\)epochsdo
23 forquerydo
24 Obtain hidden representation of entity \(s\), \(h_{s,t}\gets ERGCN(s,G_{t})\);
25 Search historical sequences of \(s\), \(h_{m}(s,t)\leftarrow\{h_{s,t-1}:T_{t-1},h_{s,t-2}:T_{t-2}\cdots,h_{s,t-m+1}:T_{t -m+1}\}\);
26 Generate hidden state vector of \(s\), \(H_{s}^{t}\gets GRU(h_{m}(s,t))\);
27 Estimate the query: \(\hat{p}(o|s,r,t)\leftarrow[e_{s}:e_{r}:H_{s}^{t}]W_{0}^{\top}+b_{o}\) ;
28 Estimate the sub-query: \(\hat{p}(r|s,t)\leftarrow[e_{s}:H_{s}^{t}]W_{r}^{\top}+b_{r}\) ;
29
30 end while
31 Calculate the total loss score: \(L^{*}=\sum[L(p(o|s,r,t),\hat{p}(o|s,r,t))+\lambda L(p(r|s,t),\hat{p}(r|s,t))]\);
32 estimate the MRR ratio: \(MRR^{*}=\frac{1}{n}\sum\frac{1}{P}\);
33 if\(MRR_{best}<MRR^{*}\)then
34\(MRR_{best}\gets MRR^{*}\);
35\(\hat{p}(o|s,r,t)\leftarrow\hat{p}(o|s,r,t)\) as estimation
36
37 end if
38
39 end while
```  
**Algorithm 1**Learning algorithm of ERGCN