{'fraction_non_alphanumeric': 0.03301435406698565, 'fraction_numerical': 0.010084652189915349, 'mean_word_length': 4.645335549553293, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Coarse-to-fine Knowledge Graph Domain Adaptation based on Distantly-supervised Iterative Training

Modern supervised learning neural network models require a large amount of manually labeled data, which makes the construction of domain-specific knowledge graphs time-consuming and labor-intensive. In parallel, although there has been much research on named entity recognition and relation extraction based on distantly supervised learning, constructing a domain-specific knowledge graph from large collections of textual data without manual annotations is still an urgent problem to be solved. In response, we propose an integrated framework for adapting and re-learning knowledge graphs from one coarse domain (biomedical) to a finer-define domain (oncology). In this framework, we apply distant-supervision on cross-domain knowledge graph adaptation. Consequently, no manual data annotation is required to train the model. We introduce a novel iterative training strategy to facilitate the discovery of domain-specific named entities and triples. Experimental results indicate that the proposed framework can perform domain adaptation and construction of knowledge graph efficiently.


I. INTRODUCTION
The triples in the knowledge graph (KG) contain the relationships between various entities, providing rich semantic background knowledge for various natural language processing (NLP) tasks, such as natural language representation [1], question answering [2], image captioning [3], and text classification [4]. Consequently, automatically constructing knowledge graphs directly from natural texts has attracted close attentions of re-searchers in recent years [5]- [7].
KG construction from text generally involves two primitive steps: named entity recognition (NER) and relation extraction (RE). Named entity recognition aims to identify the types of entities mentioned in text sequences, such as people, place, etc. in the open domain; or disease, medicine, disease symptom, etc. in the biomedical domain. The relation extraction also known as triple extraction, aims to identify the relationship between two entities, such as the birthplace relationship between people and places in the open domain; or the therapeutic relationship between drug and disease in the biomedical domain. NER and RE are necessary steps for information extraction to construct KG from the text. In addition to NER and RE, constructing a KG usually includes other steps such as coreference resolution, entity linking, knowledge fusion, and ontology extraction. In order to facilitate model evaluation, this paper mainly focuses on information extraction and then constructs a KG.
In the construction of fine-domain KG scenarios, there are usually some existing resources available, such as biomedical KGs in coarse domains, which generally cover broader concepts and more commonsense knowledge. When constructing the oncology KG, the biomedical KG is thus available. However, few studies have focused on adapting KG from the coarse domain (e.g., biomedical) to the fine domain (e.g., oncology) where a large collection of unlabeled textual data are available, which motivates the work in this paper.
Distant supervision [8] is an intuitive way to transfer coarsedomain KG to fine domains. Distant-supervision provides labels for data with the help of an external knowledge base, which saves the time of manual labeling. For distantlysupervised NER, we can build distant labels by matching unlabeled sentences with external semantic dictionaries or knowledge bases. The matching strategies usually include string matching [9], regular expressions [10], and some heuristic rules. The distantly-supervised RE holds an assumption [11]: if two entities participate in a relation, then any sentence that contains those two entities might express that relation. Following this assumption, any sentence mentioning a pair of entities that have a relation according to the knowledge base will be labeled with this relation [8].
Therefore, the KG in the coarse domain can be potentially used as a knowledge base for distant supervision, thus avoiding a large number of manual annotations. However, only using the KG of the coarse domain as the knowledge base might limit the model's ability to discover domain-specific named entities and triples in the fine domain, which further limits the construction of the fine domain KG. To address these problems, in this paper, we propose a novel coarse-to-fine knowledge graph domain adaptation (KGDA) framework. Our KGDA framework utilizes an iterative training strategy to enhance the model's ability to discover fine-domain entities and triples, thereby facilitating fast and effective coarse-to-fine KG domain adaptation.
Overall, the contributions of our work are as follows: • An integrated framework for adapting and re-learning KG from coarse-domain to fine-domain is proposed. As a case study, the biomedical domain and oncology domain are considered the coarse domain and fine domain, respectively. • Our model does not require human annotated samples with distant-supervision for cross-domain KG adaptation, and the iterative training strategy is applied to discovering domain-specific named entities and new triples. • The proposed method can be adapted to various pretrained language models (PLMs) and can be easily applied to different coarse-to-fine KGDA tasks. It is so far the simplest data-driven approach for learning a KG from free text data, with the help of the coarse domain KG. • Experimental results demonstrate the effectiveness of the proposed KGDA framework. We will release the source code and the data used in this work to fuel further research. The constructed oncology KG will be hosted as a web service to be used by the general public.

II. RELATED WORK A. Pipeline-based methods for KG construction
The pipeline-based methods apply carefully-crafted linguistic and statistical patterns to extract the co-occurred noun phrases as triples. There are many off-the-shelf toolkits available, for example, Stanford CoreNLP [12], NLTK [13], and spaCy, which can be used for the NER tasks; Reveb [14], OLLIE [15], and Stanford OpenIE [16] can be used for the information extraction task. There have been multiple pipelines [6], [17] developed as well, consisting of modules targeting different functionalities needed for the KG construction. However, the pre-defined rules of off-the-shelf toolkits are generally tailored to specific domains, such methods are not domainagnostic, and a new set of rules will be needed for a new domain.

B. Data-driven methods for KG construction
With the development of representation learning in language models, researchers began to apply data-driven models to solve the KG construction tasks. Based on how the model is trained, these works can be divided into three categories: fully-supervised methods [9], [18], semi-supervised methods [19], and weakly-supervised methods [20]. We will introduce the methods of fully-supervised and weakly-supervised in this section. Specifically, the NER, RE, and entity linking tasks in the KG construction pipeline can all be solved by fullysupervised learning methods such as long short-term memory neural network (LSTM) [21], [22]. Graph neural network methods have also been applied for domain-specific NER tasks [23] and document-level RE [24]. The bidirectional encoder representation from transformers (BERT) [25], the widelyused PLM, can also tackle the NER [26], RE [27], and entity linking [28] tasks. While the advancement of deep learningbased methods has greatly improved the effectiveness of KG construction, fully-supervised learning requires a large amount of human-annotated data text. Furthermore, the annotation can only be domain-specific, making it difficult to transfer the KG construction work to a new domain, and ultimately limiting the scalability and efficiency of the research in KG.
On the other hand, distant supervision, a weakly supervised learning method, can replace manual annotation with an existing and remote knowledge base. Previous studies have applied remote supervised learning to deal with NER [29], and RE [30], [31] tasks. Thus in this work, we adopted the distant-supervision scheme in the proposed KGDA framework. It should be noted that KG of the coarse domain (e.g., biomedical) generally will not contain the complete knowledge of its finer sub-domains (e.g., oncology). So when we use the coarse-domain KG for distant supervision, labels of the target domain will be limited by the source domain, making it less effective to discover new knowledge. To address this issue, we introduced an iterative strategy to gradually update the model via distant supervision while at the same time using the partially-trained model to discover new entities and relations from the data of the target fine domain.

A. Notation and task definition
An unstructured sentence s = [w 1 , w 2 , w 3 , ..., w n ] indicates a sequence of tokens, where n is its length. A dataset D is a collection of unstructured sentences (i.e. D = {s 1 , s 2 , s 3 , .., s m }). The knowledge graph, denoted as K, is a collection of triples t = (e i , r j , e k ), where e i ∈ E and e k ∈ E are the head entity and the tail entity respectively, and r j ∈ V is the relation between e i and e k . Here we denote coarsedomain KG as K c and fine-domain KG as K f .
In a typical scenario of KG domain adaptation, we will have an existing coarse-domain KG and a large amount of unlabeled text in the fine domain. For example, when constructing the oncology KG, we can utilize the existing biomedical KG and collect oncology-related literature as unlabeled text. KG constructed from the fine domain data would then include overlapping triples with the coarse-domain KG and new triples representing domain-specific knowledge. Specifically, the finedomain KG contains the following three types of triples: • Overlapping triples T O : Triples that also existed in the coarse-domain KG, indicating knowledge overlapping between the coarse and fine domains. • Triples of new relations but overlapping entities T R : Triples with both entity pairs existing in the coarsedomain KG but no indicated relationships between these entity pairs. • Triples of new entities T E : Triples with at least one entity not existing in the coarse-domain KG. Consequently, the relationship is also unknown in the coarse domain. Both T R and T E belong to the specific knowledge of the fine domain. The goal of the coarse-to-fine KGDA task is to adapt the KG from the coarse domain to the fine domain and leverage the knowledge from the coarse domain to guide the mining of new knowledge specific to the fine domain. Finally, we will keep the definition of entity types and relation types from coarse-domain KG when constructing the fine-domain KG.

B. Iterative training framework
While it is trivial to identify the overlapping entities E O and triples T O by distant supervision, if the NER and RE models are trained on the entire corpus, they will not be able to recognize the fine domain-specific named entities and triples (T R and T E ). Because the distant-supervision labels are generated by matching K c . Thus we introduce an iterative training strategy to construct T R and T E from the text and adapt the knowledge from K c to K f .
The overall framework of the iterative training scheme is shown in Fig. 1, and the detailed pseudo code can be found in Algorithm 1. Rather than performing distant-supervision training on the whole unlabeled text corpus, the core mechanism of the proposed iterative training is to split the whole unlabeled dataset into n sub-datasets without intersection. Before building distant-supervision corpus, the trained model is used to predict the text corpus for getting specific knowledge of fine-domain, which is conducive to mining T R and T E of the fine-domain.
As shown in Figure 1, firstly, it is necessary to preprocess the acquired text corpus in the fine domain. Preprocessing operations include: handling special characters, word segmentation, filtering sentences using human-defined rules (such as sentence length), etc. Then, our framework involves two neural network models: NER model and RE model. We replace the PLM's output layer with a classifier head as NER model model N and fine-tune it by minimizing the cross-entropy loss on distant-supervision NER corpus. Additionally, we apply the BIO scheme [32] 14: train RE(model R , corp R ) 15: 18: return K f apply the previously trained model N and mode R to extract the entities and triples in the fine-domain, and select the high confidence entities E conf and high confidence triples T conf as the specific knowledge of the fine-domain (line 7). Then, we take K c , E conf , and T conf as the external knowledge base for constructing distant-supervision corp N and corp R (line 8). Finally, we use overlapping triples T O and high-confidence triples T conf to construct a knowledge graph of fine domains (line 17).
Next, we show the details of get distant corpus in Algorithm 2 and get specific knowledge in Algorithm 3.

C. Constructing distantly-supervised corpus
Through distant-supervision, we can only match entity pairs that have a relationship and use them as positive samples. We then construct negative samples with NULL relationship by the following two schemes: 1) randomly sampling two entities which have no relationship as defined in the coarse-domain; 2) randomly sampling a word from out-of-domain words (i.e., a word that is not an entity as defined in the coarse domain) W O as one of the entities. The parameter ratio n controls the ratio of negative samples (constructed by either schemes) to the total sample size. The parameter ratio o controls the ratio of entity pairs constructed by the second scheme (i.e., via sampling the  corp R = corp R ∪ get samples(triples) 12: corp R = corp R ∪ get samples(triples n ) 13: words outside the domain) to the size of negative samples, respectively.
In addition to the K c in the source domain, we use both K c , E conf , and T conf as knowledge bases for constructing the remotely supervised corpus. This would ensure that the NER and RE models can identify the overlapping knowledge between K c and K f , while at the same time be guided to discover the new knowledge specific to the fine domain.
As shown in Algorithm 2, for building the distantlysupervised NER corpus corp N , the sentence D j i is firstly string-matched with the knowledge bases K c and E conf to extract the entities in the sentence (line 5). Afterward, the matched entities are merged into overlapping entities E O , and the NER label sequences are generated through the BIO strategy to merge into corp N (line 6 and 7). For building the distantly-supervised RE corpus corp R , we firstly take K c and T conf as knowledge bases and use entity pair matching to match the triples triples k based on K c and the triples triples c based on T conf appearing in the sentence D j i (line 8). We then build negative triples with parameters ratio n and ratio o (line 10). Finally, we construct the RE corpus based on the triples triples, triples n and corresponding sentences through a predefined relationship sample template (line 11 and 12).

