Knowledge graph updating method and system integrating text extraction and graph embedding
By integrating the knowledge graph update method of BERT+Transformer-RE and TransE, the joint optimization problem of the text extraction module and the knowledge graph embedding module is solved, efficient and real-time knowledge graph update is achieved, and the accuracy and robustness of entity relationship triples are improved.
Patent Information
- Application Number
- CN202511198999.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-10-17
AI Technical Summary
In the existing technology, the text extraction module and the knowledge graph embedding module cannot achieve end-to-end joint optimization, resulting in insufficient accuracy and robustness of entity recognition and relationship extraction, especially in dynamic scenarios where it is difficult to meet real-time requirements.
A fusion method of the BERT+Transformer-RE text extraction module and the TransE knowledge graph embedding module is adopted. By obtaining the embedded feature vectors of entities and relations, combining the full sentence feature vector and latent vector, fusion relationship prediction and entity recognition are performed, and incremental fine-tuning is performed using the FastKGE incremental LoRA plug-in to achieve efficient updating of the knowledge graph.
It significantly improves the accuracy and robustness of entity-relationship triples, reduces long-distance dependency and low-frequency relationship recognition errors, reduces graph maintenance costs, ensures real-time and consistency of updates, and improves the accuracy of rare relationship identification.
Smart Images

