Entity relationship joint extraction method, computer equipment, storage medium, computer program product and joint extraction model

By using sub-task-specific multi-layer perceptron encoding and feature interaction and fusion processing in the entity relationship joint extraction model, the feature confusion problem caused by shared feature representation is solved, and the effect of entity relationship extraction is improved.

CN119416783APending Publication Date: 2025-02-11CHONGQING BITMAP INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411370299.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

In the prior art, the joint extraction method of entity relationships uses shared features to represent it. There is a confusion of features, which affects the effect of entity relationship extraction.

Method used

The context information of the original statement is extracted through the pre-trained encoder and input it into a joint extraction model including entity subtasks and relational subtasks. The entity recognition task and relational classification are obtained using the first multi-layer perceptron and the second multi-layer perceptron respectively. The specific intermediate feature representation of the task is performed, feature interaction and fusion processing is performed, the results of feature interaction and fusion processing are output, and the NER classification module and RE classification module are input for multi-label classification solutions.

Benefits of technology

Through sub-task-specific multi-layer perceptron encoding and feature interaction and fusion processing, feature confusion is avoided, the interaction between entities and relationships is deeply explored, and the effect of entity relationship extraction is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119416783A_ABST
    Figure CN119416783A_ABST
Patent Text Reader

Abstract

The invention provides an entity relationship joint extraction method, computer equipment, a storage medium, a computer program product and a joint extraction model. The method comprises the steps that specific representations of an entity recognition task and a relation classification task are coded through a first multi-layer perceptron and a second multi-layer perceptron, a first intermediate feature representation and a second intermediate feature representation are obtained, and the specific representation of each sub-task penetrates through the implementation process of entity relation extraction of a joint extraction model. According to the method, the problem of feature confusion caused by only using shared feature representation is solved to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information extraction, and in particular to an entity relationship joint extraction method and a joint extraction model for entity relationship joint extraction. Background Art

[0002] In entity relationship extraction, the design usually includes NER (Named Entity Recognition) tasks and RE (Relation Extraction, relation classification) tasks as subtasks. According to the order in which the tasks are completed, entity relationship extraction can be divided into pipeline methods and joint extraction methods. Specifically, the pipeline method of entity relationship extraction is to determine the type of relationship between entity pairs after the entities in the sentence are identified; and the joint extraction method of entity relationship extraction specifically refers to: using a joint learning model to simultaneously solve the two subtasks of entity recognition and relationship classification, and directly output triples with existing relationships. The pipeline method will first go through the NER task to identify entities such as names, locations, and dates in the sentence. Then the output of the NER task is passed to the relationship extraction stage to extract the relationship type between entities.

[0003] Pipeline methods usually have difficulty capturing the complex interactions between the two subtasks, NER and RE. This limitation is caused by the independence of the two subtasks, where errors or ambiguities in the NER stage may propagate to the RE stage, which will greatly affect the entity relationship extraction effect. Although the joint extraction method uses the close information interaction between entities and relations to extract entities and the relationship between entity pairs at the same time, it solves the problems of the pipeline method well, but the joint extraction method still has some limitations. For example, the shared feature representation used in the two subtasks of NER and RE leads to feature confusion, which ultimately affects the entity relationship extraction effect. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present invention provides a method for joint extraction of entity relationships and a joint extraction model for joint extraction of entity relationships, which alleviates the problem in the prior art of entity relationship extraction that the joint extraction method uses shared feature representation, there is feature confusion, and the effect of entity relationship extraction is affected.

[0005] According to an embodiment of the present invention, a method for joint extraction of entity relationships includes:

[0006] Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding;

[0007] Inputting the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtaining a relation triple based on the original sentence according to an output of the joint extraction model;

[0008] In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron;

[0009] Performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, and performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0010] Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, and use a first two-dimensional table to represent the entity labels output by the NER classification module, and use a second two-dimensional table to represent the relationship labels output by the RE classification module;

[0011] A multi-label classification solution is performed based on the entity labels and the relationship labels, and the solution result is the output of the joint extraction model.

[0012] Optionally, the first multilayer perceptron and the second multilayer perceptron are different multilayer perceptrons, and the first multilayer perceptron and the second multilayer perceptron are encoded in parallel.

[0013] Optionally, before extracting the fused features, the process includes:

[0014] Introduce a position matrix for representing relative distances;

[0015] Constructing an input of a multilayer perceptron according to the fusion features and the position matrix;

[0016] The multi-layer perceptron uses multiple two-dimensional dilated convolutions to extract features, and concatenates L outputs obtained according to L dilation rates of the multiple two-dimensional dilated convolutions to obtain shared features;

[0017] Using a feedforward neural network and a Softmax activation function, a first attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, and a second attention score of the second intermediate feature representation to the first intermediate feature representation in the shared feature are calculated.

