Entity Relationship Joint Extraction Method and Electronic Device
By combining the target text and external knowledge information, using the sentence dependence analysis tree and graph attention neural network generation model to predict and screen entity relationship triplets, the problem of inaccurate entity relationship extraction in the existing technology is solved, and a more accurate and comprehensive entity relationship extraction effect is achieved.
Patent Information
- Application Number
- CN202111509942.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-12-10
AI Technical Summary
The existing joint extraction method of entity relationships fails to fully consider the correlation information between entities, resulting in inaccurate results of entity relationship extraction.
By combining the target text and external knowledge information, using the sentence dependency analysis tree and graph attention neural network generation model, the potential triplets are predicted, and the global subject-object entity generation model is used to filter out the final entity relationship triplets.
It improves the accuracy of the results of entity relationship extraction, effectively solves problems such as error accumulation, redundant entities and overlapping relationships, and ensures the comprehensiveness of the extracted entity relationship triple information.
Smart Images

Figure CN114357179B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to natural language processing technology, and particularly to an entity relationship joint extraction method and an electronic device. Background Art
[0002] Entity relationship extraction is to automatically extract the relationship between the main entity and the guest entity from unstructured text. Here, the unstructured text is composed of some specific units. The specific units here are, for example, sentences, paragraphs, chapters, etc., or some small units such as characters, words, phrases, etc.
[0003] Currently, the commonly used entity relationship joint extraction methods often only focus on the similarity between the glyph features of Chinese characters, and do not fully consider the association information between entities, resulting in inaccurate entity relationship extraction results. Summary of the Invention
[0004] The present application provides an entity relationship joint extraction method and an electronic device to improve the accuracy of entity relationship extraction results.
[0005] An embodiment of the present application provides an entity relationship joint extraction method, which is applied to an electronic device and includes:
[0006] Determine a first feature vector according to the target text and external knowledge information; the external knowledge information is information obtained from a configured knowledge base that matches the target text; the first feature vector is obtained by fusing the feature information of the target text and the external knowledge information;
[0007] Convert the sentence dependency analysis tree obtained based on the target text into an adjacency matrix, and input the adjacency matrix and the encoder output result into a graph attention neural network to obtain a second feature vector; the sentence dependency analysis tree is used to represent the sentence structure of the target text, and the encoder output result is obtained by encoding the input features, and the input features are determined according to the word segmentation result and part-of-speech recognition result of the target text;
[0008] Predict potential triples in the target text; each potential triple includes a potential relationship, a main entity and a guest entity corresponding to the potential relationship;
[0009] Based on the first feature vector and the second feature vector and through a trained global main and guest entity pair constraint matrix generation model, predict the global main and guest entity pair constraint matrix corresponding to the target text; the global main and guest entity pair constraint matrix represents the corresponding relationship between the main entity and the guest entity in the target text;
[0010] Use the global main and guest entity pair constraint matrix to extract target triples from the potential triples.
[0011] An embodiment of the present application further provides an electronic device. The electronic device includes: a processor and a machine-readable storage medium;
[0012] The machine-readable storage medium stores machine-executable instructions that can be executed by the processor;
[0013] The processor is used to execute the machine-executable instructions to implement the steps of the method disclosed above.
[0014] It can be seen from the above technical solutions that in this embodiment, when extracting entity relationships from the target text, it is necessary to rely on the sentence dependency parsing tree for reflecting the association information between entities, and after predicting the potential triples in the target text, based on the sentence dependency parsing tree and the global subject-object entity pair constraint matrix generation model, the potential triples are screened to filter out redundant triples, so as to obtain the final true entity relationship triple information, which improves the accuracy of the entity relationship extraction result and effectively solves problems such as error accumulation, redundant entities, and overlapping relationships;
[0015] Furthermore, in this embodiment, when extracting entity relationships from the target text, it is necessary to combine the target text with external knowledge information that matches the target text, which can ensure that comprehensive entity relationship triple information is extracted;
[0016] Furthermore, in this embodiment, when extracting entity relationships from the target text, it also relies on external knowledge information, sentence structure information, and part-of-speech information, which can effectively reduce the problem of difficult recognition of Chinese word segmentation boundaries. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.
[0018] Figure 1 It is a flowchart of the method provided by the embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of the first feature vector provided by the embodiment of the present application;
[0020] Figure 3 It is a schematic diagram of the sentence dependency parsing tree structure provided by the embodiment of the present application;
[0021] Figure 4 It is a schematic diagram of the feature vector provided by the embodiment of the present application;
[0022] Figure 5 It is a schematic diagram of the feature sequence of the target text provided by the embodiment of the present application;
[0023] Figure 6Schematic diagram of the global host-guest entity pair constraint matrix structure provided by an embodiment of the present application;
[0024] Figure 7 Schematic diagram of the global host-guest entity pair constraint matrix provided by an embodiment of the present application;
[0025] Figure 8 Structural diagram of the device provided by an embodiment of the present application;
[0026] Figure 9 Structural diagram of the electronic device provided by an embodiment of the present application. Detailed implementation manners
[0027] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0028] The terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms "a", "the", and "said" used in the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0029] The entity relationship joint extraction method provided in this embodiment also needs to combine external knowledge information when extracting entity relationships from unstructured text to achieve the extraction of comprehensive entity relationship triples from unstructured text and improve the accuracy of entity relationship extraction. To enable those skilled in the art to better understand the technical solutions provided in the embodiments of the present application and make the above objects, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0030] See Figure 1 , Figure 1 , which is the flowchart of the method provided by an embodiment of the present application. This method is applied to an electronic device. In this embodiment, the electronic device here can be a front-end business device such as a PC or the like, or a back-end server, etc., and this embodiment does not specifically limit it.
[0031] As Figure 1 shown, the process may include the following steps:
[0032] Step 101, determine the first feature vector according to the target text and external knowledge information.
[0033] In this embodiment, the target text is the text for which entity relationship extraction is to be performed, and it can be unstructured text. Optionally, the unstructured text can be, for example, Chinese text other than some structures such as charts.
[0034] In this embodiment, the above external knowledge information is the information obtained from the configured knowledge base that matches the target text. As an embodiment, the external knowledge information can be obtained through the following steps:
[0035] Step a1, traverse each character in the target text in sequence, determine the traversed character as the current character, match the words containing the current character in the configured knowledge base, and determine the words containing the current character in the knowledge base as the matching words corresponding to the current character; if the current character is not the last character in the target text, continue to traverse each character in the target text in sequence, and return to the step of determining the traversed character as the current character.
[0036] Optionally, in this embodiment, the words containing the current character matched in the configured knowledge base can be: starting from the current character, find the words with the current character as the word head in the configured knowledge base, and determine the words with the current character as the word head in the knowledge base as the above words containing the current character.
[0037] Step a2, determine the matching words corresponding to each character in the target text as the external knowledge information.
[0038] Taking the target text "Nanjing Yangtze River Bridge" as an example, by sequentially matching the characters in the target text according to the above steps a1 to a2, related words such as "Nanjing", "Nanjing City", "Mayor", "Yangtze River", "Yangtze River Bridge", "Bridge" can be matched, and these related words can be determined as the external knowledge information of the target text. It should be noted that here is just an example for easy understanding to describe the external knowledge information. Optionally, in this embodiment, these related words are represented in the form of word vectors.
[0039] After obtaining the external knowledge information of the target text, as described in step 101, the first feature vector can be determined based on the target text and the external knowledge information.
[0040] Optionally, as an embodiment, the first feature vector can be determined through the following steps:
[0041] Step b1, splice the external knowledge information in sequence at the specified position of the target text to obtain a reference text.
[0042] As an embodiment, the specified position here can be set according to actual needs. For example, it can be set at the end of the target text, or at the beginning of the target text, etc. This embodiment does not specifically limit it.
[0043] Step b2: Use a model based on the self-attention mechanism (Transformer) as the encoder to encode the reference text to obtain an encoded feature vector.
[0044] The Transformer model includes layers (Layer) of the self-attention mechanism (Self-Attention). In the embodiments of the present application, the structure of the Transformer model itself is not improved. Instead, the existing Transformer model is used for encoding in this embodiment.
[0045] Step b3: Clip the encoded feature vector in a masked (mask) manner to obtain a first feature vector.
[0046] Optionally, in this embodiment, the length of the first feature vector matches the length of the target text. For example, the length of the first feature vector is equal to the length of the target text.
[0047] Still taking the target text "Nanjing Yangtze River Bridge" as an example, as described above, by sequentially matching the characters in the target text according to the above steps a1 to a2, relevant words such as "Nanjing", "Nanjing City", "Mayor", "Yangtze River", "Yangtze River Bridge", "Bridge" can be matched. Then, assuming the above specified position is behind the target text, Figure 2 An example is given to show how to obtain the first feature vector. From Figure 2 It can also be seen that the first feature vector contains the feature information of the introduced external knowledge information, which is helpful for extracting comprehensive entity relationships in the follow-up. See the following description for details, and it will not be elaborated here for the time being.
[0048] It should be noted that the above first feature vector is only named for convenience of description and is not used for limitation. After obtaining the first feature vector, the following step 102 is executed.
[0049] Step 102: Convert the sentence dependency parsing tree obtained based on the target text into an adjacency matrix, and input the adjacency matrix and the encoded output result into a graph attention neural network to obtain a second feature vector; the encoded output result is obtained by encoding the input features, and the input features are determined according to the word segmentation result and the part-of-speech recognition result of the target text.
[0050] In this embodiment, natural language processing tools such as NLTK, Stanford-parser, and natural language processing tool LTP can be used to perform word segmentation and part-of-speech recognition on the target text to obtain the word segmentation result and the part-of-speech recognition result. Here, the part-of-speech recognition mainly recognizes nouns, verbs, etc. Correspondingly, the part-of-speech recognition result may include the recognized parts of speech such as nouns and verbs.
[0051] Optionally, in this embodiment, the above-mentioned sentence dependency analysis tree can be extracted from the word segmentation result through natural language processing tools such as NLTK, Stanford-parser, and natural language processing tool LTP. The sentence dependency analysis tree here represents the sentence structure information in the target text. Taking the target text "The leading actor in the movie 'X Movie' is Wu X, and the leading actor in the movie 'XX Movie' is Zhou X" as an example, the sentence dependency analysis tree extracted from the word segmentation result through natural language processing tools is as Figure 3 shown. Through Figure 3 the sentence dependency analysis tree shown, it can be seen that the sentence dependency analysis tree reflects the sentence structure information in the target text.
[0052] After obtaining the above-mentioned sentence dependency analysis tree, the sentence dependency analysis tree can be converted into an adjacency matrix. This embodiment does not specifically limit how to convert the sentence dependency analysis tree into an adjacency matrix, and there are many implementation forms. For example, the existing method of converting one-dimensional data into two-dimensional or multi-dimensional data can be used to convert the sentence dependency analysis tree into an adjacency matrix, and this embodiment does not specifically limit.
[0053] In this embodiment, the above input features at least include: the word segmentation vector corresponding to the word segmentation result obtained by performing word segmentation processing on the target text, and the part-of-speech vector corresponding to the part-of-speech recognition result obtained by performing part-of-speech recognition on the target text. Optionally, in an example, the word segmentation vector and the part-of-speech vector can be concatenated to form the above input features. After determining the above input features, the above input features can be input into the Encoder layer to obtain an output result. In this embodiment, the Encoder encoding layer can adopt traditional neural networks such as Transformer, bert, or LSTM, and this embodiment does not specifically limit.
[0054] As described in step 102, the above adjacency matrix and the encoding output result are input into the graph attention neural network, and finally a second feature vector containing sentence structure information will be obtained. Here, the graph attention neural network is trained in the form of a multi-head attention mechanism. The multi-head attention mechanism can learn more comprehensive sentence structure information from multiple different dimensions, and can improve the model's ability to self-learn sentence structure information, and can effectively reduce the impact brought by the recognition errors of natural language processing tools.
[0055] Step 103, predicting potential triples in the target text; each potential triple includes a potential relationship, a main entity corresponding to the potential relationship, and an object entity.
[0056] Optionally, in this embodiment, predicting potential triples in the target text is a two-stage prediction task. First, a multi-label binary classification task is used to predict as much as possible the relationships (potential relationships) that may exist in the target text to predict the potential relationships in the target text. Then, for each possible potential relationship, the main entity and the guest entity are identified to obtain the potential triples in the target text.
[0057] Taking the target text "The leading actor of 'Movie X' is Wu X, and the leading actor of 'Movie XX' is Zhou X" as an example, the potential triples that can be predicted may include: (Movie X, leading actor, Wu X), (Movie X, leading actor, Zhou X), (Movie XX, leading actor, Zhou X), (Movie XX, leading actor, Wu X).
[0058] Step 104, based on the first feature vector and the second feature vector and through the trained global main and guest entity pair constraint matrix generation model, predict the global main and guest entity pair constraint matrix corresponding to the target text.
[0059] In this embodiment, the global main and guest entity pair constraint matrix represents the corresponding relationship between the main entity and the guest entity in the target text. The global main and guest entity pair constraint matrix will be described by examples below and will not be elaborated here for the time being.
[0060] Optionally, as an embodiment, in this step 104, based on the first feature vector and the second feature vector and through the trained global main and guest entity pair constraint matrix generation model, predicting the global main and guest entity pair constraint matrix corresponding to the target text may include:
[0061] Step d1, convert the second feature vector into a third feature vector having the same dimension as the first feature vector.
[0062] Step d2, splice the third feature vector and the first feature vector to obtain a fourth feature vector.
[0063] Taking the target text "The leading actor of 'Movie X' is Wu X" as an example, Figure 4 illustrates an example process of step d1 and step d2. In Figure 4 the word feature matrix shown is the second feature vector, and the first feature vector is relatively the character feature matrix.
[0064] Step d3, determine the feature sequence corresponding to the target text according to the fourth feature vector, and the feature sequence includes the combination of each character in the target text and all characters in the target text.
[0065] Optionally, in this embodiment, to ensure that the feature sequence includes the combination of each character in the target text and all characters in the target text, the length of the feature sequence may be N*(N + 1) / 2, where N is the length of the target text.
[0066] Still taking the target text "The leading actor of the movie 'X Movie' is Wu X" as an example, Figure 5 An example shows the feature sequence of the target text obtained based on Figure 4 the feature vector shown. It should be noted that Figure 5 describing the feature sequence in words is only for easy understanding.
[0067] Step d4: Input the feature sequence into the global subject-object entity pair constraint matrix generation model to predict the global subject-object entity pair constraint matrix corresponding to the target text.
[0068] In this embodiment, the global subject-object entity pair constraint matrix generation model supports M relationship labels, and different relationship labels correspond to different relationships.
[0069] Based on this, the above-mentioned global subject-object entity pair constraint matrix includes 1 + 2*M matrices. Among them, the 1 + 2*M matrices include 1 entity start-entity end matrix (EH_ET), and one subject entity start-object entity start matrix (SH_OH) and one subject entity end-object entity end matrix (ST_OT) corresponding to each relationship label.
[0070] In this embodiment, the entity start-entity end matrix includes two values, 0 and 1. When it is 1, it means that the word in the corresponding row is the first word of the entity, and the word in the corresponding column is the last word of the entity. When it is 0, it means that the word in the corresponding row is not the first word of the entity, and / or the word in the corresponding column is not the last word of the entity. The rows are arranged in a row-by-row manner for the words in the target text, and the columns are arranged in a column-by-column manner for the words in the target text.
[0071] In this embodiment, the subject entity start-object entity start matrix includes three values, 0, 1, and 2. When it is 1, it means that the word in the corresponding row is the first word of the subject entity, and the word in the corresponding column is the first word of the object entity. When it is 0, it means that the word in the corresponding row is not the first word of the subject entity, and / or the word in the corresponding column is not the first word of the object entity. When it is 2, it means the transition when the position with a value of 1 in the lower triangular region of the subject entity start-object entity start matrix is mapped from the lower triangular region to the upper triangular region;
[0072] In this embodiment, the subject entity end-object entity end matrix includes three values, 0, 1, and 2. When it is 1, it means that the word in the corresponding row is the last word of the subject entity, and the word in the corresponding column is the last word of the object entity. When it is 0, it means that the word in the corresponding row is not the last word of the subject entity, and / or the word in the corresponding column is not the last word of the object entity. When it is 2, it means the transition when the position with a value of 1 in the lower triangular region of the subject entity end-object entity end matrix is mapped from the lower triangular region to the upper triangular region.
[0073] Taking the target text as an example: "The leading actor of the movie 'X Movie' is Wu X, and the leading actor of the movie 'XX Movie' is Zhou X". Figure 6 The structures of the entity head - entity tail matrix, the main entity head - guest entity head matrix, and the main entity tail - guest entity tail matrix are illustrated by way of example. Of course, taking Figure 5 the characteristic sequence corresponding to the target text "The leading actor of the movie 'X Movie' is Wu X" shown as an example, Figure 7 the corresponding entity head - entity tail matrix, main entity head - guest entity head matrix, and main entity tail - guest entity tail matrix are illustrated by way of example.
[0074] Step 105, extracting target triples from the potential triples by using the global main - guest entity pair constraint matrix.
[0075] As described above, the potential triples are obtained by first predicting the potential relationship and then identifying the entity pairs (main entity and guest entity) corresponding to the potential relationship. In this way, when there are two or more main entities and guest entities corresponding to the same potential relationship in the target text, potential triples corresponding to different entity pairs will be extracted, so a large number of redundant potential triples will be generated. Based on this, in this embodiment, the global main - guest entity pair constraint matrix can be used to delete the potential triples to obtain the target triples. Optionally, in this embodiment, extracting target triples from the potential triples by using the global main - guest entity pair constraint matrix may include:
[0076] Step e1, decoding the global main - guest entity pair constraint matrix to obtain the main - guest entity correspondence corresponding to the target text.
[0077] Regarding the content represented by the values in each matrix in the above - mentioned global main - guest entity pair constraint matrix, such as the entity head - entity tail matrix, the main entity head - guest entity head matrix, and the main entity tail - guest entity tail matrix, each matrix in the global main - guest entity pair constraint matrix, such as the entity head - entity tail matrix, the main entity head - guest entity head matrix, and the main entity tail - guest entity tail matrix, can be decoded to obtain the main - guest entity correspondence corresponding to the target text.
[0078] Step e2, for each potential triple, checking whether there is a main - guest entity correspondence in the main - guest entity correspondence that contains the main entity and the guest entity in this potential triple. If so, determining this potential triple as the target triple.
[0079] Still taking the target text as an example: "The main actors of 'Movie X' are Wu X, and the main actors of 'Movie XX' are Zhou X". Suppose the potential triples include: (Movie X, main actor, Wu X), (Movie X, main actor, Zhou X), (Movie XX, main actor, Zhou X), and (Movie XX, main actor, Wu X). Based on decoding the global subject-object entity pair constraint matrix, the corresponding subject-object entity pair relationships of the target text obtained are: (Movie X, Wu X) and (Movie XX, Zhou X). Based on step e2, by using the subject-object entity pair relationships to prune the potential triples, (Movie X, main actor, Wu X) and (Movie XX, main actor, Zhou X) are obtained as the correct target triples.
[0080] So far, the Figure 1 shown process is completed.
[0081] Through the Figure 1 shown process, it can be seen that in the embodiment of the present application, when extracting entity relationships from the target text, it is necessary to rely on the sentence dependency parsing tree for reflecting the association information between entities, and after predicting the potential triples in the target text, based on the sentence dependency parsing tree and the global subject-object entity pair constraint matrix generation model, the potential triples are screened to filter out redundant triples and obtain the final true entity relationship triple information, which improves the accuracy of the entity relationship extraction result and effectively solves problems such as error accumulation, redundant entities, and overlapping relationships;
[0082] Furthermore, in this embodiment, when extracting entity relationships from the target text, it is necessary to combine the target text with external knowledge information that matches the target text, which can ensure that comprehensive entity relationship triple information is extracted;
[0083] Furthermore, in this embodiment, when extracting entity relationships from the target text, it also relies on external knowledge information, sentence structure information, and part-of-speech information, which can effectively reduce the problem of difficult recognition of Chinese word segmentation boundaries.
[0084] The method provided by the embodiment of the present application has been described above. Next, the device provided by the embodiment of the present application will be described:
[0085] Refer to Figure 8 , Figure 8 which is the device structure diagram provided by the embodiment of the present application. This device is applied to an electronic device and includes:
[0086] A determination unit, configured to determine a first feature vector according to the target text and external knowledge information; the external knowledge information is information obtained from a configured knowledge base that matches the target text; the first feature vector is obtained by fusing the feature information of the target text and the external knowledge information;
[0087] A processing unit, configured to convert a sentence dependency parsing tree obtained based on the target text into an adjacency matrix, and input the adjacency matrix and the encoding output result into a graph attention neural network to obtain a second feature vector; the sentence dependency parsing tree is used to represent the sentence structure of the target text, and the Encoder output result is obtained by encoding the input features, and the input features are determined according to the word segmentation result and the part-of-speech recognition result of the target text;
[0088] A prediction unit, configured to predict potential triples in the target text; each potential triple includes a potential relationship, a main entity and an object entity corresponding to the potential relationship; and,
[0089] Based on the first feature vector and the second feature vector, and through a trained global main-object entity pair constraint matrix generation model, predict a global main-object entity pair constraint matrix corresponding to the target text; the global main-object entity pair constraint matrix represents the corresponding relationship between the main entity and the object entity in the target text;
[0090] An extraction unit, configured to extract target triples from the potential triples by using the global main-object entity pair constraint matrix.
[0091] Optionally, the external knowledge information is obtained through the following steps:
[0092] Traverse each word in the target text in sequence, determine the traversed word as the current word, match the word containing the current word in the configured knowledge base, and determine the word containing the current word in the knowledge base as the matching word corresponding to the current word; if the current word is not the last word in the target text, continue to traverse each word in the target text in sequence, and return to the step of determining the traversed word as the current word,
[0093] Determine the matching words corresponding to each word in the target text as the external knowledge information.
[0094] Optionally, the determining unit determines the first feature vector according to the target text and the external knowledge information, including:
[0095] Concatenate the external knowledge information in sequence at the specified position of the target text to obtain a reference text;
[0096] Use a model Transformer based on the attention mechanism as an encoder to perform encoding processing on the reference text to obtain an encoded feature vector;
[0097] Crop the encoded feature vector in the form of a mask mask to obtain the first feature vector, and the length of the first feature vector matches the length of the target text.
[0098] Optionally, the input features at least include: the token vectors corresponding to the tokenization results obtained by tokenizing the target text, and the part-of-speech vectors corresponding to the part-of-speech recognition results obtained by performing part-of-speech recognition on the target text;
[0099] The sentence dependency analysis tree is obtained based on the tokenization results.
[0100] Optionally, the prediction unit predicts the potential triples in the target text, including:
[0101] Predicting the potential relationships in the target text by using the multi-label binary classification task;
[0102] For each potential relationship, at least one main entity and at least one object entity corresponding to the potential relationship are identified from the target text to obtain potential triples.
[0103] Optionally, the prediction unit predicts the global main-object entity pair constraint matrix corresponding to the target text based on the first feature vector and the second feature vector and through a trained global main-object entity pair constraint matrix generation model, including:
[0104] Converting the second feature vector into a third feature vector having the same dimension as the first feature vector;
[0105] Concatenating the third feature vector and the first feature vector to obtain a fourth feature vector;
[0106] Determining a feature sequence corresponding to the target text according to the fourth feature vector, where the feature sequence includes the combinations between each word in the target text and all words in the target text;
[0107] Inputting the feature sequence into the global main-object entity pair constraint matrix generation model to predict the global main-object entity pair constraint matrix corresponding to the target text.
[0108] Optionally, the length of the feature sequence is N*(N + 1) / 2, where N is the length of the target text.
[0109] Optionally, the global main-object entity pair constraint matrix generation model supports M relationship labels, and different relationship labels correspond to different relationships;
[0110] The global main-object entity pair constraint matrix includes 1 + 2*M matrices; among them, the 1 + 2*M matrices include 1 entity head-entity tail matrix, and one main entity head-object entity head matrix and one main entity tail-object entity tail matrix corresponding to each relationship label;
[0111] The entity start - entity end matrix includes two values, 0 and 1. When it is 1, it indicates that the word in the corresponding row is the first word of the entity, and the word in the corresponding column is the last word of the entity. When it is 0, it indicates that the word in the corresponding row is not the first word of the entity, and / or the word in the corresponding column is not the last word of the entity. The rows are arranged by arranging the words in the target text in a row - by - row manner, and the columns are arranged by arranging the words in the target text in a column - by - column manner;
[0112] The main entity start - guest entity start matrix includes three values, 0, 1, and 2. When it is 1, it indicates that the word in the corresponding row is the first word of the main entity, and the word in the corresponding column is the first word of the guest entity. When it is 0, it indicates that the word in the corresponding row is not the first word of the main entity, and / or the word in the corresponding column is not the first word of the guest entity. When it is 2, it indicates the transition when the positions with a value of 1 in the lower triangular region of the main entity start - guest entity start matrix are mapped from the lower triangular region to the upper triangular region;
[0113] The main entity end - guest entity end matrix includes three values, 0, 1, and 2. When it is 1, it indicates that the word in the corresponding row is the last word of the main entity, and the word in the corresponding column is the last word of the guest entity. When it is 0, it indicates that the word in the corresponding row is not the last word of the main entity, and / or the word in the corresponding column is not the last word of the guest entity. When it is 2, it indicates the transition when the positions with a value of 1 in the lower triangular region of the main entity end - guest entity end matrix are mapped from the lower triangular region to the upper triangular region.
[0114] Optionally, the extracting of the target triple from the potential triples by using the global main - guest entity pair constraint matrix includes:
[0115] Decoding the global main - guest entity pair constraint matrix to obtain the corresponding relationship between the main and guest entities of the target text;
[0116] For each potential triple, check whether there is a corresponding relationship between the main and guest entities in the corresponding relationship between the main and guest entities that contains the main entity and the guest entity in this potential triple. If so, determine this potential triple as the target triple.
[0117] Thus far, the Figure 8 structural description of the shown device is completed.
[0118] This embodiment of the present application also provides Figure 8 the hardware structure of the shown device. Refer to Figure 9 , Figure 9 which is the structural diagram of the electronic device provided by this embodiment of the present application. As shown in Figure 9As shown, the hardware structure may include: a processor and a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above examples of the present application.
[0119] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above examples of the present application can be implemented.
[0120] Exemplarily, the above machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof.
[0121] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any several of these devices.
[0122] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0123] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0124] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce means for implementing the functions specified in one or more of the flows Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0125] Furthermore, these computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means for implementing the functions specified in one or more of the flows Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0126] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0127] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. An entity relationship joint extraction method, characterized in that, the method is applied to an electronic device and includes: determining a first feature vector according to a target text and external knowledge information; the external knowledge information is information obtained from a configured knowledge base that matches the target text; the first feature vector is obtained by fusing the feature information of the target text and the external knowledge information; converting a sentence dependency analysis tree obtained based on the target text into an adjacency matrix, and inputting the adjacency matrix and an encoded output result into a graph attention neural network to obtain a second feature vector; the sentence dependency analysis tree is used to represent the sentence structure of the target text, the encoded output result is obtained by encoding input features, and the input features are determined according to the word segmentation result and part-of-speech recognition result of the target text; predicting potential triples in the target text; each potential triple includes a potential relationship, a main entity corresponding to the potential relationship, and an object entity; Predict a global subject-object entity pair constraint matrix corresponding to the target text based on the first feature vector and the second feature vector and through a trained global subject-object entity pair constraint matrix generation model; the global subject-object entity pair constraint matrix characterizes the corresponding relationship between the subject entity and the object entity in the target text; wherein, the global subject-object entity pair constraint matrix generation model supports M relationship labels, and different relationship labels correspond to different relationships; the global subject-object entity pair constraint matrix includes 1 + 2 * M matrices; wherein, the 1 + 2 * M matrices include 1 entity start-entity end matrix, and a subject entity start-object entity start matrix and a subject entity end-object entity end matrix corresponding to each relationship label; the entity start-entity end matrix includes two values, 0 and 1. When it is 1, it means that the word in the corresponding row is the first word of the entity, and the word in the corresponding column is the last word of the entity. When it is 0, it means that the word in the corresponding row is not the first word of the entity, and / or the word in the corresponding column is not the last word of the entity. The rows are obtained by arranging the words in the target text in a row-wise manner, and the columns are obtained by arranging the words in the target text in a column-wise manner; the subject entity start-object entity start matrix includes three values, 0, 1, and 2. When it is 1, it means that the word in the corresponding row is the first word of the subject entity, and the word in the corresponding column is the first word of the object entity. When it is 0, it means that the word in the corresponding row is not the first word of the subject entity, and / or the word in the corresponding column is not the first word of the object entity. When it is 2, it means the transition when the position with a value of 1 in the lower triangular region of the subject entity start-object entity start matrix is mapped from the lower triangular region to the upper triangular region; the subject entity end-object entity end matrix includes three values, 0, 1, and 2. When it is 1, it means that the word in the corresponding row is the last word of the subject entity, and the word in the corresponding column is the last word of the object entity. When it is 0, it means that the word in the corresponding row is not the last word of the subject entity, and / or the word in the corresponding column is not the last word of the object entity. When it is 2, it means the transition when the position with a value of 1 in the lower triangular region of the subject entity end-object entity end matrix is mapped from the lower triangular region to the upper triangular region; Extract target triples from the potential triples using the global subject-object entity pair constraint matrix.
2. The method according to claim 1, wherein, the external knowledge information is obtained through the following steps: Traverse each word in the target text in sequence, determine the traversed word as the current word, match the word containing the current word in the configured knowledge base, and determine the word containing the current word in the knowledge base as the matching word corresponding to the current word; If the current word is not the last word in the target text, continue to traverse each word in the target text in sequence, and return to the step of determining the traversed word as the current word, Determine the matching words corresponding to each word in the target text as the external knowledge information.
3. The method according to claim 1, wherein, the determining the first feature vector based on the target text and the external knowledge information includes: Concatenate the external knowledge information in sequence at the specified position of the target text to obtain a reference text; Use the model Transformer based on the attention mechanism as an encoder to perform encoding processing on the reference text to obtain an encoded feature vector; Crop the encoded feature vector in the way of a mask to obtain the first feature vector, and the length of the first feature vector matches the length of the target text.
4. The method according to claim 1, wherein, the input features at least include: the token vectors corresponding to the tokenization results obtained by tokenizing the target text, and the part-of-speech vectors corresponding to the part-of-speech recognition results obtained by performing part-of-speech recognition on the target text; The sentence dependency parsing tree is obtained based on the tokenization results.
5. The method according to claim 1, wherein, predicting the potential triples in the target text includes: Predicting the potential relationships in the target text by using the multi-label binary classification task; For each potential relationship, identify at least one main entity and at least one object entity corresponding to the potential relationship from the target text to obtain potential triples.
6. The method according to claim 1, wherein, predicting the global main-object entity pair constraint matrix corresponding to the target text based on the first feature vector and the second feature vector and through a trained global main-object entity pair constraint matrix generation model includes: Converting the second feature vector into a third feature vector having the same dimension as the first feature vector; Concatenating the third feature vector and the first feature vector to obtain a fourth feature vector; Determine the feature sequence corresponding to the target text according to the fourth feature vector, and the feature sequence includes the combinations between each word in the target text and all words in the target text; Input the feature sequence into the global main-object entity pair constraint matrix generation model to predict the global main-object entity pair constraint matrix corresponding to the target text.
7. The method according to claim 6, wherein, the length of the feature sequence is N*(N + 1) / 2, and N is the length of the target text.
8. The method according to claim 1, wherein, extracting the target triples from the potential triples by using the global main-object entity pair constraint matrix includes: Decoding the global main-object entity pair constraint matrix to obtain the main-object entity correspondence corresponding to the target text; For each potential triple, check whether there is a main-object entity correspondence in the main-object entity correspondence that includes the main entity and the object entity in the potential triple. If so, determine the potential triple as the target triple.
9. An electronic device, wherein, the electronic device includes: a processor and a machine-readable storage medium; The machine-readable storage medium stores machine-executable instructions that can be executed by the processor; The processor is used to execute the machine-executable instructions to implement the method steps of any one of claims 1-8.
Citation Information
Patent Citations
Entity relationship extraction method and device, electronic equipment and storage medium
CN112232074A
Entity relationship joint extraction method and device, electronic equipment and storage medium
CN113157936A