Method, device, computer device and storage medium for entity linking of knowledge graph
By using training data based on positive and negative samples in the Q&A scenario to train the initial model of entity linking, the problems of poor entity consistency model and low entity linking accuracy are solved, and more efficient entity linking effect is achieved.
Patent Information
- Application Number
- JP2023576443
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2023-05-10
- Filing Date
- 2023-05-12
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2043-05-12
AI Technical Summary
In the Q&A scenario, it is difficult for the prior art to effectively build an entity consistency model, resulting in low accuracy of entity links.
The entity link initial model is trained to improve the accuracy of entity linking by obtaining training data positive and negative samples based on problem samples, entity samples, knowledge graph entity positive samples, and knowledge graph entity adjacency sub-graph samples.
This method ensures the accuracy and effectiveness of the training data by manually labeling the knowledge graph entities as positive sample data. It randomly extracts entities without labeling relationships as negative samples, which improves the randomness and effect of model training, thereby improving the accuracy of entity links.
Smart Images

Figure 0007675863000033 
Figure 0007675863000034 
Figure 0007675863000035
Abstract
Description
[Technical field]
[0001] The present application relates to the technical field of natural language processing, and in particular to a method, an apparatus, a computer device and a readable storage medium for entity linking in a knowledge graph. [Background technology]
[0002] Entity linking refers to linking entity mentions appearing in text with corresponding entities in a knowledge graph, and is an important step in many information extraction tasks and natural language understanding tasks, such as knowledge graph updating, knowledge graph-based question and answering, search engines, etc. Due to the diversity of natural language descriptions, disambiguating entity mentions is the most important part of the entity linking task.
[0003] The entity linking method is intended to build a text comparison model of entity mentions and knowledge graph entities, and most of the conventional methods are concerned with the semantic information described in the knowledge graph entity text, or model the consistency of entities in documents according to the association relationship of entity nodes in the knowledge graph, and the latter can utilize the large amount of graph structure and stored knowledge contained in the knowledge graph to obtain information other than the user problem to help resolve ambiguity, and effectively improve the accuracy of entity linking. However, in the question and answer scene, the number of entities involved in the majority of user problems is small, making it difficult to effectively build an entity consistency model, and therefore the knowledge graph is not easily utilized, and the accuracy of entity linking is relatively low.
[0004] Currently, there is no effective solution to the problem that the entity consistency model is ineffective in the question and answer scene in the related technology, and the accuracy of entity linking is relatively low. Summary of the Invention [Problem to be solved by the invention]
[0005] In order to solve the problem that the entity consistency model effect is poor in the question and answer scene in the related art and the accuracy of entity linking is relatively low, the present embodiment provides a method, an apparatus, a computer device and a readable storage medium for entity linking of knowledge graphs. [Means for solving the problem]
[0006] In a first aspect, the present embodiments provide a method for entity linking of a knowledge graph, the method comprising: Obtaining training data positive samples based on a problem sample, an entity mention sample, a knowledge graph entity positive sample, and a knowledge graph entity adjacent subgraph sample, the entity mention sample being obtained based on the problem sample, the knowledge graph entity positive sample being obtained based on a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample being obtained based on an entity relationship in the knowledge graph of the knowledge graph entity positive sample; Obtaining training data negative samples according to the problem sample, the entity mention sample, the knowledge graph entity negative samples, and corresponding knowledge graph entity adjacent subgraph samples, the knowledge graph entity negative samples being randomly obtained according to entities that have no labeling relationship with the entity mention sample in the knowledge graph; Training an entity linking initial model based on the training data positive samples and the training data negative samples to obtain an entity linking model; inputting a user problem, an entity mention, a candidate knowledge graph entity and a corresponding knowledge graph entity adjacency subgraph into the trained entity linking model to determine a target knowledge graph entity to link to the entity mention, wherein the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacency subgraph is obtained based on an entity relationship in the knowledge graph of the candidate knowledge graph entity.
[0007] In some embodiments, training an entity linking initial model based on the training data positive samples and the training data negative samples comprises: inputting the training data positive samples and the training data negative samples into the entity linking initial model to output a sample entity mention vector and a sample entity graph convolution vector; determining a loss function of the entity linking initial model based on the sample entity mention vector, the sample entity graph convolution vector, and a sample mark parameter previously obtained; training the entity linking initial model based on the loss function.
[0008] In some embodiments, the entity linking initial model comprises a text embedding module and an entity graph network embedding module, and inputting the training data positive samples and the training data negative samples into the entity linking initial model to output a sample entity mention vector and a sample entity graph convolution vector includes: inputting the problem samples and the knowledge graph entity samples into the text embedding module to output the sample entity mention vectors and sample problem vectors, wherein the knowledge graph entity samples include the knowledge graph entity positive samples and the knowledge graph entity negative samples; Obtaining attention weights of entity sample vectors in the entity graph network embedding module based on the sample problem vector; inputting the knowledge graph entity adjacency subgraph sample into the entity graph network embedding module, and outputting the sample entity graph convolution vector based on the attention weights.
[0009] In some embodiments, the text embedding module comprises a BERT model, and inputting the problem samples and knowledge graph entity samples into the text embedding module to output the sample entity mention vectors and sample problem vectors comprises: Concatenating the problem sample, the knowledge graph entity sample, the CLS flag bit, and the SEP flag bit in a predetermined format and inputting them into the BERT model; determining the sample problem vector based on a first output vector of the BERT model corresponding to the CLS flag bit.
[0010] In some embodiments, the text embedding module further comprises a multi-layer perceptron model, and inputting the problem sample and the knowledge graph entity sample to the text embedding module to output the sample entity mention vector and the sample problem vector comprises: Obtaining a second output vector of the BERT model corresponding to a start position of the entity mention sample and a third output vector of the BERT model corresponding to an end position of the entity mention sample; The method further includes concatenating the first output vector, the second output vector, and the third output vector and inputting the result into the multi-layer perceptron model to obtain the sample entity mention vector.
[0011] In some embodiments, inputting the knowledge graph entity adjacency subgraph sample to the entity graph network embedding module and outputting the sample entity graph convolution vector based on the attention weights comprises: Initializing the knowledge graph entity adjacent subgraph sample according to the first output vector to obtain a corresponding entity sample vector; inputting the entity sample vector into the entity graph network embedding module and outputting the sample entity graph convolution vector based on the attention weights.
[0012] In some embodiments, before concatenating the problem samples, knowledge graph entity samples, CLS flag bits, and SEP flag bits in the predetermined format and inputting them into the BERT model, the method further comprises: Pre-training the BERT initial model to obtain pre-trained model parameters; and constructing the BERT model based on the pre-trained model parameters.
[0013] In a second aspect, the present embodiment provides an apparatus for entity linking of a knowledge graph, the apparatus comprising: a first acquiring module for acquiring training data positive samples based on a problem sample, an entity mention sample, a knowledge graph entity positive sample, and a knowledge graph entity adjacent subgraph sample, the entity mention sample being acquired based on the problem sample, the knowledge graph entity positive sample being acquired based on a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample being acquired based on an entity relationship in the knowledge graph of the knowledge graph entity positive sample; A second obtaining module for obtaining training data negative samples according to the problem sample, the entity mention sample, the knowledge graph entity negative sample, and the corresponding knowledge graph entity adjacent subgraph sample, wherein the knowledge graph entity negative sample is obtained randomly based on an entity that has no labeling relationship with the entity mention sample in the knowledge graph; a training module for training an entity linking initial model based on the training data positive samples and the training data negative samples to obtain an entity linking model; a determination module for inputting a user problem, an entity mention, a candidate knowledge graph entity and a corresponding knowledge graph entity adjacency subgraph into the trained entity linking model to determine a target knowledge graph entity to link to the entity mention, wherein the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacency subgraph is obtained based on an entity relationship in the knowledge graph of the candidate knowledge graph entity.
[0014] In a third aspect, the present embodiment provides a computing device comprising a memory and a processor, wherein a computer program is stored in the memory, and wherein the processor is configured to execute the computer program to perform steps in the method for entity linking of knowledge graphs described in the first aspect above.
[0015] In a fourth aspect, the present embodiment provides a readable storage medium having a program stored thereon, the program, when executed by a processor, realizing steps in the method for entity linking of a knowledge graph described in the first aspect above. Effect of the Invention
[0016] Compared with the related art, the knowledge graph entity linking method of this embodiment obtains training data positive samples based on question samples, entity mention samples, knowledge graph entity positive samples, and knowledge graph entity adjacent subgraph samples, and uses the knowledge graph entities linked to the entity mention samples by manual labeling as positive training sample data to ensure the accuracy of the training data positive samples and the effectiveness of training; obtains training data negative samples based on question samples, entity mention samples, knowledge graph entity negative samples, and corresponding knowledge graph entity adjacent subgraph samples, i.e., removes the entity positive samples in the knowledge graph and then randomly extracts entities as knowledge graph entity negative samples, thereby ensuring the accuracy of the training data positive samples and the effectiveness of training; The randomness of the negative samples and the effectiveness of training are improved; an entity linking initial model is trained based on the training data positive samples and the training data negative samples to obtain an entity linking model, thereby improving the linking accuracy of the entity linking model; the user problem, the entity mention, the candidate knowledge graph entity and the corresponding knowledge graph entity adjacent subgraph are input into the trained entity linking model to determine the target knowledge graph entity to be linked to the entity mention, and the knowledge graph entity most similar to the entity mention is obtained as the linking target, thereby improving the linking effect of the entity linking model, thereby solving the problem in related technologies that the effect of the entity consistency model is poor in question and answer scenes and the accuracy of entity linking is relatively low.
[0017] Other features, objects and advantages of the present application will become more clearly apparent from the details of one or more embodiments of the present application set forth in the drawings and description that follow. [Brief description of the drawings]
[0018] The drawings described herein are intended to provide a further understanding of the present application, constitute a part of the present application, and the schematic examples of the present application and the description thereof are intended to interpret the present application and are not intended to unduly limit the present application.
[0019] [Figure 1] FIG. 1 is a block diagram of a terminal in a knowledge graph entity linking method according to some embodiments of the present application. [Diagram 2] FIG. 2 is a flowchart of a method for entity linking of a knowledge graph according to some embodiments of the present application. [Diagram 3] FIG. 3 is a flowchart for training an entity linking initial model based on training data samples according to some embodiments of the present application. [Figure 4] FIG. 4 is a flowchart of outputting a sample entity mention vector and a sample entity graph convolution vector based on training data samples according to some embodiments of the present application. [Diagram 5] FIG. 5 is a flowchart of obtaining a sample problem vector based on a problem sample and a knowledge graph entity sample according to some embodiments of the present application. [Figure 6] FIG. 6 is a flowchart of obtaining a sample entity mention vector based on a problem sample and a knowledge graph entity sample according to some embodiments of the present application. [Figure 7] FIG. 7 is a flowchart of obtaining a sample entity graph convolution vector based on a knowledge graph entity adjacent subgraph sample according to some embodiments of the present application. [Figure 8] FIG. 8 is a structural schematic diagram of an entity linking model according to some preferred embodiments of the present application. [Figure 9]FIG. 9 is a flow chart of a method for entity linking of a knowledge graph according to some preferred embodiments of the present application. [Figure 10] FIG. 10 is a block diagram of a knowledge graph entity linking apparatus according to some embodiments of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0020] In order to make the purpose, technical solution and advantages of the present application more clearly understandable, the present application is described and explained by examples with reference to the drawings as follows. It should be understood that the specific examples described herein are only for interpreting the present application, and are not intended to limit the present application.
[0021] Unless otherwise defined, technical or scientific terms in this application shall have the ordinary meanings understood by those skilled in the art in the technical field to which this application pertains. In this application, the terms "a", "one", "a kind", "the", "these" and similar terms do not indicate a numerical limitation, and they may be singular or plural. In this application, the terms "comprise", "include", "have" and any variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method and a system, product or device that includes a series of steps or modules (units) is not limited to the recited steps or modules (units), but may include unrecited steps or modules (units), or may include other steps or modules (units) inherent in the process, method, product or device. In this application, the terms "connect", "couple", "couple" and similar terms are not limited to physical or mechanical connections, but may also include electrical connections, whether direct or indirect. In this application, "plurality" refers to two or more. "And / or" describes a relation between related objects, and indicates that three relations may exist, for example, "A and / or B" may indicate three situations: "A exists independently", "A and B exist simultaneously", and "B exists independently". In general, the character " / " indicates that the preceding and following related objects are in an "or" relation. The terms "first", "second", "third", etc., in the present application are merely used to distinguish similar objects, and do not represent a specific order for the objects.
[0022] The knowledge graph entity linking method according to the embodiments of the present application may be executed in a terminal, a computer, or a similar computing device. When the method is applied to a terminal, a computer, or a similar computing device, FIG. 1 is a hardware block diagram of a terminal in the knowledge graph entity linking method according to some embodiments of the present application. As shown in FIG. 1, the terminal may include one or more (only one is shown in FIG. 1) processors 102 and a memory 104 for storing data, and the processor 102 may include, but is not limited to, a processing device such as a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may further include a transmission device 106 for communication functions and an input / output device 108. As will be understood by those skilled in the art, the structure shown in FIG. 1 is merely schematic and does not limit the structure of the terminal. For example, the terminal may further include more or less components than those in FIG. 1, or have a different configuration from that in FIG. 1.
[0023] The memory 104 may be for storing computer programs, such as software programs and modules of application software, such as a computer program corresponding to the knowledge graph entity linking method according to the present embodiment, and the processor 102 executes various functional applications and data processing, i.e., executes the above-mentioned method, by executing the computer programs stored in the memory 104. The memory 104 may include a high-speed random access memory, and may further include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some embodiments, the memory 104 may further include memories located remotely with respect to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0024] The transmission device 106 is for receiving or transmitting data through a network, including a wireless network provided by a communication provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC) and can communicate with the Internet by connecting to other network devices through a base station. In one embodiment, the transmission device 106 can be a radio frequency (RF) module and for communicating with the Internet wirelessly.
[0025] This embodiment provides a method for entity linking of knowledge graphs. FIG. 2 is a flowchart of the method for entity linking of knowledge graphs according to some embodiments of the present application. As shown in FIG. 2, the process includes the following steps S201 to S204.
[0026] In step S201, a training data positive sample is obtained based on a problem sample, an entity mention sample, a knowledge graph entity positive sample and a knowledge graph entity adjacent subgraph sample, where the entity mention sample is obtained based on the problem sample, the knowledge graph entity positive sample is obtained based on a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample is obtained based on an entity relationship in the knowledge graph of the knowledge graph entity positive sample.
[0027] In this embodiment, the problem sample refers to an existing user problem obtained by means such as collection, and the entity mention sample refers to an entity mention extracted from the problem sample by means such as a conventional NER model. One problem sample may include one or more entity mention samples. The knowledge graph entity positive sample refers to a knowledge graph entity obtained from the knowledge graph by a manual labeling manner based on the entity mention sample, and the knowledge graph entity corresponds to the entity mention sample, and the knowledge graph entity adjacent subgraph sample refers to an adjacent subgraph in the knowledge graph consisting of one-hop adjacent nodes based on the knowledge graph entity positive sample.
[0028] Specifically, a knowledge graph G may be denoted as G(V,E), where V denotes a node (entity), E denotes an edge (relationship) between nodes, and an entity e i Let e be the adjacent subgraph in the knowledge graph G. i Let Ge be the subgraph of 1-hop adjacent nodes of i It is written as:
[0029] For a user problem q, the NER model calculates the entity mention set M={m i} i=1,…,n The knowledge graph entity set E={e i} i=1,…,n We label the user problem, entity mentions, knowledge graph entities, and knowledge graph entity adjacent subgraphs into 4-tuple sets. <q,m i ,e i ,Ge i > i=1,…,n and use them as positive samples in the training data.
[0030] In step S202, a training data negative sample is obtained based on the problem sample, the entity mention sample, the knowledge graph entity negative sample and the corresponding knowledge graph entity adjacent subgraph sample, and the knowledge graph entity negative sample is randomly obtained based on entities that have no labeling relationship with the entity mention sample in the knowledge graph.
[0031] Randomly extract entities from the knowledge graph and filter the set of entities E that appear in the positive samples to obtain E*={e j} j=1,…,n where: TIFF0007675863000001.tif820, and the user problem, entity mentions, randomly extracted knowledge graph entities and their adjacent subgraphs are grouped into quaternary sets. <q,m i ,e j ,Ge j > j=1,…,n and use them as negative samples in the training data.
[0032] In step S203, an entity linking initial model is trained based on the training data positive samples and the training data negative samples to obtain an entity linking model.
[0033] The four-tuple data of the training data positive samples and the training data negative samples are input to the entity linking initial model for training, the loss function of the entity linking initial model is calculated according to the output of the entity linking initial model, and the model parameters are adjusted according to the loss function, and finally an entity linking model is obtained. The entity linking initial model can be a combination of different types of neural network models or multiple types of neural network models, including CNN, RNN, Transformer, BERT, GPT, multi-layer perceptron, etc.
[0034] In step S204, the user problem, the entity mention, the candidate knowledge graph entity and the corresponding knowledge graph entity adjacent subgraph are input into a trained entity linking model to determine a target knowledge graph entity to link to the entity mention, where the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacent subgraph is obtained based on the entity relationship in the knowledge graph of the candidate knowledge graph entity.
[0035] When a new user problem is input, an entity mention in the user problem may be extracted by an entity identification model such as an NER model, and multiple knowledge graph entities similar to the entity mention may be obtained as a set of candidate entities based on the entity mention and a text similarity evaluation algorithm, such as the BM25 algorithm, and then a knowledge graph adjacent subgraph corresponding to each of the candidate knowledge graph entities may be obtained.
[0036] The user problem, the entity mention, the candidate knowledge graph entity and the corresponding knowledge graph entity adjacent subgraph are constructed into a 4-tuple and input into the trained entity linking model to obtain a vector representation of the entity mention and a set of graph convolution vector representations of the candidate knowledge graph entity, and the candidate entity having the highest cosine similarity with the vector representation of the entity mention from the set of graph convolution vector representations is selected as the target entity to be linked.
[0037] Through the above steps S201 to S204, a training data positive sample is obtained according to the problem sample, the entity mention sample, the knowledge graph entity positive sample, and the knowledge graph entity adjacent subgraph sample, and the knowledge graph entity entity linked to the entity mention sample by manual labeling is used as the positive training sample data to ensure the accuracy of the training data positive sample and the training effectiveness; a training data negative sample is obtained according to the problem sample, the entity mention sample, the knowledge graph entity negative sample, and the corresponding knowledge graph entity adjacent subgraph sample, that is, the entity positive sample in the knowledge graph is removed, and then the entity is randomly extracted as the knowledge graph entity negative sample, thereby obtaining the training data negative sample. the randomness of the model and the effectiveness of training; an entity linking initial model is trained based on the training data positive samples and the training data negative samples to obtain an entity linking model, thereby improving the linking accuracy of the entity linking model; the user problem, the entity mention, the candidate knowledge graph entity, and the corresponding knowledge graph entity adjacent subgraph are input into the trained entity linking model to determine the target knowledge graph entity to be linked to the entity mention, and the knowledge graph entity most similar to the entity mention is obtained as the linking target, thereby improving the linking effect of the entity linking model, thereby solving the problem in related technologies that the effect of the entity consistency model is poor in question-and-answer scenes, resulting in relatively low entity linking accuracy.
[0038] In some embodiments, FIG. 3 is a flowchart for training an entity linking initial model based on training data samples according to some embodiments of the present application. As shown in FIG. 3, the process includes the following steps S301 to S303.
[0039] In step S301, training data positive samples and training data negative samples are input into an entity linking initial model to output a sample entity mention vector and a sample entity graph convolution vector.
[0040] After inputting the 4-tuple data of the training data positive samples and the training data negative samples into the entity linking initial model, the entity linking initial model processes to extract semantic information contained in the problem samples, the entity mention samples and the knowledge graph entity samples in the 4-tuple, and outputs a sample entity mention vector, which is a feature vector to which the entity mention sample is mapped, and which includes context information in the problem sample and expresses the semantic information corresponding to the entity mention sample in the form of a vector.
[0041] The entity linking initial model processes the knowledge graph entity adjacent subgraph samples in the 4-tuple data, and outputs a sample entity graph convolution vector, where the sample entity graph convolution vector is a graph convolution vector extracted based on one-hop adjacent entity relationships in the knowledge graph of the knowledge graph entity sample, and reflects semantic information corresponding to the knowledge graph entity sample.
[0042] In step S302, a loss function of an entity linking initial model is determined based on the sample entity mention vector, the sample entity graph convolution vector, and the sample mark parameters obtained in advance.
[0043] Since the sample entity mention vector and the sample entity graph convolution vector respectively represent the semantic information contained in the entity mention sample and the corresponding knowledge graph entity sample, the similarity between the two kinds of vectors can reflect the semantic similarity between the entity mention sample and the corresponding knowledge graph entity sample, and can also reflect the training effect of the entity linking initial model. The sample mark parameter is for reflecting the difference in the training effect of the entity linking model caused by the training data positive sample and the training data negative sample. If the knowledge graph entity sample in the 4-tuple data is a positive sample, the sample mark parameter is equal to 1, otherwise it is 0.
[0044] Specifically, the loss function of the entity linking initial model may be expressed as Equation 1 below.
number
[0045] In step S303, an entity linking initial model is trained based on the loss function.
[0046] The training data (including positive and negative sample pairs) is input to the entity linking initial model for training, and the initial model parameters are adjusted to minimize the loss function. When the value of the loss function is smaller than a preset threshold, the entity linking model training is completed, and the model parameters are stored.
[0047] Through the above steps S301 to S303, the training data positive samples and the training data negative samples are input into the entity linking initial model, and a sample entity mention vector and a sample entity graph convolution vector are output, thereby converting the semantic information contained in the entity mention sample and the corresponding knowledge graph entity sample into corresponding vector expressions; a loss function of the entity linking initial model is determined according to the sample entity mention vector, the sample entity graph convolution vector, and the previously obtained sample mark parameters, thereby measuring the similarity between the sample entity mention vector and the sample entity graph convolution vector by the loss function; the entity linking initial model is trained according to the loss function to obtain model parameters corresponding to the minimum value of the loss function, and a trained entity linking model is obtained, thereby improving the linking accuracy of the knowledge graph entities based on the user's questions in the question and answer scene, and improving the answering accuracy based on the user's questions.
[0048] In some embodiments, the entity linking initial model includes a text embedding module and an entity graph network embedding module. FIG. 4 is a flowchart for outputting a sample entity mention vector and a sample entity graph convolution vector based on training data positive and negative samples according to some embodiments of the present application. As shown in FIG. 4, the process includes the following steps S401 to S403:
[0049] In step S401, the problem samples and the knowledge graph entity samples are input into a text embedding module to output a sample entity mention vector and a sample problem vector, where the knowledge graph entity samples include knowledge graph entity positive samples and knowledge graph entity negative samples.
[0050] The text embedding module is a model that maps entity mention samples in a problem sample to corresponding sample entity mention vectors in a text embedding manner, and the module may be composed of different models of natural language processing and combinations of different models, such as CoVe, Transformer, BERT, roberta, etc. The input of the text embedding module includes problem samples, entity mention samples, and knowledge graph entity samples, and the entity mention samples input the problem samples to the text embedding module. Corresponding to the problem samples and the entity mention samples, the output of the text embedding module includes sample entity mention vectors and sample problem vectors, and the sample problem vector refers to the feature vector to which the problem sample is mapped.
[0051] In step S402, obtain attention weights of entity sample vectors in the entity graph network embedding module according to the sample problem vector.
[0052] The entity graph network embedding module is a model that maps an entity graph network to a corresponding feature vector in an entity graph embedding manner, and the models used in the module may include GCN, deepWalk, SDNE, node2vec, etc. In this embodiment, the entity graph network embedding module is composed of a multi-layer CA-GCN module, and an attention mechanism is added, which can give different weights to different entity relationships in the knowledge graph entity adjacent subgraph sample through weight adjustment. The attention weights may be obtained according to the sample problem vectors output by the text embedding module, thereby reflecting the impact of context information in the problem sample on the importance of different entity relationships in the knowledge graph.
[0053] Specifically, the forward propagation formula of each CA-GCN module may be expressed as Equation 2 below.
number
[0054] Cross-attention matrix TIFF0007675863000012.tif119 may first be calculated using Equation 3 below.
number
[0055] next, Normalize TIFF0007675863000018.tif118 and finally The result is TIFF0007675863000019.tif1473.
[0056] After passing through the L-layer CA-GCN module, the output of entity e at the L-th layer is TIFF0007675863000020.tif89 to its graph convolution vector V eLet us assume that.
[0057] In step S403, the knowledge graph entity adjacent subgraph sample is input into an entity graph network embedding module, and the sample entity graph convolution vector is output based on the attention weight.
[0058] The input of the entity graph network embedding module is a knowledge graph entity adjacent subgraph sample, where the adjacent subgraph sample is an adjacent subgraph consisting of one-hop adjacent nodes corresponding to the knowledge graph entity positive sample or negative sample. The output of the entity graph network embedding module is a graph convolution vector corresponding to the knowledge graph entity adjacent subgraph sample.
[0059] Through the above steps S401-S403, the problem samples and the knowledge graph entity samples are input into the text embedding module to output sample entity mention vectors and sample problem vectors, the knowledge graph entity samples include knowledge graph entity positive samples and knowledge graph entity negative samples, so that the semantic information in the problem samples and the knowledge graph entity samples is mapped to corresponding vectors by the text embedding module, and the attention weight of the entity sample vector in the entity graph network embedding module is obtained according to the sample problem vector, that is, the importance of the entity relationship in the knowledge graph entity adjacent subgraph sample is adjusted according to the context information in the problem sample, and the knowledge graph entity adjacent subgraph sample is input into the entity graph network embedding module to output the sample entity graph convolution vector according to the attention weight, so that the sample entity graph convolution vector can more accurately characterize the entity relationship in the knowledge graph, and improve the linking accuracy of the entity linking model.
[0060] In some embodiments, the text embedding module comprises a BERT model. Figure 5 is a flowchart of obtaining sample problem vectors based on problem samples and knowledge graph entity samples according to some embodiments of the present application. As shown in Figure 5, the process includes the following steps S501-S502.
[0061] In step S501, the problem sample, the knowledge graph entity sample, the CLS flag bit and the SEP flag bit are concatenated in a predetermined format and input into the BERT model.
[0062] The BERT model is a context-based text embedding model, whose main structure is a Transformer. The CLS flag bit and the SEP flag bit are semantic identifiers of the contents input to the BERT model, the CLS flag bit is for indicating whether the two input sentences have a contextual relationship, while the SEP flag bit is for splitting the two sentences.
[0063] Specifically, the training data 4-tuple<q,m,e,Ge> For example, q and e in [CLS]q[SEP]e can be synthesized into [CLS]q[SEP]e, and then converted into a numerical value by a bag-of-words model to be input to the BERT model. That is, the BERT model converts each character in the text into a one-dimensional vector, i.e., a character vector, and the model input further includes a text vector and a position vector. The BERT model takes the sum of the character vector, the text vector, and the position vector as the model input. The model output is to input the vector representation after the full-text semantic information is correspondingly fused for each character. In addition, the BERT model can also load pre-trained Chinese model parameters to take advantage of existing more general semantic information.
[0064] In step S502, a sample problem vector is determined based on the first output vector of the BERT model corresponding to the CLS flag bit.
[0065] The output vector and the input vector of the BERT model correspond to each character. The CLS flag bit is taken as the model input, and the first output vector of the corresponding BERT model is the semantic representation vector of the text. The vector is then expressed as the vector representation V query The vector can be used to guide the entity graph network embedding module to learn the importance of adjacent nodes in the manner of an attention mechanism.
[0066] Through the above steps S501-S502, the problem sample, knowledge graph entity sample, CLS flag bit and SEP flag bit are concatenated in a predetermined format and input into the BERT model, so that the BERT model obtains semantic information of the problem sample and knowledge graph entity sample and maps them into corresponding vectors. A sample problem vector is determined based on the first output vector of the BERT model corresponding to the CLS flag bit, and the sample problem vector is used to adjust the attention weight of the entity relationship in the knowledge graph entity adjacent subgraph sample, thereby improving the training effect and linking accuracy of the entity linking model.
[0067] In some embodiments, the text embedding module further includes a multi-layer perceptron model. FIG. 6 is a flowchart for obtaining a sample entity mention vector based on a problem sample and a knowledge graph entity sample according to some embodiments of the present application. As shown in FIG. 6, the process includes the following steps S601 to S602:
[0068] In step S601, a second output vector of the BERT model corresponding to the start position of the entity mention sample and a third output vector of the BERT model corresponding to the end position of the entity mention sample are obtained.
[0069] The start position of the entity mention sample is the start position of the entity mention sample in the problem sample input to the BERT model, and the end position of the entity mention sample is the end position of the entity mention sample in the problem sample input to the BERT model. Because the input and output of the BERT model correspond to each character, the output vectors corresponding to the start and end positions are also in the same sequence position.
[0070] In step S602, the first output vector, the second output vector and the third output vector are concatenated and input into a multi-layer perceptron model to obtain a sample entity mention vector.
[0071] The first, second and third output vectors output from the BERT model are input into a multi-layer perceptron model to further process the vectors corresponding to the problem sample and the entity mention sample, and finally obtain a sample entity mention vector.
[0072] Through the above steps S601 to S602, the second output vector of the BERT model corresponding to the start position of the entity mention sample and the third output vector of the BERT model corresponding to the end position of the entity mention sample are obtained, and the vector corresponding to the start position and end position of the entity mention sample are selected for further processing. The first output vector, the second output vector and the third output vector are concatenated and input into a multi-layer perceptron model to obtain a sample entity mention vector, thereby improving the characterization accuracy of the semantic information of the sample entity mention vector.
[0073] In some embodiments, FIG. 7 is a flowchart of obtaining a sample entity graph convolution vector based on a knowledge graph entity adjacent subgraph sample according to some embodiments of the present application. As shown in FIG. 7, the process includes the following steps S701 to S702:
[0074] In step S701, initialize a knowledge graph entity adjacent subgraph sample according to the first output vector to obtain a corresponding entity sample vector.
[0075] In the model training process, the entities in the knowledge graph entity adjacent subgraph sample must first be converted into corresponding input vectors through vector initialization before they can be input into the entity graph network embedding module for training. The conversion method may be random initialization, or may be initialized using word vectors or sentence vectors after pre-training. In this embodiment, the first output vector may be used to initialize the entities, thereby adding semantic information of the entity mention sample to the vector initialization process.
[0076] In step S702, the entity sample vector is input into an entity graph network embedding module, which outputs a sample entity graph convolution vector based on the attention weights.
[0077] Through the above steps S701-S702, the knowledge graph entity adjacent subgraph sample is initialized based on the first output vector to obtain the corresponding entity sample vector, thereby adding semantic information of the entity mention sample to the vector initialization process; the entity sample vector is input into the entity graph network embedding module, and the sample entity graph convolution vector is output based on the attention weight to obtain a graph convolution vector in the same vector space as the vector representation of the entity mention sample, thereby improving the accuracy of the entity linking model.
[0078] In some embodiments, the present invention further relates to a process for constructing a BERT model. Before connecting the problem sample, the knowledge graph entity sample, the CLS flag bit and the SEP flag bit in a predetermined format and inputting them into the BERT model, the process for constructing a BERT model includes the following steps S11 to S12:
[0079] In step S11, a BERT initial model is pre-trained to obtain pre-trained model parameters.
[0080] The pre-training of the BERT model means training the initial BERT model with a large amount of Chinese training data, and obtaining the pre-trained model parameters when the pre-training effect meets the expected requirements. The pre-trained model parameters can also be obtained directly from the Internet or a pre-trained model library.
[0081] In step S12, a BERT model is constructed based on the pre-trained model parameters.
[0082] The pre-training model parameters are loaded into the BERT model of the above embodiment, which may be obtained directly based on the structure of the BERT initial model, or may be obtained by modifying the BERT initial model according to actual needs.
[0083] Through the above steps S11 to S12, the BERT initial model is pre-trained to obtain the pre-trained model parameters, thereby saving the time and computational resources required for subsequently training the entity linking model and improving the training efficiency; and the BERT model is constructed based on the pre-trained model parameters to improve the training effect of the BERT model.
[0084] The present embodiment will be described and explained below with reference to a preferred embodiment. FIG. 8 is a structural schematic diagram of an entity linking model according to the preferred embodiment. As shown in FIG. 8, the entity linking model according to the preferred embodiment includes a text embedding module 81 and an entity graph network embedding module 82, and the text embedding module 81 includes a BERT model 811 and a multi-layer perceptron (MLP) 812. The entity graph network embedding module 82 includes a plurality of CA-GCN modules. The input of the BERT model 811 is a problem sample q and a knowledge graph entity sample e, which are connected together with a CLS flag bit and a SEP flag bit in a predetermined format. The problem sample q includes N characters such as Tok1 to TokN, and the knowledge graph entity sample includes M characters such as Tok1 to TokM. The output of the BERT model 811 is a vector corresponding to each character in the input, and includes a C vector and an S vector corresponding to the CLS flag bit and the SEP flag bit, respectively, and vectors such as T1 to TN, T1′ to TM′ corresponding to characters. The entity graph network embedding module 82 takes as input the knowledge graph entity adjacency subgraph samples Ge and outputs the sample entity graph convolution vectors Ve.
[0085] 9 is a flowchart of a method for entity linking of knowledge graph according to a preferred embodiment of the present invention. As shown in FIG. 9, the process includes the following steps S901 to S914.
[0086] In step S901, collect user problems, obtain entity mentions in the user problems based on the traditional NER model, manually label the knowledge graph entities corresponding to the entity mentions, and compose the user problems, entity mentions, knowledge graph entities and knowledge graph entity adjacent subgraphs into quads as positive samples of training data; In step S902, randomly extract knowledge graph entities from the knowledge graph entities, filter the linking knowledge graph entities, and compose them into quaternions together with the user questions, entity mentions, and knowledge graph entity adjacent subgraphs as negative samples of the training data; In step S903, the user problem and the knowledge graph entity in the training data quad are spliced into [CLS]user problem [SEP] knowledge graph entity, and converted into a numerical value by the bag-of-words model as the input of the BERT model; and the pre-trained Chinese model parameters are loaded into the BERT model; In step S904, the vector output by Bert at the [CLS] position is concatenated with the output vector corresponding to the start position and end position of the entity mention, and inputted into the multi-layer perceptron to obtain a vector representation of the entity mention; In step S905, the vector output by Bert at the [CLS] position is used as the initialization vector of the entity in the knowledge graph entity adjacency subgraph, and the entity is initialized and input into the entity graph network embedding module; In step S906, the vector output by Bert at the [CLS] position is used as a vector representation of the user problem. In step S907, a cross-attention matrix is calculated by fusing the user problem and the knowledge graph information according to the vector representation of the user problem and the vector representation of the entity in the knowledge graph entity adjacency subgraph;
number
number
[0087] In step S910, after passing through the CA-GCN module of the Lth layer, the output of entity e at the Lth layer is its graph convolution vector; In step S911, a loss function is obtained based on the vector representation of the entity mention, the graph convolution vector, and the sample mark parameters, and an entity linking initial model is trained based on the loss function;
number
[0088] In step S912, if the value of the loss function satisfies the preset threshold range, stop the training, obtain an entity linking model, and store the model parameters; In step S913, a user input is received, and an entity mention in the user problem is obtained using a conventional NER model, and a set of candidate knowledge graph entities for the entity mention is obtained using a conventional BM25 algorithm, and adjacent subgraphs corresponding to the candidate entities are obtained and organized into 4-tuple sets as inputs for the entity linking model; In step S914, a vector representation of the entity mention and a set of candidate entity graph folded vector representations are obtained based on the output of the entity linking model, and the candidate entity having the highest cosine similarity with the vector representation of the entity mention is selected as the entity to be linked.
[0089] Through the above steps S901 to S914, the knowledge graph entities that are manually linked to the entity mention samples are used as training data positive samples, and the entity positive samples are removed, and then entities are randomly extracted as training data negative samples, thereby improving the effectiveness and accuracy of model training. The advantages of the BERT model and the multi-layer perceptron in extracting text semantic information and the advantages of the CA-GCN model in extracting semantic information in the entity adjacency graph are utilized to obtain sample entity mention vectors and sample entity graph convolution vectors, respectively, and their similarity is measured by a loss function, thereby improving the linking accuracy of knowledge graph entities based on user questions in question-and-answer scenes. The knowledge graph entities are linked using the sample question vectors. The importance of the entity relationships in the entity adjacent subgraph samples is adjusted to generate attention weight data, and a sample entity graph convolution vector is output based on the attention weight, thereby making the sample entity graph convolution vector more accurately characterize the entity relationships in the knowledge graph; the adjacent subgraph samples are initialized based on the vector output by Bert at the [CLS] position to obtain a graph convolution vector in the same vector space as the vector representation of the entity mention sample, thereby improving the accuracy of the entity linking model; and the entity linking model compares the vector similarity of each candidate knowledge graph entity with the entity mention to obtain the knowledge graph entity that is most similar to the entity mention as the linking target, thereby improving the entity linking effect in the question and answer scene.
[0090] It should be noted that the steps depicted in the above processes or flowcharts in the figures may be performed in a computer system as a set of computer-executable instructions, and that although the flowcharts show a logical order, in some cases the steps may be performed in an order different from that shown or described here.
[0091] In some embodiments, the present application further provides a knowledge graph entity linking device, which is for implementing the above embodiments and preferred embodiments, and has already been described, so detailed description will be omitted. The terms "module", "unit", "sub-unit", etc. used hereinafter can realize a combination of software and / or hardware of a given function. In some embodiments, FIG. 10 is a block diagram of a knowledge graph entity linking device according to the present embodiment, and as shown in FIG. 10, the device: a first acquiring module 1101 for acquiring training data positive samples based on a problem sample, an entity mention sample, a knowledge graph entity positive sample, and a knowledge graph entity adjacent subgraph sample, the entity mention sample being acquired based on the problem sample, the knowledge graph entity positive sample being acquired based on a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample being acquired based on an entity relationship in the knowledge graph of the knowledge graph entity positive sample; A second obtaining module 1102 for obtaining training data negative samples according to the problem samples, the entity mention samples, the knowledge graph entity negative samples and the corresponding knowledge graph entity adjacent subgraph samples, where the knowledge graph entity negative samples are obtained randomly according to entities that have no labeling relationship with the entity mention samples in the knowledge graph; a training module 1103 for training an entity linking initial model based on the training data positive samples and the training data negative samples to obtain an entity linking model; and a determination module 1104 for inputting the user problem, the entity mention, the candidate knowledge graph entity and the corresponding knowledge graph entity adjacency subgraph into a trained entity linking model to determine a target knowledge graph entity to link to the entity mention, wherein the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacency subgraph is obtained based on an entity relationship in the knowledge graph of the candidate knowledge graph entity.
[0092] According to the knowledge graph entity linking device of this embodiment, the first acquisition module 1101 acquires training data positive samples according to the question samples, the entity mention samples, the knowledge graph entity positive samples and the knowledge graph entity adjacent subgraph samples, and uses the knowledge graph entities linked to the entity mention samples by manual labeling as sample data for positive training, thereby ensuring the accuracy of the training data positive samples and the effectiveness of training; the second acquisition module 1102 acquires training data negative samples according to the question samples, the entity mention samples, the knowledge graph entity negative samples and the corresponding knowledge graph entity adjacent subgraph samples, that is, by removing the entity positive samples in the knowledge graph and then randomly extracting entities as the knowledge graph entity negative samples, thereby obtaining the training data negative samples. the training module 1103 trains an entity linking initial model based on the training data positive samples and the training data negative samples to obtain an entity linking model, thereby improving the accuracy of the training data of the entity linking model; the determination module 1104 inputs the user question, the entity mention, the candidate knowledge graph entity and the corresponding knowledge graph entity adjacent subgraph into the trained entity linking model to determine the target knowledge graph entity to be linked to the entity mention, and obtains the knowledge graph entity most similar to the entity mention as the linking target, thereby improving the linking effect of the entity linking model, thereby solving the problem in the related art that the effect of the entity consistency model is poor in question-and-answer scenes and the accuracy of entity linking is relatively low.
[0093] In some embodiments, the training module includes an input submodule, a determination submodule, and a training submodule, where the input submodule is for inputting training data positive samples and training data negative samples into the entity linking initial model and outputting a sample entity mention vector and a sample entity graph convolution vector, the determination submodule is for determining a loss function of the entity linking initial model based on the sample entity mention vector, the sample entity graph convolution vector, and the previously obtained sample mark parameters, and the training submodule is for training the entity linking initial model based on the loss function.
[0094] According to the knowledge graph entity linking device of this embodiment, the input sub-module inputs the training data positive samples and the training data negative samples into the entity linking initial model, and outputs a sample entity mention vector and a sample entity graph convolution vector, thereby converting the semantic information contained in the entity mention sample and the corresponding knowledge graph entity sample into a corresponding vector representation; the determination sub-module determines a loss function of the entity linking initial model based on the sample entity mention vector, the sample entity graph convolution vector, and the previously obtained sample mark parameters, thereby measuring the similarity between the sample entity mention vector and the sample entity graph convolution vector by the loss function; the training sub-module trains the entity linking initial model based on the loss function, thereby obtaining model parameters corresponding to the minimum value of the loss function, and obtaining a trained entity linking model, thereby improving the linking accuracy of knowledge graph entities based on user questions in question-and-answer scenes, and improving the answering accuracy based on user questions.
[0095] In some embodiments, the entity linking initial model comprises a text embedding module and an entity graph network embedding module, and the input sub-module includes a first input unit, an acquisition unit and a second input unit, where the first input unit is for inputting problem samples and knowledge graph entity samples into the text embedding module to output a sample entity mention vector and a sample problem vector, where the knowledge graph entity samples include knowledge graph entity positive samples and knowledge graph entity negative samples, the acquisition unit is for acquiring attention weights of the entity sample vectors in the entity graph network embedding module based on the sample problem vector, and the second input unit is for inputting knowledge graph entity adjacent sub-graph samples into the entity graph network embedding module to output a sample entity graph convolution vector based on the attention weights.
[0096] According to the knowledge graph entity linking device of this embodiment, the first input unit inputs problem samples and knowledge graph entity samples into the text embedding module to output sample entity mention vectors and sample problem vectors, the knowledge graph entity samples include knowledge graph entity positive samples and knowledge graph entity negative samples, so that the semantic information in the problem samples and knowledge graph entity samples is mapped to corresponding vectors by the text embedding module, the acquisition unit acquires the attention weight of the entity sample vector in the entity graph network embedding module based on the sample problem vector, that is, adjusts the importance of the entity relationship in the knowledge graph entity adjacent subgraph sample according to the context information in the problem sample, and the second input unit inputs the knowledge graph entity adjacent subgraph samples into the entity graph network embedding module to output the sample entity graph convolution vector based on the attention weight, so that the sample entity graph convolution vector can more accurately characterize the entity relationship in the knowledge graph, thereby improving the linking accuracy of the entity linking model.
[0097] In some embodiments, the text embedding module comprises a BERT model, and the first input unit includes a first input sub-unit and a determination sub-unit, where the first input sub-unit is for concatenating the problem sample, the knowledge graph entity sample, the CLS flag bits and the SEP flag bits in a predetermined format and inputting them into the BERT model, and the determination sub-unit is for determining a sample problem vector based on a first output vector of the BERT model corresponding to the CLS flag bits.
[0098] According to the knowledge graph entity linking device of this embodiment, the first input sub-unit connects the problem sample, the knowledge graph entity sample, the CLS flag bit and the SEP flag bit in a predetermined format and inputs them into the BERT model, so as to obtain the semantic information of the problem sample and the knowledge graph entity sample by the BERT model and map them into corresponding vectors; the determination sub-unit determines a sample problem vector based on the first output vector of the BERT model corresponding to the CLS flag bit, and uses the sample problem vector to adjust the attention weight of the entity relationship in the knowledge graph entity adjacent subgraph sample, thereby improving the training effect and linking accuracy of the entity linking model.
[0099] In some embodiments, the text embedding module further comprises a multi-layer perceptron model, and the first input unit further includes an acquisition sub-unit and a second input sub-unit, where the acquisition sub-unit is for obtaining a second output vector of the BERT model corresponding to a start position of the entity mention sample and a third output vector of the BERT model corresponding to an end position of the entity mention sample, and the second input sub-unit is for concatenating the first output vector, the second output vector and the third output vector and inputting them into the multi-layer perceptron model to obtain a sample entity mention vector.
[0100] According to the knowledge graph entity linking device of this embodiment, the acquisition subunit obtains the second output vector of the BERT model corresponding to the start position of the entity mention sample and the third output vector of the BERT model corresponding to the end position of the entity mention sample, thereby selecting a vector corresponding to the start position and end position of the entity mention sample for further processing; the second input subunit concatenates the first output vector, the second output vector and the third output vector, and inputs them into the multi-layer perceptron model to obtain a sample entity mention vector, thereby improving the characterization accuracy of the semantic information of the sample entity mention vector.
[0101] In some embodiments, the second input unit includes an initialization subunit and a third input subunit, where the initialization subunit is for initializing a knowledge graph entity adjacency subgraph sample based on the first output vector to obtain a corresponding entity sample vector, and the third input subunit is for inputting the entity sample vector into the entity graph network embedding module and outputting a sample entity graph convolution vector based on the attention weight.
[0102] According to the knowledge graph entity linking device of this embodiment, the initialization subunit initializes the knowledge graph entity adjacent subgraph sample based on the first output vector to obtain a corresponding entity sample vector, thereby adding semantic information of the entity mention sample to the vector initialization process; the third input subunit inputs the entity sample vector to the entity graph network embedding module, and outputs the sample entity graph convolution vector based on the attention weight, thereby obtaining a graph convolution vector in the same vector space as the vector representation of the entity mention sample, thereby improving the accuracy of the entity linking model.
[0103] In some embodiments, the knowledge graph entity linking apparatus further includes a third acquisition module and a construction module, where the third acquisition module is for pre-training a BERT initial model to obtain pre-trained model parameters, and the construction module is for constructing a BERT model based on the pre-trained model parameters.
[0104] According to the knowledge graph entity linking device of this embodiment, the third acquisition module pre-trains the BERT initial model to obtain the pre-trained model parameters, thereby saving the time and computing resources required for subsequently training the entity linking model and improving the training efficiency; and the construction module constructs a BERT model based on the pre-trained model parameters, thereby improving the training effect of the BERT model.
[0105] In some embodiments, the present application further provides a computing device comprising a memory and a processor, wherein a computer program is stored in the memory, and wherein the processor is configured to perform the knowledge graph entity linking method according to the above embodiments by executing the computer program.
[0106] Optionally, the computing device may further comprise a transmission device and an input / output device, the transmission device being connected to the processor and the input / output device being connected to the processor.
[0107] In addition, in combination with the knowledge graph entity linking method according to the above embodiment, the present embodiment can further provide a storage medium for executing the method, wherein a program is stored in the storage medium, and when the program is executed by a processor, the knowledge graph entity linking method according to any one of the above embodiments is executed.
[0108] For specific examples of this embodiment, reference may be made to the examples described in the above embodiments and alternative embodiments, and detailed description will be omitted in this embodiment.
[0109] It should be understood that the specific embodiments described herein are merely for interpreting this application, and are not intended to limit it. Based on the embodiments of this application, all other embodiments obtained by a person skilled in the art without requiring creative efforts all belong to the scope of protection of this application.
[0110] Obviously, the drawings are merely a part of examples or embodiments of the present application, and a person skilled in the art can apply the present application to other similar situations based on these drawings without creative effort. Also, as can be understood, the work carried out in this development process may be complex and take a long time, but some of the changes in design, manufacturing, production, etc. made by a person skilled in the art based on the technical contents disclosed in this application are merely ordinary technical means, and should not be considered as a deficiency in the contents disclosed in this application.
[0111] The word "embodiment" in this application means that a specific feature, structure or characteristic described with reference to the embodiment may be included in at least one embodiment of this application. The appearance of the combination in each place in the specification does not necessarily mean the same embodiment, nor does it mean that the embodiment is mutually exclusive with other embodiments, independent or alternative. It is understood by those skilled in the art, either explicitly or implicitly, that the embodiment described in this application can be combined with other embodiments, unless there is a conflict.
[0112] The above-mentioned examples are only representative of some embodiments of the present application, and although the description is more specific and detailed, it should not be understood as limiting the scope of protection of the patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present application, all of which are within the scope of protection of the present application. Therefore, the scope of protection of the present application should be governed by the appended claims.
Claims
1. A method for entity linking of a knowledge graph, comprising the following steps 1 to 4, which are executed by a computer: In the step 1, the computer obtains a training data positive sample based on a problem sample, an entity mention sample, a knowledge graph entity positive sample, and a knowledge graph entity adjacent subgraph sample, the entity mention sample being obtained based on the problem sample, the knowledge graph entity positive sample being obtained based on a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample being obtained based on an entity relationship in the knowledge graph of the knowledge graph entity positive sample; In the step 2, the computer obtains training data negative samples according to the problem sample, the entity mention sample, the knowledge graph entity negative samples and the corresponding knowledge graph entity adjacent subgraph samples, and the knowledge graph entity negative samples are randomly obtained based on entities that have no labeling relationship with the entity mention sample in the knowledge graph; In step 3, the computer trains an entity linking initial model based on the training data positive samples and the training data negative samples to obtain an entity linking model; In step 4, the computer inputs the user problem, the entity mention, the candidate knowledge graph entity, and the corresponding knowledge graph entity adjacency subgraph into the trained entity linking model to determine a target knowledge graph entity to be linked to the entity mention, where the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacency subgraph is obtained based on an entity relationship in the knowledge graph of the candidate knowledge graph entity. A method for entity linking of a knowledge graph, comprising:
2. The computer training an entity linking initial model based on the training data positive samples and the training data negative samples comprises: The computer inputs the training data positive samples and the training data negative samples into the entity linking initial model to output a sample entity mention vector and a sample entity graph convolution vector; The computer determines a loss function of the entity linking initial model based on the sample entity mention vector, the sample entity graph convolution vector, and a sample mark parameter previously obtained; and training the entity linking initial model based on the loss function. The method for entity linking of a knowledge graph according to claim 1 .
3. the entity linking initial model includes a text embedding module and an entity graph network embedding module; The computer inputs the training data positive samples and the training data negative samples into the entity linking initial model to output a sample entity mention vector and a sample entity graph convolution vector. the computer inputs the problem sample and the knowledge graph entity sample into the text embedding module to output the sample entity mention vector and the sample problem vector, the knowledge graph entity sample including the knowledge graph entity positive sample and the knowledge graph entity negative sample; The computer obtains attention weights of entity sample vectors in the entity graph network embedding module based on the sample problem vector; and the computer inputs the knowledge graph entity adjacency subgraph sample to the entity graph network embedding module and outputs the sample entity graph convolution vector based on the attention weights. The method for entity linking of a knowledge graph according to claim 2.
4. the text embedding module includes a BERT model; The computer inputs the problem sample and the knowledge graph entity sample into the text embedding module to output the sample entity mention vector and the sample problem vector, the computer concatenates the problem sample, the knowledge graph entity sample, the CLS flag bits, and the SEP flag bits in a predetermined format and inputs them into the BERT model; determining the sample problem vector based on a first output vector of the BERT model corresponding to the CLS flag bit. The method for entity linking of a knowledge graph according to claim 3.
5. the text embedding module further comprises a multi-layer perceptron model; The computer inputs the problem sample and the knowledge graph entity sample into the text embedding module to output the sample entity mention vector and the sample problem vector, The computer obtains a second output vector of the BERT model corresponding to a start position of the entity mention sample and a third output vector of the BERT model corresponding to an end position of the entity mention sample; and the computer further comprises concatenating the first output vector, the second output vector, and the third output vector and inputting the concatenated first output vector, the second output vector, and the third output vector into the multi-layer perceptron model to obtain the sample entity mention vector. The method for entity linking of a knowledge graph according to claim 4.
6. The computer inputs the knowledge graph entity adjacency subgraph sample to the entity graph network embedding module and outputs the sample entity graph convolution vector based on the attention weights, the computer initializing the knowledge graph entity adjacency subgraph sample based on the first output vector to obtain a corresponding entity sample vector; and the computer inputting the entity sample vector to the entity graph network embedding module and outputting the sample entity graph convolution vector based on the attention weights. The method for entity linking of a knowledge graph according to claim 4.
7. Before the computer links the problem sample, the knowledge graph entity sample, the CLS flag bit and the SEP flag bit in the predetermined format and inputs them into the BERT model, the knowledge graph entity linking method includes: The computer pre-trains a BERT initial model to obtain pre-trained model parameters; and constructing the BERT model based on the pre-training model parameters. The method for entity linking of a knowledge graph according to claim 4.
8. A knowledge graph entity linking device, comprising: a first acquisition module, a second acquisition module, a training module, and a decision module; The first acquisition module is used for acquiring training data positive samples according to a problem sample, an entity mention sample, a knowledge graph entity positive sample and a knowledge graph entity adjacent subgraph sample, the entity mention sample being acquired according to the problem sample, the knowledge graph entity positive sample being acquired according to a labeling entity in the knowledge graph of the entity mention sample, and the knowledge graph entity adjacent subgraph sample being acquired according to an entity relationship in the knowledge graph of the knowledge graph entity positive sample; The second obtaining module is used for obtaining training data negative samples according to the problem sample, the entity mention sample, the knowledge graph entity negative sample, and the corresponding knowledge graph entity adjacent subgraph sample, and the knowledge graph entity negative sample is obtained randomly according to an entity that has no labeling relationship with the entity mention sample in the knowledge graph; The training module is used for training an entity linking initial model according to the training data positive samples and the training data negative samples to obtain an entity linking model; The determination module is used for inputting the user problem, the entity mention, the candidate knowledge graph entity, and the corresponding knowledge graph entity adjacency subgraph into the trained entity linking model to determine a target knowledge graph entity to be linked to the entity mention, where the entity mention is obtained based on the user problem, the candidate knowledge graph entity is obtained based on the entity mention, and the knowledge graph entity adjacency subgraph is obtained based on an entity relationship in the knowledge graph of the candidate knowledge graph entity.
2. A knowledge graph entity linking device comprising:
9. A computing device comprising a memory and a processor, A computer program is stored in the memory, and the processor is configured to execute the method for entity linking of knowledge graphs according to any one of claims 1 to 7 by executing the computer program. A computer apparatus comprising:
10. A readable storage medium on which a program is stored, When the program is executed by a processor, the program executes the steps of the method for entity linking of a knowledge graph according to any one of claims 1 to 7. A readable storage medium.
Citation Information
Patent Citations
Entity linking method and device, equipment and storage medium
CN114841164A
Method, device, electronic device, and storage medium for entity linking
JP2022040026A