Joint entity and relation extraction method and system based on deep learning and medium
Through the joint entity and relationship extraction method based on deep learning, using non-autoregressive decoder and set prediction loss function, the error propagation and order sensitivity problems of relationship extraction in the prior art are solved, and the accuracy and efficiency of relationship extraction are improved. Enhanced model generalization capabilities.
Patent Information
- Application Number
- CN202411517586.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-01-14
AI Technical Summary
The existing relationship extraction technology has problems such as error propagation, loss of information interdependence, sequence sensitivity and insufficient generalization capabilities, resulting in inaccuracy and inefficiency.
Using a joint entity and relationship extraction method based on deep learning, using the BERT model as a sentence encoder, treating joint entity and relationship extraction as a set prediction problem, generating a predicted triple set through a non-autoregressive decoder, and predicting losses through a set The function is trained in model and uses the Hungarian algorithm to find the optimal matching relationship.
It improves the accuracy and generalization ability of relationship extraction, reduces error propagation, enhances the ability to deal with triple disorder, improves prediction speed and efficiency, and reduces the workload of manually designing complex annotation solutions.
Smart Images

Figure CN119311852A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and more specifically, to a method, system and medium for extracting joint entities and relations based on deep learning. Background Art
[0002] In the field of natural language processing, relation extraction is a basic and key task, which aims to mine factual knowledge between entities from free text. Traditionally, the relation extraction task is divided into two steps: first identifying entities and then classifying the relations between these entities. When the entities have been labeled, the task is simplified to a relation classification task.
[0003] At present, the existing relationship extraction technologies mainly adopt pipeline methods, table filling methods, annotation methods or sequence-to-sequence methods. The pipeline method first identifies entities and then classifies the relationships between entities; this method has the problem of error propagation, that is, the accuracy of the second step depends on the results of the first step. The table filling method uses shared parameters to represent entities and relationships, but still extracts entities and relationships separately, which may lead to the loss of information interdependence. The annotation method regards relationship extraction as a sequence annotation problem, which requires the design of complex annotation schemes and a large amount of manual work. The sequence-to-sequence method (Seq2seq) directly generates relationship triplets by using the Seq2seq model, which is more flexible in operation, but has limited ability to handle the disorder of triples.
[0004] As mentioned above, traditional relation extraction techniques usually require the order of entities and relations to be determined in advance, which makes the learning model sensitive to the order of triples and affects the generalization ability of the model. In addition, the dependency of steps leads to error propagation, which reduces the accuracy and efficiency of relation extraction.
[0005] In view of this, it is indeed necessary to provide a technical solution to the above problems. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a method, system and medium for extracting joint entities and relationships based on deep learning in response to the above-mentioned defects of the prior art.
[0007] The technical solution adopted by the present invention to solve its technical problem is:
[0008] A joint entity and relationship extraction method based on deep learning is constructed, and the steps of the method include:
[0009] S1. Use the BERT model as a sentence encoder to obtain the context-aware embedding vector of each token in the natural sentence X input by the user.
[0010] S2, treating joint entity and relation extraction as a set prediction problem, using a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples;
[0011] S3. Setting a set prediction loss function to perform model training, and generating an optimal matching relationship between the predicted triple set and the true triple set according to the set prediction loss function.
[0012] As an improvement of the joint entity and relationship extraction method, in step S2, by setting the size of the prediction triple set to m, the non-autoregressive decoder generates a fixed size of m prediction triplets according to the received embedding vector to form a prediction triple set.
[0013] As an improvement of the joint entity and relation extraction method, m is a positive number and is larger than the size of the true triple set.
[0014] As an improvement of the joint entity and relationship extraction method, in step S2, m learnable embedding vectors are initialized as triple queries through the non-autoregressive decoder, and the m triple queries are converted into m output embedding vectors Hd. The m output embedding vectors Hd are independently decoded into relationship types and entities through a feedforward network, and finally m predicted triplets are generated.
[0015] As an improvement of the joint entity and relationship extraction method, a softmax function is used to obtain the predicted relationship type, and the probability distribution of the relationship type is obtained by calculating the formula p_r=softmax(W_r*h_d), where W_r is the weight matrix of the relationship type.
[0016] As an improvement of the joint entity and relationship extraction method, the predicted entity includes subject and object, which is obtained by decoding four 1-class classifiers of the predicted start and end indexes. The specific calculation formula is:
[0017] p_s-start=softmax(v_T1*tanh(W_1*h_d+W_2*H_e));
[0018] p_s-end=softmax(v_T2*tanh(W_3*h_d+W_4*H_e));
[0019] p_o-start=softmax(v_T3*tanh(W_5*h_d+W_6*H_e));
[0020] p_o-end=softmax(v_T4*tanh(W_7*h_d+W_8*H_e));
[0021] Among them, W_i and vi_i are learnable parameters, H_e is the output of the BERT model, W_i includes v_T1, v_T2, v_T3, v_T4; vi_i includes W_1, W_2, W_3, W_4, W_5, W_6, W_7, W_8.
[0022] As an improvement of the joint entity and relationship extraction method, in step S3, the set prediction loss function uses the Hungarian algorithm to find the element arrangement with the lowest cost, and then trains the model by calculating the loss function of each matching pair.
[0023] As an improvement of the joint entity and relation extraction method, the non-autoregressive decoder includes multiple identical Transformer layers, each of which contains a multi-head self-attention mechanism and a multi-head cross-attention mechanism for modeling the relationship between triplets and the information fusion of a given sentence.
[0024] An entity relationship joint extraction system is built based on a set prediction network model, including:
[0025] The text encoding module uses the BERT model as a sentence encoder to segment the natural sentence X input by the user into tokens through byte pair encoding and feed it into the BERT model. The BERT model outputs a context-aware embedding vector for each token.
[0026] The decoding module treats joint entity and relation extraction as a set prediction problem and uses a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples;
[0027] The matching module sets a set prediction loss function to perform model training, and generates an optimal matching relationship between the predicted triple set and the real triple set according to the set prediction loss function.
[0028] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned deep learning-based joint entity and relationship extraction method.
[0029] The beneficial effects of the present invention are as follows: the present invention adopts a non-autoregressive decoder and regards the joint entity and relationship extraction task as a set prediction problem. Therefore, it is no longer necessary to predict the order of triples, thereby significantly improving the accuracy, and also improving the ability to handle the disorder of triples and enhancing the generalization ability of the model; at the same time, the non-autoregressive decoder can decode in parallel, greatly improving the prediction speed, while reducing the workload of manually designing complex labeling schemes, and improving the efficiency and accuracy of the relationship extraction task.
[0030] In addition, since the non-autoregressive decoder does not rely on the output of previous predictions, it reduces the error propagation caused by step dependency; it can automatically extract entities and relations from natural language sentences, reducing the workload of manually designing complex labeling schemes. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work:
[0032] Figure 1 is a flowchart of a method for extracting joint entities and relations based on deep learning according to a preferred embodiment of the present invention;
[0033] Figure 2 It is a model architecture diagram of a joint entity and relationship extraction method based on deep learning according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be described clearly and completely in combination with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are partial embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0035] It should be noted that in the field of graph neural networks, Transformer usually refers to a neural network architecture based on the self-attention mechanism, which is mainly used to process sequence data, such as text data in natural language processing. It consists of multiple layers and components, among which the core are the self-attention mechanism and feedforward neural network.
[0036] The self-attention mechanism allows the model to focus on the information at different positions in the sequence and calculate the correlation between them when processing sequence data. This mechanism enables Transformer to capture long-distance dependencies, that is, the information association between positions far apart in the sequence.
[0037] The feedforward neural network is used to further process and transform the output of the self-attention mechanism to extract higher-level feature representations.
[0038] The working principle of Transformer is: first, the input sequence is converted into a vector representation through an embedding layer; then, through the stacking of multiple self-attention mechanisms and feedforward neural networks, the input sequence is deeply extracted and transformed; finally, the corresponding results are output according to the requirements of the specific task.
[0039] A method for extracting joint entities and relations based on deep learning in a preferred embodiment of the present invention comprises the following steps:
[0040] S1. Use the BERT model as a sentence encoder to obtain the context-aware embedding vector of each token in the natural sentence X input by the user.
[0041] S2, treating joint entity and relation extraction as a set prediction problem, using a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples;
[0042] S3. Setting a set prediction loss function for model training, and generating an optimal matching relationship between the predicted triple set and the true triple set according to the set prediction loss function.
[0043] The present invention adopts a non-autoregressive decoder, and regards the joint entity and relationship extraction task as a set prediction problem. Therefore, it is no longer necessary to predict the order of triples, thereby significantly improving the accuracy, and also significantly improving the ability to handle triple disorder, and enhancing the generalization ability of the model; since the non-autoregressive decoder does not rely on the output of the previous prediction, by considering the triple extraction as a set prediction problem, it can still maintain a high accuracy rate under disordered triple input, avoiding the error propagation caused by order dependence; automatically extracting entities and relationships from natural language sentences, reducing the workload of manually designing complex annotation schemes. At the same time, the non-autoregressive decoder can decode in parallel, greatly improving the prediction speed, while reducing the workload of manually designing complex annotation schemes, improving the efficiency and accuracy of the relationship extraction task.
[0044] It should be noted that the BERT model is a pre-trained language model based on the Transformer architecture, which can be translated into Chinese as "transformer-based bidirectional encoding representation". The main feature of the BERT model is bidirectional encoding, which means that it can simultaneously use contextual information to deeply understand the meaning of words, which is different from traditional unidirectional language models that can only understand words from one direction.
[0045] The working principle of the BERT model mainly includes three steps: pre-training, fine-tuning, and application. In the pre-training stage, the BERT model is trained through large-scale unlabeled text data to learn to predict masked or randomly hidden words from the input text, so as to learn the contextual information and semantic representation of words. Then, after pre-training, the BERT model can be adapted to different downstream tasks such as text classification, named entity recognition, sentence relationship discrimination, etc. by fine-tuning on specific tasks. In the fine-tuning stage, the model will be supervised for the labeled data of the specific task to optimize the model parameters.
[0046] The true triple set refers to the set of triples consisting of subjects, relations, and objects that actually exist in a given text in natural language processing tasks. These triple sets are used for model training and evaluation to ensure that the model can accurately extract entities and relations in the text. The predicted triple set is automatically generated by the model through a non-autoregressive decoder, while the true triple set is used as a reference standard to evaluate the accuracy of the prediction results.
[0047] In some embodiments of the present application, in step S2, by setting the size of the prediction triple set to m, the non-autoregressive decoder generates a fixed size of m prediction triplets according to the received embedding vector to form a prediction triple set. Specifically, before decoding, the non-autoregressive decoder needs to know the size of the target set, that is, the number of triplets in the prediction triple set, and by allowing the non-autoregressive decoder to generate a fixed size of prediction triples, the problem that the previous decoder needs to learn the extraction order of multiple triplets is eliminated.
[0048] In some embodiments of the present application, m is a positive number and is greater than the size of the real triple set. The value of m will depend on the specific data and requirements in the actual application scenario; the value of m can be set to 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 or 15; for example, if the size of the real triple set is usually 5, then m can be set to 6, 7 or higher to ensure sufficient prediction triple space.
[0049] In some embodiments of the present application, in step S2, m learnable embedding vectors are initialized as triple queries through a non-autoregressive decoder, the m triple queries are converted into m output embedding vectors Hd, and the m output embedding vectors Hd are independently decoded into relationship types and entities through a feedforward network, and finally m predicted triplets are generated.
[0050] Specifically, by setting m to be larger than the number of true triplets, the model is forced to learn to generate more triple predictions, which helps to enhance the model's ability to generalize input data and enable it to better handle input texts of different sizes and complexities. In actual situations, the number of true triplets may vary from text to text. Setting m to be larger than the number of true triplets ensures that the model has enough capacity to cover all possible triplets and reduce the occurrence of missed detections. By generating a fixed-size set of triplets, the model training process is simplified and there is no need to deal with complex dynamic output length issues. This helps to improve the training efficiency and stability of the model.
[0051] Instead of copying the tokens from the encoder side, the non-autoregressive decoder is initialized with m learnable embedding vectors, i.e., triplet queries. These queries are shared, meaning that all sentences use the same set of queries to predict triples.
[0052] In some embodiments of the present application, a softmax function is used to obtain the predicted relationship type, and the probability distribution of the relationship type is obtained by calculating the formula p_r=softmax(W_r*h_d), where W_r is the weight matrix of the relationship type.
[0053] Specifically, the softmax function is used to calculate the probability distribution of each relation type. It is calculated by the formula pr = softmax (Wrxhd). The softmax function maps the output embedding vector hd to the probability distribution of the relation type, ensuring that the sum of the probabilities of all relation types is 1.
[0054] The use of the softmax function allows the model to output a probability distribution rather than a definite relationship type when predicting the relationship type. This enhances the robustness of the model when dealing with uncertainty. The model can choose among multiple relationship types and sort different relationship types according to the probability distribution for easy subsequent processing and analysis. The softmax function can handle multi-classification problems, enabling the model to predict multiple relationship types at the same time, improving the flexibility and accuracy of the model.
[0055] It should be noted that pr is an output vector that represents the probability distribution of belonging to each category given a context or input. Each element of pr is a number between 0 and 1, and the sum of all elements is equal to 1. This is ensured by the softmax function, which converts the raw scores (or logits) into probabilities.
[0056] Softmax is a function that converts a vector (in this case Wr, hd) into a probability distribution. The output of the softmax function is a vector of the same dimension as the input vector, whose elements are the result of normalizing the input vector elements after exponential transformation.
[0057] Wr is a weight matrix used to map the hidden layer representation hd to the score (or logits) space corresponding to the number of categories; the dimension of Wr is usually |R|×|hd|, where |R| is the number of categories and |hd| is the dimension of the hidden layer representation hd; this matrix is learned during training to minimize the prediction error of the model on the training set.
[0058] hd This is the output vector of the hidden layer, which represents the high-level feature representation of the input data (such as text, image, etc.) after being processed by a series of neural network layers. The dimension of hd is usually fixed and matches the second dimension of the weight matrix Wr.
[0059] * denotes matrix multiplication. In this context, Wr*hd denotes the multiplication of the weight matrix Wr with the hidden layer representation hd, and the result is a score vector corresponding to the number of classes.
[0060] In some embodiments of the present application, the predicted entities include a subject and an object, which are obtained by decoding four 1-class classifiers that predict the start and end indexes.
[0061] Specifically, the predicted entity is obtained by decoding four 1-class classifiers, which are used to predict the start and end positions of the subject and object respectively. The working principle of the classifier is based on the softmax function and tanh activation function, and prediction is made based on the given BERT model output. By calculating the probability distribution of each position, the specific position of the entity in the sentence can be determined. The specific calculation formula is:
[0062] Probability distribution of the subject's starting position: ps-start = softmax(vT1*tanh(W1*hd+W2*He));
[0063] Probability distribution of the subject’s end position: ps-end = softmax(vT2*tanh(W3*hd+W4*He));
[0064] Probability distribution of the object start position: po-start = softmax(vT3*tanh(W5*hd+W6*He));
[0065] Probability distribution of the object end position: po-end = softmax(vT4*tanh(W7*hd+W8*He));
[0066] Among them, Wi and vi are learnable parameters, He is the output of the BERT model, and hd is the output embedding vector of the decoder.
[0067] This decoding method can accurately predict the position and scope of entities in sentences, thereby achieving joint extraction of entities and relations. Since four independent classifiers are used for decoding, they can be processed in parallel, which improves the prediction speed; the classifier is predicted based on context-aware embedding vectors, which can capture the semantic information in the sentence and improve the accuracy of the prediction. In this way, triples containing subjects, relations, and objects can be generated, providing useful information for natural language processing tasks.
[0068] It should be noted that ps-start, ps-end, po-start, po-end are output vectors, which represent the probability distribution of the subject start position, subject end position, object start position and object end position respectively. The elements of each vector are between 0 and 1, and the sum of all elements is equal to 1.
[0069] vT1,vT2,vT3,vT4 are transposed vectors, usually used to map the output of the tanh activation function to a scalar value for subsequent application of the softmax function. Their dimensions usually match the output dimensions of the tanh activation function.
[0070] Tanh is an activation function used to introduce nonlinearity. It accepts a vector or matrix as input and outputs a vector or matrix of the same dimension whose elements are the hyperbolic tangent values of the input elements.
[0071] W1, W2, W3, W4, W5, W6, W7, W8 are weight matrices used to map the hidden layer representation (hd) and entity embedding (He) to different feature spaces. The dimensions of each weight matrix are determined according to the requirements of its input and output. For example, W1 and W2 may be used to map hd and He to a feature space related to the starting position of the subject, while W3 and W4 may be used to map to a feature space related to the ending position of the subject.
[0072] hd is the output vector of the hidden layer, which represents the high-level feature representation of the input data (such as text, image, etc.) after being processed by a series of neural network layers. Its dimension is usually fixed and matches the second dimension of multiple weight matrices.
[0073] He is the embedding vector of the entity, which represents the semantic information of a specific entity (such as subject, object, etc.). Its dimension is usually fixed as well, and is combined with the third dimension of multiple weight matrices (if any) or with hd by other means (such as concatenation, summation, etc.).
[0074] In some embodiments of the present application, the ensemble prediction loss function uses the Hungarian algorithm to find the element arrangement with the lowest cost, and then trains the model by calculating the loss function of each matching pair.
[0075] Specifically, in joint entity and relation extraction, the Hungarian algorithm is used to find augmenting paths between the predicted set of triples and the true set of triples to generate an optimal match. By calculating the loss function for each matching pair, the Hungarian algorithm can find a minimum cost element arrangement between the two sets, that is, the optimal match, which helps to improve the model's predictive ability and enable the model to predict entities and relations more accurately. The optimal match found by the Hungarian algorithm can accurately evaluate the performance of the model in predicting real triples. During the training process, the loss function can be optimized using the Hungarian algorithm. By continuously iterating and adjusting the model parameters, the model can gradually learn how to extract entities and relations more accurately.
[0076] Set the set prediction loss function for model training. The set prediction loss function is used to measure the difference between the predicted triple set and the true triple set. The prediction ability of the model is improved by optimizing the loss function.
[0077] In some embodiments of the present application, the non-autoregressive decoder includes multiple identical Transformer layers, each layer containing a multi-head self-attention mechanism and a multi-head cross-attention mechanism for modeling the relationship between triplets and the information fusion of a given sentence.
[0078] Specifically, the Transformer layer is used to model the relationship between triplets and the information fusion of a given sentence; it is able to generate all predictions in parallel instead of one by one; through the multi-head self-attention mechanism, the model is able to process the information of the entire output sequence, further improving performance.
[0079] Due to the non-autoregressive approach, the multi-head self-attention mechanism in the decoder does not use causal masks, which allows the model to access information of the entire output sequence when processing.
[0080] An entity relationship joint extraction system is built based on a set prediction network model, including:
[0081] The text encoding module uses the BERT model as a sentence encoder to segment the natural sentence X input by the user into tokens through byte pair encoding and feed it into the BERT model. The BERT model outputs a context-aware embedding vector for each token.
[0082] The decoding module treats joint entity and relation extraction as a set prediction problem and uses a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples;
[0083] The matching module sets the set prediction loss function for model training and generates the optimal matching relationship between the predicted triple set and the real triple set according to the set prediction loss function.
[0084] Specifically, the text encoding module uses the BERT model as a sentence encoder. It segments the input natural language sentence into tokens and outputs a context-aware embedding vector for each token. The decoding module receives these embedding vectors through a non-autoregressive decoder and initializes a corresponding number (m) of learnable embedding vectors as triple queries. These queries are used to generate predicted triples, and all sentences share the same triple query embedding. The non-autoregressive decoder converts the m triple queries into m fixed-size output embedding vectors. These vectors are independently decoded into relation types and entities (including subjects and objects) through a feedforward network, and finally generate m predicted triples to form a predicted triple set.
[0085] The Transformer layer in the non-autoregressive decoder contains a multi-head self-attention mechanism and a multi-head cross-attention mechanism, which are used to model the relationship between triplets and the information fusion of a given sentence, thereby improving the efficiency of information processing. This method can be applied to entity and relationship extraction in various natural language processing tasks, with wide flexibility and scalability. It reduces the workload of manually designing complex annotation schemes, making relationship extraction tasks more efficient and accurate.
[0086] The set prediction network model is Set Prediction Network, namely SPN model.
[0087] In some other embodiments, the conditional probability P(Y|X; θ) of the target triple set Y={(s1, r1, o1), ..., (sn, rn, on)} is predicted based on the input natural language sentence X; specifically:
[0088] Input: natural language sentence X;
[0089] Output: target triple set Y, where each triple (si, ri, oi) represents a subject si, a relation ri, and an object oi;
[0090] Goal: Predict the conditional probability of Y given X, P(Y|X; θ), where θ represents the parameters of the model.
[0091] Among them, the Set Prediction Network (SPN) is used as the core model. SPN is a neural network architecture that can process variable-length output sets and is suitable for predicting triple sets in this task. Using SPN to parameterize the conditional probability P(Y|X; θ) means that the model will learn a function that can output the probability distribution of the triple set Y based on the input sentence X and the model parameter θ. During the training process, the model will adjust its parameter θ to maximize the probability of correctly predicting the triple set Y given the input sentence X. By predicting triple sets, structured information can be automatically extracted from the text, providing strong support for downstream tasks (such as question answering, text understanding, intelligent recommendation, etc.).
[0092] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned deep learning-based joint entity and relationship extraction method.
[0093] Computer programs are stored on computer-readable storage media, such as hard disks, USB flash drives, and optical disks. When a computer needs to execute a program, it reads the program from the storage medium, loads it into memory, and then executes the instructions of the program one by one. By executing a computer program, a computer can complete specific tasks, such as implementing the joint entity and relationship extraction method based on deep learning of the present invention to extract entities and relationships from natural language sentences.
[0094] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A joint entity and relationship extraction method based on deep learning, characterized in that , the steps of the method include: S1. Use the BERT model as a sentence encoder to obtain the context-aware embedding vector of each token in the natural sentence X input by the user. S2, treating joint entity and relation extraction as a set prediction problem, using a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples; S3. Setting a set prediction loss function to perform model training, and generating an optimal matching relationship between the predicted triple set and the true triple set according to the set prediction loss function.
2. The method for extracting joint entities and relations based on deep learning according to claim 1, characterized in that: In step S2, by setting the size of the prediction triple set to m, the non-autoregressive decoder generates m prediction triplets of a fixed size according to the received embedding vector to form a prediction triple set.
3. The method for extracting joint entities and relations based on deep learning according to claim 2, characterized in that: The m is a positive number and is larger than the size of the true triple set.
4. The method for extracting joint entities and relations based on deep learning according to claim 2, characterized in that: In the step S2, m learnable embedding vectors are initialized as triple queries through the non-autoregressive decoder, and the m triple queries are converted into m output embedding vectors Hd. The m output embedding vectors Hd are independently decoded into relationship types and entities through a feedforward network, and finally m predicted triplets are generated.
5. The method for extracting joint entities and relations based on deep learning according to claim 4, characterized in that: The softmax function is used to obtain the predicted relationship type, and the probability distribution of the relationship type is obtained by calculating the formula p_r = softmax(W_r*h_d), where W_r is the weight matrix of the relationship type.
6. The method for extracting joint entities and relations based on deep learning according to claim 5, characterized in that: The predicted entities include subject and object, which are obtained by decoding four 1-class classifiers that predict the start and end indexes. The specific calculation formula is: p_s-start=softmax(v_T1*tanh(W_1*h_d+W_2*H_e)); p_s-end=softmax(v_T2*tanh(W_3*h_d+W_4*H_e)); p_o-start=softmax(v_T3*tanh(W_5*h_d+W_6*H_e)); p_o-end=softmax(v_T4*tanh(W_7*h_d+W_8*H_e)); Among them, W_i and vi_i are learnable parameters, H_e is the output of the BERT model, W_i includes v_T1, v_T2, v_T3, v_T4; vi_i includes W_1, W_2, W_3, W_4, W_5, W_6, W_7, W_8.
7. The method for extracting joint entities and relations based on deep learning according to any one of claims 1 to 6, characterized in that: In step S3, the ensemble prediction loss function uses the Hungarian algorithm to find the element arrangement with the lowest cost, and then the model is trained by calculating the loss function of each matching pair.
8. The method for extracting joint entities and relations based on deep learning according to any one of claims 1 to 6, characterized in that: The non-autoregressive decoder consists of multiple identical Transformer layers, each of which contains a multi-head self-attention mechanism and a multi-head cross-attention mechanism to model the relationship between triplets and the information fusion of a given sentence.
9. An entity relationship joint extraction system, based on a set prediction network model, characterized in that: include: The text encoding module uses the BERT model as a sentence encoder to segment the natural sentence X input by the user into tokens through byte pair encoding and feed it into the BERT model. The BERT model outputs a context-aware embedding vector for each token. The decoding module treats joint entity and relation extraction as a set prediction problem and uses a Transformer-based non-autoregressive decoder to directly generate a set of predicted triples; The matching module sets a set prediction loss function to perform model training, and generates an optimal matching relationship between the predicted triple set and the real triple set according to the set prediction loss function.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the deep learning-based joint entity and relationship extraction method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Non-autoregression sentence sorting method
CN113378546A
Multi-label sentiment classification method and system based on non-autoregression model
CN118113871A
Joint entity relationship extraction method and device based on multi-feature semantic fusion and medium
CN118627517A
Cited By
Method and system for jointly extracting entity and relation information in text
CN120494076A
A method and system for jointly extracting entity and relation information in text
CN120494076B