Relation path embedding in knowledge graphs

Large-scale knowledge graphs have currently reached impressive sizes; however, they are still far from complete. In addition, most existing methods for knowledge graph completion only consider the direct links between entities, ignoring the vital impact of the semantics of relation paths. In this paper, we study the problem of how to better embed entities and relations of knowledge graphs into different low-dimensional spaces by taking full advantage of the additional semantics of relation paths and propose a novel relation path embedding model named as RPE. Specifically, with the corresponding relation and path projections, RPE can simultaneously embed each entity into two types of latent spaces. Moreover, type constraints are extended from traditional relation-specific type constraints to the proposed path-specific type constraints and both of the two type constraints can be seamlessly incorporated into RPE. The proposed model is evaluated on the benchmark tasks of link prediction and triple classification. The results of experiments demonstrate our method outperforms all baselines on both tasks. They indicate that our model is capable of catching the semantics of relation paths, which is significant for knowledge representation learning.


Introduction
Large-scale knowledge graphs, such as Freebase [2], WordNet [22], Yago [28], and NELL [6], are critical to natural language processing applications, e.g., question answering [8], relation extraction [26], and language modeling [1].These knowledge graphs generally contain billions of facts, and each fact is organized into a triple base format (head entity, relation, tail entity), abbreviated as (h,r,t).However, the coverage of such knowledge graph is still far from complete compared with real-world knowledge [9].Traditional knowledge graph completion approaches, such as Markov logic networks [25], suffer from feature sparsity and low efficiency.
Recently, encoding the entire knowledge graph into a low-dimensional vector space to learn latent representations of entity and relation has attracted widespread attention.These knowledge embedding models yield better performance in terms of low complexity and high scalability compared with previous works.Among these methods, TransE [5] is a classical neural-based model, which assumes that each relation can be regarded as a translation from head to tail and uses a score function S(h,r,t) to measure the plausibility for triples.TransH [32] and TransR [20] are representative variants of TransE.These variants consider entities from multiple aspects, various relations may stress on different aspects.
However, the majority of these approaches only exploit direct links that connect head and tail entities to predict potential relations between entities.These approaches do not explore the fact that relation paths, which are denoted as the sequences of relations, i.e., p ¼ ðr 1 ; r 2 ; . ..; r m ), play an important role in knowledge inference.For example, the successive facts J.K. Rowling !CreatedRole Harry Potter !DescribedIn Harry Potter and the Philosopher's Stone can be used to infer the new triple (J.K. Rowling, WroteBook, Harry Potter and the Philosopher's Stone), which does not appear in the original knowledge graph.Consequently, using relation paths to learn meaningful knowledge embeddings is a promising new research direction [10,12,23,29].
In this paper, we propose a novel relation path embedding model (RPE) to explicitly model knowledge graph by taking full advantage of the semantics of relation paths.By exploiting the compositional path projection, RPE can embed each entity into proposed path spaces for better tackling various relations with multi-mapping properties.Moreover, we extend the relation-specific type constraints [16] to the novel path-specific type constraints to improve the prediction quality.Our model is evaluated on three benchmark datasets with link prediction and triple classification.Experimental results show that RPE outperforms all baselines on these tasks, which proves the effectiveness of our method and the importance of relation paths.
The remainder of this paper is organized as follows.We first provide a brief review of state-of-the-art knowledge embedding models in Sect. 2. Two main intuitions of our model are illustrated in Sect.3. The details of RPE are introduced in Sect. 4. The experiments and analyses are reported in Sect. 5. Conclusions and directions for future work are reported in the final section.

