A Few-Shot Knowledge Graph Collaborative Editing Method Based on Breadth-First Search

Through the method based on breadth-first search, the combination of graph neural network and pre-trained language model is used to solve the semantic gap problem in knowledge graph editing, and effective editing and corresponding relationship establishment under the condition of few samples are achieved.

CN116049427BActive Publication Date: 2025-07-25WUHAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211640171.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2025-07-25
Estimated Expiration
2042-12-20

AI Technical Summary

Technical Problem

The prior art is difficult to effectively edit knowledge graphs under the conditions of few samples, especially due to the semantic gap between pre-trained language models and knowledge graphs and the difficulty in generating tasks.

Method used

Using a breadth-first search method, the knowledge graph is encoded through the graph neural network and established alignment loss with the entity representation of the pre-trained language model, the relationship linearization knowledge graph is used to form an entity sequence, and the loss training model is trained through joint alignment and reconstruction.

Benefits of technology

It realizes effective editing of knowledge graphs under the condition of few samples, bridges semantic differences, and improves the corresponding relationship editing effect between knowledge graphs and text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049427B_ABST
    Figure CN116049427B_ABST
Patent Text Reader

Abstract

The present invention proposes a knowledge graph collaborative editing method based on breadth-first search. In this method, there are two main technical contributions. First, in order to bridge the semantic gap, the correspondence between the representation of the knowledge graph (encoded by a graph neural network) and the entity representation based on a pre-trained language model is learned to strengthen the consistency of the representation. Second, in order to input the knowledge graph into the pre-trained language model, a relationship-based breadth-first search strategy is proposed to linearize the knowledge graph into a well-behaved entity sequence. The present invention can edit the knowledge graph in the form of text input and can be used for other related tasks regarding the correspondence between the knowledge graph and the text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning, and in particular, to a few-shot knowledge graph collaborative editing method based on breadth-first search. Background Art

[0002] With the continuous development of information technologies such as the Internet, Internet of Things, and cloud computing, the rapid growth of data has become a severe challenge and valuable opportunity faced by many industries, and the whole society has entered the big data era. In order to better utilize knowledge, Google proposed the concept of knowledge graph in 2012 during the upsurge of semantic research. Compared with ordinary relational databases, a knowledge graph is a semantic network that describes the entities, concepts, and their associated relationships objectively existing in the real world, and is used to describe the entities, concepts, and their mutual relationships in the physical world in symbolic form. These structured knowledges promote the understanding and utilization of knowledge by humans and computers, and are the knowledge basis for the realization of artificial intelligence applications.

[0003] In recent years, with the help of crowdsourcing platforms and information extraction systems, large-scale labeled knowledge graphs and their descriptive text pairs have been created. The emergence of large datasets has enabled data-driven models to show impressive capabilities to generate informative and fluent text for a given knowledge graph. However, due to the huge expense of the annotation process, it is not always feasible to generate large-scale labeled datasets for various fields in practice. Inspired by this, it is necessary to perform knowledge graph editing tasks based on few-shot, aiming to make the knowledge graph produce satisfactory editing effects with only a few labeled instances.

[0004] To complete this task, it is necessary to fully understand the complex semantic relationships between entities from different fields, which is challenging under limited labeled data. Inspired by the excellent capabilities of pre-trained language models in language understanding and generation tasks: after being pre-trained on a large-scale corpus, pre-trained language models encode a large amount of world knowledge into their parameters, which has potential benefits for understanding and describing the facts in the knowledge graph in the task.

[0005] However, applying pre-trained language models to knowledge graph editing tasks still faces two challenges. First, pre-trained language models are usually pre-trained on natural language texts, while the input of the knowledge graph in the task is a structured graph. This semantic gap makes it difficult for us to effectively inject the representation of the knowledge graph into the pre-trained language model, especially in the case of limited labeled instances. Second, the knowledge graph editing task needs to be generated based on the understanding of the facts in the knowledge graph. It needs to learn accurate semantic correspondence relationships between the input knowledge graph and the output text, which is difficult in the few-shot learning setting. Summary of the Invention

[0006] To solve the above problems, the present invention proposes a knowledge graph collaborative editing method based on breadth - first search. In this method, there are two main technical contributions. First, to bridge the semantic gap, the correspondence between the representation of the knowledge graph (encoded by a graph neural network) and the entity representation based on a pre - trained language model is learned to strengthen the consistency of the representation. Second, to input the knowledge graph into the pre - trained language model, we propose a relationship - based breadth - first search strategy to linearize the knowledge graph into a well - formed entity sequence.

[0007] To achieve the above object, the technical solution provided by the present invention is: a knowledge graph collaborative editing method based on breadth - first search, comprising the following steps:

[0008] Step 1, obtain the input text and the given knowledge graph, and pre - process the given knowledge graph to extract all triples of each node on the knowledge graph;

