{'fraction_non_alphanumeric': 0.024587523710676067, 'fraction_numerical': 0.008517948534411797, 'mean_word_length': 4.769564319636589, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Discover Important Paths in the Knowledge Graph Based on Dynamic Relation Confidence

Most of the existing knowledge graphs are not usually complete and can be complemented by some reasoning algorithms. The reasoning method based on path features is widely used in the field of knowledge graph reasoning and completion on account of that its have strong interpretability. However, reasoning methods based on path features still have several problems in the following aspects: Path search isinefficient, insufficient paths for sparse tasks and some paths are not helpful for reasoning tasks. In order to solve the above problems, this paper proposes a method called DC-Path that combines dynamic relation confidence and other indicators to evaluate path features, and then guide path search, finally conduct relation reasoning. Experimental result show that compared with the existing relation reasoning algorithm, this method can select the most representative features in the current reasoning task from the knowledge graph and achieve better performance on the current relation reasoning task.


Introduction
Knowledge graph(KG) can be considered as a variant of semantic network with added constraints, or a programmatic way to model a knowledge domain. Knowledge graph reasoning, which focuses on inferring new unknown knowledge from the existing KG, has been widely deployed in KG completion. For knowledge reasoning, commonly used methods concentrate on representation learning, rule, graph structure, and deep learning methods.
The KG reasoning method based on path features is an important part of the graph structure reasoning methods. This kind of method usually includes path search and reasoning. Since the path features is composed of the relation sequences in the KG, it has strong interpretability. The KG reasoning method based on path features can be traced back to the path ranking algorithm(PRA) proposed by Lao et al. [1], which extracts the relation sequences between entities as features. Later, a series of improved algorithms for path search has emerged. This paper observes and analyzes a series of typical path reasoning algorithms. In general, there are three problems that cannot be avoided in the path search and reasoning: 1. There are too many relations in a large KG, resulting in an inefficient path search. 2. Due to the sparsity of the KG, some reasoning tasks cannot find enough path features for reasoning. 3.Some path features are not relevant to the current reasoning task, so they are not helpful for reasoning.
Although some algorithms have noticed these problems and made effective improvements, there are still some shortcomings. Lao et al. [2] took data-based path walks to improve the efficiency of path search, but it only evaluates and filters the path features at the end of the path search. Gardner M et al. proposed the SFE algorithm [3] which divides the path search process into two subgraphs and searches for the intermediate entity at the same time, thereby improving the efficiency of path search. In addition, it binarizes the probability matrix to reduce the calculation. However, it still cannot choose the path related to the reasoning task and only improves efficiency. Xiong W et al. proposed the DeepPath algorithm [4], which applies reinforcement learning to search paths. Its disadvantage is that the method of reinforcement learning depends on the quality of the embedding method used. Meanwhile, the reinforcement learning network needs to be pre-trained which consumes more time.
Based on the above, this paper proposes a method that uses dynamic relation and path confidence to evaluate the path and guide the path search. Its characteristic lies in dynamically evaluating relations and paths during the path search. In the whole search process, with the search strategy is continuously optimized, the search space is continuously reduced to the area most relevant to the reasoning task. Finally, the path is selected according to the path confidence and other indicators to retain the most important path features for the reasoning task. The main contributions of this paper are as follows: • We define the dynamic evaluation indicators to evaluate the quality of relation and path in KG. This method includes path search, path selection, and finally perform relation reasoning tasks based on dynamic confidence indicators is called Dynamic confidence path(DC-Path). • We define dynamic relation confidence to guide the path search and narrow the path search space. Experiments show that path search through DC-Path can more effectively find the most important path for the current reasoning task. • We use different strategies for path selection to observe its impact on the reasoning results and discover which paths play a decisive role in the reasoning task.
The rest of this paper is composed as follows: Section2 briefly introduces related work about KG reasoning algorithms. Section3 introduces our method, and Section4 show our experiments and analysis. Section5 summarizes the full text.

Reasoning Method Based On Path Features
Path ranking algorithm (PRA) is the earliest and classic algorithm based on path features reasoning in KG. Lao et al. further improved the PRA algorithm in paper [5]. In this paper, a method of adding a reverse random walk is proposed to expand the original walking strategy, and a path containing constant is added to the path features. The DeepPath algorithm applies reinforcement learning to path search for the first time, and its core ideas are as follows: Get the current state according to the embedding of entities, and select which relation to search according to an action matrix. Set three types of rewards to continuously strengthen the strategy of walking, and finally extract the path features with the best performance. It improves the accuracy of relation reasoning tasks and uses fewer path features than PRA.After that, some new reinforcement learning methods for graph reasoning or path search were proposed [6][7][8][9].

The Reasoning Method Based On Representation Learning
The reasoning method based on representation learning maps the entities and relations in the KG to a low-dimensional space and set a score function to evaluate the correctness of a triple. Translation models are typical KG reasoning algorithms based on representation learning such as TransE [10] and its series of improved TransH [11], TransR [12], and TransD [13]. Another type of KG reasoning method that represents learning is the semantic matching model, and its typical algorithms include Analogy [14]. The advantage of this type of method is that after completing the embedding of entities and relations, reasoning can be performed efficiently through the scoring function. Compared with the reasoning method based on path features, the reasoning performance is better when facing sparse KG.In recent years, more KG reasoning methods based on representation learning have been proposed [15][16][17][18][19].

Reasoning Method Based On Association Rules
Association rule mining is another type of KG reasoning method. Association rules were first proposed for shopping analysis to indicate the shopping association in the market. There are also many association rules in KG. AMIE is a typical knowledge graph association rule mining system [20].In the AMIE system, rule confidence based partial completeness assumption is proposed to replace the traditional indicators in the field of original rule mining. It does not assume any fact that does not appear in the KG but assumes that it is missing. This inspired us to make similar confidence definitions for the paths and relations in the KG. At the same time, AMIE+ [21] also proposed a prediction method based on the partial completeness assumption confidence of association rules, which has achieved a remarkable effect on the yago3 dataset. Many rule-based KG reasoning methods have been proposed in recent years [22,23].

Reasoning Method Based On Neural Network
Recent studies have shown that the neural network coding model has a good effect on the completion of the KG [24]. Encoding models with linear/bilinear blocks can also be modeled by neural networks, such as NAM [25]. CNN are utilized for learning deep expressive features in recent years, its representative algorithms are ConvE [26], ConvKB [27]and HypER [28].GNN encoder [29]is also used to reasoning.

Method
In this section, we propose a path search algorithm based on dynamic relation confidence, to search effective path features which are further used for relation reasoning.In general, the dynamic confidence of the relation will determine the search strategy. For a specific reasoning task, if a relation appears frequently in high-quality path features, we will gradually increase the search probability of it and vice versa. In doing so, we can narrow the search space to be more relevant to the target task, and obtain the most representative path features.The framework of path search and reasoning is shown in Fig 1.Firstly, traverse the entity pairs in the training set for path search, during which both the path pool P and the relation matrix are dynamically updated to adjust the search probability. The path pool saves all the currently searched path features and their dynamic path confidence and the relation matrix saves the path dynamic confidence that each relation has participated in.After obtaining all the path features via traverse, we conduct path selection based on dynamic confidence and pairs coverage. Finally, we train a simple linear regression model using the final path features to perform relation reasoning tasks.

KG Preprocessing
Considering the sparsity and incompleteness of the existing KG, we conduct preliminary processing via inverse relation generation which is commonly used to expand the KG. Specifically, we generate the inverse relation triples for the existing triples and add them to the KG, which can alleviate the problem that some reasoning tasks cannot find enough paths for reasoning due to the sparsity of KG.
For example, we will add an inverse relation triple , ℎ −1 , ℎ for the triple (ℎ, ℎ , ). However, instead of adding an inverse relation triple for each triple directly, we first evaluate the relation in the KG. If a relation is frequently connected to the same tail entity through different head entities, we do not add an inverse relation triple for it.First of all, the triples composed of such a public entity usually represent common sense in the KG. In addition, adding such triples will generate an entity with a larger out-degree, which will affect the efficiency of path search. Meanwhile, we do not remove redundant relations from semantic information, the reason is that the relation in the KG is extremely incomplete.

Path Evaluation
Although the addition of inverse relation triples helps us expand the path features, it makes the existing path features more miscellaneous. To evaluate the quality of various path features and select effective ones for relation reasoning, we define several evaluation measures as below: path-entity support, path count, path confidence, and entity pair coverage. Notably, different from association rules, we only focus on the path and use dynamic confidence for approximate representation.
Definition 1 (Path-entity support) For a given head entity ℎ , tail entity and path feature = 1 , 2 , ..., , the path-entity support is the number of instances of target entity pairs ( ℎ , ) satisfying the path constraint in the KG: where is an arbitrary entity in the KG.
Under the constraint of a specific path feature, the head entity can reach the tail entity through different entity sequences, so this indicator is usually greater than one.
Definition 2 (Path count) For a given head entity ℎ and path feature = 1 , 2 , ..., , the path count is the number of instances of any tail entity that a head entity can reach under a specific path constraint in the KG: where is an arbitrary entity in the KG.
Definition 3 (Entity pair cover) For a given head entity ℎ , tail entity and a path feature = 1 , 2 , ..., , the entity pair cover indicates whether the current entity pair ( ℎ , ) meets the path constraint : Definition 4 (Path confidence) For a given head entity ℎ , tail entity and path feature = 1 , 2 , ..., , the path confidence indicates the proportion of the target entity pairs ( ℎ , ) to all entity pairs starting from the target head entity ℎ under a specific path constraint : where | | represents the total number of entity pairs in the training set.
The path confidence measures the overall reliability of a path in all entity pairs in the training set. When this value is 1, it means that the head entity of the positive sample can walk to the correct tail entity under the path constraint.
Definition 5 (Entity pair coverage) For a given head entity ℎ , tail entity and path feature = 1 , 2 , ..., , entity pair coverage represents the proportion of all entity pairs ( ℎ , ) in the training set that satisfy the specific path constraint :

Path Search and Strategy Update
The indicators proposed in Sec. 3.2 can evaluate path feature well, but they cannot be calculated during path search, and only can be calculated after path search, which brings great computational consumption. Therefore, we use dynamic path and relation evaluation indicators, which can constantly update during the path search and ultimately guide our path search strategy. Specifically, we build a path pool P to save the searched path. When a path is discovered for the first time, we initialize its dynamic path indicators involving path support, path count, path confidence, and entity pair coverage based on the current head entity. When searching for an existing path feature, we dynamically update its indicators. In this way, the path pool is constantly updated during path search, in which new paths are constantly added, and existing paths are constantly updated with dynamic path indicators. The dynamic confidence and dynamic entity pair coverage are approximate as follows: where represents the kth entity pair currently traversed. At the same time, we set a dynamically changing relation matrix = { } × ∈ R × , where is the total number of relations in the KG, is the number of paths in the current path pool, the entry represents whether the current relation participates in the path as follows: The confidence vector of relation is denoted as: Such a relation matrix can reflect the current importance of different relations and guide path search. We use the following three strategies to narrow the path search space: 1) Probabilistic searching based on dynamic relation confidence, 2) Sampling the entities connected by the same relation. 3) Stopping immediately after finding any tail entity. Fig. 2 provides a simple example of path search in the KG, where the target task is to reason athlete's home stadium, the current head entity is the athlete: Kobe Bryant and the tail entity is the Staples stadium. The number marked below the relation in the figure is the probability of continuing the deep search for the relation, which will be introduced below. In general, we use such simple examples to illustrate our three path search strategies.
Probabilistic search based on dynamic relation confidence For each relation that exists in the KG, the relation confidence is defined as: This is the combination of the maximum confidence and the average confidence of the path that the current relation has participated in. If the relation confidence of a relation is close to 1, it means that the average confidence and maximum confidence of the path it has participated in are both high, and this relation will be given priority when searching for the path. Among them, we use a probability function ( ): which represents the probability of continuing the deep search along with the relation . , , are used to control the degree of change in probability with the relation of confidence. During the search process, such a probability function generates the probability between 0 to 1 according to the relation confidence of the current relation. Such a probability function will ensure that we can continuously search for those important relations and terminate the search for irrelevant ones in times. As shown in part (a) of Fig. 2, for the reasoning task of the stadium, the relation between the athlete's injury and the athlete's opponent hardly participates in any path feature, so they have a low search probability. In the process of traversing entity pairs and updating the path pool, the search target gradually focus on those important relations with a high search probability, to narrow the search space and change the path feature evaluation. Particularly, if a path contains only one relation, the search will not continue. Because such a relation may be a synonym of the target relation. We will start the probabilistic search based on relation confidence after a certain number of entity pairs are traversed.
Sampling the same relation of entities In order to further narrow the search space, when an entity is connected to multiple entities through the same relation, we only search for some of them by sampling. Through such sampling, the efficiency of path search can be improved without losing too much information. As shown in Fig. 2, Lakers have a large number of players. Therefore, we can only sample and search some of its players to approximate the overall effect. This ability strategy allows us to efficiently perform path search in the KG space with a large entity out-degree value and will not completely discard the information of these height out-degree entities.
Stopping immediately after finding any tail entity Once we find any target entity, we will stop the path search. Although it is possible to find another target tail entity from the target entity, such a strategy can simplify the path to a certain extent. As shown in Figure 2 (c), we will not continue to search after searching Staples stadium to avoid redundant path features. The probabilistic depth search algorithms we called DFS-conf are shown in Algorithm 1.

