# Personalized Chinese Tourism Recommendation Algorithm Based on Knowledge Graph
## 3 Methodology
### B-TransD Knowledge Representation Model  
Knowledge Representation is a distributed representation method, which uses machine learning for training, takes into account the relationship between objects, transforms the objects into related lowdimensional vectors, and calculates the Euclidean distance or cosine distance between the objects to obtain the semantic similarity. [PERSON] [13] and others proposed the TransE knowledge representation model, which uses distance to measure the semantic relationship between entities. The closer the entities are in the Knowledge Graph, the closer they are in semantics. The TransE model is simple and can directly  
Figure 3: Shaanxi tourism knowledge graph as an example. Figure 2: Part of Chinese tourism Knowledge Graph. establish the semantic relationship between entities. It also maintains good performance in a large-scale Knowledge Graph. However, TransE model [16] can only represent one-to-one relationships, and cannot express one-to-many, many-to-one, and many-to-many complex relationships. In order to solve this problem, many scholars have extended the model, such as TransR [17], TransH [18], and TransD [19]. In the TransD model, \(r\) and \(t\) are vector representations of the head and tail entity in the entity space, \(h_{r}\) and \(t_{r}\) separately represent the vector of the head and tail entity in hyperplane, and \(M_{r}\) is the mapping Matrix from the entity space to hyperplane \(r\). Their relationship is as follows:  
\[h_{r}=hM_{r},t_{r}=tM_{r} \tag{1}\]  
In the relationship space, through constant adjustment, the head entity \(h_{r}\) is shifted along the relationship vector \(r\) to obtain the tail entity vector \(t_{r}\), so that \(h_{r}+r\) and \(t_{r}\) are as equal as possible. Euclidean distance is used to measure the distance between vectors. The loss function of TransD model is defined as follows:  
\[f_{r}(h,t)=\|h_{r}+r-t_{r}\|_{2} \tag{2}\]  
where \(\|\|_{2}\) is the 2 norm of the vector. In actual training, all vectors in the model are normalized, so that \(\|h\|_{2}\leq 1\), \(\|t\|_{2}\leq 1\), \(\|r\|_{2}\leq 1\), \(\|hM_{r}\|_{2}\leq 1\), \(\|tM_{r}\|_{2}\leq 1\). In the Knowledge Graph, the triples based on objective facts are positive triples \((h,r,t)\). The common sampling method of negative triples is to replace the head or tail entities in the correct triples with other entities at random, and obtain the negative triples \((h^{{}^{\prime}},r,t^{{}^{\prime}})\) and the wrong triplet [20,21]. The triples in the Knowledge Graph of tourist attractions are multi-relational triples, and the traditional negative triples sampling method may introduce the wrong entities. For example, there are two triples \((h,r,t_{1})\) and \((h,r,t_{2})\) in the Knowledge Graph. For the \((h,r,t_{1})\) triplet, when \(t_{1}\) is randomly replaced by \(t_{2}\), the wrong triple \((h,r,t_{2})\) is generated. In fact, \((h,r,t_{2})\) is a correct triple, which leads to the wrong negative triple [22,23]. In the Knowledge Graph, the triples based on objective facts are positive triples. The common sampling method of negative triples is to replace the head or tail entities in the correct triples with other entities at random, and obtain the negative triples. For example, given triples ([PERSON], born in Shanghai), negative examples should be generated by randomly selecting one of the entities of a similar type in Shanghai, such as Beijing, Xi'an, etc. A negative ratio is [PERSON], born, male. To solve these problems, this paper introduces the Bernoulli sampling strategy and proposes a new knowledge representation model B-TransD (Bernoulli-TransD). In the process of constructing negative triples, two statistics \(R\) and \(N\) are obtained, the mean value \(N\) is the number of tail entities connected by the head entity and the mean value \(R\) is the number of head entities connected by the tail entity, so as to calculate Probability \(P\).