[0018] Optionally, performing feature extraction on the fused features includes:

[0019] Feature extraction is performed based on the fused features, and the feature extraction uses a collaborative attention mechanism to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score to obtain a feature extraction result.

[0020] Optionally, the fusion feature is obtained by using the normalized first intermediate feature representation and the second intermediate feature representation with the condition factor introduced, and the calculation formula is:

[0021]

[0022] Among them, U ij represents the fusion feature obtained by fusing the first intermediate feature representation and the second intermediate feature representation, h i ∈H NER ,h j ∈H RE , H NER is the first intermediate feature representation, H RE is the second intermediate feature representation, γ ij is the normalized scale, λ ij is the normalized bias, and γ ij =W α h i +b α ,λ ij =W β h i +b β , where parameter W α , W β , b α , b β is a trainable parameter, γ ij With λ ij According to h i Make adjustments, d h Indicates H RE Dimension.

[0023] Optionally, according to the fusion feature and the position matrix, the input of the multi-layer perceptron MLP layer is constructed, and the formula is:

[0024] C = MLP([U; D]);

[0025] Among them, U is a matrix based on fusion features, D is a position matrix, and [;] represents a concatenation operation.

[0026] Optionally, the calculation formula for multiple 2D dilated convolutions is:

[0027] Q l =GELU(DConv l(C));

[0028] Where l represents the expansion rate, GELU represents the activation function, l∈[1,2,3], C=MLP([U;D]);

[0029] The shared features are obtained by concatenating multiple outputs obtained from multiple dilation rates of multiple two-dimensional dilated convolutions. The formula is:

[0030] Q=[Q 1 ;Q 2 ;Q 3 ];

[0031] Among them, Q represents the shared feature, Q 1 represents the output based on l=1, Q 2 represents the output based on l=2, Q 3 Represents the output based on l=3.

[0032] Optionally, a feedforward neural network and a Softmax activation function are used to calculate a first attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, and a second attention score of the second intermediate feature representation to the first intermediate feature representation in the shared feature, and the formula is:

[0033] A=FFNN(Q)

[0034] θ=Softmax(A)

[0035]

[0036] Among them, θ represents the attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, represents the second attention score of the second intermediate feature in the shared feature to the first intermediate feature, Q = [Q 1 ;Q 2 ;Q 3 ].

[0037] Optionally, a collaborative attention mechanism is used to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score, and a feature extraction result is obtained, and the formula is:

[0038]

[0039] in, H NER is the first intermediate feature representation, H RE It is the second intermediate feature representation.

[0040] Optionally, before inputting the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, the method includes:

[0041] The result of the feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation are connected as inputs of the NER classification module and the RE classification module.

[0042] Optionally, performing multi-label classification solution according to the entity label and the relationship label includes:

[0043] Combining any first intermediate feature representation and any second intermediate feature representation into an entity pair;

[0044] Predicting a first conditional probability that the entity pair belongs to an entity type, and a second conditional probability that the entity pair belongs to a relationship type;

[0045] Constructing two cross entropy loss functions based on the first conditional probability and the second conditional probability, and taking the sum of the two cross entropy loss functions as the classification loss function of the multi-label classification model;

[0046] The multi-label classification model is optimized according to the classification loss function, and the multi-label classification solution is completed through the optimized multi-label classification model.

[0047] Optionally, the first two-dimensional table represents the entity labels output by the NER classification module, and the second two-dimensional table represents the relationship labels output by the RE classification module. The formula is:

[0048]

[0049] in, represents the first two-dimensional table, represents the second two-dimensional table, is the interaction of a word representation vector in the original sentence with all possible relationship representation feature vectors, The vector representation of word j that may form an entity pair with word i and the interaction of all possible relationship representation feature vectors; The vector representing a certain relation i represents the interaction between the feature vectors of all words in the original sentence; The vector representing a certain relation j represents the interaction between the feature vectors of all words in the original sentence, Q ij is a shared feature.

[0050] Optionally, a first conditional probability that the entity pair belongs to an entity type and a second conditional probability that the entity pair belongs to a relationship type are predicted, and the formula is:

[0051]

[0052] Among them, W and b are learnable parameters, and σ(·) is the activation function.

[0053] Optionally, the two cross entropy loss functions are calculated as:

[0054]

[0055] The calculation formula of the classification loss function is:

[0056] L=L NER +L RE .

[0057] A second aspect provides a joint extraction model, including an entity subtask and a relationship subtask; the joint extraction model also includes:

[0058] A parallel encoding module, used to obtain a first intermediate feature representation of the entity recognition task through a first multi-layer perceptron, and to obtain a second intermediate feature representation of the relationship classification task through a second multi-layer perceptron;