Figure CN120806098A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and more particularly to a knowledge graph updating method and system based on text extraction and graph embedding fusion. BACKGROUND
[0002] At present, as a structured knowledge representation form, knowledge graph organizes knowledge in the real world through the graph structure of entities, attributes and relationships, and is widely used in intelligent question answering, semantic search, recommendation system and other fields.
[0003] However, the existing method usually regards text extraction (such as Transformer-RE+BERT) and knowledge graph embedding (such as TransE) as two independent subsystems, and completes model updating on the respective training sets first, and then hardens the series use of the extraction results and the graph embedding. Because of the lack of an end-to-end joint optimization mechanism, the text extraction module can only rely on the context information and cannot correct or strengthen the semantic ambiguity with the help of the structured prior of the constructed graph; on the contrary, the graph embedding module needs to wait for the next offline retraining period to absorb the high-confidence triples output by the text extraction module in real time, so it cannot immediately enrich the vector representation with new knowledge. As a result, the two cannot feedback to each other when optimizing, neither complementing each other's advantages nor forming a consistent global optimal solution. In a typical pipeline process, errors in the entity recognition stage will be directly passed on to the relationship extraction stage, and then affect the graph construction and embedding updating. One missed or misjudged entity often leads to continuous failure of downstream relationship judgment, and eventually results in serious structural errors in the knowledge graph. For frequent relationships, the model has enough data to learn; but for low-frequency or rare relationships, there are almost no samples, so the classifier cannot learn effective features; pure text models need to learn classification heads independently for each category when classifying large-scale relationships, resulting in a sharp increase in the number of parameters and insufficient ability to distinguish similar or rare relationships, which are prone to confusion. In a dynamic scenario (such as an exam registration system), the knowledge graph needs to frequently absorb newly released registration announcements and examination information. The traditional method needs to separately retrain the extraction model and the embedding model each time the update is performed, which is time-consuming and difficult to ensure that the knowledge and text modules remain synchronized after the update is completed, and cannot meet the real-time requirements.
[0004] Therefore, how to improve the accuracy and robustness of extracted entity relationship triples and realize the cyclic optimization of dynamic knowledge graph construction is a problem that those skilled in the art need to solve. SUMMARY
[0005] Therefore, the present application provides a knowledge graph updating method based on text extraction and graph embedding fusion, which improves the accuracy and robustness of extracted entity relationship triples and realizes the cyclic optimization of dynamic knowledge graph construction.
[0006] To achieve the above object, the present application adopts the following technical solutions:
[0007] A knowledge graph updating method based on text extraction and graph embedding fusion, comprising:
[0008] Obtaining an existing knowledge graph and related to-be-processed text;
[0009] Obtaining an initial entity pair embedding feature vector based on the existing knowledge graph;
[0010] Obtaining a full-sentence feature vector and a hidden vector corresponding to each subword based on the to-be-processed text;
[0011] Obtaining a text feature vector corresponding to a text entity pair based on the hidden vector and the full-sentence feature vector;
[0012] Obtaining a fusion relationship prediction probability based on the embedding feature vector and the text feature vector;
[0013] Obtaining an entity recognition probability based on the hidden vector;
[0014] Obtaining a text relationship prediction probability based on the text feature vector;
[0015] Filtering to obtain high-confidence triplets in the to-be-processed text based on the fusion relationship prediction probability, the entity recognition probability and the text relationship prediction probability, and adding the high-confidence triplets to the existing knowledge graph to obtain an updated knowledge graph;
[0016] Performing incremental updating based on the high-confidence triplets and new entities to obtain an updated knowledge graph embedding feature vector.
[0017] In one embodiment, the embedding feature vector obtaining method is:
[0018] Randomly initializing all initial head entities, initial tail entities and corresponding relationships in the existing knowledge graph to obtain a positive example embedding triplet composed of a head entity initial embedding vector, a tail entity initial embedding vector and a relationship initial embedding vector;
[0019] Replacing the head entity initial embedding vector or the tail entity initial embedding vector based on the positive example triplet to obtain a negative example embedding triplet;
[0020] Constructing a constraint loss based on the positive example embedding triplet and the negative example embedding triplet;
[0021] Based on the Adam optimizer, a plurality of rounds of iteration minimization of the constraint loss is performed to obtain a set of head entity initial embedding vectors, tail entity initial embedding vectors and relationship initial embedding vectors which can accurately reflect the structure of the existing knowledge graph as the embedding feature vectors of the initial entity pair.
[0022] In one embodiment, the hidden vector acquisition method is:
[0023] Based on the beginning and end of the sentence or paragraph in the to-be-processed text, a marked text is obtained;
[0024] Based on the marked text input to the BERT encoder, all sentences are split into a plurality of subword sequences;
[0025] Based on each of the subword sequences, a corresponding input vector is constructed;
[0026] Based on the input vector, a multi-head self-attention and feedforward network with multiple layers of stacking are input, and the vector output by the last layer is taken as the hidden vector of the subword.
[0027] In one embodiment, the text feature vector acquisition method is:
[0028] Based on the to-be-processed text, the start and end indices corresponding to the head entity and the tail entity of the marked text are obtained, and the start and end indices of the head entity and the tail entity are obtained;
[0029] Based on the head entity start and end indices and the hidden vector, a head entity text feature vector is obtained;
[0030] Based on the tail entity start and end indices and the hidden vector, a tail entity text feature vector is obtained;
[0031] Based on the head entity text feature vector, the tail entity text feature vector and the full sentence feature vector, the text feature vector is spliced.
[0032] In one embodiment, the fusion relationship prediction probability acquisition method is:
[0033] Based on the embedding feature vector and the text feature vector, linear mapping and linear weighting fusion are respectively performed to obtain a first fusion feature vector;
[0034] Based on the first fusion feature vector, the first full connection layer, the activation layer, the regularization layer and the second full connection layer are sequentially input to obtain the first original score of the marked text head and tail entity pair predicted as the rth relationship.
[0035] Based on the first original score, normalization is performed to obtain the probability of the marked text head and tail entity pair predicted as the rth relationship as the fusion relationship prediction probability.
[0036] In one embodiment, the entity recognition probability obtaining method is:
[0037] Based on the hidden vector input to the second fully connected layer for linear mapping, a second original score of token i predicted as the cth entity category is obtained;
[0038] Based on the second original score, normalization is performed to obtain the probability that token i belongs to category c as the entity recognition probability.
[0039] In one embodiment, the text relationship prediction probability obtaining method is:
[0040] Based on the text feature vector, the first fully connected layer, the activation layer and the second fully connected layer are sequentially input to obtain a third original score of the head and tail entity pair predicted as the rth relationship;
[0041] Based on the third original score, normalization is performed to obtain the probability that the head and tail entity pair is predicted as the rth relationship as the text relationship prediction probability.
[0042] In one embodiment, the high-confidence triple obtaining method is:
[0043] Based on the fusion relationship prediction probability and the text relationship prediction probability, a final relationship prediction probability is obtained by weighted fusion;
[0044] Selecting a text entity pair in the text to be processed whose entity recognition probability is greater than or equal to a first threshold value as a screening head and tail entity pair;
[0045] Based on the screening head and tail entity pair, a screening head and tail entity pair whose final relationship prediction probability is greater than a second threshold value is selected as a high-confidence entity pair;
[0046] Based on the high-confidence entity pair and the corresponding relationship, the high-confidence triple is composed.
[0047] In one embodiment, an updated knowledge graph embedding feature vector is obtained, specifically including:
[0048] Based on the newly added entity, a breadth-first search is performed on the existing knowledge graph to calculate the shortest distance between the newly added entity and other entities in the existing knowledge graph;
[0049] Obtain the number of neighbors of each entity in the existing knowledge graph and the high-confidence triple;
[0050] Based on the ratio of the number of neighbors to the incremental scale, an entity degree centrality is obtained.
[0051] rank the new entities based on the shortest distance and the entity centrality and average them into a plurality of hierarchical subsets;
[0052] insert a pair of low-rank adapter matrices based on each hierarchical subset to obtain an incremental embedding feature vector;
[0053] construct a training loss based on the incremental embedding feature vector and an initial triple embedding feature vector in the existing knowledge graph;
[0054] perform back propagation optimization on the pair of low-rank adapter matrices based on the training loss to obtain a trained pair of low-rank adapter matrices;
[0055] fuse the trained pair of low-rank adapter matrices and the initial triple embedding feature vector to obtain an updated knowledge graph embedding feature vector.
[0056] A knowledge graph updating system based on text extraction and graph embedding fusion, comprising: a data acquisition module, an embedding feature acquisition module, a hidden vector acquisition module, a text feature acquisition module, a prediction probability acquisition module, a knowledge graph updating module, and an incremental updating module;
[0057] The data acquisition module is configured to acquire an existing knowledge graph and related to-be-processed text.
[0058] The embedding feature acquisition module is configured to acquire an initial embedding feature vector of an entity pair based on the existing knowledge graph.
[0059] The hidden vector acquisition module is configured to acquire a full-sentence feature vector and a hidden vector corresponding to each subword based on the to-be-processed text.
[0060] The text feature acquisition module is configured to acquire a text feature vector corresponding to a text entity pair based on the hidden vector and the full-sentence feature vector.
[0061] The prediction probability acquisition module is configured to acquire a fusion relationship prediction probability based on the embedding feature vector and the text feature vector, acquire an entity recognition probability based on the hidden vector, and acquire a text relationship prediction probability based on the text feature vector.
[0062] The knowledge graph updating module is configured to filter high-confidence triples in the to-be-processed text based on the fusion relationship prediction probability, the entity recognition probability, and the text relationship prediction probability, and add the high-confidence triples to the existing knowledge graph to obtain an updated knowledge graph.
[0063] The incremental updating module is configured to perform incremental updating based on the high-confidence triples and new entities to obtain an updated knowledge graph embedding feature vector.
[0064] Via the technical solutions described above, compared with the prior art, the present disclosure provides a kind of knowledge graph updating method of text extraction and graph embedding fusion, with the following beneficial effects:
[0065] 1、The present application can simultaneously consider the context semantics and the existing structure in the graph when classifying the relationship of each entity pair by directly parallel splicing the embedding vector and the word vector in the BERT+Transformer-RE text extraction module, significantly reducing the problems of long-distance dependence scenario, low-frequency relationship recognition error, overlapping entity misjudgment, and fundamentally solving the technical problem of "context semantics and structural information cannot be complementary".
[0066] 2、The present application uses FastKGE incremental LoRA plug-in technology to realize "efficient incremental fine-tuning" of newly added triples. By first dividing the new entities into levels, then inserting a low-rank adapter for fine-tuning only in the corresponding layer, and at the same time using distillation loss to ensure that old knowledge is not forgotten, the present application can complete a complete embedding update in a few minutes or even tens of seconds without reloading all the data. This design not only greatly reduces the cost of maintaining the graph, but also ensures the consistency of the updated embedding and the old embedding in terms of representation ability, completely solving the technical bottleneck of "high cost of embedding update and poor real-time performance".
[0067] 3、Reduce label space redundancy and improve low-frequency relationship recognition: through embedding-guided hard negative sampling and dynamic fusion weight, focus on "difficult negative examples" and low-frequency relationships, significantly improve the discrimination accuracy of the model for rare relationships.
[0068] 4、Text and structural information complementary enhancement: during relationship classification, the text features and graph embedding prior are weighted and fused at the vector level, and the joint loss is used to drive them together, which includes three parts of loss. The first part is the text extraction loss, which includes entity recognition loss and relationship classification loss. The second part is the embedding guided loss, which takes into account the ability of the text to improve the recognition of long-tail and cross-sentence relationships. The third part is the alignment loss. When dealing with unseen entities, i.e. the entity does not appear in the knowledge graph, by minimizing this loss, a conversion matrix is obtained that can convert the entity feature vector to the embedding feature vector. BRIEF DESCRIPTION OF DRAWINGS
[0069] In order to more clearly illustrate the technical solutions in the embodiments or the prior art, the following will briefly introduce the drawings needed in the embodiment or prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and those skilled in the art can obtain other drawings according to the provided drawings without creative labor.
[0070] Figure 1 A text extraction and graph embedding fusion knowledge graph updating method flowchart is provided.
[0071] Figure 2 A high-confidence triple obtaining method flowchart is provided.
[0072] Figure 3 A text extraction and graph embedding fusion knowledge graph updating system structure schematic diagram is provided. DETAILED DESCRIPTION
[0073] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.
[0074] Embodiment 1
[0075] As shown in the drawings, Figure 1 The present application discloses a text extraction and graph embedding fusion knowledge graph updating method, comprising:
[0076] Obtain existing knowledge graph and related to-be-processed text;
[0077] Obtain initial entity pair embedding feature vector based on the existing knowledge graph;
[0078] Obtain full sentence feature vector and hidden vector corresponding to each subword based on the to-be-processed text;
[0079] Obtain text feature vector corresponding to the text entity pair based on the hidden vector and the full sentence feature vector;
[0080] Obtain fusion relationship prediction probability based on the embedding feature vector and the text feature vector;
[0081] Obtain entity recognition probability based on the hidden vector;
[0082] Obtain text relationship prediction probability based on the text feature vector;
[0083] Filter high-confidence triples in the to-be-processed text based on the fusion relationship prediction probability, the entity recognition probability and the text relationship prediction probability, and add them to the existing knowledge graph to obtain an updated knowledge graph;
[0084] Incrementally update based on the high-confidence triples and the new entities to obtain updated knowledge graph embedding feature vector.
[0085] Embodiment 2
[0086] The embodiment of the present application discloses a knowledge graph updating method of text extraction and graph embedding fusion, comprising:
[0087] An existing knowledge graph and related to-be-processed text are acquired.
[0088] The most initial existing knowledge graph is constructed according to existing domain knowledge by manually selecting triples. The to-be-processed text is domain-related text information, and is text information related to triples of the existing knowledge graph.
[0089] An embedding feature vector of an initial entity pair is acquired based on the existing knowledge graph.
[0090] Corresponding embedding vectors are obtained based on the existing knowledge graph by using a TransE algorithm, and all head entity and tail entity embedding vectors constitute e0∈h0∪t0, and all relationship embedding vectors constitute r0. If there is a new entity, the new entity is updated through an incremental updating process, so that the latest embedding feature is obtained. The embedding vectors of a pair of head and tail entities and the corresponding relationship embedding vectors are spliced to obtain the embedding feature vector of the entity pair.
[0091] Further, the embedding feature vector acquisition method is:
[0092] Based on random initialization of all initial head entities h, initial tail entities t and corresponding relationships r in the existing knowledge graph, head entity initial embedding vectors h0, tail entity initial embedding vectors t0 and relationship initial embedding vectors (h0, r0, t0) are obtained (usually k = 100);
[0093] Based on the positive example triple, a negative example triple is obtained by replacing the head entity initial embedding vector (h', r, t) or the tail entity initial embedding vector (h, r, t').
[0094] The constraint loss is constructed based on the positive example triple and the negative example triple.
[0095] Based on the Adam optimizer, the constraint loss is minimized through multiple rounds of iteration to obtain a group of head entity initial embedding vectors, tail entity initial embedding vectors and relationship initial embedding vectors that can accurately reflect the structure of the existing knowledge graph as the embedding feature vector of the initial entity pair.
[0096] Further, the constraint loss L init Specifically,
[0097]
[0098] Wherein, δ>0, represents the hyperparameter, used to keep the minimum distance difference margin between positive and negative triplets in the vector space, so as to distinguish the boundary between positive and negative samples more clearly, represents the positive example set, represents the corresponding negative example set generated for each positive example, h'0 and t'0 are the entity vectors replaced in the negative example.
[0099] Further, using the Adam optimizer, multiple rounds of iteration are used to minimize L init , so that the embedding vector of each entity e0 and the embedding vector of the relationship r0 are updated synchronously, so that the loss L init converges, obtaining a set of initial embedding parameters {e0, r0} that can accurately reflect the existing knowledge graph structure as the embedding feature vector v kg :
[0100] represents the initial embedding vector of the entity , and r0(r) ∈ r0 represents the initial embedding vector of the relationship r (i) .
[0101] Based on the to-be-processed text, the full-sentence feature vector and the hidden vector corresponding to each subword are obtained.
[0102] Further, the hidden vector acquisition method is:
[0103] Based on the beginning and end of the sentence or paragraph in the to-be-processed text, a marked text is obtained;
[0104] Based on the marked text, input to the BERT encoder to split all the sentences into multiple subword sequences;
[0105] Based on each subword sequence, a corresponding input vector is constructed;
[0106] Based on the input vector, a multi-head self-attention and feedforward network stacked in multiple layers are input, and the vector output by the last layer is taken as the hidden vector z i of the subword.
[0107] Further, the to-be-processed text annotated by artificial marking is: (i) Wherein, T represents the complete original sentence or text paragraph corresponding to the i-th record, represents the annotated head entity, represents the annotated tail entity, r (i) ∈{1,…,C rel} represents the relationship category between the annotated head entity and tail entity, which includes the no relationship category, a p and b p correspond to the head entity the start token index and the end token index of the head entity, c p ∈{1,…,C ent} represents the entity category to which the head entity belongs, a q and b q respectively correspond to the start token index and the end token index of the tail entity , c q represents the entity category to which the tail entity belongs.
[0108] Further, the tokenized text T' obtained by adding [CLS] and [SEP] markers at the beginning and end of the text T to be processed is split into a subword unit sequence <t0, t1, …, t n > by using the Wordpiece tokenizer of BERT, where t0=[CLS], t n =[SEP], and an input vector
[0109] x i =E token (t i )+E pos (i)+E seg (s i );
[0110] wherein E token (t i ) represents the word embedding of the word t i , E token is a word embedding matrix randomly initialized and updated step by step during BERT training to learn distributed semantics capable of representing various contextual usages of the word, in the form of a lookup table matrix of |V|×d, where |V| is the size of the word table (WordPiece subword table) and d is the hidden dimension; E pos (i) represents the position embedding of the word t i , E pos is a position embedding matrix randomly initialized and updated step by step during BERT training to learn position information encoding of each subword and other subword position interactions, in the form of a lookup table matrix of L max ×d, where L max is the maximum sequence length (such as 512) and d is the hidden dimension; E seg (s i ) is the segment embedding of the word t i , E segis a piecewise embedding matrix that is randomly initialized and updated step by step during BERT training, learning to distinguish whether the current subword belongs to sentence 1 or sentence 2 (BERTBase only distinguishes the 1st sentence or the 2nd sentence), and is in the form of a lookup table matrix with a size of 2xd, where d is the hidden dimension.
[0111] Subsequently, x i As the input of the Transformer framework, it is sequentially passed through the L-layer stacked multi-head self-attention + feedforward network:
[0112]
[0113] Obtain the output of the last layer As the hidden vector of this subword (token), that is, obtain
[0114] Finally, the hidden vector of each subword (token) is obtained and the full-sentence feature vector
[0115] Based on the hidden vector and the full-sentence feature vector, the text feature vector corresponding to the text entity pair is obtained.
[0116] Further, the text feature vector acquisition method is:
[0117] Based on the to-be-processed text, the start and end indices corresponding to the head entity and the tail entity of the labeled text are obtained, and the head entity start and end indices and the tail entity start and end indices are obtained.
[0118] Based on the head entity start and end indices and the hidden vector, the head entity text feature vector is obtained.
[0119] Based on the tail entity start and end indices and the hidden vector, the tail entity text feature vector is obtained.
[0120] Based on the head entity text feature vector, the tail entity text feature vector, and the full-sentence feature vector, the text feature vector is obtained.
[0121] Further, based on the head entity start and end indices a, b and the hidden vector z i the head entity text feature vector v p is obtained.
[0122] Based on the tail entity start and end indices c, d and the hidden vector z i the tail entity text feature vector v q is obtained.
[0123] Based on the head entity text feature vector v p , the tail entity text feature vector vq and the full sentence feature vector v cls concatenate to obtain the text feature vector For each entity pair in the text to be processed, the above text feature vector is obtained.
[0124] The fusion relationship prediction probability is obtained based on the embedding feature vector and the text feature vector.
[0125] The fusion relationship prediction probability acquisition method is:
[0126] The embedding feature vector and the text feature vector are linearly mapped based on the embedding feature vector and the text feature vector, and linearly weighted fusion is performed to obtain a first fusion feature vector;
[0127] The first fusion feature vector is sequentially input to a first full connection layer, an activation layer, a regularization layer and a second full connection layer based on the first fusion feature vector, to obtain a first original score of the head and tail entity pair of the labeled text predicting the rth relationship.
[0128] Based on the first original score, normalization is performed to obtain a probability that the head and tail entity pair of the labeled text predicts the rth relationship, as the fusion relationship prediction probability.
[0129] Further, the embedding feature vector v kg and the text feature vector v text are linearly mapped, respectively, to obtain an embedding mapping vector u kg and a text mapping vector u text :
[0130] u text =W t v text +b t ;
[0131] u kg =W k v kg +b k ;
[0132] wherein, and both represent vector mapping matrices, which respectively map the text feature vector and the embedding feature vector to dimensional space, and both represent mapping biases;
[0133] The embedding mapping vector u kg and the text mapping vector u text are linearly weighted fused to obtain a first fusion feature vector u comb :
[0134] u comb =αutext + (1 - a)u kg , a e (0, 1) ;
[0135] based on the fusion feature vector u comb is sequentially input to the first full connection layer and the activation layer to obtain a first processing feature h1:
[0136]
[0137] wherein W1 represents a weight matrix of the first layer full connection, used to map the d' dimensional input to the hidden layer dimension h, b1 represents a bias vector of the first layer full connection, learned together with W1, used to adjust the activation threshold of each hidden unit;
[0138] based on the first processing feature h1 input to the regularization layer Dropout to prevent overfitting, to obtain a second processing feature h2:
[0139] h2 = Dropout (h1) ;
[0140] based on the second processing feature h2 input to the second full connection layer to obtain a first original score of the head and tail entity pair of the labeled text predicted as the rth relationship
[0141]
[0142] wherein, W2 represents a weight matrix of the second layer full connection, used to map the h dimensional hidden layer input to the relationship category number dimension C rel , b2 represents a bias vector of the second layer full connection, learned together with W2, used to adjust the activation threshold of each class unit;
[0143] based on the first original score for normalization to obtain a probability of the head and tail entity pair of the labeled text predicted as the rth relationship, as a fusion relationship prediction probability
[0144]
[0145] wherein, represents the normalized probability of the entity pair predicted as the category r, represents that the score is amplified nonlinearly, is the sum of all amplified scores, ensuring that D + , D - respectively represent the collection of positive example triplets and the collection of negative example triplets, and the embedding guidance loss ensures that the fusion vector can distinguish between positive and negative triplets.
[0146] Furthermore, for unseen entities, that is, entities that have not appeared in the existing knowledge graph but appear in the text, the text feature vector of the entity Mapped to the embedded feature vector space, the embedded vector is obtained
[0147] Based on the embedding vector e new and the embedded feature vector v kg Splicing to get the updated embedded feature vector v kg1 ;
[0148] Based on the updated embedding feature vector v kg1 The mapping is updated to embed the mapping vector u kg1 :u kg1 =W k v kg1 +b k ;
[0149] Based on the text feature vector v new Mapping gets updated text mapping vector u text1 =W t v newt +b t ;
[0150] Based on the updated embedding mapping vector u kg1 and update the text mapping vector u text1 Perform linear weighted fusion to obtain the second fusion feature vector u comc :
[0151] u comc =αu text1 +(1-α)u kg1 α∈(0,1);
[0152] Based on the second fusion feature vector u comc Carry out the above process.
[0153] Furthermore, the above and the embedding vector e new Embedded feature vector v for concatenation kg is an incomplete v kg , v kg It is the concatenation of the feature vectors of [head entity, relation, tail entity]. If the head entity is missing, then v kg The column vector of the head entity will be missing.
[0154] Furthermore, for all entity sets E that appear in the training text and are embedded in the existing knowledge graph ∩ Minimize the alignment loss L align :
[0155]
[0156] For the most appropriate conversion matrix And the bias term Wherein, Indicates the entity vector in the text feature, Indicates the entity vector in the embedded feature, and then the embedded vector of the new entity can be obtained:
[0157]
[0158] The entity recognition probability is obtained based on the hidden vector.
[0159] The entity recognition probability obtaining method is:
[0160] The hidden vector is input to the second fully connected layer for linear mapping to obtain the second original score of token i predicted as the cth entity category;
[0161] Based on the second original score, normalization is performed to obtain the probability that the predicted token i belongs to category c as the entity recognition probability.
[0162] Further, the hidden vector z i of each token obtained by BERT is input to the second fully connected layer for linear mapping to the entity category space to obtain the second original score of token i predicted as the cth entity category
[0163]
[0164] Wherein, is the unnormalized score (logits ent ) output via the second layer of full connection, Each dimension of the vector is the original score (logit ent ) of token i predicted as the cth entity category;
[0165] Based on the second original score , the probability that the predicted token i belongs to category c is obtained via Softmax normalization as the entity recognition probability
[0166]
[0167] The text relationship prediction probability is obtained based on the text feature vector.
[0168] The text relationship prediction probability obtaining method is:
[0169] The text feature vector is sequentially input to a first full connection layer, an activation layer and a second full connection layer to obtain a third original score of the head-tail entity pair predicting the rth relationship;
[0170] The third original score is normalized to obtain a probability of the head-tail entity pair predicting the rth relationship as a text relationship prediction probability.
[0171] Further, the text feature vector is sequentially input to a first full connection layer and an activation layer to obtain a first intermediate feature
[0172]
[0173] Based on the first intermediate feature , the text feature vector is input to a second full connection layer to obtain a third original score l of the head-tail entity pair predicting the rth relationship. rel :
[0174]
[0175] Based on the third original score l rel , a probability of the head-tail entity pair predicting the rth relationship is obtained via Softmax normalization as a text relationship prediction probability.
[0176]
[0177] wherein, is an unnormalized score (logits rel ) output via the second layer full connection, each dimension of the vector is an original score (logit rel ) of the corresponding entity pair (e p , e q ) predicting the rth relationship, and each dimension of the vector is an original score (logit rel ) of the corresponding entity pair (e p , e q ) predicting the r'th relationship.
[0178] Based on the fusion relationship prediction probability, the entity recognition probability and the text relationship prediction probability, high-confidence triplets in the text to be processed are screened and added to an existing knowledge graph to obtain an updated knowledge graph.
[0179] As shown in Figure 2 , the high-confidence triplet acquisition method is:
[0180] Based on weighted fusion of the fusion relationship prediction probability and the text relationship prediction probability, a final relationship prediction probability is obtained.
[0181] Select a text entity pair in the text entity in the to-be-processed text with a probability greater than or equal to a first threshold value as a screening head-tail entity pair;
[0182] Based on the screening head-tail entity pair, select a screening head-tail entity pair with a final relationship prediction probability greater than a second threshold value as a high-confidence entity pair;
[0183] Based on the high-confidence entity pair and the corresponding relationship, a high-confidence triple is formed.
[0184] Based on the high-confidence triple and the new entity, incremental updating is performed to obtain an updated knowledge graph embedding feature vector.
[0185] The updated knowledge graph embedding feature vector is obtained, specifically including:
[0186] Based on the new entity, a breadth-first search is performed on the existing knowledge graph to calculate the shortest distance between the new entity and other entities in the existing knowledge graph;
[0187] The number of neighbors of each entity in the existing knowledge graph and the high-confidence triple is obtained;
[0188] Based on the ratio of the number of neighbors to the incremental scale, an entity degree centrality is obtained;
[0189] Based on the shortest distance and the entity degree centrality, the new entity is sorted and evenly divided into multiple hierarchical subsets;
[0190] Based on each hierarchical subset, a low-rank adapter matrix pair is inserted to obtain an incremental embedding feature vector;
[0191] Based on the incremental embedding feature vector and the initial triple embedding feature vector in the existing graph, a training loss is constructed;
[0192] Based on the training loss, the low-rank adapter matrix pair is optimized through back propagation to obtain a trained low-rank adapter matrix pair;
[0193] Based on the trained low-rank adapter matrix pair and the initial triple embedding feature vector, fusion is performed to obtain an updated knowledge graph embedding feature vector.
[0194] Further, the low-rank adapter matrix pair (A l ,B l ) is used to represent the hierarchical increment ΔW l =A l B l , where k is the embedding dimension of the original embedding vector, and a is the internal rank of the adapter, which is generally 4, 8, 16, or 32;
[0195] The fine-tuning vector of all entities and relationships in the existing knowledge graph is Δhl = AW l h0, Ar l = AW l r0, At l = AW l t0, where h0, r0, t0are the original head entity, relation and tail entity embedding vectors in the existing knowledge graph, and then the updated vectors can be obtained: h l = h0+ Ah l , r l = r0+ Ar l , t l = t0+ At l ; where h l represents the head entity incremental embedding vector, r l represents the relation incremental embedding vector, and t l represents the tail entity incremental embedding vector.
[0196] During incremental training, that is, the process of obtaining the best adapter matrix, the training loss function is designed as:
[0197]
[0198] where γ > 0 is a hyperparameter, in order to keep the minimum distance difference margin between positive and negative triplets in the vector space; β ∈ (0, 1) is a distillation weight, used to constrain the original distance of the old triplets after updating, so as to prevent forgetting; is the newly added positive triplet set this time, is the pseudo-triplet set obtained by negative sampling; the subscript l in the formula indicates the head entity, relation and tail entity belonging to the l layer; and the superscript'represents the negative example corresponding to the head entity, relation and tail entity.
[0199] The first term of the training loss function makes the model learn the structural information of the newly added triplets, and the second term keeps the “translation distance” of all old triplets unchanged through squared error, so that the embedding scores of the original old triplets on remain consistent after updating, in order to avoid forgetting. Only {A l ,B l} is optimized by back propagation, and the learning rate can be set to 1 × 10 -3 . After 10-30 iterations, the incremental update is completed, and the trained low-rank adapter matrix pair AW l1 = A l1 B l1 is obtained.
[0200] Based on the trained low-rank adapter matrix pair AW l1 , the original embedding {e0, r0} is fused to obtain the updated entity / relation embedding {e new= e0+ AW l e0, r new = r0+ AW l r0, for next extraction; for new entities, trained AW l1 is the corresponding updated knowledge graph embedding feature vector.
[0201] Further, in the embodiment, the embedding guidance loss function L entity recognition probability and text relation prediction probability is constructed respectively based on the fusion relation prediction probability guide , the entity recognition loss function L ent and the relation classification loss function L rel :
[0202]
[0203] where D + , D - represent the collection of positive triplets and the collection of negative triplets respectively, the embedding guidance loss ensures that the fusion vector can distinguish between positive and negative triplets; m represents the length of the token sequence, C ent represents the total number of entity categories, y i,c ∈{0,1} represents the true entity label of token i (one-hot indication), where (e p ,e q ,r) + is a positive example labeled as true relation r, and None represents the "no relation" category, which is used as a negative example;
[0204] Subsequently, the four losses L ent , L rel , L guide , L align are combined by weighting to obtain the total loss L joint in the joint training stage:
[0205] L joint = L ent + L rel + λ1L guide + λ2L align ;
[0206] where λ1, λ2>0 are fusion hyperparameters used to balance the weights of text extraction and graph embedding guidance. In the forward propagation process, the loss of each item is calculated respectively: L ent , L rel , L guide , L align , and then weighted sum is performed according to the formula, because the gradient formula is in L jointThe derivative is taken and passed back to all trainable parameters at once, so that "text + structure" joint optimization can be achieved. After training until the performance of the validation set converges, an end-to-end joint model is obtained that can use context understanding and graph priors to extract entities / relationships. This model can be used to extract high-confidence entity-relationship triples (h new ,r new ,t new ).
[0207] The joint model includes:
[0208] The text feature extraction network uses the BERT encoder to map text into token-level (word-level) hidden vector representations; and obtains the text-level features corresponding to the entity by concatenating the vocabulary vector and the sentence vector.
[0209] The embedding vector acquisition network uses the TransE algorithm to obtain the embedding vectors of entities that already exist in the knowledge graph, and obtains the embedding vectors of entities that do not exist in the knowledge graph through aligned projection;
[0210] The embedding-guided entity relation extraction network fuses text features with embedded features for relation classification, while also considering contextual features and the structural characteristics of the graph. Furthermore, the entity recognition head uses token-level hidden vectors to predict entity categories, while the plain text relation classification head uses token-level vectors and sentence vectors for multi-relation classification.
[0211] The joint model can automatically convert any newly input registration notice or examination instructions text into high-confidence entity-relationship-entity triples in an end-to-end pipeline.
[0212] The continuous training process of the present invention is implemented through three core stages: 1. Full TransE embedding (Formula L init : positive and negative triple margin-ranking optimization) to lay the structural prior foundation; 2. Joint text extraction + embedding guidance (Formula L joint : NER / RE loss plus embedding guidance loss and alignment loss) simultaneously optimizes NER, relation classification, embedding guidance and alignment modules in the same forward / backward propagation, achieving "zero pipeline error accumulation" semantic-structural deep fusion; 3. FastKGE incremental update (Formula L inc: Incremental triple margin-ranking with distillation constraint) only fine-tunes LoRA adapter, ensures that old knowledge is not forgotten while realizing second-level graph embedding update. Through the three-stage closed-loop iteration (extraction → update → re-extraction), the present application "end-to-end text extraction and graph embedding deep integration of integrated knowledge graph construction method" breaks through the optimization path of text extraction and graph embedding, realizes the "extraction result real-time update embedding" and "embedding priori feeding back to extraction" of the closed loop, greatly improves the efficiency and accuracy of knowledge graph construction in dynamic scenarios (such as examination registration).
[0213] The present application can make the text model consider the context semantics and the existing structure in the graph at the same time when classifying the relationship of each entity pair by directly parallel splicing the embedding vector and the word vector in the BERT+Transformer-RE text extraction module, significantly reducing the problems of long-distance dependence scene, low-frequency relationship recognition error, and overlapping entity misjudgment, and fundamentally solving the technical problem that context semantics and structure information cannot be complementary.
[0214] In view of the low efficiency problem that the traditional embedding needs to be retrained every time in the dynamic scene (such as the examination registration system) of the knowledge graph, the present application adopts the FastKGE incremental LoRA plug-in technology to realize the "efficient incremental fine-tuning" of the newly added triples. By first classifying the new entities by level, then inserting a low-rank adapter for fine-tuning only in the corresponding layer, and at the same time using distillation loss to make the old knowledge not be forgotten, the present application can complete a complete embedding update in a few minutes or even tens of seconds without reloading all the data. This design not only greatly reduces the maintenance cost of the graph, but also ensures the consistency of the updated embedding and the old embedding in the representation ability, completely solving the technical bottleneck of "high cost of embedding update and poor real-time performance".
[0215] Embodiment 3
[0216] As shown in Figure 3 , a knowledge graph updating system for text extraction and graph embedding fusion includes a data acquisition module, an embedding feature acquisition module, a hidden vector acquisition module, a text feature acquisition module, a prediction probability acquisition module, a knowledge graph updating module, and an incremental updating module.
[0217] The data acquisition module is used to acquire an existing knowledge graph and related to-be-processed text.
[0218] The embedding feature acquisition module is used to acquire an initial embedding feature vector of an entity pair based on the existing knowledge graph.
[0219] The hidden vector acquisition module is used to acquire a full-sentence feature vector and a hidden vector corresponding to each subword based on the to-be-processed text.
[0220] The text feature acquisition module is configured to obtain a text feature vector corresponding to the text entity pair based on the hidden vector and the full-sentence feature vector.
[0221] The prediction probability acquisition module is configured to obtain a fusion relationship prediction probability based on the embedding feature vector and the text feature vector, an entity recognition probability based on the hidden vector, and a text relationship prediction probability based on the text feature vector.
[0222] The knowledge graph updating module is configured to filter high-confidence triples in the text to be processed based on the fusion relationship prediction probability, the entity recognition probability, and the text relationship prediction probability, and add the high-confidence triples to an existing knowledge graph to obtain an updated knowledge graph.
[0223] The incremental updating module is configured to perform incremental updating based on the high-confidence triples and new entities to obtain an updated knowledge graph embedding feature vector.
[0224] Further, in the embodiment, the function implementation processes of the modules correspond to the above method content one by one, and will not be described one by one here.
[0225] Embodiment 4
[0226] Based on the same inventive concept, the application further provides a computer device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0227] The memory is used to store a computer program.
[0228] The processor is used to execute the program stored on the memory, and can realize the knowledge graph updating method of text extraction and graph embedding fusion in one of embodiments 1 or 2.
[0229] The electronic device can include a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus. The processor can call the logic instructions in the memory to execute the knowledge graph updating method of text extraction and graph embedding fusion in one of embodiments 1 or 2.
[0230] In addition, the logic instructions in the memory described above can be implemented in the form of software function units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for making a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the embodiments of the method of the present application.
[0231] The storage medium described above includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0232] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the related parts can be referred to the method part.
[0233] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A knowledge graph updating method integrating text extraction and graph embedding, characterized in that: include: Obtain existing knowledge graphs and related texts to be processed; Obtaining an embedding feature vector of an initial entity pair based on the existing knowledge graph; Obtaining a full sentence feature vector and a hidden vector corresponding to each subword based on the text to be processed; Obtaining a text feature vector corresponding to the text entity pair based on the hidden vector and the full sentence feature vector; Obtaining a fusion relationship prediction probability based on the embedded feature vector and the text feature vector; Obtaining entity recognition probability based on the hidden vector; Obtaining a text relationship prediction probability based on the text feature vector; Based on the fusion relationship prediction probability, the entity recognition probability and the text relationship prediction probability, high confidence triples in the text to be processed are screened and added to the existing knowledge graph to obtain an updated knowledge graph; Incremental updates are performed based on the high-confidence triples and newly added entities to obtain updated knowledge graph embedding feature vectors.
2. The knowledge graph updating method of integrating text extraction and graph embedding according to claim 1 is characterized in that: The method for obtaining the embedded feature vector is: Based on the random initialization of all initial head entities, initial tail entities and corresponding relationships in the existing knowledge graph, the initial embedding vector of the head entity, the initial embedding vector of the tail entity and the initial embedding vector of the relationship are obtained to form a positive example embedding triple; Obtaining a negative example embedding triplet by replacing the head entity initial embedding vector or the tail entity initial embedding vector based on the positive example triplet; Constructing a constraint loss based on the positive example embedding triplet and the negative example embedding triplet; Based on the Adam optimizer, multiple rounds of iterations are performed to minimize the constraint loss, and a set of head entity initial embedding vectors, tail entity initial embedding vectors and relationship initial embedding vectors that can accurately reflect the structure of the existing knowledge graph are obtained as the embedding feature vectors of the initial entity pair.
3. The knowledge graph updating method integrating text extraction and graph embedding according to claim 1 is characterized in that: The hidden vector acquisition method is: Marking the beginning and end of sentences or paragraphs in the text to be processed to obtain a marked text; Split all sentences into multiple subword sequences based on the labeled text input to the BERT encoder; Constructing a corresponding input vector based on each of the subword sequences; Based on the input vector, a multi-layer stacked multi-head self-attention and feedforward network is input, and the vector output by the last layer is used as the hidden vector of the subword.
4. The knowledge graph updating method integrating text extraction and graph embedding according to claim 1 is characterized in that: The method for obtaining the text feature vector is: Based on the text to be processed, the start and end subscripts corresponding to the annotated text head entity and the annotated text tail entity are obtained, and the start and end subscripts of the head entity and the start and end subscripts of the tail entity are obtained accordingly; Obtaining a head entity text feature vector based on the head entity start and end subscripts and the hidden vector; Obtaining a tail entity text feature vector based on the tail entity start and end subscripts and the hidden vector; The text feature vector is obtained by concatenating the head entity text feature vector, the tail entity text feature vector and the full sentence feature vector.
5. The knowledge graph updating method of integrating text extraction and graph embedding according to claim 4 is characterized in that: The method for obtaining the fusion relationship prediction probability is: Performing linear mapping and linear weighted fusion based on the embedded feature vector and the text feature vector to obtain a first fused feature vector; Based on the first fused feature vector, the first fully connected layer, the activation layer, the regularization layer, and the second fully connected layer are sequentially input to obtain a first original score of the head and tail entity pairs of the annotated text predicted to be the rth relationship; Normalization is performed based on the first original score to obtain the probability that the head and tail entity pairs of the annotated text are predicted to be the rth relationship, which is used as the fusion relationship prediction probability.
6. The knowledge graph updating method integrating text extraction and graph embedding according to claim 5 is characterized in that: The entity recognition probability acquisition method is: Input the hidden vector to the second fully connected layer for linear mapping, and obtain a second original score for token i predicted to be the c-th entity category; Normalization is performed based on the second original score to obtain the probability of predicting that token i belongs to category c as the entity recognition probability.
7. The knowledge graph updating method integrating text extraction and graph embedding according to claim 5 is characterized in that: The method for obtaining the text relationship prediction probability is: Based on the text feature vector, the first fully connected layer, the activation layer, and the second fully connected layer are sequentially inputted, and a third original score of the text head and tail entity pair predicted to be the rth relationship is obtained; Normalization is performed based on the third original score to obtain the probability that the text head and tail entity pair is predicted to be the rth relationship, which is used as the text relationship prediction probability.
8. The knowledge graph updating method integrating text extraction and graph embedding according to claim 1 is characterized in that: The method for obtaining high confidence triples is: Obtaining a final relationship prediction probability based on weighted fusion of the fusion relationship prediction probability and the text relationship prediction probability; Selecting text entity pairs in the to-be-processed text whose entity recognition probability is greater than or equal to a first threshold as screening head and tail entity pairs; Based on the filtered head and tail entity pairs, selecting the filtered head and tail entity pairs whose final relationship prediction probability is greater than a second threshold as high-confidence entity pairs; The high-confidence triples are composed based on the high-confidence entity pairs and corresponding relationships.
9. The knowledge graph updating method integrating text extraction and graph embedding according to claim 1 is characterized in that: Get the updated knowledge graph embedding feature vector, including: Perform a breadth-first search on the existing knowledge graph based on the newly added entity, and calculate the shortest distance between the newly added entity and other entities in the existing knowledge graph; Obtaining the number of neighbors of each entity and the high-confidence triple in the existing knowledge graph; Obtaining entity degree centrality based on the ratio of the number of neighbors to the increment size; Sorting the newly added entities based on the shortest distance and the entity degree centrality and evenly dividing them into multiple hierarchical subsets; Insert a low-rank adapter matrix pair based on each level subset to obtain the incremental embedding feature vector; constructing a training loss based on the incremental embedding feature vector and the initial triplet embedding feature vector in the existing graph; Performing back-propagation optimization on the low-rank adapter matrix pair based on the training loss to obtain a trained low-rank adapter matrix pair; The updated knowledge graph embedding feature vector is obtained by fusing the trained low-rank adapter matrix pair and the initial triplet embedding feature vector.
10. A knowledge graph updating system integrating text extraction and graph embedding, for executing a knowledge graph updating method integrating text extraction and graph embedding according to any one of claims 1 to 9, characterized in that: include: Data acquisition module, embedding feature acquisition module, hidden vector acquisition module, text feature acquisition module, prediction probability acquisition module, knowledge graph update module and incremental update module; The data acquisition module is used to obtain the existing knowledge graph and related text to be processed; The embedding feature acquisition module is used to acquire the embedding feature vector of the initial entity pair based on the existing knowledge graph; The hidden vector acquisition module is used to obtain the full sentence feature vector and the hidden vector corresponding to each subword based on the text to be processed; The text feature acquisition module is used to obtain a text feature vector corresponding to a text entity pair based on the hidden vector and the full sentence feature vector; The prediction probability acquisition module is used to obtain the fusion relationship prediction probability based on the embedded feature vector and the text feature vector; Obtaining entity recognition probability based on the hidden vector; obtaining text relationship prediction probability based on the text feature vector; The knowledge graph updating module is used to screen high-confidence triples in the text to be processed based on the fusion relationship prediction probability, the entity recognition probability and the text relationship prediction probability and add them to the existing knowledge graph to obtain an updated knowledge graph; The incremental update module is used to perform incremental updates based on the high-confidence triples and newly added entities to obtain an updated knowledge graph embedding feature vector.
Citation Information
Cited By
Chronic disease dynamic knowledge graph updating method and system, and storage medium
CN122531788A