A Method for Constructing a Knowledge Graph of Echinococcosis Based on a Joint Extraction Model and Its Application
By constructing a knowledge graph of echinococcosis using a joint extraction model, the problem of incomplete extraction of echinococcosis literature information in existing technologies is solved, and end-to-end knowledge triple extraction is achieved, thereby improving the data support capability for echinococcosis research.
Patent Information
- Application Number
- CN202211579157.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-12-07
AI Technical Summary
Existing information extraction models are unable to effectively extract knowledge triples from echinococcosis literature, resulting in incomplete information in the constructed knowledge graph, which cannot meet the needs of echinococcosis research.
A joint extraction model-based approach is adopted. By defining the knowledge graph pattern of echinococcosis, a training dataset is constructed. A multi-stage joint extraction model with BioBert encoding layer, entity decoding stage and relation decoding stage is used to solve the problems of entity nesting and relation overlap, and end-to-end knowledge triple extraction is achieved.
It improves the ability to extract knowledge triples from echinococcosis literature, constructs a more comprehensive knowledge graph, reduces data collection complexity, improves recognition performance, and solves the shortcomings of existing information extraction models.
Smart Images

Figure CN116049422B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing, specifically a method for constructing a knowledge graph of echinococcosis based on a joint extraction model and its application. Background Technology
[0002] Echinococcosis is a parasitic disease caused by the infection of the host by the larval stage of Echinococcus granulosus. This is mainly because there is relatively little literature on echinococcosis and it is scattered. Researchers find it difficult to extract the information they want from these scattered studies, and there is a lack of a dedicated echinococcosis database to summarize this scattered information, which makes it difficult to carry out research on echinococcosis.
[0003] In recent years, knowledge graphs have emerged as a novel knowledge base technology and have been widely used in knowledge storage and representation, information retrieval, search engines, and intelligent question answering. Knowledge graphs use knowledge triples as storage material, abstracting knowledge into a connected graph structure, and are equipped with a dedicated graph query language to facilitate users' rapid storage and retrieval of information. A large portion of the knowledge triples that serve as the data source for knowledge graphs originate from unstructured text data. Manually obtaining knowledge triples is very difficult. With the development of deep learning, information extraction methods based on deep learning models have been successively used for automated knowledge mining. However, these information extraction models all have some drawbacks: traditional pipeline models suffer from entity redundancy, error propagation, and low subtask interaction; early joint extraction models are insufficient in extracting sentence patterns with special structures that frequently appear in echinococcosis literature. For example, sequence labeling-based methods struggle to solve the problem of overlapping relationships, and pointer labeling-based methods struggle to solve the problem of nested entities. These shortcomings make it difficult for existing information extraction models to be applied to information extraction tasks in echinococcosis literature, resulting in incomplete information coverage in the constructed knowledge graphs, which is detrimental to echinococcosis research. Summary of the Invention
[0004] This invention aims to address the shortcomings of existing technologies by proposing a method for constructing a knowledge graph of echinococcosis based on a joint extraction model and its application. The goal is to improve the ability to extract knowledge triples from echinococcosis literature, thereby enabling the constructed knowledge graph to cover as much complete information as possible about echinococcosis. This knowledge graph will then be integrated into an online echinococcosis database to effectively support echinococcosis research.
[0005] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:
[0006] The present invention provides a method for constructing a knowledge graph of echinococcosis based on a joint extraction model, characterized by the following steps:
[0007] Step 1. Define the schema of the echinococcosis knowledge graph:
[0008] Step 1.1. After obtaining the echinococcosis literature collection and extracting the keywords of each echinococcosis literature, count the word frequencies of all keywords, and use the word frequencies to delete all keywords with non-relational semantics, so as to obtain a set of keywords with relational semantics;
[0009] Step 1.2. Sort the set of keywords with relational semantics in reverse order according to the word frequencies, and select the top X keywords with the highest word frequencies as the X relational types in the echinococcosis schema P;
[0010] Step 2. Construct the echinococcosis training data set:
[0011] Step 2.1. Extract the abstract and text parts of each echinococcosis literature, and split the abstract and text parts respectively according to the sentence terminator to obtain the split echinococcosis literature sentences, and form a set a of echinococcosis literature sentences;
[0012] Step 2.2. Randomly select u echinococcosis literature sentences from the set a of echinococcosis literature sentences to form a subset b, and then delete the sentences in subset b from set a; u < U, where U represents the total number of sentences in the set a of echinococcosis literature sentences;
[0013] Step 2.3. Annotate each sentence in subset b one by one to obtain the annotated echinococcosis data set c. Let any annotated sample in data set c be denoted as sp = {s, TS}, where s = {w1, w2, …, w it , …, w lw} represents an echinococcosis literature sentence in sample sp, w iw represents the iw-th vocabulary in it, lw represents the vocabulary size,
[0014] TS = {t1, t2, …, t it , …, t lt} represents the annotation of sentence s, where t it = (head it , r it , tail it ) is the it-th knowledge triple, head it represents the head entity of t it , tail j represents the tail entity of t it , and head it , tail it ∈ s, and head it , tail it is a combination of vocabularies, and the vocabularies of the two do not overlap; r it represents t itRelationship type, r it ∈P; lt represents the number of knowledge triples;
[0015] Step 3. Construct a joint extraction model for echinococcosis information, including: an encoding stage, an entity decoding stage, and a relationship decoding stage; among them, the encoding stage includes a preprocessing layer, a word embedding layer, and a BioBert encoding layer; the entity decoding stage includes an entity matrix construction layer and an entity vector decoding layer; the relationship decoding stage includes a CLN normalization layer and a relationship decoding layer;
[0016] Step 3.1. Input the sentence s into the joint extraction model for echinococcosis information, and the preprocessing layer in the encoding stage judges the vocabulary amount lw in s. If lw > N, then s is segmented to obtain a segmented sentence set, where any one segmented sentence is denoted as S, S ∈ s, and S = {W1, W2, …, W in , …, W N}, W in represents the in-th vocabulary. If the vocabulary amount of the last segmented sentence is less than N, it is padded with empty characters to N so that the vocabulary amount of all segmented sentences is equal to N; if lw < N, the vocabulary amount of s is padded with empty characters to N; where N represents the maximum vocabulary amount;
[0017] Step 3.2. There is a preset dictionary in the word embedding layer, and the dictionary contains several key-value pairs, where the key is the vocabulary and the value is the binary index;
[0018] Input the segmented sentence s into the word embedding layer in the encoding stage, and use the dictionary to query the in-th vocabulary W in to obtain the binary index a in of the in-th vocabulary W in in the dictionary, so as to obtain the dictionary embedding vector
[0019] α = {a1, a2, …, a in , …, a N};
[0020] The word embedding layer embeds the in-th vocabulary W in according to the serial number of S in s to obtain the segmented sentence index b in , so as to obtain the segmented sentence index embedding vector β = {b1, b2, …, b in , …, b N};
[0021] The word embedding layer embeds the in-th vocabulary W in according to the serial number of the in-th vocabulary W in in S to obtain the position index c in , so as to obtain the position embedding vector γ = {c1, c2, …, cin ,…,c N};
[0022] The word embedding layer uses equation (1) to obtain the word embedding vector set I = {I1, I2, ..., I...} in ,…,I N}:
[0023] I in =a in +b in +c in (1)
[0024] In equation (1), I in Indicates the in-th word W in Word embedding vectors;
[0025] Step 3.3: Input the word embedding vector set I of the sentence S into the BioBert encoding layer for encoding to obtain the encoding vector T, and let n represent the length of the encoding vector T;
[0026] Step 3.4: Input the encoded vector T into the entity decoding stage for entity recognition.
[0027] Step 3.4.1: The entity matrix construction layer defines and randomly initializes a two-dimensional matrix EM with dimension n×n;
[0028] Step 3.4.2: The entity matrix construction layer uses equations (2) and (3) to calculate the scoring left multiplication matrix Q and the scoring right multiplication matrix P, respectively:
[0029] Q = W q T+b q (2)
[0030] P = W p T+b p (3)
[0031] In equations (2) and (3), W q Let b represent the weight matrix of Q. q W represents the bias vector of Q. p Let b represent the weight matrix of P. p Represents the bias vector of P;
[0032] Step 3.4.3: After the entity matrix construction layer performs an orthogonal transformation on T, it obtains the position encoding matrix R, and R satisfies equation (4);
[0033]
[0034] In equation (4), R j-i Let R represent the ji-th column vector of R.j Let R represent the j-th column vector of R. i Let R represent the i-th column vector. Indicates transpose;
[0035] Step 3.4.4: The entity matrix construction layer uses equation (5) to obtain any segment of the encoded subsequence T in the encoded vector T. |i,j| The score Score(i,j):
[0036]
[0037] In equation (5), Q i P represents the i-th column vector in the scoring matrix Q. j This represents the vector in the j-th column of the scoring matrix P;
[0038] Step 3.4.5: The entity matrix construction layer will... |i,j| Mapped to the i-th row and j-th column element of EM (i,j) Thus, the mapped two-dimensional matrix EM is obtained;
[0039] Step 3.4.6: The model entity vector decoding layer sets an entity vector E of length n and initializes it as an all-zero vector, then maps the elements EM... (i,j) The sequence E accumulated from position i to position j in E |i,j| At each position within, the mapped entity vector E is obtained;
[0040] Step 3.5: After concatenating the encoded vector T and the mapped entity vector E, the concatenation is input into the relation decoding stage, and the CLN normalization layer performs normalization processing, thereby obtaining the echinococcosis entity relation link vector using equation (1).
[0041] L = {l1, l2, ..., l i ,…,l n}:
[0042]
[0043] In equation (6), l i Let e represent the i-th vector unit of L. i Let g represent the i-th vector unit of the mapped entity vector E, where μ and σ represent the mean and standard deviation of T+E, respectively. i c represents the i-th element of the self-optimized gain vector in the CLN normalization layer. i This represents the i-th element of the condition vector of the CLN normalization layer;
[0044] Step 3.6: Input L into the relation decoding layer and use the entity relation exhaustive algorithm to predict all knowledge triples in L:
[0045] Step 3.6.1: Transform L into the i-th vector unit l i up to the j-th vector unit l j The entity L constitutes |i,j| Let t be any it-th knowledge triple in TS. it head entity it ;
[0046] Step 3.6.2: Set one of the X relation types in the echinococcosis model P to t. it relation type r it ;
[0047] Step 3.6.3: The relation decoding layer performs a transformation activation on L and outputs the starting index vector of the tail entity.
[0048] tail start ={ts1,ts2,…,ts y ,…,ts n The end index vector of the tail entity. end ={te1,te2,…,te z ,…,te n}, where ts y The tail entity's starting index vector is represented by the tail. start The element at position y in the middle, te z The tail entity's end index vector represents the vector at which the entity ends. end The element at position z in the middle, y, z∈[1,n];
[0049] Step 3.6.4: Set the probability threshold λ. If ts y and te z If all values are greater than λ and y ≤ z, then it is determined that the y-th vector unit l is the one that is in the middle. y up to the z-th vector unit l z The entity L constitutes |y,z| It is the knowledge triplet t in L. it tail entity sequence it Thus, a complete knowledge triplet t is obtained. it =(head) it ,r it ,tail it );
[0050] Step 3.6.5: Following the process of Steps 3.6.2-3.6.4, traverse each relation type in the echinococcosis pattern P to obtain the annotation of the clause S composed of several knowledge triples;
[0051] Step 3.7: The total loss of the echinococcosis information joint extraction model is the sum of the cross-entropy loss in the entity decoding stage and the cross-entropy loss in the relation decoding stage;
[0052] Step 4: Train the joint extraction model for echinococcosis information and construct a knowledge graph of echinococcosis:
[0053] Step 4.1: Iteratively train the echinococcosis information joint extraction model using the echinococcosis dataset c, and calculate the total loss function to update the model parameters until the total loss function converges, thereby obtaining the trained echinococcosis information joint extraction model TM.
[0054] Step 4.2: Take out Uu unlabeled echinococcosis literature sentences from subset b in sequence, input them into the trained echinococcosis information joint extraction model TM, and output the predicted labels of Uu echinococcosis literature sentences and store them in the triple prediction set RS.
[0055] Step 4.3: Store the prediction head entity and prediction tail entity of any prediction knowledge triple in the triple prediction set RS into the entity set ES, and remove duplicate entities and relations in RS and ES.
[0056] Step 4.4: Construct a knowledge graph of echinococcosis using a graph database:
[0057] Step 4.4.1: Traverse the deduplicated ES' and create graph entities corresponding to each prediction head entity and prediction tail entity in the graph database;
[0058] Step 4.4.2: Traverse the deduplicated RS' and retrieve the graph entity corresponding to the head entity and the graph entity corresponding to the tail entity in any predicted knowledge triple from the graph database, and create the relationship type between the two.
[0059] Step 4.4.3: After all relations are created, the relational connectivity graph composed of graph entities participating in multiple sets of knowledge triples serves as the constructed echinococcosis knowledge graph.
[0060] The present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a program that supports the processor in executing the echinococcosis knowledge graph construction method, and the processor is configured to execute the program stored in the memory.
[0061] The present invention discloses a computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, performs the steps of the echinococcosis knowledge graph construction method.
[0062] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0063] 1. This invention automates the extraction of knowledge triples by constructing an information extraction model. The model is trained by sampling a portion of the data as a dataset, enabling the model to obtain knowledge triples from echinococcosis literature end-to-end. This reduces the complexity of data collection in the echinococcosis knowledge graph construction process. Only enough literature sentences need to be provided as input to make the constructed echinococcosis knowledge graph more comprehensive and complete in terms of echinococcosis-related information.
[0064] 2. This invention adopts a three-stage joint extraction as the design architecture of the extraction model, unifying the entity recognition subtask and the relation extraction subtask in one model. By using a common loss function, the two subtasks iterate together, which increases the interactivity between the two subtasks and avoids the performance defects of the relation extraction subtask caused by the error propagation and entity redundancy of the entity recognition subtask in the pipeline method, thus improving the overall recognition performance of echinococcosis.
[0065] 3. Based on the characteristics of the corpus in echinococcosis literature, this invention employs multiple optimization strategies to address the problem of poor model recognition accuracy caused by the large number of special sentence patterns appearing in echinococcosis literature sentences. In the entity decoding stage, the BioPointer strategy is used to solve the problem of entity re-nesting, and in the relation decoding stage, the entity relation exhaustive algorithm is used to solve the problem of relation overlap. All of the above optimizations improve the model's ability to extract knowledge triples from echinococcosis literature. Attached Figure Description
[0066] Figure 1 This is a flowchart of the method of the present invention;
[0067] Figure 2 This is a model framework diagram of the present invention. Detailed Implementation
[0068] In this embodiment, a method for constructing a knowledge graph of echinococcosis based on a joint extraction model improves the ability to extract knowledge triples from echinococcosis literature by designing a specialized information extraction model tailored to the corpus characteristics of echinococcosis literature. Figure 1 The flowchart shows the steps to be followed:
[0069] Step 1. Define the schema of the echinococcosis knowledge graph, aiming to pre-define the relationship categories of the graph, ensure that the stored content of the graph has the maximum information value, and also set classification goals in the knowledge triple extraction task of the model:
[0070] Step 1.1. After obtaining the echinococcosis literature collection and extracting the keywords of each echinococcosis literature, count the word frequencies of all keywords, and use the word frequencies to delete all non-relational semantic keywords, so as to obtain a set of relational semantic keywords;
[0071] Step 1.2. Sort the set of relational semantic keywords in reverse order according to the word frequencies. The keywords with relational semantics refer to the keywords that can be used as relationship types and usually have verb characteristics. Select the X keywords with the highest word frequencies as the X relationship types in the echinococcosis schema P;
[0072] Step 2. Construct the echinococcosis training data set, aiming to train an automated end-to-end extraction model through a relatively limited set of manually annotated samples, so as to reduce the human cost in the task of constructing the echinococcosis knowledge graph:
[0073] Step 2.1. Extract the abstract and text parts of each echinococcosis literature, and split the abstract and text parts respectively according to the sentence terminator to obtain the split echinococcosis literature sentences, and form a set a of echinococcosis literature sentences;
[0074] Step 2.2. Randomly select u echinococcosis literature sentences from the set a of echinococcosis literature sentences to form a subset b, and then delete the sentences in subset b from set a; u < U, where U represents the total number of sentences in the set a of echinococcosis literature sentences;
[0075] Step 2.3. Annotate each sentence in subset b one by one to obtain the annotated echinococcosis data set c. Let any annotated sample in data set c be denoted as sp = {s, TS}, that is, a set composed of a sentence and all knowledge triples in the sentence. Among them, s = {w1, w2, …, w iw , …, w lw} represents an echinococcosis literature sentence in sample sp, w iw represents the iw-th vocabulary in it, lw represents the vocabulary size, and TS = {t1, t2, …, t it , …, t lt} represents the annotation of sentence s. Among them, t it = (head it , r it , tail it ) is the it-th knowledge triple, head it represents the head entity of t it , and tail jDenote t it as the tail entity, and head it , tail it ∈s, and head it , tail it is a combination of words, and the words of the two do not overlap; r it denotes the relationship type of t it , r it ∈P; lt represents the number of knowledge triples;
[0076] Step 3. Construct a combined extraction model for echinococcosis information. The model architecture is as Figure 2 shown, including: an encoding stage, an entity decoding stage, and a relationship decoding stage; among them, the encoding stage includes a preprocessing layer, a word embedding layer, and a BioBert encoding layer; the entity decoding stage includes an entity matrix construction layer and an entity vector decoding layer; the relationship decoding stage includes a CLN normalization layer and a relationship decoding layer;
[0077] Step 3.1. Input the sentence s into the combined extraction model for echinococcosis information, and the preprocessing layer in the encoding stage judges the vocabulary size lw in s. If lw > N, then s is segmented to obtain a segmented sentence set. The purpose of segmentation is to perform unified fixed-length processing for the downstream. Among them, any segmented sentence is denoted as S, S∈s, and S = {W1, W2,..., W in ,..., W N}, W in represents the in-th word. If the number of words in the last segmented sentence is less than N, then it is padded with empty characters to N, so that the number of words in all segmented sentences is equal to N; if lw < N, then the number of words in s is padded to N with empty characters; where N represents the maximum vocabulary size;
[0078] In the word embedding layer, there is a preset dictionary, which contains several key-value pairs. Among them, the key is the word, and the value is the binary index;
[0079] Input the segmented sentence S into the word embedding layer in the encoding stage, and use the dictionary to query the in-th word W in to obtain the binary index a in of the in-th word W in in the dictionary, so as to obtain the dictionary embedding vector α of S = {a1, a2,..., a in ,..., a N};
[0080] The word embedding layer embeds the in-th word W in according to the serial number of S in s to obtain the segmented sentence index b in , so as to obtain the segmented sentence index embedding vector β = {b1, b2,..., b in ,..., bN};
[0081] Word embedding layer based on the in-th word W nn The index in S corresponds to the in-th word W. in Embedding is performed to obtain the position index c. in Thus, the position embedding vector γ = {c1, c2, ..., c in ,…,c N};
[0082] The word embedding layer uses equation (1) to obtain the word embedding vector set I = {I1, I2, ..., I...} in ,…,I N}:
[0083] I in =a in +b in +c in (1)
[0084] In equation (1), I in Indicates the in-th word W in Word embedding vectors;
[0085] Step 3.3: Input the word embedding vector set I of sentence S into the BioBert encoding layer for encoding to obtain the encoding vector T. Let n represent the length of the encoding vector T. The BioBert model has been pre-trained on a large amount of biomedical corpus, and the encoded vector has the characteristics of biomedical corpus. It has a good feature representation ability for sentences in echinococcosis literature.
[0086] Step 3.4: Input the encoded vector T into the entity decoding stage for entity recognition. The entity decoding layer performs entity recognition by constructing an entity matrix. For a one-dimensional vector, any subsequence can be mapped to a point in the upper triangular part of the two-dimensional entity matrix. By scoring this point in the entity matrix, a certain vector subsequence is indirectly scored to obtain the score of any possible entity sequence. Since the points corresponding to two nested entities in the entity matrix are completely independent, the obtained scores are calculated separately, thus solving the entity nesting problem.
[0087] Step 3.4.1: Define and randomly initialize a two-dimensional matrix EM with dimension n×n in the entity matrix construction layer;
[0088] Step 3.4.2: The entity matrix construction layer uses equations (2) and (3) to calculate the left-multiplication matrix Q and the right-multiplication matrix P of the scoring matrix, respectively:
[0089] Q = W q T+b q (2)
[0090] P = W p T+b p (3)
[0091] In equations (2) and (3), W q Let b represent the weight matrix of Q. q W represents the bias vector of Q. p Let b represent the weight matrix of P. p Represents the bias vector of P;
[0092] Step 3.4.3: After the entity matrix construction layer performs an orthogonal transformation on T, the position encoding matrix R is obtained, and R satisfies equation (4);
[0093]
[0094] In equation (4), R j-i Let R represent the ji-th column vector of R. j Let R represent the j-th column vector of R. i Let R represent the i-th column vector. Indicates transpose;
[0095] Step 3.4.4: The entity matrix construction layer uses equation (5) to obtain any segment of the encoded subsequence T in the encoded vector T. |i,j| The score Score(i,j), T |i,j| This represents the sequence from position i to position j in the encoded vector T:
[0096]
[0097] In equation (5), Q i P represents the i-th column vector in the scoring matrix Q. j This represents the vector in the j-th column of the scoring matrix P;
[0098] Step 3.4.5, Entity Matrix Construction Layer will T |i,j| Mapped to the i-th row and j-th column element of EM (i,j) Thus, the mapped two-dimensional matrix EM is obtained;
[0099] Step 3.4.6: The model entity vector decoding layer sets an entity vector E of length n and initializes it as an all-zero vector. The mapped elements EM... (i,j) The sequence E accumulated from position i to position j in E |i,j| At each position within, the mapped entity vector E is obtained;
[0100] Step 3.5: After concatenating the encoded vector T and the mapped entity vector E, the concatenation is input into the relation decoding stage. The concatenation of these two vectors adopts the idea of residual network, which ensures that the downstream can use the entity scores obtained in the entity decoding stage, and does not lose the corpus features in the sentence encoded vector. The CLN normalization layer performs normalization processing, so as to obtain the echinococcosis entity relation link vector L={l1,l2,…,l i ,…,l n}:
[0101]
[0102] In equation (6), l i Let e represent the i-th vector unit of L. i Let g represent the i-th vector unit of the mapped entity vector E, where μ and σ represent the mean and standard deviation of T+E, respectively. i c represents the i-th element of the self-optimized gain vector in the CLN normalization layer. i This represents the i-th element of the conditional vector in the CLN normalization layer. In the implementation mechanism of CLN, compared with the usual normalization, the output after labeling is controlled by optimizing the gain vector and the conditional vector. These two vectors are also trained iteratively through samples to obtain the normalized output that maximizes the benefit to the downstream classification task.
[0103] Step 3.6: Input L into the relation decoding layer and use the entity relation exhaustive algorithm to predict all knowledge triples in L. The algorithm mainly adopts the idea of exhaustively enumerating all combinations. Through a double loop-like approach, it combines each entity in the upstream entity vector with each relation in the echinococcosis pattern, and uses this combination as a condition to predict the tail entity. Due to the exhaustive nature of the head entity and relation combination, and the fact that the selection of the two is independent, the relation overlap problem can be solved.
[0104] Step 3.6.1: Transform L into the i-th vector unit l i up to the j-th vector unit l j The entity L constitutes |i,j| Let t be any it-th knowledge triple in TS. it head entity it ;
[0105] Step 3.6.2: Set one of the X relation types in the echinococcosis model P to t. it relation type r it ;
[0106] Step 3.6.3: The relation decoding layer performs a transformation activation on L and outputs the starting index vector tail of the tail entity. start={ts1,ts2,…,ts y ,…,ts n The end index vector of the tail entity. end ={te1,te2,…,te z ,…,te n},in,
[0107] ts y The tail entity's starting index vector is represented by the tail. start The element at position y in the middle, te z Represents the end index vector of the tail entity
[0108] tail end The element at position z in the middle, y, z∈[1,n];
[0109] Step 3.6.4: Set the probability threshold λ. If ts y and te z If all values are greater than λ and y ≤ z, then it is determined that the y-th vector unit l is the one that is in the middle. y up to the z-th vector unit l z The entity L constitutes |y,z| It is the knowledge triplet t in L. it tail entity sequence it Thus, a complete knowledge triplet t is obtained. it =(head) it ,r it ,tail it );
[0110] Step 3.6.5: Following the process of Steps 3.6.2-3.6.4, traverse each relation type in the echinococcosis pattern P to obtain the annotation of the clause S composed of several knowledge triples;
[0111] Step 3.7: The total loss of the echinococcosis information joint extraction model is the sum of the cross-entropy loss in the entity decoding stage and the cross-entropy loss in the relation decoding stage;
[0112] Step 4: Train the joint extraction model for echinococcosis information and construct a knowledge graph of echinococcosis:
[0113] Step 4.1: Use the echinococcosis dataset c to iteratively train the echinococcosis information joint extraction model and calculate the total loss function to update the model parameters until the total loss function converges, thereby obtaining the trained echinococcosis information joint extraction model TM.
[0114] Step 4.2: Take out Uu unlabeled echinococcosis literature sentences from subset b in sequence, input them into the trained echinococcosis information joint extraction model TM, and output the predicted labels of Uu echinococcosis literature sentences and store them in the triple prediction set RS.
[0115] Step 4.3: Store the prediction head entity and prediction tail entity of any prediction knowledge triple in the triple prediction set RS into the entity set ES, and remove duplicate entities and relations in RS and ES.
[0116] Step 4.4: Construct a knowledge graph of echinococcosis using a graph database. The graph construction adopts the approach of first constructing entities and then constructing relationships for the already created entities. The purpose is to prevent the same entity from being repeatedly created in the graph database, which would lead to the entity nodes becoming disconnected.
[0117] Step 4.4.1: Traverse the deduplicated ES' and create graph entities corresponding to each prediction head entity and prediction tail entity in the graph database;
[0118] Step 4.4.2: Traverse the deduplicated RS' and retrieve the graph entity corresponding to the head entity and the graph entity corresponding to the tail entity in any predicted knowledge triple from the graph database, and create the relationship type between the two.
[0119] Step 4.4.3: After all relations are created, the relational connectivity graph composed of graph entities participating in multiple sets of knowledge triples serves as the constructed echinococcosis knowledge graph.
[0120] In this embodiment, an electronic device includes a memory and a processor. The memory is used to store a program that supports the processor in executing the above-described echinococcosis knowledge graph construction method, and the processor is configured to execute the program stored in the memory.
[0121] In this embodiment, a computer-readable storage medium stores a computer program, which, when run by a processor, executes the steps of the above-described echinococcosis knowledge graph construction method.
Claims
1. A method for constructing a hydatidosis knowledge graph based on a joint extraction model, characterized in that, is performed according to the following steps: Step 1, define the mode of the hydatid disease knowledge graph: Step 1.1, after obtaining the hydatid disease literature set and extracting the keywords of each hydatid disease literature, the word frequency of all keywords is counted, and all non-relationship semantic keywords are deleted using the word frequency, thereby obtaining a set of relationship semantic keywords; Step 1.
2. Sort the keyword set of the relationship semantics in reverse order according to the word frequency, and select the top two keywords with the highest word frequency as the relationship types in the echinococcosis pattern Step 2, construct a hydatid disease training data set: Step 2.1, extract the abstract and text part of each hydatid disease literature, and split the abstract and text part according to the sentence terminal symbol to obtain the split hydatid disease literature sentences and form a hydatid disease literature sentence set a; Step 2.
2. Randomly select a sentence from the set of sentences a of the literature on echinococcosis After the echinococcosis literature sentences are binned and form subset b, the sentences in subset b are removed from set a; , represents the total number of sentences in the set of echinococcosis literature sentences a; Step 2.
3. Label each sentence in the subset b one by one to obtain the labeled hydatid disease dataset c, and let any one labeled sample in the dataset c be denoted as , wherein, represents one hydatid disease literature sentence in the sample , represents the th vocabulary in the sentence, represents the vocabulary size, represents the label of the sentence , wherein, is the th knowledge triple, represents the head entity of , represents the tail entity of , and , and is the combination of the vocabularies, and the vocabularies of the two do not overlap; represents the relationship type of , ; represents the number of knowledge triples; Step 3, build a hydatid disease information joint extraction model, including: coding stage, entity decoding stage, and relationship decoding stage; wherein the coding stage includes a preprocessing layer, a word embedding layer, and a BioBert coding layer; the entity decoding stage includes an entity matrix construction layer and an entity vector decoding layer; the relationship decoding stage includes a CLN standardization layer and a relationship decoding layer; Step 3.1: Translate the sentence The echinococcosis information is jointly extracted into the model, and processed by the preprocessing layer in the encoding stage. vocabulary in Make a judgment, if Then for Perform clause segmentation to obtain a set of clauses, where any one clause is denoted as . , ,and , Indicates the first If the number of words in the last clause is less than [number of words], then [the sentence is incomplete]. Then, use null characters to pad to N, so that the number of words in all clauses is equal to N. ;like Then use an empty character to The vocabulary size is supplemented to N; among which, Indicates the maximum vocabulary size; Step 3.2, the word embedding layer is pre-set with a dictionary, and the dictionary includes a plurality of key-value pairs, wherein the key is a word and the value is a binary index; Splitting sentences Input into the word embedding layer of the encoding stage, and query the first word in the dictionary to get the first word Binary index in the dictionary , so as to get Dictionary embedding vector ; The word embedding layer is based on exist The sequence number in the first vocabulary Embedding is performed to obtain the sentence index. Thus, the sentence index embedding vector is obtained. ; The word embedding layer embeds the sequence of words in the first ; The word embedding layer obtains a set of word embedding vectors using equation (1) : (1) In formula (1), represents the word embedding vector of the th vocabulary word. Step 3.3: Divide the clauses Word embedding vector set The input is encoded in the BioBert encoding layer to obtain the encoded vector. Let n represent the encoding vector. Length; Step 3.4, encoding the vector Input the entity decoding phase for entity recognition: Step 3.4.1, the entity matrix construction layer defines and randomly initializes a two-dimensional matrix of dimension ; Step 3.4.2, the entity matrix construction layer calculates the scoring left multiplication matrix and the scoring right multiplication matrix using equations (2) and (3), respectively and (3) : (2) (3) in formula (2) and formula (3), denotes a weight matrix of denotes a bias vector of denotes a weight matrix of denotes a bias vector of Step 3.4.
3. The entity matrix construction layer pair After the orthogonal transformation, the position encoding matrix is obtained, and satisfies equation (4). (4) In formula (4), denotes the first column vector of denotes the first column vector of denotes the first column vector of denotes the transpose; Step 3.4.
4. The entity matrix construction layer uses equation (5) to obtain the code vector of any one of the encoding subsequences : (5) In formula (5), denotes a scoring matrix denotes a scoring matrix column vector, denotes a scoring matrix denotes a scoring matrix column vector; Step 3.4.5: The entity matrix construction layer will... Mapped to The Line number Column elements Thus, the mapped two-dimensional matrix is obtained. ; Step 3.4.6: The model entity vector decoding layer is set with an entity vector of length n. And initialize it as an all-zero vector, and map the elements. Accumulated to The The position to the first A sequence of positions At each position within, thus obtaining the mapped entity vector. ; Step 3.5, encoding vector and mapped entity vector After splicing, input into the relationship decoding stage and standardized by the CLN standardization layer, so as to obtain the echinococcosis entity relationship link vector by formula (6) : (6) In equation (6), express The One vector unit, Represents the mapped entity vector The One vector unit, and They represent The mean and standard deviation, The first element representing the self-optimized gain vector in the CLN normalization layer. One element, The first condition vector in the CLN normalization layer represents the condition vector of itself. One element; Step 3.6, the input to the relation decoding layer and predict all knowledge triples in the middle: Step 3.6.1, to the i-th vector unit to the j-th vector unit one entity set to the label any i-th head entity of the i-th knowledge triple ; Step 3.6.2, Hydatid disease pattern middle One type of relation is set as: Relationship types ; Step 3.6.
3. The relationship decoding layer on the source side performs conversion activation and outputs a start index vector of the tail entity and an end index vector of the tail entity , wherein, represents the start index vector of the tail entity in the position element, represents the end index vector of the tail entity in the position element, Step 3.6.4: Set the probability threshold , like and All greater than , and Then it is determined that the y-th vector unit up to the z-th vector unit An entity constituted yes Chinese knowledge triples tail entity sequence Thus, a complete knowledge triple is obtained. ; Step 3.6.
5. Traverse the hydatid disease model according to the procedures of Step 3.6.2-Step 3.6.4 each relation type, thereby obtaining a clause composed of several knowledge triples annotation; Step 3.7, the total loss of the hydatid disease information joint extraction model is the sum of the cross-entropy loss of the entity decoding stage and the cross-entropy loss of the relationship decoding stage; Step 4, train the hydatid disease information joint extraction model and build a hydatid disease knowledge graph: Step 4.1, iteratively train the hydatid disease information joint extraction model by using the hydatid disease data set c, and calculate the total loss function for updating the model parameters until the total loss function converges, thereby obtaining the trained hydatid disease information joint extraction model ; Step 4.2, sequentially take out from the subset b The unannotated hydatidosis document sentences are input into the trained hydatidosis information joint extraction model The prediction result is output The prediction result of the hydatidosis document sentences is stored in the triple prediction set The prediction result is output Step 4.3, predicting sets of triples The predicted head and tail entities in any of the predicted knowledge triples are stored in the entity set and the entities and relations that are duplicated in and are removed; Step 4.4, use a graph database to construct a hydatid disease knowledge graph: Step 4.4.1, traversing the de-duplicated and create a graph entity corresponding to each pair of predicted head entity and predicted tail entity in the graph database; Step 4.4.2, traversing the de-duplicated and retrieve from the graph database the head entity corresponding to any of the predicted knowledge triples and the tail entity corresponding to any of the predicted knowledge triples, and create a relationship type between the two. Step 4.4.3, after all the relationships are created, the relationship connected graph composed of graph entities participating in multiple groups of knowledge triples is used as the constructed hydatid disease knowledge graph.
2. An electronic device comprising a memory and a processor, characterized in that The memory is used to store a program supporting the processor to execute the hydatid disease knowledge graph construction method of claim 1, and the processor is configured to execute the program stored in the memory.
3. A computer-readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to perform the steps of the hydatid disease knowledge graph construction method of claim 1.
Citation Information
Patent Citations
Legal knowledge graph construction method and equipment based on entity relationship joint extraction
CN113204649A
Medical plan recommendation system and method based on knowledge graph representation learning
WO2021189971A1