D. Discovering fine-domain specific knowledge
Recall that in the proposed iterative training framework, the whole unlabeled dataset is divided into n sub-dataset T new = merge triple( T new , triples ) 18: j = j + 1 19: end while 20: T conf = get confidence triple( T new , th pt , th pt ) 21: return E new , E conf , T new , T conf D i , i = 1...n, the fine-domain specific knowledge discovery will be performed on each sub-dataset except the first one D i , i = 2...n (line 5 to 16 in Algorithm 1). For each new subdataset D i , i = 2...n, we will use the previously-updated models model N and model R to predict the new entities and triples. Afterward, the sub-dataset will be used for updating model N and model R via distantly-supervised training. As noisy or incorrect entities and triples could be discovered during this procedure, we developed a filtering mechanism only to keep the entities and triples with higher confidence. Specifically, we design the rules for filtering the discovered entities and triples by: 1) probability of the new entities and triples predicted by the corresponding models should be greater than pre-defined thresholds th pe and th pt , respectively; 2) cumulative frequency of the new entities and triples discovered from datasets D 2 to D i should be greater than the pre-defined thresholds th f e and th f t , respectively.
As shown in Algorithm 3, for discovering new entities E new , we will apply the trained model N on dataset D i and obtain entities that are disjoint with K c (line 5 and 6). Then, we will merge entities with the previously-discovered entity set E new (line 7). Finally, we will select the "highconfident" entity as E conf based on the mechanism above by the prediction probability and cumulative frequency (line 10). For the discovery of new triples T new , we will enumerate entity pairs that are disjoint with the K c (line 13 -15). We will then use the trained RE model and the predefined sample template to predict the relationship of the entity pairs and delete the triples whose predicted relationship is NULL (line 16). Other processing is similar to the discovery of new entities.
After Algorithm 3, discovered entities specific to the fine domain are stored in E conf . Discovered triples T R (new relation, overlapping entity) and T E (new relation, new entity) are stored in T conf . In the next iteration, Algorithm 2 will then use the updated E conf and T conf for building distantsupervision corpus. Such iterative design can facilitate the interoperability between the two competing tasks based on a fixed number of unannotated data samples in the fine target domain: distantly-supervised training of the NER and RE models versus the discovery of new knowledge using the trained NER and RE models, thus improve the efficiency of performing KG domain adaptation and construction without any annotation.