State-of-the-art
In this paper, We first concentrate on three classical translation-based models that only consider direct links between entities.The first translation-based model is TransE inspired by [21].TransE defines the score function as Sðh; r; tÞ ¼ kh þ r À tk for each triple (the bold lowercase letter denotes a column vector).The score will become smaller if the triple (h,r,t) is correct; otherwise, the score will become higher.The embeddings are learned by optimizing a global margin-loss function.This assumption looks quite simple, but it was shown to achieve great results empirically.However, TransE cannot address more complex relations with multi-mapping properties well, i.e., 1-to-N (bring out), N-to-1 (gender of), and N-to-N (work with).To alleviate this problem, TransH projects entities into a relation-dependent hyperplane by the normal vector w r : h h ¼ h À w T r hw r and t h ¼ t À w T r tw r (restrict kw r k 2 ¼ 1).The corresponding score function is Sðh; r; tÞ ¼ kh h þ r À t h k.TransE and TransH achieve translations on the same embedding space, whereas TransR assumes that each relation should be used to project entities into different relation-specific embedding spaces since different relations may place emphasis on different entity aspects.The projected entity vectors are h r ¼ M r h and t r ¼ M r t (the bold uppercase letter M denotes a matrix); thus, the new score function is defined as Sðh; r; tÞ ¼ kh r þ r À t r k.In addition, there are other novel knowledge embedding models [14,15] focusing on efficient relation projection are evaluated in our experiments.Multi-source information learning for knowledge graph completion, which aims at utilizing heterogeneous data to enrich knowledge embedding, is a promising research.For instance, [33] employs the convolutional neural networks (CNN) to learn embeddings from extra entity description for zero-shot scenarios.
Another research direction focuses on improving the prediction performance by using prior knowledge in the form of relation-specific type constraints [7,16,30].Note that each relation should contain Domain and Range fields to indicate the subject and object types, respectively.For example, the relation HasChildren's Domain and Range types both belong to a person.By exploiting these limited rules, the harmful influence of a merely data-driven pattern can be avoided in part.For example, Type-constrained TransE [16] imposes these constraints on the global margin-loss function to better distinguish similar embeddings in latent space.
A third related direction is PTransE [19] and the path ranking algorithm (PRA) [17].PTransE considers relation paths as translations between head and tail entities and primarily addresses two problems: (1) exploits a variant of PRA to select reliable relation paths and (2) explores three path representations by compositions of relation embeddings.PRA, as one of the promising research innovations for knowledge graph completion, has also attracted considerable attention [11,18,24,31].It uses the path-constrained random walk probabilities as path features to train linear classifiers for different relations.In large-scale knowledge graphs, relation paths have great significance for enhancing the reasoning ability for more complicated situations.However, none of the aforementioned models can take full advantage of the semantics of relation paths.

The intuitions
The semantics of relation path is a semantic interpretation via composition of the meanings of its components.The impact of the semantics can be observed from TransE comprising multi-step relations: For the successive triples Based on the semantic similarity, we propose a novel relation path embedding model (RPE), whose projection and type constraints of the specific relation are extended to the specific path.Furthermore, the experimental results demonstrate that by explicitly using the additional semantics, RPE significantly outperforms all baselines on link prediction and triple classification tasks.
Figure 1 illustrates the basic idea for relation-specific and path-specific projections.Each entity is projected by M r and M p into the corresponding relation and path spaces.These different embedding spaces hold the following hypothesis: in the relation-specific space, relation r is regarded as a translation from head h r to tail t r ; likewise, p Ã , the path representation by the composition of relation embeddings, is regarded as a translation from head h p to tail t p in the path-specific space.We design two types of compositions to dynamically construct the path-specific projection M p without extra parameters.Moreover, we also propose a novel path-specific type constraints to better distinguish similar embeddings in different latent spaces.
Another intuition is the semantics of some relation paths p is unreliable for reasoning new facts of that entity pair.
For instance, there is a common relation path h !HasChildren t 0 !GraduatedFrom t, but this path is meaningless for inferring additional relationships between h and t.Therefore, reliable relation paths are urgently needed.As Lao et al. suggests [17], relation paths that end in many possible tail entities are more likely to be unreliable for the entity pair.Therefore, we also rank the relation paths to select reliable relation paths.Precisely, we denote all entities constitute the entity set f, and all relations constitute the relation set R. For a triple (h,r,t), P all ¼ fp 1 ; p 2 ; . ..; p k g is the path set for the entity pair (h,t).Pðtjh; p i ), the probability of reaching t from h following the sequence of relations indicated by p i , can be recursively defined as follows: If p i is an empty path, If p i is not an empty path, then p 0 i is defined as r 1 ; . ..; r mÀ1 ; subsequently, Endðp 0 i ) is the set of ending nodes of p 0 i .RPE obtains the reliable relation paths set P filter ¼ fp 1 ; p 2 ; . ..; p z g by selecting relation paths whose probabilities are above a certain threshold g.

Relation path embedding
In this section, we would introduce the novel path-specific projection and type constraints and provide the details of training RPE.