Path Selection
After path search, we select the path features in the path pool and set the entity pair coverage threshold to delete those path features with high confidence but extremely low coverage. Although the confidence of these path features is high, the scope of application in the knowledge is narrow. And we use segmentation thresholds to filter paths based on the confidence of the path. Therefore, we usually set different thresholds for paths with a length of 1 and greater than 1.

Train linear regression models for relation reasoning tasks
Similar to algorithms such as PRA and DeepPath, we perform path search and get the filtered path, and finally, train a simple linear regression to perform the relation reasoning task. The input feature is a probability matrix representing the probability of the current head entity being able to walk to the correct tail entity through the current path. The higher the final output score, the more likely the entity pair has the relation.

Dataset
We evaluate the proposed method on two datasets: NELL-995 [4] and FB15K-237 [30]. The NELL-995 dataset is a subset of the 995th iteration of the NELL system, and the frequent but meaningless relations are deleted. The FB15K-237 dataset is a subset sampled from FB15K [10]. During path search, we only delete the corresponding triples and inverse triples from the KG for the currently searched head entity and tail entity set. The specific information of the datasets is shown in Table 1.

Baseline and details
We compare our method with the following methods: translation models, Analogy, Rescal, and DeepPath.
• Translation models. We use the following translation method as the baseline: TransE [10]. It regards the relation as the translation of the head entity to the target entity and map entities and relations to the same vector space by constraining the difference between vectors.
TransR [12]. It improves on TransE [10] and embeds entities and relations into different spaces. For the relation, an additional matrix is added to describe the space where the relation is located. TransH [11]. It embeds entities and relations into the same vector space, but the representation of entities in different relations is different. TransD [13]. It simplifies the TransR [12] model, uses two vectors to represent entities or relations. One of the vectors represents the entity and relation, and the other is used to construct the dynamic mapping matrix.
• Rescal [31]. It is a semantic matching model that performs reasoning by matching the underlying semantics of entities and the relations in the vector space. Its scoring function is bilinear and uses a matrix to represent relations. • Analogy [14]. It further models the analogy properties of entities and relations. At the same time, Analogy proved that DistMult [32], HolE [17], ComplEx [33] and other models can be regarded as its special cases. • DeepPath [4]. It use reinforcement learning to search for paths and set up three different rewards functions: global accuracy rewards, path efficiency rewards, and path diversity rewards to find paths. Its reasoning performance has been proved to be better than the path ranking algorithm.