IV. EXPERIMENTS
In this work, we used the adaptation of KG from the biomedical domain (coarse) to the oncology domain (fine) as an example to demonstrate the workflow of the KGDA framework, as well as to evaluate its effectiveness in practice. Implementation details of the experiment are also provided, along with the publicly-available data and the containerized environment in the released source code, for easy replication of the experiment and the development of other KG methods.

A. Dataset
We downloaded papers from 12 international journals (journal details can be found in the supplemental materials) in the oncology domain. PDF files of the papers were cleaned and converted to sentences. In total, we included nearly 240,000 sentences as the unlabeled text corpus of the oncology domain D. The coarse-domain KG K c used in this work is the biomedical KG 1 , defines 18 entity types and 19 relationship types, including 5.2 million English entities and 7.34 million triples. The lists of entity types and relationship types can be found in the supplementary materials.

B. Evaluation
Similar to the previous works [11], we evaluate our method in two schemes: held-out evaluation and manual evaluation. For the held-out evaluation, we reserved a part of the text corpus of D as the test set. During the testing, we then compared the prediction results of the NER and RE models with the labels matched with K c , and calculated the precision, recall, and F1 of the held-out dataset. Specifically, we use seqvel 2 to evaluate the micro average precision, recall, F1 of NER. When evaluating the RE model, we perform relation classification prediction on the triples existing in K c and corresponding entity pairs appearing in the held-out corpus. Finally, weighted average precision, recall, and F1 from the held-out evaluation will be reported.
As the labels of testing samples in the held-out evaluation are all inferred by distant supervision from the coarse domain, such scheme can only evaluate whether the trained model can capture the knowledge in the coarse domain, but cannot evaluate the ability of the models to discover new knowledge in the fine-domain. Therefore, we also adopted the manual evaluation scheme, consisting of the evaluations of: 1) the entities specific to fine domain E conf , which are not presented in K c ; 2) the triples of new relations T R ; 3) the triples of new entities T E . We randomly sampled 50 cases of E conf , T R , and T E respectively, then asked one physician to manually label them for whether the entities and triples are correct. As the number of name entities and triples instances that are expressed in the corpus is unknown, we cannot estimate the recall of fine-domain KG. Therefore, we only show the precision of E conf , T R , and T E . We fully recognize that the discovery of new knowledge in the fine-domain is an indispensable task for this work and we are recruiting more medical experts to conduct human reader study and performance evaluation for the proposed model.