[0009] Step 2, for the input text, perform text representation processing using a pre - trained language model;

[0010] Step 3, construct a knowledge graph encoder based on a graph neural network to generate entity encodings or vectors by utilizing the multi - relational information in the knowledge graph;

[0011] Step 4, establish an alignment loss by minimizing the Euclidean distance between the entity vectors based on the graph neural network and the text based on the pre - trained language model in the semantic space;

[0012] Step 5, traverse the knowledge graph and linearize it into an entity sequence α e ;

[0013] Step 6, input α e into the decoder of the language model to obtain a text sequence, and input the hidden vector of the text sequence in the decoder into the knowledge graph for relationship prediction to obtain a reconstruction loss;

[0014] Step 7, through the joint alignment loss and prediction loss, use the Adam optimization algorithm for model training to update the network parameters of the language model and the graph neural network;

[0015] Step 8, repeat steps 2 to 7 for T times;

[0016] Step 9, in the test phase, input any text to obtain the edited knowledge graph.

[0017] Further, in step 2, the implementation process of the text representation processing is as follows;

[0018]

[0019] Here, T is the input sample, and ρ(·) is the encoder of the pre-trained language model, and is the obtained text representation.

[0020] Furthermore, the implementation process of generating entity encodings in step three is as follows;

[0021]

[0022] Here, v e represents the encoding or vector of an entity e in the knowledge graph, which is obtained by preprocessing the knowledge graph, that is, by extracting all triples of each node on the knowledge graph in step one; similarly, v e′ is the encoding or vector of an entity e' other than entity e in the knowledge graph, which is obtained by preprocessing the knowledge graph; σ(·) represents the graph neural network; the superscripts (l) and (l + 1) respectively represent the l-th layer and the (l + 1)-th layer of the network; r is the relationship related to e and e' in the knowledge graph, and the set of all relationships in the entire knowledge graph is R; is the neighbor set in the knowledge graph under the condition of r; and are the trainable learning matrices of the l-th layer; finally, the entity encoding will be denoted as where L represents the number of layers of the graph neural network.

[0023] Furthermore, the calculation formula of the alignment loss is as follows;

[0024]

[0025] Here, is the text representation, is the entity encoding, and ||·||2 represents the 2-norm.

[0026] Furthermore, the calculation formula of the entity sequence in step five is as follows;

[0027]

[0028] Here, α e is the linearized entity sequence.

[0029] Furthermore, the specific implementation method of step six is as follows;

[0030] T e = ρ -1 (α e )⑸

[0031] p(r|e, e′) = softmax(W soft T E )⑹

[0032] Here, T e is the generated text, and ρ -1 (·) is the decoder of the pre-trained language model, and its hidden vector representation is T E , W soft are learnable parameters;

[0033] During this process, the reconstruction loss is:

[0034]

[0035] Furthermore, the expressions of the joint alignment loss and the prediction loss in step seven are:

[0036]

[0037] Here, the hyperparameters λ1 and λ2 control the weights of the two different objective terms.

[0038] Furthermore, the BERT language model is adopted in step two.

[0039] Furthermore, the RGCN graph neural network is adopted in step three.

[0040] Compared with the prior art, the advantages and beneficial effects of the present invention are as follows: The knowledge graph collaborative editing method based on breadth-first search bridges the semantic differences between the knowledge graph encoding and the pre-trained language model, and establishes a relationship-based knowledge graph linearization, so that the input text can be used to edit the knowledge graph, and this editing method can be used for other related tasks regarding the correspondence between the knowledge graph and the text. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a process diagram of knowledge graph collaborative editing in the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0042] The technical solution of the present invention will be further described below in conjunction with the drawings and embodiments.

[0043] This application provides a knowledge graph collaborative editing method based on breadth-first search, including:

[0044] Step 1: Obtain input: Obtain the input text and the given knowledge graph, and preprocess the given knowledge graph to extract all triples of each node on the knowledge graph;

[0045] Step 2: Pre-training of the pre-trained language model and text preprocessing: For the input text, we perform text representation processing:

[0046]

[0047] Here, T is the input sample, and ρ(·) is the encoder of the pre-trained language model, which is the obtained text representation.

[0048] Step 3: Knowledge graph encoding: We construct a knowledge graph encoder based on a graph neural network. We generate entity encodings by leveraging the multi-relational information in the knowledge graph:

[0049]