Experimental Setting
Reasoning task For a head entity and target relation, we try to find the tail entity that is most likely to form a triple from the candidate tail entity. For the relation to be reasoned, the set of positive samples is denoted as , which is further split into training and testing sets. We use the training set for path search and linear model training and the reasoning performance is evaluated based on the testing set. A positive sample and its corresponding negative samples together form a sequence. The trained linear model can calculate the score of each candidate triple in the sequence and sort the sequence in descending order. We evaluate the performance of relation reasoning according to the ranking of positive samples in the sequence using mean average precision (MAP) index: If there are pairs of correct triples in sequence, the MAP could be calculated as follows: Finally, we get the average MAP of all entity pairs in the testing set.
Details and parameter settings The code of translation models comes from Fast-TransX 1 . For each reasoning task, we delete the positive sample entity pairs in the testing set from the KG to perform the embedding task. The learning rate is set to 0.01 and the margin is 1, the relation and entity embedding dimensions are both 100, and the training is performed 1000 times. For Analogy and Rescal, we get the result based on the provided code in OpenKE 2 and use the default parameters. The DeepPath algorithm is based on Xiong's code at DeepPath 3 . For our method DC-Path, the maximum path length is set to 3. In the probability function, , , are set to 0.99, 0.01, 0.5 respectively. Four threshold parameters are set for path selection: 1 and 2 represent the confidence threshold with path length equal to 1 and greater than 1 respectively. 1 and 2 represent the entity pairs coverage threshold with path length equal to 1 and greater than 1 respectively. In the NELL-995 data set, we set the above four thresholds as{0.