[0059] Feature interaction and fusion processing, used to perform feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0060] A classification processing module, used to input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into a NER classification module and a RE classification module, and to represent the entity labels output by the NER classification module with a first two-dimensional table, and to represent the relationship labels output by the RE classification module with a second two-dimensional table;

[0061] A multi-label classification solution module, used for performing multi-label classification solution according to the entity label and the relationship label, and the solution result is the output of the joint extraction model;

[0062] When the joint extraction model is used for joint extraction of entity relations, the input is the initial context embedding obtained by extracting the context information of the original sentence through a pre-trained encoder; the output of the joint extraction model is used to obtain a relation triple based on the original sentence.

[0063] The beneficial effects of the present invention are as follows: the specific representations of the entity recognition task and the relationship classification task are encoded by the first multilayer perceptron and the second multilayer perceptron to obtain the first intermediate feature representation and the second intermediate feature representation, so that the specific representation of each subtask runs through the implementation process of the joint extraction model for entity relationship extraction, and to a certain extent overcomes the problem of feature confusion caused by only using the shared feature representation mentioned above. In the process of implementing entity relationship extraction by the joint extraction model, the fused features are first obtained by using the normalized first intermediate feature representation and the second intermediate feature representation with the introduction of conditional factors, and the dynamically adjusted feature representation can be obtained. Compared with directly using the shared features provided by the entity recognition task and the relationship classification task for extraction, the complex relationship and context information between the features can be better captured. Then, the fused features are feature extracted, and the results of feature interaction and fusion processing are output, and the interaction between the first intermediate feature representation and the second intermediate feature representation is deeply mined, thereby deeply mining the interaction between the entity and the relationship between the two words in the original sentence. Finally, the entity recognition task and the relationship classification task are regarded as table filling problems, and multi-label classification is solved to obtain the output of the joint extraction model. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 Flowchart of the implementation of the entity relationship joint extraction method according to an embodiment of the present invention;

[0065] Figure 2 A schematic diagram of the composition structure of a joint extraction model for joint extraction of entity relationships according to another embodiment of the present invention;

[0066] Figure 3 Schematic diagram of the module structure of the joint extraction model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0067] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0068] like Figure 1 As shown, the embodiment of the present invention proposes a method for joint extraction of entity relationships, including but not limited to the following steps:

[0069] S1. Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding.

[0070] In a preferred implementation, the above step S1 uses BERT as a pre-trained encoder.

[0071] S2. Input the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtain a relation triple based on the original sentence according to an output of the joint extraction model.

[0072] An embodiment of the present invention provides a joint extraction model, and obtains a relation triple based on the original sentence according to the output of the joint extraction model.

[0073] S21. In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron.

[0074] In an embodiment of the present invention, the initial context embedding output by the pre-trained encoder will be used for entity recognition tasks and relation classification tasks respectively. Since the NER task usually places more emphasis on the lexical-level features in the sentence, and the RE task usually gives priority to the global semantics of the entire sentence and the contextual features of the entity, therefore, in specific applications, relying solely on the shared feature representation of these two subtasks may lead to feature confusion.

[0075] According to the above-mentioned step S21, the embodiment of the present invention uses a multilayer perceptron specific to a subtask to obtain a specific representation of each subtask, that is, the specific representations of the entity recognition task and the relationship classification task are encoded by the first multilayer perceptron and the second multilayer perceptron, so that the specific representation of each subtask runs through the implementation process of entity relationship extraction by the joint extraction model, which overcomes the above-mentioned problem of feature confusion caused by only using shared feature representations to a certain extent.

[0076] In addition, in one embodiment, the first multilayer perceptron and the second multilayer perceptron in the above step S21 are different multilayer perceptrons, and the first multilayer perceptron and the second multilayer perceptron are encoded in parallel.

[0077] S22, performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation;

[0078] Among them, the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with the introduction of conditional factors to obtain the fused feature, and performs feature extraction on the fused feature to output the result of the feature interaction and fusion processing.

[0079] According to the above step S22, the embodiment of the present invention obtains fused features based on the first intermediate feature representation and the second intermediate feature representation, rather than directly extracting shared features provided by the entity recognition task and the relationship classification task, which is an improvement on the acquisition of shared features. Among them, by using the normalized first intermediate feature representation and the second intermediate feature representation that introduce conditional factors to obtain fused features, a dynamically adjusted feature representation can be obtained to better capture the complex relationships and contextual information between features. Feature extraction is performed on the fused features, and the results of feature interaction and fusion processing are output, which deeply mines the interaction between the first intermediate feature representation and the second intermediate feature representation, thereby deeply mining the interaction between entities and relationships between two words in the original sentence.

[0080] S23. Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, and use the first two-dimensional table to represent the entity labels output by the NER classification module, and use the second two-dimensional table to represent the relationship labels output by the RE classification module.