Path-specific projection
The novel idea of RPE is that the semantics of reliable relation paths is similar to the semantics of the relation between an entity pair and both of them can be exploited for reasoning.For a triple (h,r,t), RPE exploits projection matrices M r , M p 2 R mÂn to project entity vectors h; t 2 R n in entity space into the corresponding relation and path spaces simultaneously (m is the dimension of relation embeddings, n is the dimension of entity embeddings, and m may differ from n).The projected vectors (h r , h p , t r , t p ) in their respective embedding spaces are denoted as follows: Because relation paths are those sequences of relations p ¼ ðr 1 ; r 2 ; . ..; r m Þ, we dynamically use M r to construct M p to decrease the model complexity.Subsequently, we explore two compositions for the formation of M p , which are formulated as follows: where addition composition (ACOM) and multiplication composition (MCOM) represent cumulative addition and multiplication for path projection.Matrix normalization is applied on M p for both compositions.The new score function is defined as follows: Gðh; r; tÞ ¼ Sðh; r; tÞ þ k Á Sðh; p; tÞ

Path-specific type constraints
In RPE, based on the semantic similarity between relations and reliable relation paths, we extend the relation-specific type constraints to novel path-specific type constraints.In type-constrained TransE, the distribution of corrupted triples is a uniform distribution.
In our model, we incorporate the two type constraints with a Bernoulli distribution.For each relation r, we denote the Domain r and Range r to indicate the subject and object types of relation r. f Domain r is the entity set whose entities conform to Domain r , and f Range r is the entity set whose entities conform to Range r .We calculate the average numbers of tail entities for each head entity, named teh, and the average numbers of head entities for each tail entity, named het.The Bernoulli distribution with parameter teh tehþhet for each relation r is incorporated with the two type constraints, which can be defined as follows: RPE samples entities from f Domain r to replace the head entity with probability teh tehþhet , and it samples entities from f Range r to replace the tail entity with probability het tehþhet .The objective function for RPE is defined as follows: . .; tg as the set of corrupted triples, where each element of C 0 is obtained by randomly sampling from f. C 00 , whose element conforms to the two type constraints with a Bernoulli distribution, is a subset of C 0 .The Max(0, x) returns the maximum between 0 and x. c 1 and c 2 are the hyperparameters of margin, which separate correct triples and corrupted triples.By exploiting these two types of prior knowledge, RPE could better distinguish similar embeddings in different embedding spaces, thus allowing it to achieve better prediction quality.

Training details
We adopt stochastic gradient descent (SGD) to minimize the objective function.TransE or RPE (initial) can be exploited for the initializations of all entities and relations in practice.The score function of RPE (initial) without using relation and path projections is as follows: Gðh; r; tÞ ¼ Sðh; r; tÞ þ k Á Sðh; p; tÞ We also employ this score function in our experiment as a baseline.The projection matrices Ms are initialized as identity matrices.RPE holds the local closed-world assumption (LCWA) [9], where each relation's domain and range types are based on the instance level.Thus, the type information is collected by accurate data provided by knowledge graph or the entities shown in observed triples.
Note that each relation r has the reverse relation r À1 ; therefore, to increase supplemental path information, RPE utilizes the reverse relation paths.LeBron James.For each iteration, we randomly sample a correct triple (h,r,t) with its reverse ðt; r À1 ; hÞ, and the final score function of our model is defined as follows: Theoretically, we can arbitrarily set the length of the relation path, but in the implementation, we prefer to take a smaller value to reduce the time required to enumerate all relation paths.Moreover, as suggested by the path-constrained random walk probability Pðtjh; pÞ, as the path length increases, Pðtjh; pÞ will become smaller and the relation path will more likely be cast off.
In our model, we particularly concentrate on how to better utilize presented relation paths to promote the performance of knowledge representation learning.Furthermore, based on the semantics of relation paths, RPE is a general framework.More sophisticated relation projection, type constraints and external information are compatible  Regularize the embeddings and projection matrices in T batch 18: end loop with it, and they can be easily incorporated into RPE to get further improvements.Algorithm 1 gives the detailed procedure of learning RPE with path-specific projection and type constraints.

Complexity analysis
Table 2 lists the complexity (model parameters and time complexity in an epoch) of classical baselines and our models.We denote RPE only with path constraints as RPE (PC), RPE only with ACOM path projection as RPE (ACOM).N e and N r represent the numbers of entities and relations.N t denotes the number of triples for training.p is the expected number of relation paths between the entity pair, and l is the expected length of relation paths.n is the dimension of entity embedding and m is the dimension of relation embedding.k is the number of hidden units of a neural network and s is the number of slice of a tensor.It is noticed that RPE (PC) has the same number of model parameters of TransE OðN e n þ N r mÞ and RPE (ACOM), RPE (PC ?ACOM) have the same numbers of model parameters of TransR OðN e n þ N r ðn þ 1ÞmÞ.Both TransE and TransR are the classical models.In terms of time complexity, RPE (PC) has the same magnitude of PTran-sE(ADD, 2-hop) OðpN t Þ, both RPE(ACOM) and RPE(PC ?ACOM) retain in a magnitude Oð2mnpN t Þ similar to TransR Oð2mnN t Þ.In practice, our models take roughly 9 h for training, which can be accelerated by increasing the value of threshold g.For comparison purposes, the efficient implementations of classical knowledge embedding models1 are exploited.

