# Few-Shot Knowledge Graph Completion Model Based on Relation Learning
## 4 Model
### Loss Function
This indicates that: (a) the high-order neighborhood entity encoder based on the gate mechanism can effectively enhance the information contained in the center entity, and the gate mechanism can filter out the impact of noisy neighbors; (b) by introducing the neighborhood relation representation of entity pairs in the reference set, FRL-KGC can improve the quality of relation embeddings, facilitate relation prediction, and reduce dependence on entity pairs, thus improving the model's generalization ability; (c) the combined structure of the LSTM network and the Transformer module in the Transformer learner is better than using them separately, where the LSTM network can effectively enhance fine grained contextual semantic representation, and combined with the powerful Transformer module can improve the accuracy of link prediction. ### Impact of Few-Shot Size

To illustrate the impact of the few-shot size on the model's performance, impact of few-shot size experiments were conducted on the Wiki-One dataset, as shown in Figure 7. The horizontal axis represents the size \(K\) of the reference set, and the vertical axis represents the evaluation index. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Ablation on Model**} & \multicolumn{4}{c}{**Five-Shot on Wiki-One**} \\ \cline{2-5}  & **MRR** & **Hits@10** & **Hits@5** & **Hits@1** \\ \hline A1\_a & 0.314 & 0.443 & 0.386 & 0.258 \\ A1\_b & 0.336 & 0.469 & 0.395 & 0.272 \\ A2\_a & 0.343 & 0.483 & 0.425 & 0.267 \\ A3\_a & 0.331 & 0.453 & 0.383 & 0.279 \\ A3\_b & 0.301 & 0.432 & 0.371 & 0.264 \\ FRL-KGC (ours) & **0.357** & **0.494** & **0.431** & **0.296** \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Ablation study of FRL-KGC under five-shot settings on Wiki-One. Bold numbers denote the best. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Model**} & \multicolumn{4}{c}{**NELL-One**} & \multicolumn{4}{c}{**Wiki-One**} \\ \cline{2-9}  & **MRR** & **Hits@10** & **Hits@5** & **Hits@1** & **MRR** & **Hits@10** & **Hits@5** & **Hits@1** \\ \hline \multicolumn{9}{c}{Traditional models} \\ \hline TransE & 0.176 & 0.316 & 0.234 & 0.109 & 0.134 & 0.188 & 0.158 & 0.106 \\ DistMult & 0.211 & 0.312 & 0.256 & 0.135 & 0.076 & 0.154 & 0.101 & 0.024 \\ ComplEx & 0.186 & 0.299 & 0.231 & 0.119 & 0.081 & 0.182 & 0.121 & 0.032 \\ SimplE & 0.156 & 0.284 & 0.225 & 0.094 & 0.097 & 0.181 & 0.125 & 0.045 \\ RotatE & 0.176 & 0.331 & 0.245 & 0.109 & 0.052 & 0.091 & 0.065 & 0.026 \\ \hline \multicolumn{9}{c}{Few-shot models} \\ \hline GMatching (MaxP) & 0.176 & 0.294 & 0.233 & 0.113 & 0.263 & 0.387 & 0.337 & 0.197 \\ MetaR (Pre-train) & 0.162 & 0.282 & 0.233 & 0.101 & 0.320 & 0.443 & 0.397 & 0.262 \\ MetaR (In-train) & 0.308 & 0.502 & 0.423 & 0.210 & 0.229 & 0.323 & 0.289 & 0.197 \\ FSRL & 0.269 & 0.482 & 0.369 & 0.178 & 0.221 & 0.269 & 0.183 & 0.163 \\ FAAN & 0.265 & 0.416 & 0.347 & 0.187 & 0.314 & 0.451 & 0.384 & 0.245 \\ GANA & 0.296 & 0.497 & 0.412 & 0.194 & 0.324 & 0.437 & 0.375 & 0.264 \\ FRL-KGC (ours) & **0.337** & **0.521** & **0.454** & **0.253** & **0.357** & **0.494** & **0.431** & **0.296** \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Results of five-link prediction on NELL-One and Wiki-One. Bold numbers denote the best results, and underlined numbers indicate suboptimal results. As shown in Figure 7, as the number of instances in the reference set \(K\) increases, the MRR and Hits@1 values of FRL-KGC gradually increase, and the overall prediction accuracy of all models improves. However, after reaching a certain level, the performance improvement tends to flatten and then decreases again. This indicates that the size of the reference set is a crucial factor affecting the accuracy of link prediction when predicting new triplets. With a larger reference set, there is more reference information for the query triplet, which can improve the accuracy of link prediction. However, when the reference set is too large, the prediction accuracy may decrease.