[0081] S24. Perform multi-label classification solution according to the entity label and the relationship label, and the solution result is the output of the joint extraction model.

[0082] The embodiment of the present invention regards the entity recognition task and the relationship classification task as a table filling problem. Therefore, the above step S23 uses the NER classification module and the RE classification module to output the entity label and the relationship label respectively. The purpose is to perform multi-label classification solution through the above step S24 to obtain the output of the joint extraction model.

[0083] It can be understood that the embodiment of the present invention is to achieve entity-relationship joint extraction. Therefore, multi-label classification is to use the sigmoid function to judge the entity and relationship categories for each pair of words in the two-dimensional table, and the entity and relationship categories are not unique. Therefore, decoding the output of the joint extraction model can obtain the relationship triples based on the original sentence.

[0084] Through the above steps S1 and S2, and S21 to S24, the entity relationship joint extraction method provided by the embodiment of the present invention encodes the specific representation of the entity recognition task and the relationship classification task through the first multilayer perceptron and the second multilayer perceptron to obtain the first intermediate feature representation and the second intermediate feature representation, so that the specific representation of each subtask runs through the implementation process of the joint extraction model for entity relationship extraction, and to a certain extent overcomes the problem of feature confusion caused by only using the shared feature representation. In the process of implementing entity relationship extraction by the joint extraction model, the first intermediate feature representation and the second intermediate feature representation with the introduction of conditional factors are first used to obtain the fused feature, and the dynamically adjusted feature representation can be obtained. Compared with the direct use of the shared features provided by the entity recognition task and the relationship classification task for extraction, the complex relationship and context information between the features can be better captured. Then, the fused feature is extracted, and the result of the feature interaction and fusion processing is output, and the interaction between the first intermediate feature representation and the second intermediate feature representation is deeply mined, thereby deeply mining the interaction between the entity and the relationship between the two words in the original sentence. Finally, the entity recognition task and the relationship classification task are regarded as table filling problems, and multi-label classification is solved to obtain the output of the joint extraction model.

[0085] The embodiment of the present invention also describes the detailed implementation of the feature interaction and fusion processing shown in the above step S22.

[0086] For ease of explanation, illustratively, the above step S1 extracts the context information of the original sentence through the pre-trained encoder, and the obtained initial context embedding is expressed as:

[0087] H=BERT(X)

[0088] Among them, X is the sentence and H is the initial context embedding.

[0089] The output of step S21 encoding the specific representations of the entity recognition task and the relationship classification task through the first multilayer perceptron and the second multilayer perceptron, that is, the first intermediate feature representation and the second intermediate feature representation are:

[0090] H NER =MLP(H)

[0091] H RE =MLP(H)

[0092] Among them, the first intermediate feature represents H NER is a specific representation for the entity recognition task, H RE is a specific representation for the relation classification task. Since the initial context embedding H is actually a matrix, H NER and H RE Also a matrix.

[0093] The feature interaction and fusion processing shown in the above step S22 includes two steps: one is S221: using the normalized first intermediate feature representation and the second intermediate feature representation with the introduction of conditional factors to obtain the fused feature; the other is S222: performing feature extraction on the fused feature and outputting the result of the feature interaction and fusion processing.

[0094] The embodiment of the present invention first describes the latter step, that is, step S222, wherein the information represented by the fused feature is relatively single and cannot comprehensively reflect the interaction between the first intermediate feature representation and the second intermediate feature representation. Therefore, before extracting the fused feature, the fused feature is first processed to obtain the shared feature, and the implementation steps are as follows:

[0095] S222a1, introducing a position matrix for representing relative distances;

[0096] S222a2, constructing an input of a multilayer perceptron according to the fusion features and the position matrix;

[0097] S222a3, the multilayer perceptron uses multiple two-dimensional dilated convolutions to perform feature extraction, and concatenates L outputs obtained according to L dilation rates of the multiple two-dimensional dilated convolutions to obtain shared features;

[0098] S222a4. Use a feedforward neural network and a Softmax activation function to calculate a first attention score of the first intermediate feature representation in the shared feature to the second intermediate feature representation, and a second attention score of the second intermediate feature representation in the shared feature to the first intermediate feature representation.

[0099] Through the above steps, the embodiment of the present invention sets different expansion rates to analyze the interaction between words at different distances, thereby enhancing the multi-scale perception ability of the model. By inserting holes between the convolution kernel elements, the dilated convolution can significantly expand the receptive field of the convolution kernel without increasing the number of parameters, which enables the network to capture a wider range of contextual information. The first attention score and the second attention score are calculated separately, which is to convert the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature, so that when the following step S222 is used for feature extraction, the interaction between the first intermediate feature representation and the second intermediate feature representation can be accurately mined, and then the interaction between entities and relationships between two words in the original sentence can be deeply mined.