Experiments
We evaluate our model on two classical large-scale knowledge graphs: Freebase and WordNet.Freebase is a large collaborative knowledge graph that contains billions of facts about the real world, such as the triple (Beijing, Locatedin, China), which describes the fact that Beijing is located in China.WordNet is a large lexical knowledge base of English, in which each entity is a synset that expresses a distinct concept, and each relationship is a conceptual-semantic or lexical relation.We use two subsets of Freebase, FB15K and FB13 [5], and one subset of WordNet, WN11 [27].These datasets are commonly used in various methods, and Table 3 presents the statistics of them, where each column represents the numbers of entity type, relation type and triples that have been split into training, validation and test sets.
In our model, each triple has its own reverse triple for increasing the reverse relation paths.Therefore, the total number of triples is twice as many as the original datasets.We utilize the type information provided by [34] for FB15K.As for FB13 and WN11, we exploit the LCWA to collect the type information, so we do not depend on the auxiliary data, the domain and range of each relation are approximated by the observed triples.
To examine the retrieval and discriminative ability of our model, RPE is evaluated on two standard subtasks of knowledge graph completion: link prediction and triple classification.The experimental results and analyses are concluded in the following two subsections.

Link prediction
The link prediction is a classical evaluation of knowledge graph completion, it focuses on predicting the possible h or t for test triples when h or t is missed.Rather than requiring one best answer, it places more emphasis on ranking a list of candidate entities from the knowledge graph.FB15K is benchmark dataset to be employed for this task.

Evaluation protocol
We follow the same evaluation procedures as used in knowledge embedding models.First, for each test triple (h,r,t), we replace h or t with every entity in f.Second, each corrupted triple is calculated by the corresponding score function S(h,r,t).The final step is to rank the original correct entity with these scores in descending order.
Two evaluation metrics are reported: the average rank of correct entities (Mean Rank) and the proportion of correct entities ranked in the top 10 (Hits@10).Note that if a corrupted triple already exists in the knowledge graph, then it should not be considered to be incorrect.We prefer to remove these corrupted triples from our dataset and call this setting ''filter''.If these corrupted triples are reserved, then we call this setting ''raw''.In both settings, if the latent representations of entity and relation are better, then a lower mean rank and a higher Hits@10 should be achieved.Because we use the same dataset, the baseline results reported in [5,14,15,19,20,32] are used for comparison.

Analysis of results
Table 4 reports the results of link prediction, in which the first column is translation-based models, the variants of PTransE, Multi-source information learning model DKRL, and our models.As mentioned above, RPE only with MCOM path projection is denoted as RPE (MCOM).The numbers in bold are the best performance, and n-hop indicates the path length n that PTransE exploits.From the results, we can observe the followings.
(1) Our models significantly outperform the classical knowledge embedding models (TransE, TransH, TransR, TransD, and TranSparse) and PTransE on FB15K with the metrics of mean rank and Hits@10 (''filter'').Most notably, compared with TransE, mean rank reduces by 29.6, 67.2% and Hits@10 rises by 49.0 and 81.5% in RPE (ACOM).The results demonstrate that the path-specific projection can make better use of the semantics of relation paths, which are crucial for knowledge graph completion.
(2) RPE with path-specific type constraints and projection (RPE (PC ?ACOM) and RPE (PC ?MCOM)) is a compromise between RPE (PC) and RPE (ACOM).RPE (PC) improves slightly compared with the baselines.We believe that this result is primarily because RPE (PC) only focuses on local information provided by related embeddings, ignoring some global information compared with the approach of randomly selecting corrupted entities.(3) In terms of mean rank, RPE (ACOM) has shown the best performances.Especially compared with PTransE, it achieves 14.5 and 24.1% error reductions in the ''raw'' and ''filter'' settings, respectively.In terms of Hits@10, although RPE (ACOM) is 2.7% lower than TransD (bern) on ''raw'', however, it gets 10.6% higher than the latter on ''filter''.
Table 5 presents the separated evaluation results by mapping properties of relations on FB15K.Mapping properties of relations follows the same rules in [5], and the metrics are Hits@10 on head and tail entities.From Table 4, we can conclude that (1) RPE (ACOM) outperforms all baselines in all mapping properties of relations.In particular, for the 1-to-N, N-to-1, and N-to-N types of relations that plague knowledge embedding models, RPE (ACOM) improves 4.1, 4.6, and 4.9% on head entity's prediction and 6.9, 7.0, and 5.1% on tail entity's prediction compared with previous state-of-the-art performances achieved by PTransE (ADD, 2-hop).( 2) RPE (MCOM) does not perform as well as RPE (ACOM), and we believe that this result is because RPE's path representation is not consistent with RPE (MCOM)'s composition of projec-  prediction, and the results of experiments further demonstrate the better expressibility of our model.

