Entity relationship extraction method, device, equipment and storage medium
Through entity disambiguation and meta-learning multi-select matching network training model, the problems of noise and data labeling errors in supervised learning methods are solved, and high-accuracy entity relationship extraction is achieved in small-sample data sets.
Patent Information
- Application Number
- CN202310402376.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-06
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-04-06
AI Technical Summary
Existing supervised learning methods have low accuracy in entity relationship extraction due to noise and data labeling errors, especially in the case of small sample datasets.
Through entity disambiguation and key component extraction, the entity relationship extraction model is trained using a meta-learning-based multi-selection matching network. The model parameters are optimized by combining the attention layer and loss function to improve the accuracy of entity relationship extraction.
In the case of few sample data annotations, the data annotation error is reduced, a more accurate entity relationship extraction model is trained, and the accuracy of entity relationship extraction is improved.
Smart Images

Figure CN116306656B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to an entity relationship extraction method, apparatus, device and storage medium. Background Art
[0002] Entity relationship extraction is to extract the implicit semantic relationships between different entities from unstructured text, thereby obtaining a more structured relationship expression, such as entity relationship triples.
[0003] Traditional entity relationship extraction typically uses supervised learning methods to extract entity relationships from corpora. However, during the entity relationship extraction process, due to the extraction of a large number of words unrelated to the entity relationship, which is the noise in the entity extraction process, the accuracy of entity relationship extraction is low. To improve the accuracy, it is necessary to increase the number of samples. Increasing the number of samples requires manually annotating a large amount of training data. However, due to the large amount of data, the annotated data has certain errors, and the accuracy of entity relationship extraction will also be low. Therefore, the existing supervised learning relationship extraction model suffers from the problem of low entity relationship extraction accuracy when only a small sample data set is used. Summary of the Invention
[0004] The present invention provides an entity relationship extraction method, apparatus, device and storage medium, the main purpose of which is to improve the accuracy of entity relationship extraction.
[0005] To achieve the above object, the present invention provides an entity relationship extraction method, comprising:
[0006] Obtaining the text to be extracted, and obtaining the entity reference item set and real entity relationship predefined in the text to be extracted;
[0007] Selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and performing key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted;
[0008] Obtaining multiple choice entity relationships of the real entity relationship, and encoding the target entity set and the multiple choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set;
[0009] Matching the entity feature vector set with each entity relationship in the multiple-choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set;
[0010] Calculating the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjusting the parameters of the entity relationship extraction model according to the loss value until the loss value meets a preset condition, thereby obtaining a trained entity relationship extraction model;
[0011] The trained entity relationship extraction model is used to extract entity relationships from the text to be extracted, thereby obtaining an entity relationship extraction result for the text to be extracted.
[0012] Optionally, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set includes:
[0013] Calculating the entity influence of each candidate entity in the candidate entity set in the corresponding entity referent;
[0014] The candidate entities whose importance is greater than a preset value are selected from the entity influence degrees as the target candidate entity set corresponding to the entity reference item set, and the remaining candidate entity sets corresponding to the entity reference item set are removed to obtain the disambiguated entity set.
[0015] Optionally, the using the entity relationship matching layer of the entity relationship extraction model to match the entity feature vector set with each entity relationship in the multiple choice entity relationships to obtain a predicted entity relationship matching the entity feature vector set includes:
[0016] Utilizing the entity relationship matching layer to obtain each entity relationship in the multiple choice entity relationships corresponding to the sentence vector instance in the entity feature vector set;
[0017] Calculating the Euclidean distance between each of the sentence vector instances and each of the entity relationships to obtain multiple entity relationship matching results between the sentence vector instances and the entity relationships;
[0018] An entity relationship matching result with the highest similarity is selected from the plurality of entity relationship matching results as the predicted entity relationship of the entity feature vector set.
[0019] Optionally, selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted includes:
[0020] Selecting text entities with the same name as each entity reference item in the entity reference item set from the text to be extracted as an initial candidate entity set;
[0021] Determining whether the number of initial candidate entity sets corresponding to each of the entity referents reaches a preset threshold;
[0022] When the number of initial candidate entity sets corresponding to the entity referent term does not reach a preset threshold, the initial candidate entity set is used as a candidate entity set for the entity referent term;
[0023] When the number of initial candidate entity sets corresponding to the entity reference term reaches a preset threshold, the semantic similarity between the entity reference term and the initial candidate entity set is calculated, and the initial candidate entities in the initial candidate entity set that are equal to the preset threshold number are selected from high to low according to the semantic similarity as the candidate entity set of the entity reference term.
[0024] Optionally, the target entity set and multiple choice entity relationships are encoded using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set, including:
[0025] Using the attention layer to vectorize the target entity set and the multiple choice entity relationships respectively to obtain a target entity vector set and a multiple entity relationship vector set, wherein the attention layer includes a spatial attention mechanism and a channel attention mechanism;
[0026] The head entity vector set and the tail entity vector set of the target entity vector set are labeled, and the head entity vector set, the tail entity vector set and the multiple entity relationship vector sets are feature-encoded in parallel using the spatial attention mechanism and the channel attention mechanism to obtain the entity feature vector set.
[0027] Optionally, extracting key components from the disambiguated entity set to obtain a target entity set of the text to be extracted includes:
[0028] The parts of speech of the disambiguation entity set are identified, and useless words in the disambiguation entity set are removed according to the parts of speech to obtain the target entity set.
[0029] Optionally, before obtaining the predefined entity reference item set and real entity relationship in the text to be extracted, the method further includes:
[0030] Defining entity types in the text to be extracted, and labeling the text to be extracted according to the entity types to obtain the entity reference item set;
[0031] The relationship types between the entity reference item sets are defined, and the entity reference item sets are labeled according to the relationship types to obtain the text entity relationships.
[0032] In order to solve the above problems, the present invention further provides an entity relationship extraction device, which includes:
[0033] An entity definition module is used to obtain the text to be extracted, and obtain the predefined entity reference item set and real entity relationship in the text to be extracted;
[0034] An entity disambiguation module is used to select a candidate entity set corresponding to the entity referent item set from the text to be extracted, perform entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and perform key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted;
[0035] An entity encoding module, configured to obtain multiple-choice entity relationships of the real entity relationship, and encode the target entity set and the multiple-choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set;
[0036] An entity relationship matching module, configured to match the entity feature vector set with each entity relationship in the multiple choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set;
[0037] An entity training module is used to calculate the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjust the parameters of the entity relationship extraction model according to the loss value until the loss value meets the preset conditions, thereby obtaining a trained entity relationship extraction model;
[0038] The entity relationship extraction module is used to use the trained entity relationship extraction model to extract entity relationships from the text to be extracted, and obtain the entity relationship extraction result of the text to be extracted.
[0039] In order to solve the above problem, the present invention further provides an electronic device, comprising:
[0040] a memory storing at least one computer program; and
[0041] The processor executes the computer program stored in the memory to implement the entity relationship extraction method described above.
[0042] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned entity relationship extraction method.
[0043] In an embodiment of the present invention, first, by selecting a candidate entity set corresponding to the entity reference item set from the text to be extracted, the candidate entity set is subjected to entity disambiguation to obtain a disambiguated entity set, thereby determining the true entity corresponding to the entity reference item set, removing entity noise irrelevant to the true entity, and extracting key components from the disambiguated entity set to obtain a target entity set, thereby removing some irrelevant entity components and improving the accuracy of subsequent entity relationship extraction; secondly, by training an entity relationship extraction model, the entity relationship extraction task can be transformed into a multi-select matching network based on meta-learning, thereby achieving the goal of reducing data labeling errors and training a target entity set of an entity relationship extraction model with higher accuracy in the case of few sample data annotations; finally, the trained entity relationship extraction model is used to extract entity relationships from the text to be extracted to obtain an entity relationship extraction result, thereby improving the accuracy of entity relationship extraction. Therefore, the entity relationship extraction method, device, equipment and storage medium proposed in the embodiment of the present invention can improve the accuracy of entity relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A flowchart of an entity relationship extraction method provided by one embodiment of the present invention;
[0045] Figure 2 A detailed flowchart of a step in the entity relationship extraction method provided by one embodiment of the present invention;
[0046] Figure 3 A detailed flowchart of a step in the entity relationship extraction method provided by one embodiment of the present invention;
[0047] Figure 4 A schematic diagram of a module of an entity relationship extraction device provided by an embodiment of the present invention;
[0048] Figure 5 A schematic diagram of the internal structure of an electronic device for implementing an entity relationship extraction method provided by one embodiment of the present invention.
[0049] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0051] Embodiments of the present invention provide a method for extracting entity relationships. The entity relationship extraction method may be executed by at least one electronic device, such as a server or a terminal, that can be configured to execute the method provided by the embodiments of this application. In other words, the entity relationship extraction method may be executed by software or hardware installed on a terminal or server device, where the software may be a blockchain platform. The server may include, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster.
[0052] Reference Figure 1 FIG. 1 is a flow chart of an entity relationship extraction method provided by an embodiment of the present invention. In the embodiment of the present invention, the entity relationship extraction method includes the following steps S1-S6:
[0053] S1. Obtain the text to be extracted, and obtain the predefined entity reference item set and real entity relationship in the text to be extracted.
[0054] In an embodiment of the present invention, the text to be extracted is the text from which entity relationships are to be extracted, and the specific content of the text can be determined based on actual business scenarios. For example, the text to be extracted can include transaction information between various financial products and investment status of various financial products.
[0055] In an embodiment of the present invention, the entity reference item set refers to the set of all entities in the text to be extracted, primarily manifested in the fact that the same entity may have different entity reference items in the text. For example, in the insurance field, if a policyholder A purchases critical illness insurance, the entity reference item for policyholder A may be the insurance claimant or the insurance beneficiary. Alternatively, the same entity reference item may refer to different entities in different contexts. For example, the critical illness insurance in the entity reference item may refer to a consumption-based critical illness insurance or a savings-based critical illness insurance.
[0056] In an embodiment of the present invention, the real entity relationship refers to the real relationship between entity referents in the text to be extracted. For example, if there are two entities in the target entity set, namely investor a and financial product B, then the entity relationship between investor a and financial product B can be an investment relationship.
[0057] As an embodiment of the present invention, before obtaining the predefined entity reference item set and real entity relationship in the text to be extracted, the method further includes:
[0058] The entity types in the text to be extracted are defined, and the text to be extracted is annotated according to the entity types to obtain the entity reference item set; the relationship types between the entity reference item sets are defined, and the entity reference item sets are annotated according to the relationship types to obtain the real entity relationships.
[0059] In one embodiment of the present invention, the entity type in the text to be extracted can be defined by a naming recognition algorithm, and the text to be extracted can be labeled according to the entity type to obtain the entity reference item set; the relationship type refers to the association between entity reference items, for example, there is an insurance underwriting relationship between the two entities of insurance name and policyholder.
[0060] Specifically, the entity type may be a financial product name, an investor's name, an investor's contact number, etc.; by marking the text to be extracted according to the entity type, the type of the entity reference item set may be determined.
[0061] Furthermore, annotation can be performed using a preset annotation tool (such as the Bart annotation tool).
[0062] S2. Select a candidate entity set corresponding to the entity reference item set from the text to be extracted, perform entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and perform key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted.
[0063] In the embodiment of the present invention, the candidate entity set refers to a set of entities with the same name as the entity referent in the text to be extracted; the target entity set refers to a set of all entities after removing text noise entities.
[0064] In one embodiment of the present invention, since the same entity has different entity reference items in the text to be extracted, and the same entity reference item can refer to different entities in different contexts, a candidate entity set corresponding to the entity reference item set is selected from the text to be extracted, and the candidate entity set is subjected to entity disambiguation to obtain a disambiguated entity set. The true entity corresponding to the entity reference item set can be determined, and entity noise irrelevant to the true entity can be removed. The disambiguated entity set is subjected to key component extraction to obtain the target entity set of the text to be extracted. Some irrelevant entity components can be removed, thereby improving the accuracy of subsequent entity relationship extraction.
[0065] As an embodiment of the present invention, the step of selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted includes:
[0066] Select text entities with the same name as each entity reference item in the entity reference item set from the text to be extracted as the initial candidate entity set; determine whether the number of initial candidate entity sets corresponding to each entity reference item reaches a preset threshold; when the number of initial candidate entity sets corresponding to the entity reference item does not reach the preset threshold, use the initial candidate entity set as the candidate entity set of the entity reference item; when the number of initial candidate entity sets corresponding to the entity reference item reaches the preset threshold, calculate the semantic similarity between the entity reference item and the initial candidate entity set, and select the initial candidate entities in the initial candidate entity set that are equal to the preset threshold number as the candidate entity set of the entity reference item according to the semantic similarity from high to low.
[0067] In the candidate entity set selection process, if there is no text entity with the same name in the text to be extracted, the corresponding entity reference item is classified as an empty entity; if there is a unique text entity with the same name corresponding to the entity reference item in the text to be extracted, the text entity with the same name is directly used as a candidate entity; further, the entity reference item set can be represented as M = {m1, m2, ..., mn}, and n represents the number of entity reference items in the text to be extracted. By selecting entities with the same name as the entity reference items, the initial candidate entity set can be obtained as E = {e1, e2, ..., es}, and s represents the number of candidate entities.
[0068] In one embodiment of the present invention, in order to avoid the impact of too many candidate entities on the efficiency of entity disambiguation, a preset threshold of k candidate entities can be selected as the candidate entity set. When the number of candidate entities is less than or equal to k, all candidate entities corresponding to the entity reference term are selected as its candidate entity set; when the number of candidate entities is greater than k, the semantic similarity between the entity reference term and the initial candidate entity set can be calculated, and the candidate entity set corresponding to the entity reference term can be obtained based on the semantic similarity.
[0069] Specifically, the semantic similarity between the entity referent and the initial candidate entity set can be calculated using the following formula:
[0070]
[0071] Among them, contextsim(m,es) represents semantic similarity; m represents the entity referent; ei represents the i-th candidate entity; X represents the word vector of the context of entity referent m; Y represents the word vector of candidate entity ei; X·Y represents the vector inner product; ||X|| represents the length of the word vector of the context of entity referent m; ||Y|| represents the length of the word vector of candidate entity ei.
[0072] As an embodiment of the present invention, refer to Figure 2As shown, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set includes the following steps S21-S22:
[0073] S21, calculating the entity influence degree of each candidate entity in the candidate entity set in the corresponding entity referent;
[0074] S22. Select candidate entities whose importance is greater than a preset value from the entity influence degrees as the target candidate entity set corresponding to the entity reference item set, and remove the remaining candidate entity sets corresponding to the entity reference item set to obtain the disambiguated entity set.
[0075] The entity influence of each candidate entity in the candidate entity set in the corresponding entity referent can be calculated by the following formula:
[0076]
[0077] Among them, P(e i ) represents the e i The entity influence degree of candidate entities; N represents the number of candidate entities; d represents the damping factor; M(e i ) indicates that i The set of other candidate entities connected to the candidate entity; N(e j ) indicates that j The set of other candidate entities connected to the candidate entity; P(e j )e j The entity influence degree of each candidate entity; W(e j ,e i ) means e i With e j The weight between candidate entities; W(e j ,e p ) means e j With e p The weights between candidate entities.
[0078] In an embodiment of the present invention, the preset value may be 0.8.
[0079] Furthermore, extracting key components from the disambiguation entity set to obtain the target entity set of the text to be extracted includes:
[0080] The parts of speech of the disambiguation entity set are identified, and useless words in the disambiguation entity set are removed according to the parts of speech to obtain the target entity set.
[0081] Among them, the parts of speech include nouns, verbs, adjectives and adverbs, etc., and the parts of speech of the disambiguated entity set can be identified by the Hanlp tool; further, the identified adjectives, adverbs and other modifiers can be removed to obtain the target entity set.
[0082] S3. Obtain multiple-choice entity relationships of the real entity relationship of the document, and use the attention layer in the preset entity relationship extraction model to encode the target entity set and the multiple-choice entity relationship to obtain an entity feature vector set.
[0083] In the embodiment of the present invention, the entity feature vector set refers to a set including target entity set features and multiple-choice entity relationship features.
[0084] In an embodiment of the present invention, the preset entity relationship extraction model is a matching network based on meta-learning and integrated with the self-attention mechanism. Through this model, the entity relationship extraction task can be transformed into a multi-selection matching network based on meta-learning, thereby reducing the error in data annotation when there is little sample data annotation, and training a more accurate entity relationship extraction model.
[0085] The embodiment of the present invention uses the attention layer in the preset entity relationship extraction model to encode the target entity set and the multiple-choice entity relationship, so as to accurately extract the features of the target entity set and the multiple-choice entity relationship.
[0086] In one embodiment of the present invention, the multiple choice entity relationships of the real entity relationship can be obtained by directly connecting the relationship names in the real entity relationship using separators to obtain the multiple choice entity relationship corresponding to each real entity relationship.
[0087] Specifically, a multi-choice entity relationship can be expressed as follows: [C]rel 1[C]rel 2···[C]rel N, where [C] represents a separator and rel1, rel2, and relN represent the names of the connected relationships. For example, a target relationship extraction task contains three new relationships: Entity-Destination(e1,e2), Component-Whole(e1,e2), and Cause-Effect(e2,e1). The relationship descriptions can be connected together to form a multi-choice entity relationship "[C]Entity-Destination(e1,e2)[C]Component-Whole(e1,e2)[C]Cause-Effect(e2,e1)."
[0088] As an embodiment of the present invention, the target entity set and multiple choice entity relationships are encoded using the attention layer in the preset entity relationship extraction model to obtain an entity feature vector set, including:
[0089] The target entity set and the multiple-choice entity relationships are respectively vectorized using the attention layer to obtain a target entity vector set and a multiple-entity relationship vector set, wherein the attention layer includes a spatial attention mechanism and a channel attention mechanism; the head entity vector set and the tail entity vector set of the target entity vector set are labeled, and the head entity vector set, the tail entity vector set and the multiple-entity relationship vector set are feature-encoded in parallel using the spatial attention mechanism and the channel attention mechanism to obtain the entity feature vector set.
[0090] Among them, the spatial attention mechanism is composed of a convolution module and a residual connection module. The spatial attention mechanism can effectively extract the position description of the target entity vector set; the channel attention mechanism is composed of a convolution layer and a pooling layer. The channel attention mechanism can obtain the learning content of the target entity vector set. In the parallel process of the spatial attention mechanism and the channel attention mechanism, sufficient feature information can be obtained in limited sample data, thereby improving the accuracy of feature encoding.
[0091] S4. Utilize the entity relationship matching layer of the entity relationship extraction model to match the entity feature vector set with each entity relationship in the multiple choice entity relationships to obtain a predicted entity relationship that matches the entity feature vector set.
[0092] In the embodiment of the present invention, the main function of the entity relationship matching layer is to find the entity relationship corresponding to the target entity vector set from the multiple choice entity relationships. The predicted entity relationship is the entity relationship of the target entity set predicted according to the preset relationship extraction model.
[0093] The embodiment of the present invention uses the entity relationship matching layer of the entity relationship extraction model to match the entity feature vector set with each entity relationship in the multiple-choice entity relationship to obtain a predicted entity relationship that matches the entity feature vector set. The entity relationship extraction task can be converted into a multi-choice matching network based on meta-learning. In the case of a small number of training samples, the entity relationship that best matches the entity feature vector set is selected as the predicted entity relationship to improve the accuracy of subsequent entity relationship extraction.
[0094] As an embodiment of the present invention, refer to Figure 3As shown, the entity relationship matching layer of the entity relationship extraction model is used to match the entity feature vector set with each entity relationship in the multiple choice entity relationships to obtain a predicted entity relationship that matches the entity feature vector set, including the following steps S41-S43:
[0095] S41, using the entity relationship matching layer to obtain each entity relationship in the multiple choice entity relationships corresponding to the sentence vector instance in the entity feature vector set;
[0096] S42. Calculate the Euclidean distance between each sentence vector instance and each entity relationship to obtain multiple entity relationship matching results between the sentence vector instance and the entity relationship;
[0097] S43: Selecting the entity relationship matching result with the highest similarity from the plurality of entity relationship matching results as the predicted entity relationship of the entity feature vector set.
[0098] Among them, each entity relationship can be represented by the hidden state of the separator, that is, in, represents the i-th entity relationship, The hidden state can be used to linearly divide different types of entity relationships, thereby improving the accuracy of subsequent matching.
[0099] The sentence vector instance can be expressed as: Among them, X represents the sentence vector instance, Indicates the entity relationship corresponding to the e1 entity, Indicates the entity relationship corresponding to the e2 entity, h [p] It represents the entity relationship between the sentence p corresponding to e1 and e2, and avg refers to the average of the hidden states of [e1], [e2] and [p].
[0100] In one embodiment of the present invention, the Euclidean distance can be calculated using the following formula:
[0101]
[0102] Among them, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X, where X represents the sentence vector instance. Equivalent to y i Represents the i-th entity relationship, D(X,y i ) represents the Euclidean distance between the sentence vector instance and the i-th instance, y j represents the j-th entity relationship, and N represents the number of entity relationships j.
[0103] Furthermore, the entity relationship matching result with the highest similarity can be selected from the multiple entity relationship matching results using the following formula:
[0104]
[0105] in, Indicates the entity relationship matching result with the highest similarity, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X, X represents the sentence vector instance, y i Represents the i-th entity relationship.
[0106] S5. Calculate the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjust the parameters of the entity relationship extraction model according to the loss value until the loss value meets the preset conditions, thereby obtaining a trained entity relationship extraction model.
[0107] In an embodiment of the present invention, the preset condition may be set according to an actual model training scenario. For example, the preset condition may be that the loss value is less than a preset threshold.
[0108] In one embodiment of the present invention, the loss value between the predicted entity relationship and the actual entity relationship can be calculated using the following loss function:
[0109]
[0110] Among them, L(x,y) represents the loss value, N represents the number of entity relations i, X represents the sentence vector instance, and y i Represents the i-th entity relationship, δ represents the Kronecker function, if but otherwise Indicates the entity relationship matching result with the highest similarity, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X.
[0111] In an optional embodiment of the present invention, when the loss value is less than a preset threshold, a trained entity relationship extraction model is obtained; when the loss value is not less than the preset threshold, the model parameters are adjusted by a random descent gradient algorithm until the loss value is less than the preset threshold, thereby obtaining a trained entity relationship extraction model.
[0112] S6. Utilize the trained entity relationship extraction model to perform entity relationship extraction on the text to be extracted, and obtain an entity relationship extraction result of the text to be extracted.
[0113] In an embodiment of the present invention, the trained entity relationship extraction model can locate the start and end positions of the entity from the text to be extracted, and extract entity relationships from the text to be extracted to obtain an entity relationship extraction result of an entity-entity relationship-entity triple structure.
[0114] In an embodiment of the present invention, first, by selecting a candidate entity set corresponding to the entity reference item set from the text to be extracted, the candidate entity set is subjected to entity disambiguation to obtain a disambiguated entity set, thereby determining the true entity corresponding to the entity reference item set, removing entity noise irrelevant to the true entity, and extracting key components from the disambiguated entity set to obtain a target entity set, thereby removing some irrelevant entity components and improving the accuracy of subsequent entity relationship extraction; secondly, by training an entity relationship extraction model, the entity relationship extraction task can be transformed into a multi-select matching network based on meta-learning, thereby achieving the goal of reducing data labeling errors and training a target entity set of an entity relationship extraction model with higher accuracy in the case of few sample data annotations; finally, the trained entity relationship extraction model is used to extract entity relationships from the text to be extracted to obtain an entity relationship extraction result, thereby improving the accuracy of entity relationship extraction. Therefore, the entity relationship extraction method proposed in an embodiment of the present invention can improve the accuracy of entity relationship extraction.
[0115] The entity relationship extraction device 100 of the present invention can be installed in an electronic device. Depending on the functions to be implemented, the entity relationship extraction device can include an entity definition module 101, an entity disambiguation module 102, an entity encoding module 103, an entity relationship matching module 104, an entity training module 105, and an entity relationship extraction module 106. The modules of the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can perform fixed functions, which are stored in the memory of the electronic device.
[0116] In this embodiment, the functions of each module / unit are as follows:
[0117] The entity definition module 101 is used to obtain the text to be extracted, and obtain the predefined entity reference item set and real entity relationship in the text to be extracted.
[0118] In an embodiment of the present invention, the text to be extracted is the text from which entity relationships are to be extracted, and the specific content of the text can be determined based on actual business scenarios. For example, the text to be extracted can include transaction information between various financial products and investment status of various financial products.
[0119] In an embodiment of the present invention, the entity reference item set refers to the set of all entities in the text to be extracted, primarily manifested in the fact that the same entity may have different entity reference items in the text. For example, in the insurance field, if a policyholder A purchases critical illness insurance, the entity reference item for policyholder A may be the insurance claimant or the insurance beneficiary. Alternatively, the same entity reference item may refer to different entities in different contexts. For example, the critical illness insurance in the entity reference item may refer to a consumption-based critical illness insurance or a savings-based critical illness insurance.
[0120] In an embodiment of the present invention, the real entity relationship refers to the real relationship between entity referents in the text to be extracted. For example, if there are two entities in the target entity set, namely investor a and financial product B, then the entity relationship between investor a and financial product B can be an investment relationship.
[0121] The entity definition module 101 may also be used to:
[0122] Before obtaining the predefined entity reference item set and real entity relationship in the text to be extracted, defining the entity type in the text to be extracted, and annotating the text to be extracted according to the entity type to obtain the entity reference item set;
[0123] The relationship types between the entity-referring item sets are defined, and the entity-referring item sets are labeled according to the relationship types to obtain the real entity relationships.
[0124] In one embodiment of the present invention, the entity type in the text to be extracted can be defined by a naming recognition algorithm, and the text to be extracted can be labeled according to the entity type to obtain the entity reference item set; the relationship type refers to the association between entity reference items, for example, there is an insurance underwriting relationship between the two entities of insurance name and policyholder.
[0125] Specifically, the entity type may be a financial product name, an investor's name, an investor's contact number, etc.; by marking the text to be extracted according to the entity type, the type of the entity reference item set may be determined.
[0126] Furthermore, annotation can be performed using a preset annotation tool (such as the Bart annotation tool).
[0127] The entity disambiguation module 102 is used to select a candidate entity set corresponding to the entity reference item set from the text to be extracted, perform entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and perform key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted.
[0128] In the embodiment of the present invention, the candidate entity set refers to a set of entities with the same name as the entity referent in the text to be extracted; the target entity set refers to a set of all entities after removing text noise entities.
[0129] In one embodiment of the present invention, since the same entity has different entity reference items in the text to be extracted, and the same entity reference item can refer to different entities in different contexts, a candidate entity set corresponding to the entity reference item set is selected from the text to be extracted, and the candidate entity set is subjected to entity disambiguation to obtain a disambiguated entity set. The true entity corresponding to the entity reference item set can be determined, and entity noise irrelevant to the true entity can be removed. The disambiguated entity set is subjected to key component extraction to obtain the target entity set of the text to be extracted. Some irrelevant entity components can be removed, thereby improving the accuracy of subsequent entity relationship extraction.
[0130] As an embodiment of the present invention, the step of selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted includes:
[0131] Select text entities with the same name as each entity reference item in the entity reference item set from the text to be extracted as the initial candidate entity set; determine whether the number of initial candidate entity sets corresponding to each entity reference item reaches a preset threshold; when the number of initial candidate entity sets corresponding to the entity reference item does not reach the preset threshold, use the initial candidate entity set as the candidate entity set of the entity reference item; when the number of initial candidate entity sets corresponding to the entity reference item reaches the preset threshold, calculate the semantic similarity between the entity reference item and the initial candidate entity set, and select the initial candidate entities in the initial candidate entity set that are equal to the preset threshold number as the candidate entity set of the entity reference item according to the semantic similarity from high to low.
[0132] In the candidate entity set selection process, if there is no text entity with the same name in the text to be extracted, the corresponding entity reference item is classified as an empty entity; if there is a unique text entity with the same name corresponding to the entity reference item in the text to be extracted, the text entity with the same name is directly used as a candidate entity; further, the entity reference item set can be represented as M = {m1, m2, ..., mn}, and n represents the number of entity reference items in the text to be extracted. By selecting entities with the same name as the entity reference items, the initial candidate entity set can be obtained as E = {e1, e2, ..., es}, and s represents the number of candidate entities.
[0133] In one embodiment of the present invention, in order to avoid the impact of too many candidate entities on the efficiency of entity disambiguation, a preset threshold of k candidate entities can be selected as the candidate entity set. When the number of candidate entities is less than or equal to k, all candidate entities corresponding to the entity reference term are selected as its candidate entity set; when the number of candidate entities is greater than k, the semantic similarity between the entity reference term and the initial candidate entity set can be calculated, and the candidate entity set corresponding to the entity reference term can be obtained based on the semantic similarity.
[0134] Specifically, the semantic similarity between the entity referent and the initial candidate entity set can be calculated using the following formula:
[0135]
[0136] Among them, contextsim(m,es) represents semantic similarity; m represents the entity referent; ei represents the i-th candidate entity; X represents the word vector of the context of entity referent m; Y represents the word vector of candidate entity ei; X·Y represents the vector inner product; ||X|| represents the length of the word vector of the context of entity referent m; ||Y|| represents the length of the word vector of candidate entity ei.
[0137] As an embodiment of the present invention, the entity disambiguation module 102 performs entity disambiguation on the candidate entity set to obtain a disambiguated entity set by performing the following operations, including:
[0138] Calculating the entity influence of each candidate entity in the candidate entity set in the corresponding entity referent;
[0139] The candidate entities whose importance is greater than a preset value are selected from the entity influence degrees as the target candidate entity set corresponding to the entity reference item set, and the remaining candidate entity sets corresponding to the entity reference item set are removed to obtain the disambiguated entity set.
[0140] The entity influence of each candidate entity in the candidate entity set in the corresponding entity referent can be calculated by the following formula:
[0141]
[0142] Among them, P(e i ) represents the e i The entity influence degree of candidate entities; N represents the number of candidate entities; d represents the damping factor; M(e i ) indicates that i The set of other candidate entities connected to the candidate entity; N(e j ) indicates that j The set of other candidate entities connected to the candidate entity; P(e j )ej The entity influence degree of each candidate entity; W(e j ,e i ) means e i With e j The weight between candidate entities; W(e j ,e p ) means e j With e p The weights between candidate entities.
[0143] In an embodiment of the present invention, the preset value may be 0.8.
[0144] Furthermore, extracting key components from the disambiguation entity set to obtain the target entity set of the text to be extracted includes:
[0145] The parts of speech of the disambiguation entity set are identified, and useless words in the disambiguation entity set are removed according to the parts of speech to obtain the target entity set.
[0146] Among them, the parts of speech include nouns, verbs, adjectives and adverbs, etc., and the parts of speech of the disambiguated entity set can be identified by the Hanlp tool; further, the identified adjectives, adverbs and other modifiers can be removed to obtain the target entity set.
[0147] The entity encoding module 103 is used to obtain the multiple choice entity relationships of the real entity relationships in the document, and use the attention layer in the preset entity relationship extraction model to encode the target entity set and the multiple choice entity relationships to obtain an entity feature vector set.
[0148] In the embodiment of the present invention, the entity feature vector set refers to a set including target entity set features and multiple-choice entity relationship features.
[0149] In an embodiment of the present invention, the preset entity relationship extraction model is a matching network based on meta-learning and integrated with the self-attention mechanism. Through this model, the entity relationship extraction task can be transformed into a multi-selection matching network based on meta-learning, thereby reducing the error in data annotation when there is little sample data annotation, and training a more accurate entity relationship extraction model.
[0150] The embodiment of the present invention uses the attention layer in the preset entity relationship extraction model to encode the target entity set and the multiple-choice entity relationship, so as to accurately extract the features of the target entity set and the multiple-choice entity relationship.
[0151] In one embodiment of the present invention, the multiple choice entity relationships of the real entity relationship can be obtained by directly connecting the relationship names in the real entity relationship using separators to obtain the multiple choice entity relationship corresponding to each real entity relationship.
[0152] Specifically, a multi-choice entity relationship can be expressed as follows: [C]rel 1[C]rel 2···[C]rel N, where [C] represents a separator and rel1, rel2, and relN represent the names of the connected relationships. For example, a target relationship extraction task contains three new relationships: Entity-Destination(e1,e2), Component-Whole(e1,e2), and Cause-Effect(e2,e1). The relationship descriptions can be connected together to form a multi-choice entity relationship "[C]Entity-Destination(e1,e2)[C]Component-Whole(e1,e2)[C]Cause-Effect(e2,e1)."
[0153] As an embodiment of the present invention, the entity encoding module 103 encodes the target entity set and multiple choice entity relationships using the attention layer in the preset entity relationship extraction model by performing the following operations to obtain an entity feature vector set, including:
[0154] Using the attention layer to vectorize the target entity set and the multiple choice entity relationships respectively to obtain a target entity vector set and a multiple entity relationship vector set, wherein the attention layer includes a spatial attention mechanism and a channel attention mechanism;
[0155] The head entity vector set and the tail entity vector set of the target entity vector set are labeled, and the head entity vector set, the tail entity vector set and the multiple entity relationship vector sets are feature-encoded in parallel using the spatial attention mechanism and the channel attention mechanism to obtain the entity feature vector set.
[0156] Among them, the spatial attention mechanism is composed of a convolution module and a residual connection module. The spatial attention mechanism can effectively extract the position description of the target entity vector set; the channel attention mechanism is composed of a convolution layer and a pooling layer. The channel attention mechanism can obtain the learning content of the target entity vector set. In the parallel process of the spatial attention mechanism and the channel attention mechanism, sufficient feature information can be obtained in limited sample data, thereby improving the accuracy of feature encoding.
[0157] The entity relationship matching module 104 is configured to match the entity feature vector set with each entity relationship in the multiple-choice entity relationship using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set.
[0158] In the embodiment of the present invention, the main function of the entity relationship matching layer is to find the entity relationship corresponding to the target entity vector set from the multiple choice entity relationships. The predicted entity relationship is the entity relationship of the target entity set predicted according to the preset relationship extraction model.
[0159] The embodiment of the present invention uses the entity relationship matching layer of the entity relationship extraction model to match the entity feature vector set with each entity relationship in the multiple-choice entity relationship to obtain a predicted entity relationship that matches the entity feature vector set. The entity relationship extraction task can be converted into a multi-choice matching network based on meta-learning. In the case of a small number of training samples, the entity relationship that best matches the entity feature vector set is selected as the predicted entity relationship to improve the accuracy of subsequent entity relationship extraction.
[0160] As an embodiment of the present invention, the entity relationship matching module 104 matches the entity feature vector set with each entity relationship in the multiple choice entity relationships using the entity relationship matching layer of the entity relationship extraction model by performing the following operations to obtain a predicted entity relationship that matches the entity feature vector set, including:
[0161] Utilizing the entity relationship matching layer to obtain each entity relationship in the multiple choice entity relationships corresponding to the sentence vector instance in the entity feature vector set;
[0162] Calculating the Euclidean distance between each of the sentence vector instances and each of the entity relationships to obtain multiple entity relationship matching results between the sentence vector instances and the entity relationships;
[0163] An entity relationship matching result with the highest similarity is selected from the plurality of entity relationship matching results as the predicted entity relationship of the entity feature vector set.
[0164] Among them, each entity relationship can be represented by the hidden state of the separator, that is, in, represents the i-th entity relationship, The hidden state can be used to linearly divide different types of entity relationships, thereby improving the accuracy of subsequent matching.
[0165] The sentence vector instance can be expressed as: Among them, X represents the sentence vector instance, Indicates the entity relationship corresponding to the e1 entity, Indicates the entity relationship corresponding to the e2 entity, h [p] It represents the entity relationship between the sentence p corresponding to e1 and e2, and avg refers to the average of the hidden states of [e1], [e2] and [p].
[0166] In one embodiment of the present invention, the Euclidean distance can be calculated using the following formula:
[0167]
[0168] Among them, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X, where X represents the sentence vector instance. Equivalent to y i Represents the i-th entity relationship, D(X,y i ) represents the Euclidean distance between the sentence vector instance and the i-th instance, y j represents the j-th entity relationship, and N represents the number of entity relationships j.
[0169] Furthermore, the entity relationship matching result with the highest similarity can be selected from the multiple entity relationship matching results using the following formula:
[0170]
[0171] in, Indicates the entity relationship matching result with the highest similarity, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X, X represents the sentence vector instance, y i Represents the i-th entity relationship.
[0172] The entity training module 105 is used to calculate the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjust the parameters of the entity relationship extraction model according to the loss value until the loss value meets the preset conditions, thereby obtaining a trained entity relationship extraction model.
[0173] In an embodiment of the present invention, the preset condition may be set according to an actual model training scenario. For example, the preset condition may be that the loss value is less than a preset threshold.
[0174] In one embodiment of the present invention, the loss value between the predicted entity relationship and the actual entity relationship can be calculated using the following loss function:
[0175]
[0176] Among them, L(x,y) represents the loss value, N represents the number of entity relations i, X represents the sentence vector instance, and y i Represents the i-th entity relationship, δ represents the Kronecker function, if but otherwise Indicates the entity relationship matching result with the highest similarity, P(y i |X) represents the matching result of the i-th instance relationship corresponding to the sentence vector instance X.
[0177] In an optional embodiment of the present invention, when the loss value is less than a preset threshold, a trained entity relationship extraction model is obtained; when the loss value is not less than the preset threshold, the model parameters are adjusted by a random descent gradient algorithm until the loss value is less than the preset threshold, thereby obtaining a trained entity relationship extraction model.
[0178] The entity relationship extraction module 106 is used to extract entity relationships from the text to be extracted using the trained entity relationship extraction model to obtain an entity relationship extraction result of the text to be extracted.
[0179] In an embodiment of the present invention, the trained entity relationship extraction model can locate the start and end positions of the entity from the text to be extracted, and extract entity relationships from the text to be extracted to obtain an entity relationship extraction result of an entity-entity relationship-entity triple structure.
[0180] In an embodiment of the present invention, first, by selecting a candidate entity set corresponding to the entity reference item set from the text to be extracted, the candidate entity set is subjected to entity disambiguation to obtain a disambiguated entity set, thereby determining the true entity corresponding to the entity reference item set, removing entity noise irrelevant to the true entity, and extracting key components from the disambiguated entity set to obtain a target entity set, thereby removing some irrelevant entity components and improving the accuracy of subsequent entity relationship extraction; secondly, by training an entity relationship extraction model, the entity relationship extraction task can be transformed into a multi-select matching network based on meta-learning, thereby achieving the goal of reducing data labeling errors and training a target entity set of an entity relationship extraction model with higher accuracy in the case of few sample data annotations; finally, the trained entity relationship extraction model is used to perform entity relationship extraction on the text to be extracted to obtain an entity relationship extraction result, thereby improving the accuracy of entity relationship extraction. Therefore, the entity relationship extraction device proposed in an embodiment of the present invention can improve the accuracy of entity relationship extraction.
[0181] like Figure 5 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the entity relationship extraction method of the present invention.
[0182] The electronic device may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as an entity relationship extraction program.
[0183] Wherein, the memory 11 includes at least one type of medium, and the medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example: SD or DX memory, etc.), a magnetic memory, a local disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the memory 11 can also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the entity relationship extraction program, etc., but can also be used to temporarily store data that has been output or is to be output.
[0184] In some embodiments, the processor 10 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The processor 10 is the control core (Control Unit) of the electronic device, connecting the various components of the entire electronic device using various interfaces and lines, and executing programs or modules (such as entity relationship extraction programs) stored in the memory 11, as well as calling data stored in the memory 11, to perform various functions of the electronic device and process data.
[0185] The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Such a bus may be classified as an address bus, a data bus, a control bus, etc. The communication bus 12 is configured to enable communication between the memory 11 and at least one processor 10. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0186] Figure 5 Only the electronic device with components is shown, and it can be understood by those skilled in the art that Figure 5The structure shown does not limit the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0187] For example, although not shown, the electronic device may further include a power source (such as a battery) for powering various components. Preferably, the power source may be logically connected to the at least one processor 10 via a power management device, thereby implementing functions such as charge management, discharge management, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The electronic device may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0188] Optionally, the communication interface 13 may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices.
[0189] Optionally, the communication interface 13 may further include a user interface, which may be a display or an input unit (such as a keyboard). Optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0190] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0191] The entity relationship extraction program stored in the memory 11 of the electronic device is a combination of multiple computer programs. When running in the processor 10, it can achieve the following:
[0192] Obtaining the text to be extracted, and obtaining the entity reference item set and real entity relationship predefined in the text to be extracted;
[0193] Selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and performing key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted;
[0194] Obtaining multiple choice entity relationships of the real entity relationship, and encoding the target entity set and the multiple choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set;
[0195] Matching the entity feature vector set with each entity relationship in the multiple-choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set;
[0196] Calculating the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjusting the parameters of the entity relationship extraction model according to the loss value until the loss value meets a preset condition, thereby obtaining a trained entity relationship extraction model;
[0197] The trained entity relationship extraction model is used to extract entity relationships from the text to be extracted, thereby obtaining an entity relationship extraction result for the text to be extracted.
[0198] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0199] Furthermore, if the module / unit integrated into the electronic device is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0200] An embodiment of the present invention may further provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor of an electronic device, the computer program may implement:
[0201] Obtaining the text to be extracted, and obtaining the entity reference item set and real entity relationship predefined in the text to be extracted;
[0202] Selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and performing key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted;
[0203] Obtaining multiple choice entity relationships of the real entity relationship, and encoding the target entity set and the multiple choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set;
[0204] Matching the entity feature vector set with each entity relationship in the multiple-choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set;
[0205] Calculating the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjusting the parameters of the entity relationship extraction model according to the loss value until the loss value meets a preset condition, thereby obtaining a trained entity relationship extraction model;
[0206] The trained entity relationship extraction model is used to extract entity relationships from the text to be extracted, thereby obtaining an entity relationship extraction result for the text to be extracted.
[0207] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0208] In the several embodiments provided herein, it should be understood that the disclosed media, devices, apparatuses, and methods may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the module division is merely a logical functional division, and actual implementation may employ other division methods.
[0209] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0210] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.
[0211] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0212] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0213] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0214] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. Second-order terms are used to indicate names and do not imply any particular order.
[0215] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. 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 solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for extracting entity relationships, characterized in that: The method comprises: Obtaining the text to be extracted, and obtaining the entity reference item set and real entity relationship predefined in the text to be extracted; Selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted, performing entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and performing key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted; Obtaining multiple choice entity relationships of the real entity relationship, and encoding the target entity set and the multiple choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set; Matching the entity feature vector set with each entity relationship in the multiple-choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set; Calculating the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjusting the parameters of the entity relationship extraction model according to the loss value until the loss value meets a preset condition, thereby obtaining a trained entity relationship extraction model; Performing entity relationship extraction on the text to be extracted using the trained entity relationship extraction model to obtain an entity relationship extraction result of the text to be extracted; The performing entity disambiguation on the candidate entity set to obtain the disambiguated entity set includes: calculating the entity influence degree of each candidate entity in the candidate entity set in the corresponding entity reference item, selecting candidate entities with an importance greater than a preset value from the entity influence degrees as the target candidate entity set corresponding to the entity reference item set, and removing the remaining candidate entities corresponding to the entity reference item set to obtain the disambiguated entity set; The target entity set and multiple choice entity relationships are encoded using the attention layer in the preset entity relationship extraction model to obtain an entity feature vector set, including: Using the attention layer to vectorize the target entity set and the multiple choice entity relationships respectively to obtain a target entity vector set and a multiple entity relationship vector set, wherein the attention layer includes a spatial attention mechanism and a channel attention mechanism; The head entity vector set and the tail entity vector set of the target entity vector set are labeled, and the head entity vector set, the tail entity vector set and the multiple entity relationship vector sets are feature-encoded in parallel using the spatial attention mechanism and the channel attention mechanism to obtain the entity feature vector set.
2. The entity relationship extraction method according to claim 1, characterized in that: The method of using the entity relationship matching layer of the entity relationship extraction model to match the entity feature vector set with each entity relationship in the multiple choice entity relationships to obtain a predicted entity relationship that matches the entity feature vector set includes: Utilizing the entity relationship matching layer to obtain each entity relationship in the multiple choice entity relationships corresponding to the sentence vector instance in the entity feature vector set; Calculating the Euclidean distance between each of the sentence vector instances and each of the entity relationships to obtain multiple entity relationship matching results between the sentence vector instances and the entity relationships; An entity relationship matching result with the highest similarity is selected from the plurality of entity relationship matching results as the predicted entity relationship of the entity feature vector set.
3. The entity relationship extraction method according to claim 1, wherein: The step of selecting a candidate entity set corresponding to the entity referent item set from the text to be extracted includes: Selecting text entities with the same name as each entity reference item in the entity reference item set from the text to be extracted as an initial candidate entity set; Determining whether the number of initial candidate entity sets corresponding to each of the entity referents reaches a preset threshold; When the number of initial candidate entity sets corresponding to the entity referent term does not reach a preset threshold, the initial candidate entity set is used as a candidate entity set for the entity referent term; When the number of initial candidate entity sets corresponding to the entity reference term reaches a preset threshold, the semantic similarity between the entity reference term and the initial candidate entity set is calculated, and the initial candidate entities in the initial candidate entity set that are equal to the preset threshold number are selected from high to low according to the semantic similarity as the candidate entity set of the entity reference term.
4. The entity relationship extraction method according to any one of claims 1 to 3, characterized in that: The step of extracting key components from the disambiguation entity set to obtain a target entity set for the text to be extracted includes: The parts of speech of the disambiguation entity set are identified, and useless words in the disambiguation entity set are removed according to the parts of speech to obtain the target entity set.
5. The entity relationship extraction method according to any one of claims 1 to 3, characterized in that: Before obtaining the predefined entity reference item set and real entity relationship in the text to be extracted, the method further includes: Defining entity types in the text to be extracted, and labeling the text to be extracted according to the entity types to obtain the entity reference item set; The relationship types between the entity reference item sets are defined, and the entity reference item sets are labeled according to the relationship types to obtain the text entity relationships.
6. An entity relationship extraction device, used to implement the entity relationship extraction method according to any one of claims 1 to 5, characterized in that: The device comprises: An entity definition module is used to obtain the text to be extracted, and obtain the predefined entity reference item set and real entity relationship in the text to be extracted; An entity disambiguation module is used to select a candidate entity set corresponding to the entity referent item set from the text to be extracted, perform entity disambiguation on the candidate entity set to obtain a disambiguated entity set, and perform key component extraction on the disambiguated entity set to obtain a target entity set of the text to be extracted; An entity encoding module, configured to obtain multiple-choice entity relationships of the real entity relationship, and encode the target entity set and the multiple-choice entity relationships using an attention layer in a preset entity relationship extraction model to obtain an entity feature vector set; An entity relationship matching module, configured to match the entity feature vector set with each entity relationship in the multiple choice entity relationships using the entity relationship matching layer of the entity relationship extraction model to obtain a predicted entity relationship that matches the entity feature vector set; An entity training module is used to calculate the loss value between the predicted entity relationship and the real entity relationship using the loss function of the entity relationship extraction model, and adjust the parameters of the entity relationship extraction model according to the loss value until the loss value meets the preset conditions, thereby obtaining a trained entity relationship extraction model; The entity relationship extraction module is used to use the trained entity relationship extraction model to extract entity relationships from the text to be extracted, and obtain the entity relationship extraction result of the text to be extracted.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the entity relationship extraction method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the entity relationship extraction method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Open relationship extraction method and device, electronic equipment and storage medium
CN113051356A