[0050] Here, v e represents the encoding / vector of an entity e in the knowledge graph ( obtained by preprocessing the knowledge graph, i.e., by extracting all triples of each node in the knowledge graph in Step 1); similarly, v e ′ is the encoding / vector of an entity e′ other than entity e in the knowledge graph ( obtained by preprocessing the knowledge graph, i.e., by extracting all triples of each node in the knowledge graph in Step 1); σ(·) represents the graph neural network; the superscripts (l) and (l + 1) represent the l-th layer and the (l + 1)-th layer of the network, respectively; r is the relation related to e and e′ in the knowledge graph, and the set of all relations in the entire knowledge graph is R; is the neighbor set (the set of neighbors of entity) in the knowledge graph under the condition of r; and are the trainable matrices at the l-th layer.

[0051] We construct an L-layer network. At this time, our entity encoding will be denoted as

[0052] Step 4: Text-graph semantic alignment: To narrow the semantic gap of the model, we establish an alignment loss by minimizing the Euclidean distance between the entity vectors based on the graph neural network and the text based on the pre-trained language model in the semantic space

[0053]

[0054] Here, ||·||2 represents the 2-norm.

[0055] Step 5 Knowledge Graph Encoding Linearization: We propose a relationship-based breadth-first search strategy to traverse and linearize the knowledge graph into an entity sequence:

[0056]

[0057] Here, α e is the linearized entity sequence, and other variables can refer to the description in formula (2).

[0058] Step 6 Knowledge Graph Reconstruction: We input α e into the decoder of the language model to obtain a text sequence; and input the hidden vector of the text sequence in the decoder into the knowledge graph for relationship prediction:

[0059] T e = ρ -1 (α e ) ⑸

[0060] p(r|e,e′) = softmax(W soft T E ) ⑹

[0061] Here, T e is the generated text, ρ -1 (·) is the decoder of the pre-trained language model, and its hidden vector representation is T E , W soft are learnable parameters, and softmax represents the softmax function.

[0062] During this process, the reconstruction loss is:

[0063]

[0064] Step 7 Network Optimization Parameter Adjustment: Through the joint loss function, the Adam optimization algorithm is used for model training to update the network parameters of the language model and the graph neural network:

[0065]

[0066] Here, the hyperparameters λ1 and λ2 control the weights of the two different objective terms.

[0067] Step 8 Repeat Steps 2 to 7 for T times;

[0068] Step 9 In the test phase, input any text to obtain the edited knowledge graph.

[0069] The present invention provides an unsupervised image conversion method oriented to the target domain based on a generative adversarial network. The specific embodiments described are only used to illustrate the implementation manner of the present invention and do not limit the scope of the present invention.

[0070] Next, we take Chinese BERT [1] as the language model and RGCN [2] as the graph neural network as examples to illustrate the process of the present invention, which specifically includes the following steps:

[0071] 1. Obtain input: As Figure 1 shown, assume that the input text is "Zhou Lei is from Wuhan University of Technology"; the given knowledge graph is the Chinese high school geography knowledge graph (CKGG [3]). Perform preprocessing on the geography graph and extract all triples of each node on the knowledge graph.

[0072] 2. Pre-training of the pre-trained language model and text preprocessing:

[0073] Pre-training: The language model performs word tokenization on the original data samples (text and graph information); constructs a dictionary according to the tokenized results. Secondly, converts the tokenized text sequence into a token sequence according to the dictionary, and adds start and end symbols to the head and tail of the token sequence respectively, and performs padding. Finally, generates corresponding text vectors according to the processed results.

[0074] Text preprocessing: Use the encoder of the language model to execute formula (1) to obtain text representations.

[0075] 3. Knowledge graph encoding: Construct a 12-layer graph neural network (L = 12), and each layer executes formula (2) to finally obtain the knowledge graph encoding.

[0076] 4. Text-graph semantic alignment: Use formula (3) to enforce the model, narrow the semantic gap of the model, and further standardize the collaborative editing task of the knowledge graph.

[0077] 5. Linearization of knowledge graph encoding: Use a 12-layer graph neural network to execute formula (4) to obtain a linearized entity sequence.

[0078] 6. Knowledge graph reconstruction: Use the decoder of the language model to execute formula (5), and take its result and execute formula (6) for reconstruction; the loss in the reconstruction process executes formula (7).

[0079] 7. Network optimization parameter adjustment: We use the joint loss function (i.e., formula (8)), use the Adam optimizer for training, set the batch size to 20, set the learning rate to 0.00001, set the momentum to 0.5 and 0.999. In all experiments, the set hyperparameters are as follows: λ1 = 0.5 and λ2 = 0.5.

[0080] 8. Repeat steps 2 to 7 for T times;

[0081] 9. In the testing stage, any text input is given to obtain the edited knowledge graph.

[0082] Advantages of the present invention: The knowledge graph collaborative editing method based on breadth-first search bridges the semantic differences between knowledge graph encoding and pre-trained language models, and establishes a relationship-based linearization of the knowledge graph, enabling the present invention to edit the knowledge graph in the form of text input and be applicable to other related tasks regarding the correspondence between knowledge graphs and texts.