[0100] Based on this, the following step S222, i.e., extracting the fused features, is implemented as follows:

[0101] S2221, performing a first feature extraction based on the fused feature, wherein the first feature extraction uses a collaborative attention mechanism to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score, to obtain a feature extraction result;

[0102] S2222. Perform a second feature extraction based on the feature extraction result, and use a dual affine attention module to combine the feature extraction result with the first intermediate feature representation and the second intermediate feature representation to obtain a second feature extraction result.

[0103] For the previous step, that is, step S221, the normalization of the conditional factors is implemented by CLN (Conditional Layer Normalization), and the calculation formula is as follows:

[0104]

[0105] Among them, U ij represents the fusion feature obtained by fusing the first intermediate feature representation and the second intermediate feature representation, h i ∈H NER ,h j ∈H RE , H NER is the first intermediate feature representation, H RE is the second intermediate feature representation, γ ij is the normalized scale, λ ij is the normalized bias, and γ ij =W α h i +b α ,λ ij =W β h i +b β , where parameter W α , W β 、b α 、b β is a trainable parameter, γ ij With λ ij According to h i Make adjustments, d h Indicates H RE Dimension.

[0106] In the above formula, the learned parameter W is used α , W β 、b α 、b β , can be used for γ ij With λij Scaling and offsetting, then U ij It becomes a function that changes according to the input parameters. Therefore, through CLN, additional conditional information is allowed to be introduced in the normalization process, thereby dynamically adjusting the feature representation to better capture the complex relationships between features and contextual information.

[0107] Exemplarily, based on the above Uij, in the embodiment of the present invention, in the above processing of the fused features to obtain the shared features, the calculation formulas of steps S222a1 to S222a4 are respectively:

[0108] In step S222a1, the input of the multi-layer perceptron MLP layer is constructed according to the fusion feature and the position matrix, and the formula is:

[0109] C = MLP([U; D]);

[0110] Among them, U is a matrix based on fusion features, D is a position matrix, and [;] represents a concatenation operation.

[0111] In step S222a2, the calculation formula of the multiple two-dimensional dilated convolution is:

[0112] Q l =GELU(DConv l (C));

[0113] Where l represents the expansion rate, GELU represents the activation function, l∈[1,2,3], C=MLP([U;D]);

[0114] The shared features are obtained by concatenating multiple outputs obtained from multiple dilation rates of multiple two-dimensional dilated convolutions. The formula is:

[0115] Q=[Q 1 ;Q 2 ;Q 3 ];

[0116] Among them, Q represents the shared feature, Q 1 represents the output based on l=1, Q 2 represents the output based on l=2, Q 3 Represents the output based on l==3.

[0117] In step S222a3, a feedforward neural network and a Softmax activation function are used to calculate a first attention score of the first intermediate feature representation in the shared feature to the second intermediate feature representation, and a second attention score of the second intermediate feature representation in the shared feature to the first intermediate feature representation, and the formula is:

[0118] A=FFNN(Q)

[0119] θ=Softmax(A)

[0120]

[0121] Among them, θ represents the attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, represents the second attention score of the second intermediate feature in the shared feature to the first intermediate feature, Q = [Q 1 ;Q 2 ;Q 3 ].

[0122] Based on this, in the above step S222, i.e., extracting the fusion features, the calculation formulas of steps S2221 and S2222 are respectively:

[0123] In step S2221, the collaborative attention mechanism is used to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score, and obtain the feature extraction result, which is formulated as follows:

[0124]

[0125] in, H NER is the first intermediate feature representation, H RE It is the second intermediate feature representation.

[0126] It should be noted that the above step S2221 effectively simulates the complex interaction between the two subtasks within the joint extraction framework, that is, using entity information to predict relationships, and using relationship information to predict entities, thereby achieving mutual reinforcement between the two subtasks and accurately mining the interaction between words, which helps to improve the extraction accuracy.

[0127] The embodiment of the present invention also describes in detail the implementation process of obtaining the output of the joint extraction model shown in the above steps S23 and S24.

[0128] First, the embodiment of the present invention solves the problem of feature overlap or confusion through the above steps S21 and S22, and outputs the second feature extraction result obtained by extracting the fused features based on the first intermediate feature representation and the second intermediate feature representation, that is, the result of feature interaction and fusion processing. However, in the entity relationship extraction model, in order to extract entity relationship triples, it is necessary to obtain both shared feature representations and specific representations for each subtask. Therefore, before the above step S23, that is, before inputting the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, it includes:

[0129] The result of the feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation are connected as inputs of the NER classification module and the RE classification module.