Results and analysis
Relation Reasoning Accuracy And Paths Used In this part, we report the reasoning results of each method and the analysis of the used path number. Table 2 reports the results of performance comparison between our method and baselines, from which we can see that DC-Path significantly outperforms most baselines in most cases. The reasoning results in the NELL-995 data set show that in most tasks, DC-Path can get higher reasoning accuracy than these baselines. Although the reasoning results on FB15k-237 show that not every task performs better than these baselines, the average accuracy of the method is still leading. Therefore, we can conclude that DC-Path can get better reasoning accuracy than these mainstream reasoning methods. Table 3 shows the number of paths used in the final reasoning of DeepPath and DC-Path. DC-Path greatly reduces the number of path features used and achieve better performance. Meanwhile, we also found that there are more path features in FB15k-237. On average, there are nearly 33 path features for each task. And the number of path features of different reasoning tasks is very unbalanced. There are nearly a hundred paths for task: but only 1 path for task: . This is why in sparse reasoning tasks, path-based reasoning methods are usually inferior to representation learning methods.

Time Consumption Of Path Search
We ran our code on a computer with 16GB of RAM and an i7 8th generation processor. For the NELL-995 dataset, the average time consumption on path search for each target relation is about 21s, while for FB15k-237, the average time is about 1100s. We also discover that DeepPath usually spends more search time. Since the reinforcement learning strategy of the DeepPath algorithm can discover longer path features, its path search cost is also greater, usually more than 10000 seconds. The reason may be that it needs to train the neural network many times. Therefore, our method can greatly reduce the time consumption in path search and use path features with a limited length to achieve good reasoning results. The Impact Of Different Confidence Thresholds On The Results In this part, we explore the influence of different path confidence thresholds on the reasoning results. We keep the paths whose path length is one and the path confidence is greater than 0.3, and the entity pair coverage is greater than 0.01. On this basis, we fix the entity pair coverage threshold to 0.01 and test the accuracy of relation reasoning with different confidence thresholds. Fig. 3 and Fig. 4 shows the number of path features retained by different path confidence thresholds and the reasoning accuracy (MAP) when using these path features for relation reasoning. We can find that the MAP of many target relations does not decrease significantly as the threshold increases, which means that those paths whose path confidence is greater than 0.5 or even higher play a key role in relation reasoning.The performance of some reasoning tasks is poor because of that there are too few effective reasoning paths that meet the confidence threshold.
Display Some Paths And Relations In this part, we show some high confidence paths in several tasks and the most relevant top-2 relations among them. Table 3 shows the important paths and their confidence in some tasks. These paths are of high quality in terms of semantic logic analysis and path confidence, which shows the effectiveness of our path search method. Through the first two most relevant relationships in the target task. It can be found that they are usually semantically closely related to the target reasoning relation, which also shows that our strategy of narrowing the path search space through dynamic relation confidence is effective. We can find that some short paths have high confidence. This proves that short paths play a greater role in reasoning.

Conclusion
This paper designs and implements a path feature search method to perform KG reasoning tasks named DC-Path. It is based on dynamic path confidence and uses it to perform relation reasoning tasks. Different from the previous reasoning methods based on graph structure , this method uses dynamic relation confidence and other indicators to achieve path search and evaluation during the searching process. Relation reasoning tasks on NELL-995 and FB15K-237 show that this method can effectively search path features for reasoning, and obtain good reasoning results, which provides new ideas for the KG reasoning method based on path features.