We live in an evolving world with a lot of heterogeneity as well as new entities being created continuously. For example, scientific papers and Wikipedia pages describing facts about new entities, are being constantly added (e.g. . These new findings further trigger the inference of newer facts, each with its own diverse reasoning. We are interested in developing such automated reasoning systems for large knowledge-bases (KBs).
In machine learning, non-parametric methods hold the promise of handling evolving data (Cover 1 Code available at https://github.com/ ameyagodbole/ Prob-CBR and Hart, 1967; Rasmussen, 2000) . Most current KG completion models learn low dimensional parametric representation of entities and relations via tensor factorization or sophisticated neural approaches (Nickel et al., 2011; Bordes et al., 2013; Socher et al., 2013; Sun et al., 2019; Vashishth et al., 2020) . Another line of work learns Hornclause style reasoning rules from the KG and stores them in its parameters (Rocktäschel and Riedel, 2017; Das et al., 2018; Minervini et al., 2020) . However, these parametric approaches work with a fixed set of entities and it is unclear how these models will adapt to new entities. This paper presents a k-nearest neighbor (KNN) based approach for KG reasoning that is reminiscent of case-based reasoning (CBR) in classical AI. A CBR system solves a new problem by retrieving 'cases' that are similar to the given problem, revising the solution to retrieved cases (if necessary) and reusing it for the new problem (Schank, 1982; Leake, 1996, inter-alia) . For the task of finding a target entity given a source entity and binary KG relation (e.g. (JOHN VON NEU-MAN, PLACE OF DEATH, ?) in Figure 1 ), our approach first retrieves k similar entities (cases) to the query entity. Next, for each retrieved entity, it finds multiple KG paths 2 (each path is a solution to retrieved cases) to the entity they are connected by the query relation (e.g. paths between (RICHARD FEYNMAN, USA)). However, one solution seldom works for all queries. For example, even though the path 'BORN IN' is predictive of 'PLACE OF DEATH' for US-born scientists (figure 1), it does not work for scientists who have immigrated to USA. To handle this, we present a probabilistic CBR approach which learns to weighs paths with respect to an estimate of its prior and its precision, given the query. The prior of a path rep- Figure 1 : Given the query, (JON VON NEUMANN, PLACE OF DEATH, ?), our model gathers reasoning paths from similar entities such as other scientists. However, not all gathered paths work for a query e.g. the path ('BORN(x, y)') would not work for VON NEUMANN. This highlights the importance of learning path weights for clusters of similar entities. Even though 'BORN IN' could be a reasonable path for predicting PLACE OF DEATH, this does not apply for VON NEUMANN and other scientists in his cluster. The precision parameter of the path given the cluster helps in penalizing the 'BORN IN' path. Note that the node USA is repeated twice in the figure to reduce clutter. resents its frequency while the precision represents the likelihood that the path will lead to a correct answer entity. To obtain robust estimates of the path parameters, we cluster similar entities together and compute them by simple count statistics ( §2.2.3).
Apart from computing these estimates, our method needs no further training. Overall, our simple approach outperforms several recent parametric rule learning methods (Das et al., 2018; Minervini et al., 2020) and performs competitively with various state-of-the-art KG completion approaches (Dettmers et al., 2018) on multiple datasets.
An advantage of non-parametric models is that it can adapt to growing data by adjusting its number of parameters. In the same spirit, we show that our model can seamlessly handle an 'open-world' setting in which new entities arrive in the KG. This is made possible by several design choices such as (a) representing entities as sparse (non-learned) vector of its relation types ( §2.2.1), (b) our use of an online non-parametric hierarchical clustering algorithm (Monath et al., 2019) that can efficiently recompute changes in cluster assignments because of the newly added entity ( §2.3), (c) and a simple and efficient way of recomputing the prior and precision parameters for paths per cluster ( §2.2.3).
Current models for KG completion that learn entity representations for a fixed set of entities cannot handle the open-world setting. In fact we show that, retraining the models continually with new data leads to severe degradation of the model performance with models forgetting what it had learned before. For example, the performance (MRR) of ROTATE model (Sun et al., 2019) drops by 11 points (absolute) on WN18RR in this setting ( §3.4). On the other hand, we show that with new data, the performance of our model is consistent as it is able to seamlessly reason with the newly arrived data.
Our work is most closely related to a recent concurrent work by Das et al. (2020) where they propose a model that gathers paths from entities similar to the query entity. However, Das et al. (2020) encourages path that occur frequently in the KG and does not learn to weigh paths differently for queries. This often leads to wrong inference leading to low performance. For example, on the test-II evaluation subset of FB122 where all triples can be inferred by logical rules, Das et al. (2020) scores quite low (63 MRR) because of learning incorrect rules. On the other hand, we score significantly higher (94.83 MRR) demonstrating that we can learn more effective rules. In fact, we consistently and significantly outperform Das et al. (2020) on several benchmark datasets. Also, unlike us, they do not test themselves in the challenging open-world setting.
The contributions of this paper are as follows: (a) We present a KNN based approach for KG completion that gathers reasoning paths from entities that are similar to the query entity. Following a principled probabilistic approach ( §2.2), our model weighs each path by its likelihood of reaching a correct answer which penalizes paths that are spurious in nature. (b) The parameters of our model grow with data and can be estimated efficiently using simple count statistics ( §2.3). Apart from this, our approach needs no training. We show that our simple approach significantly outperforms various rule learning methods (Das et al., 2018; Minervini et al., 2020; Das et al., 2020) on many benchmark datasets. (c) We also show that our model can easily handle addition of facts about new entities and is able to seamlessly integrate and reason with the newly added data significantly outperforming parametric embedding based models.
2 Non-parametric Reasoning in KGs
Let V denote the set of entities, R denote the set of binary relations and G denote a KB or equivalently a Knowledge Graph (KG). Formally,
is a directed labeled multigraph where V and E denote the vertices and edges of the graph respectively. Note that, E ⊆ V × R × V . Let (e 1 , r, e 2 ) denote a fact in G where e 1 , e 2 ∈ V and r ∈ E. Also, following previous approaches (Bordes et al., 2013) , we add the inverse relation of every edge, i.e., for an fact (e 1 , r, e 2 ) ∈ E, we add the edge (e 2 , r −1 , e 1 ) to the graph. (If the set of binary relations R does not contain the inverse relation r −1 , it is added to R as well).
Task: We consider the task of query answering on KGs, i.e., answering questions of the form (e 1q , r q , ?), where answer is an entity in the KG.
A path in a KG between two entities e s , e t is defined as a sequence of alternating entity and relations that connect e s and e t . A length of a path is the number of relation (edges) in the path. Formally, let a path p = (e 1 , r 1 , e 2 , . . . , r n , e n+1 ) with st(p) = e 1 , en(p) = e n+1 and len(p) = n. We also define a path type as the sequence of the relations in p, i.e., type(p) = (r 1 , r 2 , . . . , r n ). Let P denote the set of all paths in G. Let P n ⊆ P = {p | len(p) ≤ n} be the set of all paths of length up to n. Also, let P n denote the set of all path types with length up to n, i.e. P n = {type(p) | p ∈ P n }. Let P n (e 1 , r) ⊆ P n denote all path types of length up to n that originate at e 1 and end at the entities that are connected to e 1 by a direct edge of type r. In other words, if S e 1 r = {e 2 | (e 1 , r, e 2 ) ∈ G} denotes the set of entities that are connected to e 1 via a direct edge r, then P n (e 1 , r) denotes the set of all path types of length up to n that start from e 1 and end at entities in S e 1 r . By definition, r ∈ P n (e 1 , r).
Similarly, we define P n (e 1 , r) which contain paths instead of path types.
Given a query, our approach gathers KG path types from entities that are similar to the query entity. Each path type is weighed with respect to an estimate of both its frequency and precision ( §2.2.1). By clustering similar entities together ( §2.2.2), our model obtains robust estimate of the path statistics ( §2.2.3). Our approach is non-parametric because -(a) Instead of storing reasoning rules in parameters (Das et al., 2018; Minervini et al., 2020) , it derives them dynamically from k-similar entities (like a non-parametric k-nn classifier (Cover and Hart, 1967) ). (b) We cluster entities together using a non-parametric clustering approach and provide an efficient way of adding / estimating parameters when entities are added to the KG ( §2.3).
Our approach first finds k similar entities to the query entity that have atleast an edge of type r q . For example, for the query (MELINDA GATES, WORKS IN CITY, ?), we would consider WAR-REN BUFFET if we observe (WARREN BUFFET, WORKS IN CITY, OMAHA). We refer to these entities as 'contextual entities'. Each entity is represented as a sparse vector of its outgoing edge types, i.e. e i ∈ {0, 1} |R | . If entity e i has m distinct outgoing edge types, then the dimension corresponding to those types are set to 1. This is an extremely simple and flexible way of representing entities which we find to work well. Also note that, as more data is added about an entity, this sparse representation makes it trivial to update the embeddings.
Let E c,q denote the set of contextual entities for the query q. To compute E c,q , we first sort entities with respect to their cosine distance with respect to query entity and select the k entities with the least distance and which have the query relation r q . For each contextual entity e c , we gather the path types (up to length n) that connect e c to the entities it is connected by the edge r q (i.e. P n (e c , r q ) in §2.1). These extracted path types will be used to reason about the query entity. Let P n (E c,q , r q ) = e c ∈E c,q P n (e c , r q ) represent the set of unique path types from the contextual entities. The probability of finding the answer entity e 2 given the query is given by:
P (e 2 | e 1q , r q ) = ∑ p∈P n (E (c,q) ,r q ) P(e 2 , p | e 1q , r q ) = ∑ p P(p | e 1q , r q )P(e 2 | p, e 1q , r q ) (1)
We marginalize the random variable representing the path types obtained from E c,q . P(p | e 1q , r q ) denotes the probability of finding a path type given the query. This term captures how frequently each path type co-occurs with a query and represents the prior probability for a path type. On the other hand, P(e 2 | p, e 1q , r q ) captures the proportion of times, when a path type p is traversed starting from the query entity, we reach the correct answer instead of some other entity. This term can be understood as capturing the likelihood of reaching the right answer or the 'precision' of a reasoning path type. This is crucial in penalizing 'spurious' path types that sometimes coincidentally find the right answer entity. For example, for the query relation WORKS IN CITY, the path type (FRIEND∧ LIVES IN CITY) might have a high prior probability (since people often have many friends in the city where they work). However, this path is 'spurious' with respect to WORKS IN CITY, since they might have friends living in various cities and hence this path type will not necessarily return the correct answer.
Equation 1 has parameters for each entity in the KG. For large KGs, this can quickly lead to parameter explosion. Also, estimating per-entity parameter leads to noisy estimates due to sparsity. Instead, we choose to cluster similar entities together. Let c be a random variable representing the cluster assignment of the query entity. Then for the pathprior term, we have
We assume that each entity is assigned to one cluster, so P(c | e 1q , r q ) is zero for all clusters except the cluster in which the query entity belongs to. Secondly we assume, that the prior probability of a path given the entity and cluster can be determined from the cluster alone and is independent of each entity in the cluster. In other words, if c e 1q is the cluster in which the e 1,q has been assigned, then P(p | c e 1q , e 1q , r q ) = P(p | c e 1q , r q ). Instead of perentity parameters, we now aggregate statistics over entities in the same cluster and have per-cluster parameters. We also show that this leads to significantly better performance ( §3.3). A similar argument applies for the path-precision term in which we calculate the proportion of times, a path leads to the correct answer entity starting from each entity in the cluster.
To perform clustering, we use hierarchical agglomerative clustering with average linkage with the entity-entity similarity defined in §2.2.1. We extract a non-parameteric number of clusters from the hierarchy using a threshold on the linkage function. Agglomerative clustering has been shown to be effective in many knowledge-base related tasks such as entity resolution (Lee et al., 2012; Vashishth et al., 2018) and in general has shown to outperform flat clustering methods such as K-means (Green et al., 2012; Kobren et al., 2017) . A flat clustering is extracted from the hierarchical clustering by using a threshold on the linkage function score. We perform a breadth first search from the root of the tree stopping at nodes for which the linkage is above the given threshold. The nodes where the search stops give a flat clustering (refer to §A.2 for more detail on this).
Next we discuss how to estimate path prior and precision terms. There exists abundant modeling choices to estimate them. For example, following Chen et al. (2018) , we could train a neural network model to estimate P(p | c e 1q , r q ). However, with our original goal of designing a simple and efficient non-parametric model, we estimate these parameters by simple count statistics from the KG. E.g., the path prior P(p | c, r q ) is estimated as
For each entity in cluster c, we consider the paths that connect e c to entities it is directly connected to via edge type r q (P n (e c , r q ) in §2.1). The path prior for a path type p is computed as the proportion of times the type of paths in P n (e c , r q ) is equal to p.
Note that in equation 2, if a path type appears multiple times, we count all instances. For example, for the query relation WORKS IN CITY, a path of the form (CO WORKER ∧ WORKS IN CITY) can occur multiple times, since a person can have multiple different co-workers. Considering just path types will lead to under-weighing of such important paths. Similarly, the path-precision probability (P(e 2 | p, c, r q )) can be estimated as,
Let P n (e c ) denote the paths of up to length n starting from the entity e c . Note, unlike P n (e c , r q ), the paths in P n (e c ) do not have to end at specific entities. Also from §2.1, en(p) denotes the end entity for a path p and S e c r q denotes the set of entities that are connected to e c via a direct edge of type r q . Equation 3, therefore, estimates the proportion of times the path p successfully ends at one of the answer entities when starting from e c , given r q .
There are several advantages in estimating the parameters using simple count statistics. Firstly, they are extremely simple, and statistics for each entity in clusters can be computed in parallel making them extremely time efficient. Secondly once they are computed, our approach needs no further training. Lastly, when new data is added, it makes it easy to update the parameters without training from scratch.
To summarize, given a query entity (e 1q , r q ), our method gathers reasoning paths from k similar entities to e 1q . These reasoning paths are then traversed in the KG starting from e 1q , leading to a set of candidate answer entities. The score of each answer entity candidate is computed as a weighted sum of the reasoning paths the lead to them (Equation 1). Each path is weighed with an estimate of its frequency (Equation 2) and precision (Equation 3) given the query relation. The next section describes how we extend our model for open-world setting where new entities and facts are added to the KB.
A great benefit of non-parametric models is that it can seamlessly handle growing data by adding new parameters. New entities constantly arrive in the world (e.g. new Wikipedia articles about entities are frequently created). We consider a setting (Figure 2) in which new entities with few facts (edges) about them keep getting added to the KG. This setting is challenging for parametric models (Das et al., 2018; Sun et al., 2019) as it is unclear how these models can incorporate new entities without retraining from scratch. However, retraining to obtain entity embeddings on industrial scale KGs might be impractical (e.g. consider Facebook social graph where new users are joining continuously). Next, we show that our approach can handle this setting efficiently in the following way: (a) Adding/updating entity representations: First we need to create entity representations for the newly arrived entities. Also, for some existing entities for which new edges were added (e.g. BILL GATES, DURHAM, etc. in figure 2) , their representations need to be updated. Recall, that we represent entities as a sparse vector of its edge types and hence this step is trivial for our approach. (b) Updating cluster assignments: Next the new entities needs to be added to clusters of similar entities. Also, the cluster assingments of entities that got updated can also change as well and their change can further trigger changes to the clustering of other entities. To handle this, one could naively cluster all entities in the KG, however that could be wasteful and time-consuming for large KGs. Instead, we use an online hierarchical clustering algorithm -GRINCH (Monath et al., 2019), which has shown to perform as well as agglomerative clustering in the online setting. GRINCH observes one entity at a time, placing it next to its nearest neighbor and performing local re-arrangements in the form of rotations of tree nodes and global rearrangments in the form of grafting a subtrees from part of the tree to another. Entities can be deleted from a hierarchy by simply removing the corresponding leaf node. We first use GRINCH to delete the entities whose representations had changed because of the addition of the new node and then incrementally add those entities back along with the newly added entities in the KG. We extract a flat clustering from the hierarchical clustering built (c) Re-estimating new parameters: After reassigning clusters, the final step is to estimate the per-cluster parameters. This computation is efficient as it is clear from equations 2 and 3 that the contribution from each entity in a cluster can be computed independently (and hence can be easily parallelized). However, even for each entity, this computation needs path traversal in the KG which is expensive. We show that we do not have to recompute for all entities in the clusters. Let n denote the maximum length of a reasoning path considered by our model. For every new entity e i added to the KG, we need to recompute statistics for entities that lie within cycles of length up to (n + 1) starting from e i . Please refer to appendix (A.4) for a justification of this result.
In this section, we evaluate our proposed approach on a wide array of knowledge-base completion (KBC) benchmarks ( §3.3). To evaluate the nonparametric nature of our approach, we also evaluate on an 'open-world' setting ( §2.3) in which new entities are added to the KG. We demonstrate our proposed approach is competitive to several stateof-the-art methods on benchmarks in the standard setting, but it greatly outperforms other methods in the online setting ( §3.4). The best hyper-parameters for all experiments including the range of hyperparameter tried and results on validation set are noted in §A.6.
Data. We evaluate on the following KBC datasets: Evaluation metrics. Following previous work, we evaluate our method using HITS@N and mean reciprocal rank (MRR), which are standard metrics for evaluating a ranked list.
Knowledge Base Completion. Given an entity e 1 and a relation r, our task is retrieve all entities e 2 such that (e 1 , r, e 2 ) belongs in the edges E in a KG G. This task is known as tail prediction. If the relation is instead the inverse relation r −1 , we assume that we are given an e 2 and asked to predict entities e 1 such that (e 1 , r −1 , e 2 ) belongs in the edges E (head prediction). To be exactly comparable to baselines, we report an average of head and tail prediction results 3 . We are given a knowledge graph with three partitions of edges, E train , E dev , E test .
For this task, we evaluate against several stateof-the-art embeddings based models such as Dist-Mult (Yang et al., 2015) , Open-world Knowledge Base Completion. In this setting, we begin with the top 10% of the most popular nodes (with several edges going out from them) and add more randomly selected nodes such that the initial seed KB contains 50% of all the entities in V . This is to ensure, that the seed KB is not too sparse and the initial models trained on them are meaningful. Next, any edges between the nodes selected are added to the seed KB. We divide the rest of the entities randomly into 10 batches. Each batch of entities is incrementally added to the KB along with the edges contained in it. The validation and test set are also divided in the same way, i.e. if both the head and tail entity of a triple are present in the KB, only then the triple is put in the corresponding splits.
Parametric models for KBC that learn representations for a fixed set of entities can not handle 'open-world' setting out-of-the-box. We extend the most competitive embedding based model -RotatE (Sun et al., 2019) for this task. For every new entity arriving in a batch, we initialize a new entity embedding for it. We explore two ways of initial- Table 3 : Results on WN18RR (above) and below) izing the new entity embeddings -(a) random initialization, and (b) average of element-wise rotation of entity embeddings w.r.t the relation that this new entity is connected to. Specifically, let t denote the new entity and let S = {(h, r,t)} be the facts associated with entity t. Then the embedding e t is computed as
Here, • represents the Hadamard (or element-wise) product. This initialization minimizes the RotatE objective for the new embedding ensuring that it is "well-placed" according to the model in the previous time step. Embeddings for new relations are initialized randomly. Next, the model is further trained on the new batch of triples so that the new entity embeddings get trained. Note, for massive KGs, it might be impractical to re-train on the entire data as new batches of data arrive frequently, however to still prevent the model to forget what it had learned before, we also sample m% of triples that it had already been trained on and re-train on them. We ensure that triples in the neighborhood of the newly added entities are ten times likely to be sampled more than other triples. We also try a setting where we try freezing the initially trained entity embeddings and only training the new entity and relation embeddings.
The results for KBC tasks are presented in Table 2 and 3 4 . Our method does significantly better than parametric rule learning approaches such as MIN-ERVA, GNTPs and the recent case-based approach of Das et al. (2020) . We would like to highlight the difference between the performance of our model and that of Das et al. (2020) on the test-II evaluation of FB122 where triples can be answered by learning logical rules. This results emphasizes the importance of our probabilistic weighing of paths. We also perform comparably to most embedding based models and achieve state-of-the-art results on the overall test sets of FB122 and NELL-995. We report the mean over 3 runs for our model. We perform an ablation where we do not cluster entities (i.e. every entity has its own cluster) and have per-entity parameters. Table 4 notes the drop in performance due to the noisy estimates of path prior and precision parameters because of sparsity. Table 6 shows an example where our model learns to score different paths based on the type of entities present in the cluster.
Effect of path length on WN18RR: On the dev set of WN18RR, out of 2985 queries where 4 There are no reported results of GNTPs on NELL-995 our method does not rank the answer in the top-10, 2030 queries require a minimum path length greater than 3. Path-based reasoning models have no power to answer these queries. To correct for this, we perform an experiment with the path length n = 5 (950 of 2030 answers are reachable). The results in Table 5 show that our method recovers a significant portion of performance when allowed to use longer reasoning paths. Figure 3 reports the result for this task. We report results on the RotatE model with randomly initialized embeddings for new entities (RotatE) and the model with systematic initialization of new entity embeddings (RotatE+). We experiment with m = {10%, 30%} of previously seen edges and retrain on them. We find that not including previously seen edges leads to severe degradation of overall performance due to the model forgetting what it had learned in the past. We also report results with freezing the already seen entity representations and only learning representations for new entities (RotatE-Freeze). All models were trained till the validation set (containing both new and old triples) performance stopped improving. For our approach, we also report results for an oracle setting where we re-cluster all entities as new data arrives and re-estimate all parameters from scratch (instead of using GRINCH and recomputing only required parameters ( §2.3). For both datasets, the offline-best results were obtained by RotatE (47.1 for FB122 test-I, 48 for WN18RR). We report performance on the entire evaluation set (full) and also on the set containing the newly added edges (new). The main summary of the results are (i) RotatE model converges to a much lower performance in the online setting losing at least 8 MRR points in FB122 and at least 11 points in WN18RR. On FB122, we observe that the model prefers to learn new information more by sacrificing previously learned facts (2nd subfigure in figure 3 ) (ii) In the freeze setting, the model performance deteriorates quickly after a certain point indicating saturation, i.e. it becomes hard for the model to learn new information about arriving entities by keeping the parameters of the existing entities fixed. (iii) On the full evaluation, RotatE+ performs better than RotatE showing that bad initialization deteriorates performance over time, however, there is still a large gap between the best performance (iv) Our approach almost matches our performance in oracle setting indicating the effectiveness of the online clustering and fast parameter approximation. (v) Lastly, we perform closest to the offline best results outperforming all variants of RotatE.
Open-world KG completion. Shi and Weninger (2018) consider the task of open-world KG completion. However, they use text descriptions to learn entity representations using convolutional neural networks. Our model does not use additional text data and we use very simple entity representations that helps us to perform well. Tang et al. (2019) learns to update a KG with new links by reading news. Even though they handle adding or deleting new edges, they do not observe new entities. Lastly, none of them learn from similar entities using a CBR approach.
Inductive representation learning on KGs. Recent works (Teru et al., 2020; Wang et al., 2020) learn entity independent relation representations and hence allow them to handle unseen entities. However, they do not perform contextual reasoning by gathering reasoning paths from similar entities. Moreoever, in our open-world setting, we consider the more challenging setting, where new facts and entities are arriving in a streaming fashion and we give an efficient way of updating parameters using online hierarchical clustering. This allows our method to be applicable in settings where the initial KG is small and it grows continuously.
Rule induction in knowledge graphs. Classic work in inductive logic programming (ILP) (Muggleton et al., 1992; Quinlan, 1990) induce rules from grounded facts. However, they need explicit counter-examples which are not present in KBs and they do not scale to large KBs. Recent ILP approaches (Galárraga et al., 2013 , 2015 try to fix Figure 3 : Results for open-world setting when trained with 10% (top row) and 30% (bottom row) of already seen edges. Our online method matches the offline version of our approach and outperforms the online variants of RotatE. After all data is observed our online method achieves results closest to the best offline method's results.
(athlete-led-sports-team, team-plays-in-league) (athlete-home-stadium, league-stadiums −1 )
(politician-us-member-of-political-group, person-belongs-to-organization −1 , agent-belongs-to-organization) (agent-collaborates-with-agent, agent-belongs-to-organization) (Getoor and Taskar, 2007; Kok and Domingos, 2007; Schoenmackers et al., 2010) and probabilistic logic approaches (Richardson and Domingos, 2006; Broecheler et al., 2010; Wang et al., 2013) combine machine learning and logic to learn rules. However, none of these work derive reasoning rules dynamically from similar entities in the knowledge graph.
Bayesian non-parametric approaches for linkprediction. There is a rich body of work in bayesian non-parametrics to automatically learn the latent dimension of entities (Kemp et al., 2006; Xu et al., 2006) . Our method does not learn latent dimension of entities, instead our work is nonparametric because it gathers reasoning paths from nearest neighbors and can seamlessly reason with new entities by efficiently updating parameters using online non-parametric hierarchical clustering.
Embedding-based approach for link prediction. We also compare to the more popular embeddings based models based on tensor factorization or neural approaches (Nickel et al., 2011; Bordes et al., 2013; Dettmers et al., 2018; Sun et al., 2019) . Our simple approach which needs no iterative opti-mization outperforms most of them and performs comparably to the latest RotatE model. Moreover we outperform RotatE in the online experiments.
CBR for KG completion. There has been few attempts to apply CBR for knowledge management (Dubitzky et al., 1999; Bartlmae and Riemenschneider, 2000) , however they do not do contextualized reasoning or consider online settings. Our work is most closely related to the recent work of Das et al. (2020) . However, since it does not take in to account the importance of each path, it suffers from low performance, with our model outperforming it in several benchmarks.
We present a simple yet accurate approach for probabilistic case-based reasoning in knowledge bases. Our method is non-parametric, deriving reasoning rules dynamically from similar entities in the KB and is capable of handling new entities. We cluster similar entities together and estimate per-cluster parameters that measures the prior and precision of paths using simple count statistics. Our simple approach performs competitively to the best embeddings based models on several benchmarks and outperforms all models in the open-world setting.
Algorithm 1 Select a flat clustering from a tree structure. 
A.1 Entity Clusters Both clustering methods used in this paper, hierarchical agglomerative clustering (HAC) and GRINCH measure similarities between sets of clusters via a linkage function. In particular, we use average pairwise linkage. For two sets A and B, this is defined as:
A hierarchical clustering T over the entities V , encodes a large number of flat partitions of the entities, often referred to as tree consistent partitions in the clustering literature. We select one of these tree consistent partitions using a threshold on the linkage function, τ. The algorithm performs a breadth first search starting at the root node. The search stops at any node for which the linkage is above the given value τ. Pseudocode is given in Algorithm 1.
We analyze the number of entities that need to be re-clustered and added in each round. We observe that it is significantly fewer than the number of entities in the KB. Note that an online method like the one proposed in this paper just needs to run on the new and modified entities while a batch algorithm would need to run on the entire KB. 
Proposition: Let n denote the maximum length of a reasoning path considered by our model. For every new entity e i added to the KG, we need to recompute statistics for entities that lie within cycles of length up to (n + 1) starting from e i . We see from Eq 2, that the estimate for the prior for a path type p depends on P n (e c , r q ) i.e. the set of paths that lead from e c to entities that are connected to e c via relation r q . WLOG, say e t is such an entity i.e. (e c , r q , e t ) ∈ G. When a new entity/edge is added to the KG, this set of paths might increase.
It is easy to see that the set P n (e c , r q ) is updated iff a new path p new of length ≤ n appears between e c and e t . In this case, the edges in p new would form a cycle with the edge (e c , r q , e t ). The length of the cycle would be at most len(p new ) + 1 which in turn is at most of length n + 1. This, to find entities for which the prior has changed after the addition of a new edge/entity, it is sufficient to find entities lying on cycles of length up to n + 1 starting from the new entity/edge. This mechanism for finding entities for recomputation is only approximate when computing the precision. We see from Eq 3, that the numerator depends on paths that lead to the answer entity (as with prior) while denominator depends on all n length paths around e c . So, if the numerator is ever to be increased, we would catch that update by the proposed cycle finding method. However, even if an entity does not lie on a cycle with the new edge/entity, if there is a path of length n from e c to the new edge/entity, the denominator count would Table 7 shows some example of new entities arriving and getting assigned to their respective clusters by GRINCH.
Computing Infrastructure: All our experiments were run on a Xeon E5-2680 v4 @ 2.40GHz CPU with 128 GB RAM. No GPUs were needed for the experiments.
The results on the validation set are reported in table 8 and avg. of 3 runs are reported in table 9. The NELL-995 does not come with a validation set, and therefore we selected 3000 edges randomly from the full NELL KB. As a result, many of the query relations were different from what was present in the splits of NELL-995 and hence is not a good representative. However, we report test results for the best hyper-parameter values that we got on this validation set.
The fixed number of parameters in our model are essentially the sparse non-learned entity vectors (which can be easily stored in COO format without taking much space). Other than that, our model is non-parametric with the number of parameters tied to the data. For experiments on WN18RR:
• Inference time: 18.9 queries/s (total of 6268 queries)
• Train time: around 20 mins.
• Best Hyper-parameters: • Hyper-parameter method / bounds: Grid search -K: [5, 10 , 15, 20, 30 , 40, 50 