C. Implementation settings
We divide the corpus D into six equal subsets, and each subset contains around 40,000 sentences. We used D 1 to D 5 for model training and KG construction. We reserved D 6 for heldout evaluation. We tested BERT [25], Bio ClinicalBERT [33], biomed RoBERTa [34] for initializing NER and RE models. Our experiments were run on an Ubuntu system computer with three NVIDIA 1080Ti graphics cards. The learning rate, batch size, and epochs are set as 2E-05, 20, and 4, respectively. Hyperparameters th f e ,th pe ,th f t ,th pt are set as 2, 0.95, 3, 0.97. The parameters ratio n and ratio o that control negative sampling are set to 0.2 and 0.3. The results of the NER and RE models evaluated by the held-out dataset are shown in Table I and Table II, respectively. The KGDA frameworks initialized by the three pre-trained language models (BERT, Bio ClinicalBERT, and biomed RoBERTa) all show good performance in held-out evaluations, demonstrating the robustness of our framework. 69587 20615 1631  24580 905  Bio ClinicalBERT 70055 20611 1936  25312 1195  biomed RoBERTa  69497 20495 1625  23183 1071  TABLE III  THE NUMBER Table III, with each row belonging to one pre-trained language models used. Numbers of E O and T O have minor differences among different pre-trained language models, possibly due to the conflicts in strings matching of knowledge bases. E conf , T R , and T E represent specific knowledge of the fine domain. We sampled 50 cases from E conf , T R , and T E for manual evaluation, and the results are shown in Table IV.