[0083] The relevant references are as follows:

[0084] [1] Cui Y, Che W, Liu T, et al. Pre-training with whole word masking for Chinese BERT[J]. IEEE / ACM Transactions on Audio, Speech, and Language Processing, 2021, 29: 3504-3514.

[0085] [2] Schlichtkrull M, Kipf T N, Bloem P, et al. Modeling relational data with graph convolutional networks[C] / / European semantic web conference. Springer, Cham, 2018: 593-607.

[0086] [3] Open source address: http: / / www.openkg.cn / dataset / groups / ckgg.

[0087] The specific embodiments described herein are merely illustrative of the spirit of the present invention. Those skilled in the art of the present invention can make various modifications or supplements to the described specific embodiments or use similar methods for substitution, but will not deviate from the spirit of the present invention or exceed the scope defined by the appended claims.

Claims

1. A collaborative editing method for knowledge graphs based on breadth-first search, characterized in that It includes the following steps: Step 1: Obtain the input text and the given knowledge graph, and preprocess the given knowledge graph to extract all triples of each node on the knowledge graph; Step 2: For the input text, perform text representation processing using a pre-trained language model; Step 3: Construct a knowledge graph encoder based on a graph neural network to generate entity encodings or vectors by leveraging the multi-relational information in the knowledge graph; Step 4: Establish an alignment loss by minimizing the Euclidean distance between the entity vectors based on the graph neural network and the text based on the pre-trained language model in the semantic space; Step 5: Traverse and linearize the knowledge graph into an entity sequence α through a relationship-based breadth-first search strategy e ; Step 6, input α e into the decoder of the language model to obtain a text sequence, and input the hidden vector of the text sequence in the decoder into the knowledge graph for relationship prediction to obtain a reconstruction loss; Step 7: Through the joint alignment loss and prediction loss, adopt the Adam optimization algorithm to train the model and update the network parameters of the language model and the graph neural network; Step 8: Repeat steps 2 to 7 for T times; Step 9: In the test phase, input any text to obtain the edited knowledge graph.

2. The collaborative editing method of the knowledge graph based on breadth - first search according to claim 1, characterized in that: In step 2, the implementation process of text representation processing is as follows; Here, T is the input sample, and ρ(·) is the encoder of the pre-trained language model, which is the obtained text representation.

3. The knowledge graph collaborative editing method based on breadth-first search according to claim 1, wherein: The implementation process of generating entity encodings or vectors in step 3 is as follows; Here, v e represents the encoding or vector of an entity e in the knowledge graph, which is obtained by preprocessing the knowledge graph, that is, by extracting all triples of each node on the knowledge graph in step one; similarly, v e′ is the encoding or vector of an entity e ′ other than entity e in the knowledge graph, which is obtained by preprocessing the knowledge graph; σ(·) represents the graph neural network; the superscripts (l) and (l + 1) represent the l-th layer and the (l + 1)-th layer of the network respectively; r is the relationship related to e and e ′ in the knowledge graph, and the set of all relationships in the entire knowledge graph is R; is the neighbor set in the knowledge graph under the condition of r; and are the trainable learning matrices of the l-th layer; finally, the entity encoding will be denoted as where L represents the number of layers of the graph neural network.

4. The collaborative editing method of the knowledge graph based on breadth-first search according to claim 1, wherein: The calculation formula of the alignment loss is as follows; Here, is the text representation, is the entity encoding, and ||·||2 represents the 2-norm.

5. The collaborative editing method of the knowledge graph based on breadth-first search according to claim 3, wherein: The calculation formula of the entity sequence in step 5 is as follows; Here, α e is a linearized sequence of entities.

6. The collaborative editing method of the knowledge graph based on breadth-first search according to claim 3, characterized in that: The specific implementation method of step 6 is as follows; T e = ρ -1 (α e )⑸ p(r|e,e ′ ) = softmax(W soft T E )⑹ Here, T e is the generated text, and ρ -1 (·) is the decoder of the pre-trained language model, and its hidden vector representation is T E , W soft are learnable parameters; During this process, the reconstruction loss is:

7. The collaborative editing method of the knowledge graph based on breadth - first search according to claim 3, characterized in that: The expressions of the joint alignment loss and prediction loss in step 7 are: Here, the hyperparameters λ1 and λ2 control the weights of the two different objective terms.

8. The collaborative editing method of the knowledge graph based on breadth-first search according to claim 1, characterized in that: The BERT language model is adopted in step 2.

9. The collaborative editing method of a knowledge graph based on breadth-first search according to claim 1, characterized in that: The RGCN graph neural network is adopted in step 3.

Citation Information

Patent Citations

  • Knowledge graph completion method and device based on semantic alignment and symmetric structure coding

    CN114117075A

  • Knowledge graph completion method and device based on improved TextRank

    CN115422369A