[0130] The embodiment of the present invention regards both NER and RE as table filling problems. Therefore, two two-dimensional tables are used to represent entity labels and relationship labels respectively. Exemplarily, the first two-dimensional table represents the entity labels output by the NER classification module, and the second two-dimensional table represents the relationship labels output by the RE classification module. The formula is:

[0131]

[0132] in, represents the first two-dimensional table, Represents the second two-dimensional table. It can be understood that according to the above formula,

[0133]

[0134] is the interaction of a word representation vector in the original sentence with all possible relationship representation feature vectors, The vector representation of word j that may form an entity pair with word i and the interaction of all possible relationship representation feature vectors; The vector representing a certain relation i represents the interaction between the feature vectors of all words in the original sentence; The vector representing a certain relation j represents the interaction between the feature vectors of all words in the original sentence, Q ij is a shared feature.

[0135] It should be noted that NER can identify entity spans, and the RE task can also be viewed as a table filling problem, where only the first word in the entity needs to be classified. Therefore, the above steps connect the task-specific representations with the shared representations, which serve as the input of the NER or RE classification module.

[0136] Based on this, the above step S24, i.e., performing multi-label classification and solving according to the entity label and the relationship label, includes the following steps:

[0137] S241, combining any first intermediate feature representation and any second intermediate feature representation into an entity pair;

[0138] S242, predicting a first conditional probability that the entity pair belongs to an entity type, and a second conditional probability that the entity pair belongs to a relationship type;

[0139] S243, constructing two cross entropy loss functions based on the first conditional probability and the second conditional probability, and taking the sum of the two cross entropy loss functions as the classification loss function of the multi-label classification model;

[0140] S244. Optimizing the multi-label classification model according to the classification loss function, and completing the multi-label classification solution through the optimized multi-label classification model.

[0141] Exemplarily, the above step S242, i.e. predicting the first conditional probability that the entity pair belongs to the entity type and the second conditional probability that the entity pair belongs to the relationship type, is formulated as follows:

[0142]

[0143] Among them, W and b are learnable parameters, and σ(·) is the activation function.

[0144] The calculation formulas of the above step S243, i.e., the two cross entropy loss functions, are:

[0145]

[0146] The calculation formula of the classification loss function is:

[0147] L=L NER +L RE .

[0148] like Figure 2 As shown, the embodiment of the present invention further provides a joint extraction model for realizing entity-relationship joint extraction, and the joint extraction model includes entity subtasks and relationship subtasks. Structurally, the joint extraction model also includes:

[0149] A parallel encoding module 21, configured to obtain a first intermediate feature representation of the entity recognition task through a first multi-layer perceptron, and obtain a second intermediate feature representation of the relationship classification task through a second multi-layer perceptron;

[0150] Feature interaction and fusion processing 22, used to perform feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with the condition factor introduced to obtain fusion features, performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0151] A classification processing module 23, used to input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into a NER classification module and a RE classification module, and to represent the entity labels output by the NER classification module in a first two-dimensional table, and to represent the relationship labels output by the RE classification module in a second two-dimensional table;

[0152] A multi-label classification solution module 24, used for performing multi-label classification solution according to the entity label and the relationship label, and the solution result is the output of the joint extraction model;

[0153] In a specific application, when the joint extraction model is used for entity relationship joint extraction, the input is the initial context embedding obtained by extracting the context information of the original sentence through a pre-trained encoder; the output of the joint extraction model is used to obtain a relation triple based on the original sentence.

[0154] like Figure 3 As shown, the embodiment of the present invention also provides a module structure of a joint extraction model, and is explained in combination with the above steps S1, S2, S21 to S24. Let A be the initial context embedding obtained by the pre-trained encoder used in S1, and A is input into Figure 3 In the joint extraction model shown, according to step S21, the initial context embedding A is passed through a parallel encoder composed of a first multilayer perceptron and a second multilayer perceptron to obtain a first intermediate feature representation and a second intermediate feature representation a. According to S222a1 to S222a4, S2221 to S2222 of step S222, the first intermediate feature representation and the second intermediate feature representation a are subjected to feature interaction and fusion processing, that is, they are sequentially subjected to the normalized CLN with the introduction of conditional factors, combined with the multiple two-dimensional dilated convolution MLP of the position matrix D, and feature extraction based on the collaborative attention mechanism to obtain the result of the feature interaction and fusion processing and input it into the NER classification module b and the RE classification module c. According to step S23, the NER classification module b outputs a first two-dimensional table d, and the RE classification module c outputs a second two-dimensional table e. The multi-label classification solution of the above step S24 is not shown. In addition, combined with Figure 2 , Figure 3 The Encoder in is Figure 2 An implementation of the parallel encoding module 21 in Figure 3 The CLN, MLP combined with D, and Co-Attention in Figure 2 An implementation of the feature interaction and fusion processing module 22 in Figure 3 b and c in Figure 2 An implementation of the classification processing module 23 in.