Triple classification
Triple classification is recently proposed by [26], it aims to predict whether a given triple (h,r,t) is true, which is a binary classification problem.We conduct this task on three benchmark datasets: FB15K, FB13 and WN11.

Evaluation protocol
We set different relation-specific thresholds fd r g to perform this task.For a test triple (h,r,t), if its score S(h,r,t) is below d r , then we predict it as a positive one; otherwise, it is negative.fd r g is obtained by maximizing the classification accuracies on the valid set.

Implementation
We directly compare our model with prior work using the results about knowledge embedding models reported in [20] for WN11 and FB13.Because [19] does not evaluate PTransE's performance on this task, we use the code of PTransE that is released in [19] to complete it.FB13 and WN11 already contain negative samples.For FB15K, we use the same process to produce negative samples, as , and g ¼ 0:05, taking the L 1 norm on FB15K.We exploit RPE (initial) for initiation, and we set the path length as 2 and the maximum epoch as 500.(3) In contrast to WN11 and FB13, the significant improvements on FB15K indicate that although LCWA can compensate for the loss for type information, the actual relation-type information is predominant.

Hyperparameter selection
Theoretically speaking, our models are most affected by learning rate, margin and embedding dimension.RPE exploits the pre-trained models for training.Thus we choose a relatively small learning rate for refinement, such as 0.0001.
We make a comparison of RPE (ACOM) and RPE (PC ?ACOM) with different hyperparameters (margin c 1 and dimension of entity embedding n) as shown in Figure 2. c 1 is tuned in the definite range {1, 2, 3, 4, 5} and n is tuned in the definite range {20, 40, 60, 80, 100, 120}.Other parameters keep the optimal settings explained in Sect.5.2.2.From the figure, we can see that: (1) Even without hyperparameter selection RPE can maintain high classification ability.The whole accuracies of RPE (ACOM) and RPE (PC ?ACOM) exceed 75 and 77%, respectively.(2) In the condition of fine granularity, the margin and embedding dimension play an important role in model learning.

Conclusions and future work
In this paper, we propose a novel relation path embedding model (RPE) for knowledge graph completion.To the best of our knowledge, this is the first time that a path-specific projection has been proposed, and it simultaneously embeds each entity into relation and path spaces to learn more meaningful embeddings.We also put forward the novel pathspecific type constraints based on relation-specific constraints to better distinguish similar embeddings in the latent space.Extensive experiments show that RPE outperforms all baseline models on link prediction and triple classification tasks.Moreover, the path-specific projection and constraints introduced by RPE are quite open strategies which can be easily incorporated into many other translation-based and multi-source information learning models.
In the future, we will explore the following directions: (1) Incorporate other potential semantic information into the relation path modeling, such as the information provided by those intermediate nodes connected by relation paths.(2) With the booming of deep learning for natural language processing [35], we plan to use convolutional

Fig. 1
Fig. 1 Simple illustration of relation-specific and pathspecific projections tions.Although RPE (PC) improves little compared with PTransE, we will indicate the effectiveness of relationspecific and path-specific type constraints in triple classification.(3) We use the relation-specific projection to construct path-specific ones dynamically; then, entities are encoded into relation-specific and path-specific spaces simultaneously.The experiments are similar to link

Fig. 2
Fig. 2 Hyperparameter tuning for RPE.The vertical axis is the accuracy of triple classification.The left horizontal axis represents the margin c 1 and the right represents the dimension of entity embedding n r 2 % t and h þ r 3 % t.It thus implicitly expresses that the semantics of r 3 is similar to the semantic composition of p ¼ ðr 1 ; r 2 Þ.

Table 3
Statistics of the datasets

Table 4
Evaluation results on link prediction

Table 5
Evaluation results on FB15K by mapping properties of relations (%)

Table 6
; thus, path-specific constraints can raise the determinability of knowledge embedding model experimentally.Moreover, lengthening the distances for similar entities in embedding space is essential to specific tasks.