F. Knowledge graph construction in the fine domain
As our ultimate goal, we can construct the KG in the fine domain by combining T O , T R , and T E . We selected biomed RoBERTa as the backbone language model for KGDA and constructed the knowledge graph correspondingly. An example of the KG we built is shown in the supplementary material.

G. Ablation study
We investigated the impact of 3 techniques employed by KGDA on its held-out experiment performance by removing the corresponding component from the framework: w/o (cumulative): When using corpus D i to train NER and RE models, the cumulative corpus is not used. i.e. delete lines 9 and 10 in Algorithm 1 and mark corp N and corp R in line 8 as corp N and corp R respectively.
w/o (iter): Remove the iterative training strategy and only use K C as an external knowledge base.
w/o (iter, type): Remove the iterative training strategy and delete the entity type in the template of RE. In, this method, the template is "[CLS] head entity [SEP] tail entity [SEP] sentence".
The results of the ablation analysis are shown in Table V. Compared to the complete framework with w/o (cumulative), it can be seen that the using of accumulated data through iterations is beneficial for improving the generalization ability of NER and RE models. The held-out performances of the model without iteration indicates that the iterative training strategy can not only discover the specific knowledge in the fine domain, but also maintain the ability to discover overlapping knowledge between coarse and fine domain. The RE performance of w/o (iter) is slightly better than that of w/o (iter, type), indicating that specifying the entity type of the entities is helpful for improving the performance of the RE task.

V. CONCLUSION AND DISCUSSION
In this paper, we propose an integrated, end-to-end framework for knowledge graph domain adaptation using distant supervision, which can be used to construct KG from fully unlabeled raw text data with the guidance of an existing KG. To deal with the potential challenges in distant supervision, which might limit the knowledge discovered from the new domain, we propose an iterative training strategy, which divides an unlabeled corpus into multiple corpuses. For each new corpus to the model, we then combine the knowledge in the coarse domain with the knowledge identified from the previous corpuses for distantly-supervised training. By adopting the iterative training strategy, our proposed KGDA framework can discover not only knowledge that overlaps with the coarse domain, but also knowledge specific to the fine domain and unknown to the coarse domain, thus enabling coarse-tofine domain adaptation. We implemented the adaptation from biomedical KG to the oncology domain in our experiments and verified the effectiveness of the KGDA framework through held-out and manual evaluation.
Several limitations and challenges remain beyond the current work for more effective and accurate KG construction: Firstly, more thorough evaluation with human reader study is needed to validate that new knowledge relevant (not only correct) to the target domain can be discovered by KGDA. Secondly, it has been recognized by the field that distant supervision will inevitably introduce noisy labels [31], [35], thus the denoising step is usually needed but not implemented in the current version of KGDA. Thirdly, there has been existing KG constructed in the related domains of oncology and cancer research. We will investigate the scheme to allow adaption from multiple sources (not only the coarse domain) to leverage this existing knowledge better. Another type of crucial prior information for this work is clinical ontology, where we will integrate the relationships defined in ontology and entity description to enhance the model. Fourthly, an essential premise of the KGDA is that we assume the source and target domains share the same set of entity types and relation types, which can limit the knowledge discovered from the fine domain. We will investigate data mining techniques to adaptively add/remove entity and relation types in the fine domain. Finally, there have been many new large-scale pretrained language models developed such as GPT-3 in recent years. While our model uses variations of BERT (Biome-dRoBERTa and BioClinicalBERT) as backbone networks, we can easily adapt KGDA to other language models.