[0155] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0156] Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding;

[0157] Inputting the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtaining a relation triple based on the original sentence according to an output of the joint extraction model;

[0158] In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron;

[0159] Performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, and performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0160] Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, and use a first two-dimensional table to represent the entity labels output by the NER classification module, and use a second two-dimensional table to represent the relationship labels output by the RE classification module;

[0161] A multi-label classification solution is performed based on the entity labels and the relationship labels, and the solution result is the output of the joint extraction model.

[0162] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0163] Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding;

[0164] Inputting the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtaining a relation triple based on the original sentence according to an output of the joint extraction model;

[0165] In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron;

[0166] Performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, and performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0167] Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, and use a first two-dimensional table to represent the entity labels output by the NER classification module, and use a second two-dimensional table to represent the relationship labels output by the RE classification module;

[0168] A multi-label classification solution is performed based on the entity labels and the relationship labels, and the solution result is the output of the joint extraction model.

[0169] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0170] Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding;

[0171] Inputting the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtaining a relation triple based on the original sentence according to an output of the joint extraction model;

[0172] In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron;

[0173] Performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, and performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing;

[0174] Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, and use a first two-dimensional table to represent the entity labels output by the NER classification module, and use a second two-dimensional table to represent the relationship labels output by the RE classification module;

[0175] A multi-label classification solution is performed based on the entity labels and the relationship labels, and the solution result is the output of the joint extraction model.

[0176] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0177] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0178] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

[0179] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. A method for joint extraction of entity relations, characterized in that: include: Extract the context information of the original sentence through the pre-trained encoder to obtain the initial context embedding; Inputting the initial context embedding into a joint extraction model including an entity subtask and a relation subtask, and obtaining a relation triple based on the original sentence according to an output of the joint extraction model; In the joint extraction model, a first intermediate feature representation of the entity recognition task is obtained through a first multilayer perceptron, and a second intermediate feature representation of the relationship classification task is obtained through a second multilayer perceptron; Performing feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, and performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing; Input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, use a first two-dimensional table to represent the entity labels output by the NER classification module, and use a second two-dimensional table to represent the relationship labels output by the RE classification module; A multi-label classification solution is performed based on the entity labels and the relationship labels, and a solution result is the output of the joint extraction model.

2. The entity relationship joint extraction method according to claim 1, characterized in that: The first multilayer perceptron and the second multilayer perceptron are different multilayer perceptrons, and the first multilayer perceptron and the second multilayer perceptron are encoded in parallel.

3. The entity relationship joint extraction method according to claim 1 or 2, characterized in that: Before extracting the fusion features, the following steps are included: Introducing a position matrix for representing relative distances; Constructing an input of a multilayer perceptron according to the fusion features and the position matrix; The multi-layer perceptron uses multiple two-dimensional dilated convolutions to extract features, and concatenates L outputs obtained according to L dilation rates of the multiple two-dimensional dilated convolutions to obtain shared features; Using a feedforward neural network and a Softmax activation function, a first attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, and a second attention score of the second intermediate feature representation to the first intermediate feature representation in the shared feature are calculated.

4. The entity relationship joint extraction method according to claim 3, characterized in that: Performing feature extraction on the fusion feature includes: Feature extraction is performed based on the fused features, and the feature extraction uses a collaborative attention mechanism to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score to obtain a feature extraction result.

5. The entity relationship joint extraction method according to claim 4, characterized in that: The fusion feature is obtained by using the normalized first intermediate feature representation and the second intermediate feature representation with the conditional factor introduced, and the calculation formula is: Among them, U ij represents the fusion feature obtained by fusing the first intermediate feature representation and the second intermediate feature representation, h i ∈H NER ,h j ∈H RE , H NER is the first intermediate feature representation, H RE is the second intermediate feature representation, γ ij is the normalized scale, λ ij is the normalized bias, and γ ij =W α h i +b α ,λ ij =W β h i +b β , where parameter W α , W β 、b α 、b β is a trainable parameter, γ ij With λ ij According to h i Make adjustments, d h Indicates H RE Dimension.

6. The entity relationship joint extraction method according to claim 5, characterized in that: According to the fusion features and the position matrix, the input of the multi-layer perceptron MLP layer is constructed, and the formula is: C = MLP([U; D]); Among them, U is a matrix based on fusion features, D is a position matrix, and [;] represents a concatenation operation.

7. The entity relationship joint extraction method according to claim 6, characterized in that: The calculation formula for multiple two-dimensional dilated convolutions is: Q l =GELU(DConv l (C)); Where l represents the expansion rate, GELU represents the activation function, l∈[1,2,3], C=MLP([U;D]); The shared features are obtained by concatenating multiple outputs obtained from multiple dilation rates of multiple two-dimensional dilated convolutions. The formula is: Q=[Q 1 ;Q 2 ;Q 3 ]; Among them, Q represents the shared feature, Q 1 represents the output based on l=1, Q 2 represents the output based on l=2, Q 3 Represents the output based on l=3.

