SlowGuess/NAACL_2022_OCR huggingface dataset:
Huda Hakami<sup>1</sup>, Mona Hakami<sup>2</sup>, Angrosh Mandya<sup>3</sup> and Danushka Bollegala<sup>3,4</sup>
$^{1}$ Department of Computer Science, Taif University, Saudi Arabia
$^{2}$ King Saud University, Saudi Arabia
<sup>3</sup>University of Liverpool, UK
4 Amazon
hahakami@tu.edu.sa, mohakami@ksu.edu.sa
{angrosh, danushka}@liverpool.ac.uk
Prior work on integrating text corpora with knowledge graphs (KGs) to improve Knowledge Graph Embedding (KGE) have obtained good performance for entities that co-occur in sentences in text corpora. Such sentences (textual mentions of entity-pairs) are represented as Lexicalised Dependency Paths (LDPs) between two entities. However, it is not possible to represent relations between entities that do not co-occur in a single sentence using LDPs. In this paper, we propose and evaluate several methods to address this problem, where we borrow LDPs from the entity pairs that co-occur in sentences in the corpus (i.e. with mention entity pairs) to represent entity pairs that do not co-occur in any sentence in the corpus (i.e. without mention entity pairs). We propose a supervised borrowing method, SuperBorrow, that learns to score the suitability of an LDP to represent a without-mention entity pair using pre-trained entity embeddings and contextualised LDP representations. Experimental results show that SuperBorrow improves the link prediction performance of multiple widely-used prior KGE methods such as TransE, DistMult, ComplEx and RotatE.
Knowledge Graphs (KGs) are a structured form of information that underline the relationships between real-world entities (Ehrlinger and Wöß, 2016; Kroetsch and Weikum, 2016; Paulheim, 2017). A KG is represented using a set of relational tuples of the form  $(h,r,t)$ , where  $r$  represents the relation between the head entity  $h$  and the tail entity  $t$ . For example, the relational tuple (Joe Biden, president-of, US) indicates that the president-of relation holds between Joe Biden and US. There exists a large number of publicly available and widely used KGs, such as Freebase (Bollacker et al., 2008), DBpedia (Auer et al., 2007), and YAGO ontology (Suchanek et al., 2007). KGs
have been effectively applied in various NLP tasks such as, relation extraction (Riedel et al., 2013; Weston et al., 2013), question answering (Das et al., 2017; Sydorova et al., 2019), and dialogue systems (Xu et al., 2020). However, most KGs suffer from data sparseness as many relations between entities are not explicitly represented (Min et al., 2013).
To overcome the sparsity problem, Knowledge Graph Embedding (KGE) models learn representations (a.k.a. embeddings) for entities and relations in a given KG in a vector space, which can then be used to infer missing links between entities (Bordes et al., 2013; Nickel et al., 2015; Wang et al., 2017). Such models are trained to predict relations that are likely to exist between entities (known as link prediction or KG completion) according to some scoring formula. Although previously proposed KGE methods have shown good empirical performances for KG completion (Minervini et al., 2015), the KGEs are learnt from the KGs only, which might not represent all the relations that exist between the entities included in the KG. To overcome this limitation, prior work has used external text corpora in addition to the KGs (Toutanova et al., 2015; Xu et al., 2016; Long et al., 2016; An et al., 2018; Wang et al., 2019b,a; Lu et al., 2020). Compared to structured KGs, unstructured text corpora are abundantly available, up-to-date and have diverse linguistic expressions for extracting relational information.
The co-occurrences of two entities within sentences (a.k.a textual mentions) in a text corpus has shown its success for text-enhanced KGEs (Komninos and Manandhar, 2017; An et al., 2018). For example, the relational tuple in the Freebase KG (Joe Biden, president-of, US) is mentioned in the following sentence "Joseph Robinette Biden Jr. is an American politician who is the 46th and current president of the United States." This sentence expresses the president-of relation between the two
Human Language Technologies, pages 2887 - 2898
entities Joe Biden and US. As the entity-pair (Joe Biden,US) appears in a single sentence, we call it a with-mention entity-pair. However, even in a large text corpus, not every related entity pair co-occurs in a specified window, which are referred to as without-mention entity-pairs in previous studies. For instance, if we consider the widely used FB15K-237 KG (Toutanova et al., 2015) and the ClueWeb12 (Gabrilovich et al., 2013) text corpus with FB entity mention annotations, $^{1}$ $33\%$  of entity-pairs in FB15k-237 do not have textual mentions within the same sentences. This sparseness problem limits the generalisation capabilities of using textual mentions for enhancing KGEs. Specifically, Toutanova et al. (2015); Komninos and Manandhar (2017) have shown larger improvements in link prediction for with-mention entity-pairs over without-mention pairs.
In this paper, we propose a method to augment a given KG with additional textual relations extracted from a corpus and represented as LDPs. The augmented KG can then be used to train any KGE learning method. This is attractive from both scalability and compatibility point of views because our proposal is agnostic to the KGE learning method that is subsequently used for learning KGEs. Our main contribution in this paper is to improve link prediction for without-mention entity-pairs by borrowing LDPs from with-mention entity-pairs to overcome the sparseness in co-occurrences of the without-mention entity-pairs. We show that learning a supervised borrowing method, SuperBorrow, that scores suitable LDPs to represent without-mention entity-pairs based on pre-trained entity embeddings and contextualised LDP embeddings boosts the performance of link prediction using a series of KGE methods, compared to what would have been possible without textual relations.
KGEs from a Multi-relational Graph: Typically, KG embedding models consist of two main steps: (a) defining a scoring function for a tuple, and (b) learning entity and relation representations. Entities are usually represented as vectors, whereas relations can be represented by vectors (e.g. TransE (Bordes et al., 2013), DistMult (Yang et al., 2014) and ComplEx (Trouillon et al., 2016)) matrices (e.g. RESCAL (Nickel et al., 2011)), or
KGE method	Score function f(h,R,t)
TransE (Bordes et al., 2013)	||h+r-t||l1/2
DistMult (Yang et al., 2014)	{h,r,t}
ComplEx (Trouillon et al., 2016)	{h,r,t}
RotatE (Sun et al., 2019)	||h○r-t||2
Table 1: Score functions proposed in KGE methods. Entity embeddings  $\mathbf{h},\mathbf{t} \in  {\mathbb{R}}^{d}$  are vectors in all models, except in ComplEx where  $\mathbf{h},\mathbf{t} \in  {\mathbb{C}}^{d}$  . Here,  ${\ell }_{1/2}$  denotes either  ${\ell }_{1}$  or  ${\ell }_{2}$  norm of a vector. In ComplEx,  $\bar{\mathbf{t}}$  is the element-wise complex conjugate.
by 3D tensors (e.g. Neural Tensor Network (Socher et al., 2013)).
Using some form of a representation, scoring functions are then defined to evaluate the strength of a relation  $r$  between  $h$  and  $t$  entities in a triple. TransE is one of the earliest and well-known distance-based KGE method that performs a linear translation and its scoring function is given in Table 1. Alternatively, a bilinear function is used in several KGE models, such as RESCAL, DistMult and ComplEx, for which scoring functions are defined in Table 1. KGEs are learnt such that the observed facts (positive triples) are assigned higher scores compared to that of the negative triple (for example generated by perturbing a positive instance by replacing its head or tail entities by an entity randomly selected from the set of entities) by minimising a loss function, such as the logistic loss or the margin loss.
Conventional KGE models are trained using the facts in the KGs, which are often incomplete. Therefore, to overcome the sparsity of structured KGs, we propose to integrate information from a text corpus, thereby augmenting the KG. The augmented KG is then used as the input to existing KGE methods to learn accurate entity and relation embeddings. In particular, we do not modify the scoring functions nor optimisation objectives for the respective KGE methods, which makes our proposed approach applicable in many existing KGE methods without any modifications.
Text-Enhanced KGEs: Recently, a new line of research that combines textual information with relational graphs has emerged (Lu et al., 2020). Different combination methods have been proposed for this purpose. Wang et al. (2014) proposed a model to embed both entities and words (using entity names and Wikipedia anchors) into the same low-dimensional vector space to capture relational
<sup>1</sup>200 million sentences in CluWeb12 annotated with FB entity mention annotations.
information from a KG and the co-occurrences from the corpus. Rosso et al. (2019) control the amount of information shared between the two data sources in the joint embedding space using regularisation. This joint model is further enhanced by incorporating entity descriptions from an external corpus, which are jointly learnt with the KG (Zhong et al., 2015; Xie et al., 2016; Veira et al., 2019). In a different scenario, the text-enhanced knowledge embedding model by Wang et al. (2016) creates a co-occurrence network of words and entities from an entity-annotated corpus. The authors define point-wise and pair-wise contexts using the co-occurrence frequencies in the network. Then, entity and relation embeddings are enhanced using textual point-wise and pair-wise embeddings, respectively. Similarly, Rezayi et al. (2021) construct an augmented KG that has nodes from external text. The original and the augmented graphs are then aligned to suppress the noise and distil relevant information. In our work, we focus on adding extra edges to the KG rather than nodes as in Rezayi et al. (2021) and Wang et al. (2016).
In addition to contextual information and textual descriptions of individual words/entities, sentences where two entities co-occur have been used as contextual evidence to learn KGEs (Toutanova et al., 2015; Komninos and Manandhar, 2017; Tang et al., 2019). For example, Toutanova et al. (2015) extracted LDPs by parsing co-occurring sentences in a text corpus, which are then used as textual relations in the KG. This model can be seen as a special case of universal schema (Riedel et al., 2013), which combines textual and KG relations in the same entity-pair co-occurrence matrix, subsequently decomposed to obtain entity embeddings. Komninos and Manandhar (2017) proposed a novel triple scoring function where textual mentions are used as a source of supporting evidence for a triple.
Our problem setting differs from prior work on text-enhanced KGEs in two important ways. First, we do not modify the underlying structure of the KGE method, which is attractive from both scalability and compatibility of our proposal. Second, rather than considering only entity-pairs that are occurring within a specified context in the corpus (i.e. with-mention entity-pairs), we propose to borrow LDPs from with-mention entity-pairs to overcome the data sparseness in without-mention entity-pairs that never co-occur within any sentence in the corpus.
A relational KG  $\mathcal{D}$  consists of a set of entities  $\mathcal{E}$  and a set of relations  $\mathcal{R}$ . In  $\mathcal{D}$ , knowledge is represented by relational tuples  $(h, r, t) \in \mathcal{D}$ , where the head entity  $h$  is related to the tail entity  $t$  by the KG relation  $r$ . In this work, we assume relations to be asymmetric in general (if  $(h, r, t) \in \mathcal{D}$  then it does not necessarily follow that  $(t, r, h) \in \mathcal{D}$ ). The goal is to learn representations for entities and relations such that missing tuples can be accurately inferred.
As KGs  $\mathcal{D}$  are often sparse with many missing edges between entities, the learnt KGEs are affected, which in return impacts the performance of KGEs on downstream tasks such as link prediction. To address this sparseness problem, we consider the availability of a text corpus  $\mathcal{T}$  where relational facts are expressed using contexts in which an entity-pair co-occurs. The textual relations that are extracted from  $\mathcal{T}$  can be injected into  $\mathcal{D}$  before applying a KGE method.
To align  $\mathcal{D}$  with  $\mathcal{T}$ , entity linking is applied to resolve ambiguous entity mentions in the text with unique entities in the KG (Gabrilovich et al., 2013; Shen et al., 2014). Then, Sentences that mentions two entities are considered as textual mentions of relations between entities. Assuming that the corpus is annotated using the entities in  $\mathcal{D}$ , there are multiple possibilities to obtain relational features of sentences that mention the entities. Following previous work (Toutanova et al., 2015), we first run a dependency parser (Chen and Manning, 2014) on each sentence containing an entity-pair to obtain LDPs. Then, if  $\mathcal{E}$  contains the head and tail entities of an LDP  $l$  (but the entity-pair might not be connected by KG relations), we insert  $l$  into  $\mathcal{R}$  to form a textual triple  $(h,l,t)\in \mathcal{D}$ . The augmented KG is then used to learn embeddings for  $\mathcal{E}$  and  $\mathcal{R}$  using different KGE methods. During KGE processes, we treat both original relations in the KG and the augmented LDPs equally. In principle, any existing KGE learning method can be applied on the augmented KG as we later see in our experiments.
One obvious limitation of the above-described method is that entity-pairs that never co-occur in any contextual window (e.g. a sentence) will not be connected by any LDP during the augmentation process. This is fine if the two entities are truly unrelated. However, this is problematic for entities that are related in the KG but their relations were not sufficiently covered in the text corpus because of the coverage issues and small size
of the corpus. As we later see in our evaluations (§ 5), this is indeed the case for the majority of the without-mention entity-pairs. To overcome this limitation of our proposal, next we describe a method to borrow LDPs from with-mention entity-pairs to without-mention entity pairs. It is worth noting that we do not connect any two entities by LDPs, but only those that are related in the KG and predicted to be associated with an LDP by the proposed method.
3.1 Learn to Borrow LDPs
Given a without-mention entity pair  $(h^{*},t^{*})$ , we propose a supervised borrowing method SuperBorrow to rank LDPs that are extracted for the with mention entity-pairs from a text corpus. Given pretrained entity representations  $h$  and  $t$ , we learn an entity-pair encoder,  $f$ , parametrised by  $\theta$ , to create an entity-pair representation,  $f(h,t;\theta)$ , for  $(h,t)$ . In this work, the encoder  $f$  is implemented as a multilayer perceptron with a nonlinear activation, where the input entity-pair to the MLP is encoded as follows:
$$
\boldsymbol {x} = \left[ \boldsymbol {h} \oplus \boldsymbol {t} \oplus (\boldsymbol {h} - \boldsymbol {t}) \oplus (\boldsymbol {h} \circ \boldsymbol {t}) \right] \tag {1}
$$
Here,  $\oplus$  denotes the concatenation of vectors and  $\circ$  is the element-wise multiplication between two vectors. (1) considers the information in the head and tail entity embeddings independently as well as the interactions between their corresponding dimensions. These features for entity-pairs have been used successfully for representing semantic relations in prior work (Washio and Kato, 2018; Joshi et al., 2018; Hakami and Bollegala, 2019). The final output vector  $f(h,t;\theta)$  of the MLP is treated as the representation of the entity-pair  $(h,t)$ .
As an alternative to representing the relationship between two entities in an entity-pair  $(h,t)$  by  $f(h,t;\theta)$  using the corresponding entity embeddings, we can use  $\mathcal{S}_{(h,t)}$ , the set of LDPs connecting  $h$  and  $t$  entities (Bollegala et al., 2010). Because an LDP is a sequence of textual tokens, we can use any sentence encoder to represent an LDP by a vector. Specifically, in our experiments later we use the pretrained sentence encoder SBERT (Reimers and Gurevych, 2019) to represent an LDP,  $l$ , by a vector,  $l$ .
We require LDPs that co-occur with an entity-pair  $(h,t)$  to be similar to  $f(h,t;\theta)$  than LDPs that do not co-occur with  $(h,t)$ . Specifically, we use the set of with-mention entity-pairs with their
Relations	Entities	Triples Train/Test	w-m	w/o-m
FB	237	14,541	272,115/20,466	2,344	18,122
Text	1,100	12,930	404,009/-	-	-
Table 2: Statistics of the datasets. w-m and w/o-m denote the number of test instances respectively in with- mention and without-mention entity-pair sets.
associated LDPs as positive training instances  $S = \{(h,l,t)\}$ . LDPs that are associated with either  $h$  or  $t$  alone (not both) are used as negative training instances  $S_{(h,t)}^{\prime}$  as given by (2).
$$
\begin{array}{l} \mathcal {S} _ {(h, t)} ^ {\prime} = \{(h, l ^ {\prime}, t) | \exists t ^ {\prime}: (h, l ^ {\prime}, t ^ {\prime}) \in \mathcal {D} \land t ^ {\prime} \neq t, \\ \exists h ^ {\prime}: \left(h ^ {\prime}, l ^ {\prime}, t\right) \in \mathcal {D} \wedge h ^ {\prime} \neq h \rbrace \tag {2} \\ \end{array}
$$
We learn the parameters of  $f(h,t,\theta)$  by minimising the marginal loss over  $S_{(h,t)}$  and  $S_{(h,t)}^{\prime}$  as shown in (3).
$$
\sum_ {(h, l, t) \in \mathcal {S}} \sum_ {(h, l ^ {\prime}, t) \in \mathcal {S} _ {(h, t)} ^ {\prime}} \max  \left(0, \gamma - f (h, t; \theta) ^ {\top} \left(\boldsymbol {l} - \boldsymbol {l} ^ {\prime}\right)\right) \tag {3}
$$
Here,  $\gamma (\geq 0)$  is the margin and is set to 1 in our experiments. To determine which LDPs to be borrowed for a particular without-mention entity pair,  $(h^{*},t^{*})$ , we first compute its representation,  $f(h^{*},t^{*};\theta)$  using the  $\theta$  found by minimising (3) above. We then score each LDP,  $l$ , using the sentence encoder model, by the inner-product,  $f(h^{*},t^{*};\theta)^{\top}l$ . We then select the top- $k$  LDPs with the highest inner-products with  $f(h^{*},t^{*};\theta)$  to augment the KG. The number of borrowed LDPs  $(k)$  is a hyperparameter that is tuned using the validation triples selected from the KG.
Datasets: We use FB15k237 as the KG and ClueWeb  $12^{2}$  as the corpus for extracting LDPs for the entity-pairs in the FB157k237 KG. Specifically, we use the textual triples consisting of LDPs that are extracted and made available<sup>3</sup> by Toutanova et al. (2015). The number of extracted unique LDPs and textual triples in this dataset are respectively
2https://lemurproject.org/clueweb12/
3https://www.microsoft.com/en-us/download/details.aspx?id=52312
Model	overall	with-mention	without-mention
MRR	MR	H@10	H@3	H@1	MRR	MR	H@10	H@3	H@1	MRR	MR	H@10	H@3	H@1
TransE (KG only)	0.336	113	0.523	0.368	0.243	0.314	135	0.508	0.349	0.218	0.333	111	0.519	0.364	0.241
KG+ExtractedLDPs	0.314	126	0.495	0.343	0.224	0.433	43	0.659	0.489	0.319	0.293	138	0.468	0.318	0.206
LinkAll	0.344	105	0.531	0.380	0.249	0.430	44	0.653	0.493	0.316	0.328	113	0.510	0.360	0.235
Co-occurrence	0.502	47	0.695	0.553	0.402	0.412	48	0.639	0.464	0.297	0.506	47	0.695	0.557	0.408
NeighbBorrow	0.491	49	0.682	0.541	0.392	0.422	46	0.646	0.475	0.308	0.493	50	0.68	0.542	0.395
SuperBorrow	0.751	15	0.868	0.799	0.681	0.394	49	0.629	0.445	0.277	0.787	11	0.888	0.835	0.723
DistMult (KG only)	0.302	133	0.489	0.333	0.209	0.257	149	0.436	0.289	0.165	0.302	131	0.489	0.333	0.209
KG+ExtractedLDPs	0.325	113	0.512	0.357	0.232	0.427	35	0.656	0.483	0.311	0.306	125	0.488	0.335	0.216
LinkAll	0.329	108	0.521	0.363	0.233	0.437	33	0.670	0.496	0.315	0.309	118	0.497	0.339	0.215
Co-occurrence	0.365	74	0.574	0.404	0.261	0.428	33	0.664	0.479	0.310	0.351	81	0.558	0.388	0.248
NeighbBorrow	0.415	54	0.639	0.465	0.302	0.412	35	0.645	0.463	0.297	0.408	57	0.631	0.458	0.295
SuperBorrow	0.482	53	0.681	0.535	0.377	0.415	35	0.655	0.475	0.291	0.482	56	0.678	0.534	0.379
ComplEx (KG only)	0.312	125	0.493	0.342	0.222	0.275	142	0.459	0.299	0.185	0.312	124	0.493	0.342	0.222
KG+ExtractedLDPs	0.321	107	0.505	0.349	0.229	0.407	36	0.637	0.458	0.291	0.304	117	0.482	0.329	0.216
LinkAll	0.328	107	0.519	0.361	0.232	0.432	34	0.665	0.493	0.311	0.309	118	0.496	0.338	0.216
Co-occurrence	0.358	76	0.570	0.399	0.252	0.436	33	0.679	0.499	0.319	0.342	83	0.552	0.380	0.238
NeighbBorrow	0.428	47	0.650	0.479	0.315	0.418	35	0.646	0.478	0.298	0.422	50	0.643	0.472	0.309
SuperBorrow	0.489	42	0.687	0.540	0.385	0.416	38	0.653	0.481	0.291	0.491	43	0.686	0.541	0.388
RotatE (KG only)	0.358	94	0.560	0.395	0.259	0.331	120	0.527	0.365	0.236	0.354	92	0.557	0.391	0.254
KG+ExtractedLDPs	0.359	94	0.551	0.396	0.264	0.448	44	0.672	0.509	0.333	0.341	101	0.528	0.374	0.247
LinkAll	0.363	91	0.558	0.400	0.266	0.442	44	0.671	0.503	0.321	0.346	98	0.536	0.378	0.251
Co-occurrence	0.435	54	0.639	0.484	0.329	0.441	46	0.663	0.499	0.327	0.426	56	0.629	0.473	0.321
NeighbBorrow	0.463	43	0.672	0.514	0.357	0.443	45	0.675	0.497	0.326	0.457	44	0.664	0.508	0.351
SuperBorrow	0.682	19	0.836	0.739	0.594	0.412	51	0.652	0.473	0.290	0.706	16	0.851	0.764	0.621
Table 3: Results of link prediction on FB15K237. Higher is better for all metrics except for the mean rank (MR) for which lower values indicate better performance. The best result for each metric and each KGE method is shown in bold.
2, 740, 176 and 3, 978, 014. To make the training of KGE methods computationally efficient, we filter out LDPs that occur in less than 100 distinct entity-pairs in the corpus. The FB15k237 test set is split into with-mention (i.e. entity-pairs that co-occur in some LDP) and without-mention (i.e. entity-pairs that do not co-occur in any LDP) sets as shown in Table 2. According to Table 2, there are  $88.14\%$  without-mention entity-pairs in the test set. Note that even if we consider the complete set of LDPs from the ClueWeb12, the portion of without-mention test entity-pairs in FB15k237 is only  $73.23\%$ . This shows the significance of the problem of representing without-mention entity-pairs, which is the focus of this paper.
Training SuperBorrow: We used the with- mention entity-pairs in train split of FB15K237 to train SuperBorrow. The number of entity-pairs in the training set is 311,906, and on average we have 1.32 LDPs per entity-pair. On average, we generate 100 negative triples for each with-mention pair. We hold-out  $10\%$  of the training entity-pairs for validation purposes (we obtain 280716 and 31190 entitypairs for training and validation, respectively). To represent each entity, we use the publicly available 100-dimensional pre-trained RelWalk embed
dings, $^{4}$  which are publicly available for the entities and relations in FB15k237.
According to (1), the input layer of the trained MLP has 400 features. The hyperparameters including the number of hidden layers  $\{2,3\}$ ,  $\ell_2$ , regularisation coefficient  $\{0,0.01,0.001\}$ , the learning rate  $\{0.01,0.1\}$  and the non-linear activation  $\{\tanh, \mathrm{relu}, \mathrm{sigmoid}\}$  are tuned using the above-mentioned validation set. The MLP consists of two 768-dimensional layers, and the last layer represents the entity-pair to be mapped to the LDP embedding space that has 768 dimensions encoded using the SBERT paraphrase-distilroberta-base model, which has reported SoTA performance on various knowledge-intensive tasks (Warstadt et al., 2020). SuperBorrow is trained for 50 iterations using mini-batch Stochastic Gradient Descent with momentum and a batch size of 128. The source for SuperBorrow is publicly available. $^6$
4https://github.com/LivNLP/ Relational-Walk-for-Knowledge-Graphs
5https://huggingface.
co/sentence-transformers/
paraphrase-distilroberta-base-v2
<sup>6</sup>https://github.com/Huda-Hakami/
Learning-to-Borrow-for-KGs