8. The entity relationship joint extraction method according to claim 7, characterized in that: Using a feedforward neural network and a Softmax activation function, a first attention score of the first intermediate feature representation in the shared feature to the second intermediate feature representation, and a second attention score of the second intermediate feature representation in the shared feature to the first intermediate feature representation are calculated, and the formula is: A=FFNN(Q) θ=Softmax(A) Among them, θ represents the attention score of the first intermediate feature representation to the second intermediate feature representation in the shared feature, represents the second attention score of the second intermediate feature in the shared feature to the first intermediate feature, Q = [Q 1 ;Q 2 ;Q 3 ].

9. The entity relationship joint extraction method according to claim 8, characterized in that: The collaborative attention mechanism is used to capture the interaction between the first intermediate feature representation and the second intermediate feature representation in the shared feature according to the first attention score and the second attention score, and obtain the feature extraction result. The formula is: in, H NER is the first intermediate feature representation, H RE It is the second intermediate feature representation.

10. The entity relationship joint extraction method according to claim 1, characterized in that: Before inputting the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into the NER classification module and the RE classification module, the method includes: The result of the feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation are connected as inputs of the NER classification module and the RE classification module.

11. The entity relationship joint extraction method according to claim 10, characterized in that: Performing multi-label classification solution according to the entity label and the relationship label includes: Combining any first intermediate feature representation and any second intermediate feature representation into an entity pair; Predicting a first conditional probability that the entity pair belongs to an entity type, and a second conditional probability that the entity pair belongs to a relationship type; Constructing two cross entropy loss functions based on the first conditional probability and the second conditional probability, and taking the sum of the two cross entropy loss functions as the classification loss function of the multi-label classification model; The multi-label classification model is optimized according to the classification loss function, and the multi-label classification solution is completed through the optimized multi-label classification model.

12. The entity relationship joint extraction method according to claim 11, characterized in that: The first two-dimensional table represents the entity labels output by the NER classification module, and the second two-dimensional table represents the relationship labels output by the RE classification module. The formula is: in, represents the first two-dimensional table, represents the second two-dimensional table, is the interaction of a word representation vector in the original sentence with all possible relationship representation feature vectors, The vector representation of word j that may form an entity pair with word i and the interaction of all possible relationship representation feature vectors; The vector representing a certain relation i represents the interaction between the feature vectors of all words in the original sentence; The vector representing a certain relation j represents the interaction between the feature vectors of all words in the original sentence, Q ij is a shared feature.

13. The entity relationship joint extraction method according to claim 12, characterized in that: Predict the first conditional probability that the entity pair belongs to the entity type, and the second conditional probability that the entity pair belongs to the relationship type, the formula is: Among them, W and b are learnable parameters, and σ(·) is the activation function.

14. The entity relationship joint extraction method according to claim 13, characterized in that: The calculation formulas of the two cross entropy loss functions are: The calculation formula of the classification loss function is: L=L NER +L RE .

15. A joint extraction model, characterized in that: Including entity subtasks and relationship subtasks; the joint extraction model also includes: A parallel encoding module, used to obtain a first intermediate feature representation of the entity recognition task through a first multi-layer perceptron, and to obtain a second intermediate feature representation of the relationship classification task through a second multi-layer perceptron; Feature interaction and fusion processing, used to perform feature interaction and fusion processing on the first intermediate feature representation and the second intermediate feature representation; wherein the feature interaction and fusion processing uses the normalized first intermediate feature representation and the second intermediate feature representation with conditional factors introduced to obtain fusion features, performs feature extraction on the fusion features, and outputs the result of the feature interaction and fusion processing; A classification processing module, used to input the result of feature interaction and fusion processing, the first intermediate feature representation and the second intermediate feature representation into a NER classification module and a RE classification module, and to represent the entity labels output by the NER classification module with a first two-dimensional table, and to represent the relationship labels output by the RE classification module with a second two-dimensional table; A multi-label classification solution module, used for performing multi-label classification solution according to the entity label and the relationship label, and the solution result is the output of the joint extraction model; When the joint extraction model is used for joint extraction of entity relations, the input is the initial context embedding obtained by extracting the context information of the original sentence through a pre-trained encoder; the output of the joint extraction model is used to obtain a relation triple based on the original sentence.

16. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the entity relationship joint extraction method described in any one of claims 1 to 14.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the entity relationship joint extraction method described in any one of claims 1 to 14 are implemented.

18. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the entity relationship joint extraction method described in any one of claims 1 to 14 are implemented.