Entity Relationship Extraction Methods, Apparatus and Equipment

CN115936006BActive Publication Date: 2026-08-14SANY HEAVY MACHINERY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-06
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0004]本发明提供一种实体关系抽取方法、装置及设备,用以解决现有技术中实体关系抽取时的效率较低的缺陷,实现了实体关系抽取的效率的提升

Benefits of technology

[0042]本发明提供的实体关系抽取方法,对待抽取的文本句子对应的子句分别基于提取的语义特征向量进行实体关系抽取,然后将多个子句对应的多元组进行组合,并获得包含的多元组存在一致性关系的多元组组合,从而将多个子句的实体关系抽取结果组合在一起,实现了跨句的实体关系抽取,保证了跨句的实体关系抽取的连贯性,不仅提高了效率,而且可以避免多个子句放在一起造成相互干扰,提升了实体关系抽取的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115936006B_ABST
    Figure CN115936006B_ABST
Patent Text Reader

Abstract

This invention relates to the field of natural language processing, providing a method, apparatus, and device for entity relation extraction. The method includes: acquiring N clauses corresponding to a text sentence to be extracted; for each clause, extracting its semantic feature vector; based on the semantic feature vector, extracting entity relations from the clause to obtain all tuples corresponding to the clause, where each tuple contains at least a subject, a predefined relation, and an object; based on all tuples corresponding to the N clauses, obtaining all combinations of tuples; each combination of tuples contains N tuples, each corresponding to a different clause; determining whether there is a consistent relation among the N tuples in the combination; and obtaining the entity relation extraction result of the text sentence to be extracted based on the combination of tuples containing N tuples with consistent relations. This solves the problem of low efficiency in entity relation extraction, enables cross-sentence entity relation extraction, and improves efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus and device for entity relation extraction. Background Technology

[0002] Entity relation extraction is a text processing technique that extracts relationships between entities from text and represents them as triples (subject, relation, object), where both the subject and object are entities. Each entity can have multiple relationships with multiple entities. This is the foundation for building knowledge graphs and can be applied to fields such as text mining, intelligent question answering, and information retrieval.

[0003] In practical applications, traditional entity relation extraction methods are inefficient when extracting entity relations from complex, long sentences. Therefore, improving the efficiency of entity relation extraction is a crucial issue that the industry urgently needs to address. Summary of the Invention

[0004] This invention provides an entity relation extraction method, apparatus, and device to address the shortcomings of low efficiency in entity relation extraction in the prior art, thereby improving the efficiency of entity relation extraction.

[0005] This invention provides a method for entity relation extraction, comprising:

[0006] Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0007] For each clause, a semantic feature vector of the clause is extracted. Based on the semantic feature vector of the clause, entity relations are extracted from the clause to obtain all tuples corresponding to the clause. Each tuple contains at least a subject, a preset relation, and an object.

[0008] Based on all the tuples corresponding to the N clauses, all combinations of tuples are obtained; each combination of tuples contains N tuples, and the N tuples correspond to different clauses respectively;

[0009] Determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0010] Based on the combination of N tuples that have a consistent relationship, the entity relation extraction result of the text sentence to be extracted is obtained.

[0011] According to the entity relation extraction method provided by the present invention, determining whether there is a consistent relation among the N tuples included in the tuple combination includes:

[0012] The tuple combination is input into the consistency model to obtain the result of whether there is a consistency relationship among the N tuples contained in the tuple combination output by the consistency model;

[0013] The consistency model is trained based on tuple-group combined samples and corresponding sample labels.

[0014] According to the entity relation extraction method provided by the present invention, the semantic feature vector of the clause includes sentence vector and word vector;

[0015] The step of inputting the tuple combination into the consistency model includes:

[0016] The sentence vectors of the N sentences and the word vectors corresponding to the entities in the tuple combination are input into the consistency model.

[0017] According to the entity relation extraction method provided by the present invention, the semantic feature vector of the clause includes sentence vector and word vector;

[0018] The tuple is a quadruple, which includes the subject type, the subject, the preset relationship, and the object;

[0019] The entity relation extraction is performed on the clause based on its semantic feature vector to obtain all tuples corresponding to the clause, including:

[0020] The semantic feature vector of the clause is input into the first entity relation extraction model corresponding to the clause to obtain all triples corresponding to the clause output by the first entity relation extraction model. The triples include the subject, the preset relation and the object.

[0021] Input the sentence vector and the character vector corresponding to the subject in the triple into the first classification model to obtain the subject type of the subject output by the first classification model;

[0022] Based on all the triples and the subject type of the subject in the triples, obtain all the quadruples corresponding to the clause.

[0023] According to an entity relation extraction method provided by the present invention, the tuple is a quadruple, and the quadruple includes subject type, subject, preset relation and object;

[0024] The entity relation extraction is performed on the clause based on its semantic feature vector to obtain all tuples corresponding to the clause, including:

[0025] The semantic feature vector of the clause is input into the second entity relation extraction model corresponding to the sentence to obtain all the quadruplets output by the second entity relation extraction model.

[0026] According to the entity relation extraction method provided by the present invention, the semantic feature vector includes sentence vectors and word vectors;

[0027] Obtaining all the quadruplets output by the second entity relation extraction model includes:

[0028] Input all the word vectors in the semantic feature vector of the clause into the second classification model to obtain the subject and subject type of the clause output by the second classification model;

[0029] Under the subject type of the subject, based on all the word vectors in the word vectors corresponding to the subject and the semantic feature vectors of the clause, the object under each preset relation is identified to obtain the quadruple.

[0030] According to the entity relation extraction method provided by the present invention, obtaining all tuple combinations based on all tuples corresponding to N clauses includes:

[0031] By using the Cartesian product to combine all the tuples corresponding to the N clauses, all combinations of the tuples are obtained.

[0032] According to the entity relation extraction method provided by the present invention, the extraction of the semantic feature vector of the clause includes:

[0033] The clause is input into a pre-trained model to obtain the semantic feature vector of the clause output by the pre-trained model, wherein the pre-trained model is pre-trained based on a corpus.

[0034] The present invention also provides an entity relation extraction device, comprising:

[0035] The clause retrieval module is used to retrieve N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0036] The relation extraction module is used to extract the semantic feature vector of each clause, extract entity relations based on the semantic feature vector of the clause, and obtain all tuples corresponding to the clause. The tuples include at least a subject, a preset relation, and an object.

[0037] The tuple combination module is used to obtain all tuple combinations based on all the tuples corresponding to the N clauses; each tuple combination contains N tuples, and the N tuples correspond to different clauses respectively;

[0038] A consistency determination module is used to determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0039] The result acquisition module is used to obtain the entity relation extraction result of the text sentence to be extracted based on the combination of the N tuples that have a consistent relationship.

[0040] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the entity relation extraction method as described above.

[0041] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the entity relation extraction method as described above.

[0042] The entity relation extraction method provided by this invention extracts entity relations for each clause corresponding to the text sentence to be extracted based on the extracted semantic feature vectors. Then, it combines the tuples corresponding to multiple clauses and obtains a tuple combination in which the included tuples have consistent relations. This combines the entity relation extraction results of multiple clauses together, realizing cross-sentence entity relation extraction and ensuring the continuity of cross-sentence entity relation extraction. This not only improves efficiency but also avoids mutual interference caused by placing multiple clauses together, thus improving the accuracy of entity relation extraction. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0044] Figure 1 This is one of the flowcharts illustrating the entity relation extraction method provided by the present invention;

[0045] Figure 2 This is the second flowchart of the entity relation extraction method provided by the present invention;

[0046] Figure 3 This is a schematic diagram of the entity relationship extraction device provided by the present invention;

[0047] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0049] The following is combined with Figures 1 to 2 The entity relation extraction method of the present invention is described.

[0050] This embodiment provides a method for entity relation extraction, such as... Figure 1 As shown, this method is executed by an entity relation extraction device, and the method includes at least the following steps:

[0051] Step 101: Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1.

[0052] In practical applications, the text sentence to be extracted can be pre-divided into N clauses, where N is a positive integer greater than 1. Taking a fault diagnosis scenario as an example, the text sentence to be extracted can be divided into 3 clauses: the first clause is the sentence describing the fault scene, the second clause is the sentence describing the cause of the fault, and the third clause is the sentence describing the processing result.

[0053] Step 102: For each clause, extract the semantic feature vector of the clause, and based on the semantic feature vector of the clause, extract entity relations of the clause to obtain all tuples corresponding to the clause. The tuples include at least a subject, a preset relation, and an object.

[0054] In implementation, a clause can yield one or more tuples. Each tuple contains at least a subject, a predefined relation, and an object. The subject and object are entities; the subject is the head entity, and the object is the tail entity. The predefined relation is the entity relationship between the subject and object, and its category can be set according to the specific situation. For example, in a fault diagnosis scenario, the tuple (crossshaft, equipment component & fault location, drive shaft) can be obtained, where the crossshaft is the subject, equipment component & fault location is the predefined relation, and drive shaft is the object. Another example is the tuple (oil leak, phenomenon description & equipment component, crossshaft), where oil leak is the subject, phenomenon description & equipment component is the predefined relation, and crossshaft is the object.

[0055] Each tuple can further include a subject type, making the information of the extracted tuple more comprehensive. Then, the tuple can be a quadruple, and correspondingly, the quadruple includes a subject type, the subject, the preset relationship, and the object. The subject type can be set according to the actual situation. Still taking the scenario of fault diagnosis as an example, the quadruple can be (Phenomenon description, oil leakage, Phenomenon description & equipment part, cross shaft), where Phenomenon description is the subject type, oil leakage is the subject, Phenomenon description & equipment part is the preset relationship, and cross shaft is the object. Or the quadruple can be (Equipment part, cross shaft, Equipment part & fault location, transmission shaft), where Equipment part is the subject type, cross shaft is the subject, Equipment part & fault location is the preset relationship, and transmission shaft is the object.

[0056] Exemplarily, extracting the semantic feature vector of the clause specifically may include: inputting the clause into a pre-trained model to obtain the semantic feature vector of the clause output by the pre-trained model, and the pre-trained model is pre-trained based on a corpus. The corpus contains various corpora in the application field. The pre-trained model pre-trained using the corpus has learned the knowledge of various corpora, and the semantic feature vector of the clause can be more accurately extracted using this pre-trained model. The pre-trained model can adopt BERT. BERT is a pre-trained language representation model, and ERNIE, Roberta, etc. can also be used.

[0057] In implementation, an entity relationship extraction model pre-trained can be used to perform entity relationship extraction on the clause.

[0058] For each clause, the clause can be preprocessed first, and then based on the preprocessed clause, the semantic feature vector of the clause is extracted.

[0059] Among them, preprocessing the clause includes:

[0060] First, removing stop words and meaningless words from the clause.

[0061] Common stop words can include modal particles such as "ne", "a", "me".

[0062] Meaningless words are words that have no association with entity relationship extraction. They can be set according to different tasks. For example, in the scenario of fault diagnosis, they can be "call for", "customer feedback", "inform the customer", etc.

[0063] In implementation, stop words and meaningless words can be collected in advance.

[0064] Since the text sentences to be extracted are mostly colloquial descriptions, stop words and meaningless words usually have no clear meaning and do not have a positive impact on the entity relation extraction process. Too many stop words or meaningless words will directly affect the convergence speed of the loss function and the accuracy of the model in the entity relation extraction process. Furthermore, when using a pre-trained model, excessively long text input will affect the effectiveness of the semantic feature vectors extracted by the pre-trained model. Therefore, during preprocessing, stop words and meaningless words are removed first, and only more meaningful words are retained.

[0065] 2. Format the clauses. Specifically, represent the clauses in a set format, such as {"text":clause}.

[0066] It should be noted that during the training phase, for the labeled clause samples, it is also necessary to filter out invalid or incorrectly labeled clause samples, and match the labeled entities with the sentence samples to find the position index of the labeled entities in the clause samples, resulting in the format f1:{“text”: clause sample,“triple_list”:[(subject1, preset relation1, object1, subject1 first and last positions, object1 first and last positions), (subject2, preset relation2, object2, subject2 first and last positions, object2 first and last positions),…]}, or the format f2:{“text”: clause sample,“triple_list”:[(subject type, subject1, preset relation1, object1, subject1 first and last positions, object1 first and last positions), (subject type, subject2, preset relation2, object2, subject2 first and last positions, object2 first and last positions),…]}. The content corresponding to the triple_list contains the labeled entities.

[0067] When extracting the semantic feature vector of a clause, the clause input to the pre-trained model is split into multiple characters according to the characters to obtain character vectors, including sentence vectors. In addition, it is necessary to distinguish characters appearing in different positions in the clause through position vectors. After feature extraction, the semantic feature vector of the clause is obtained. The output of the pre-trained model includes sentence vectors and character vectors of each character based on contextual semantic information.

[0068] By using the semantic feature vector of the clause and a pre-trained entity relation extraction model to extract entity relations from the clause, all tuples corresponding to the clause can be obtained.

[0069] Step 103: Based on all the tuples corresponding to the N clauses, obtain all tuple combinations; each tuple combination contains N tuples, and the N tuples correspond to different clauses respectively.

[0070] Based on all the tuples corresponding to N clauses, a tuple combination is obtained. The number of tuples in the tuple combination is the same as the number of clauses, and the tuples in the tuple combination come from different clauses. Taking three clauses as an example, the tuple combination can be ((Subject Type, Subject 1, Presupposition Relation 1, Object 1), (Subject Type, Subject 2, Presupposition Relation 2, Object 2), (Subject Type, Subject 3, Presupposition Relation 3, Object 3)).

[0071] For example, the first clause is the sentence describing the fault scene, the second clause is the sentence describing the cause of the fault, and the third clause is the sentence describing the processing result. The tuples obtained from the first clause include A1, A2, and A3, the tuples obtained from the second clause include B1 and B2, and the tuples obtained from the third clause include C1 and C2. Then, we can obtain the tuple combination (A1, B1, C1), the tuple combination (A2, B1, C1), the tuple combination (A3, B1, C1), the tuple combination (A1, B2, C1), and so on.

[0072] Specifically, a Cartesian product is used to combine all the tuples corresponding to the N clauses to obtain all possible combinations of tuples. The number of combinations of tuples is the product of the number of tuples corresponding to each clause, thus allowing for the rapid acquisition of various possible combinations of tuples. For example, suppose the first clause yields n1 tuples, the second clause yields n2 tuple elements, and the third clause yields n3 tuples. Performing a Cartesian product on the sets of tuples obtained from each clause yields n1*n2*n3 combinations of tuples.

[0073] Step 104: Determine whether there is a consistency relationship among the N tuples contained in the tuple combination.

[0074] Since the multiple tuples in the tuple combination come from different clauses of the text sentence to be extracted, these tuples may be related or unrelated. For example, the first clause is the sentence describing the fault scene, the second clause is the sentence describing the fault cause, and the third clause is the sentence describing the processing result. The sentence describing the fault scene contains multiple tuples corresponding to fault phenomena, the sentence describing the fault cause contains multiple tuples corresponding to fault causes, and the sentence describing the processing result also contains multiple tuples corresponding to processing results. A certain fault phenomenon may only be related to a certain fault cause and a certain processing result, and unrelated to other fault causes and processing results. Therefore, the tuple corresponding to a certain fault phenomenon is related to the tuple corresponding to a certain fault cause and the tuple corresponding to a certain processing result, exhibiting a consistency relationship, but unrelated to other tuples corresponding to fault causes and processing results, exhibiting no consistency relationship. In this step, it can be determined whether there is a consistency relationship among the N tuples contained in the tuple combination. If so, it means that the N tuples in the tuple combination are related and contain useful information, which can be retained; otherwise, it means that the N tuples in the tuple combination are unrelated and contain meaningless information, which can be removed.

[0075] Step 105: Based on the combination of the N tuples that have a consistent relationship, obtain the entity relation extraction result of the text sentence to be extracted.

[0076] Specifically, after removing tuple combinations that lack consistency relationships, the remaining tuple combinations with consistency relationships are used as the entity relation extraction results for the text sentences to be extracted, thus achieving cross-sentence entity relation extraction. In this way, by selecting the final tuple combinations with consistency relationships, the relevant tuples for each sentence (clause) are accurately obtained, completing the extraction of all useful information between sentences while ensuring consistency.

[0077] In related technologies, entity relation extraction is often performed directly on an entire sentence, which is inefficient for longer sentences. In this embodiment, however, entity relations are extracted from the clauses corresponding to the text sentence based on the extracted semantic feature vectors. Then, the tuples corresponding to multiple clauses are combined, and a tuple combination containing tuples with consistent relationships is obtained. This combines the entity relation extraction results of multiple clauses, achieving cross-sentence entity relation extraction and ensuring its continuity. This not only improves efficiency but also avoids mutual interference caused by placing multiple clauses together, thus enhancing the accuracy of entity relation extraction.

[0078] In an exemplary embodiment, determining whether there is a consistency relationship among the N tuples included in the tuple combination may include:

[0079] The tuple combination is input into the consistency model to obtain the result of whether there is a consistency relationship among the N tuples contained in the tuple combination output by the consistency model;

[0080] The consistency model is trained based on tuple-group combined samples and their corresponding sample labels. The tuple-group combined samples carry the corresponding sample labels.

[0081] In practical applications, a consistency model can be pre-trained. Specifically, an initial model is constructed, and tuple combinations carrying sample labels are obtained. If there is a consistency relationship among the tuple samples in the tuple combination, the sample label is the first label, such as 1; otherwise, the sample label is the second label, such as 0. The initial model is then trained using the tuple combination samples to obtain the consistency model.

[0082] For example, inputting the tuple combination into the consistency model may specifically include: inputting the sentence vectors of the N sentences and the word vectors corresponding to the entities in the tuple combination into the consistency model.

[0083] The consistency model can employ a binary classification model, which can be constructed based on the sigmoid activation function. Based on this, the result of whether there is a consistency relationship among the N tuples in the tuple combination output by the consistency model is obtained. Specifically, this can include performing a fully connected operation on the sentence vector of each clause and the feature vector of the entity in the tuple combination, resulting in a fully connected vector. The feature vector of the entity can be the average vector of the first and last character vectors of the entity, or the average vector of all character vectors of the entity, etc. Then, based on the fully connected vector, it is determined whether there is a consistency relationship among the N tuples in the tuple combination. If yes, a first result (e.g., 1) is output; otherwise, a second result (e.g., 0) is output. Based on this, tuple combinations that output the second result are filtered out, thereby obtaining tuple combinations with consistency relationships across sentences.

[0084] In this way, by directly using the extracted semantic feature vectors, and taking the sentence vector of each clause and the word vector corresponding to the entity in the tuple combination as input, we can determine whether there is a consistency relationship among the N tuples contained in the tuple combination. This avoids the complexity of the operation, and the input is a richer and more useful information distribution, which improves the accuracy of the consistency model output.

[0085] Since the consistency model is trained based on the combination of tuple samples and their corresponding sample labels, it can learn the potential consistency relationships between tuples. Therefore, in this embodiment, the pre-trained consistency model can determine whether there is a consistency relationship among the N tuples contained in the tuple combination, further improving the accuracy of entity relationship extraction.

[0086] In an exemplary embodiment, when the semantic feature vector of the clause includes sentence vectors and word vectors, and the tuple is a quadruple containing subject type, subject, preset relation, and object, the entity relation extraction is performed on the clause based on the semantic feature vector of the clause to obtain all tuples corresponding to the clause, such as... Figure 2 As shown, it can specifically include:

[0087] Step 201: Input the semantic feature vector of the clause into the first entity relation extraction model corresponding to the clause to obtain all triples corresponding to the clause output by the first entity relation extraction model. The triples include the subject, the preset relation and the object.

[0088] The first entity relation extraction model is used to extract triples containing the subject, the preset relation, and the object.

[0089] In practical applications, a first entity relation extraction model can be pre-trained. Specifically, a first preset model is constructed to train the first entity relation extraction model, and labeled clause samples are obtained. The clause samples are preprocessed, and then semantic feature vectors are extracted from the clause samples. Based on the semantic feature vectors of the clause samples, the first preset model is trained to obtain the first entity relation extraction model. The clause samples carry triplet annotations.

[0090] Among them, the first relation extraction model can adopt the Casrel model. The Casrel model is an entity relation extraction model based on parameter sharing and joint learning. It uses a stacked pointer network, which is simple and can extract triples quickly and accurately.

[0091] For example, obtaining all triples corresponding to the clause output by the first entity relation extraction model may include:

[0092] First, based on the semantic feature vector of the clause, all possible subjects are identified. Specifically, all character vectors in the semantic feature vector are linearly transformed through a linear layer, and then a binary classifier (e.g., sigmoid activation function) is used to identify whether each character is the beginning or end of a subject. For example, start represents the beginning position and end represents the end position. Subsequently, the identified start and end are paired using the nearest matching principle to obtain the set of subjects. The characters between the paired start and end are the characters corresponding to the subjects.

[0093] Then, under the preset relationships of each category, the objects related to the subject are identified. For example, the word vectors corresponding to the start and end of the subject are averaged to obtain the feature vector of the subject. The feature vector of the subject is added to each word vector separately and used as the input feature vector for object recognition. Using the preset relationship of each category as prior knowledge, a binary classifier (such as the sigmoid activation function) is used to perform binary classification on the input feature vector under the preset relationship of each category to identify the start and end of the object. Subsequently, the start and end of the identified objects are paired using the nearest matching principle to obtain the object, thereby obtaining a set of triples (subject, preset relationship, object).

[0094] Step 202: Input the sentence vector and the word vector corresponding to the subject in the triple into the first classification model to obtain the subject type of the subject output by the first classification model.

[0095] The first classification model is used to classify the subject type of a subject. It implements a multi-classification task.

[0096] For example, obtaining the subject type of the subject output by the first classification model may include:

[0097] Based on the word vectors corresponding to the subject in the triplet, the feature vector of the subject is obtained. For example, the feature vector of the subject is obtained by averaging the word vectors corresponding to the start and end of the subject. The sentence vector of the clause is added to the feature vector of the subject in the triplet, and after linear transformation and ReLU activation function, the softmax function is used to identify the subject type of the subject.

[0098] In practical applications, a first classification model can be pre-trained. Specifically, a second preset model is constructed to train the first classification model, and the sentence vector of the clause sample and the character vector corresponding to the subject in the triplet and the labeled subject type are obtained. The second preset model is then trained to obtain the first classification model.

[0099] Besides the Softmax function, the first classification model can also use related algorithms such as fastText and TextCNN.

[0100] Step 203: Based on all the triples and the subject type of the subject in the triples, obtain all the quadruples corresponding to the clause.

[0101] In practical applications, the identified subject types may have a small number of subjects, resulting in an uneven distribution of subject types. To address this, the quadruple-obtaining scheme provided in this embodiment can be adopted. After extracting the first entity relation model from the triples, a first classification model is added to further classify the subject types. In the first classification model, instead of using a single subject feature vector, the subject feature vector and the clause sentence vector are fused to identify the subject type. This results in more accurate identification of the subject type, thereby accurately obtaining the clause quadruple (subject type, subject, relation, object).

[0102] In an exemplary embodiment, when the tuple is a quadruple containing a subject type, the subject, the preset relation, and the object, the step of extracting entity relations from the clause based on the semantic feature vector of the clause to obtain all tuples corresponding to the clause may include:

[0103] The semantic feature vector of the clause is input into the second entity relation extraction model corresponding to the sentence to obtain all the quadruplets output by the second entity relation extraction model.

[0104] The second entity relation extraction model is used to extract a quadruple containing subject type, subject, the preset relation, and object.

[0105] In practical applications, a second entity relation extraction model can be pre-trained. Specifically, a third pre-defined model is constructed to train the second entity relation extraction model, and labeled clause samples are obtained. These clause samples are preprocessed, and their semantic feature vectors are extracted. Based on these semantic feature vectors, the third pre-defined model is trained to obtain the second entity relation extraction model. The clause samples contain four-tuple annotations, including not only annotations for the subject, pre-defined relation, and object, but also annotations for the subject type.

[0106] In practical applications, if there is no problem of uneven distribution of subject types, the second relation extraction model can be used to directly obtain the quadruple (subject type, subject, relation, object) of each clause, thereby improving the efficiency of entity relation extraction.

[0107] For example, obtaining all the four tuples output by the entity relation extraction model may include:

[0108] Input all the word vectors in the semantic feature vector of the clause into the second classification model to obtain the subject and subject type of the clause output by the second classification model;

[0109] Under the subject type of the subject, based on all the word vectors in the word vectors corresponding to the subject and the semantic feature vectors of the clause, the object under each preset relation is identified to obtain the quadruple.

[0110] The second relation extraction model can employ the Casrel model, as the traditional Casrel model can extract triples. To address this, the inventors have provided an improved Casrel model. Based on this, when identifying the subject, the sigmoid activation function is no longer used; instead, the softmax function is employed. The softmax function identifies whether each character is at the beginning or end of a position, and also identifies the subject type at the start and end points. Under the same subject type, the nearest-match principle is used to obtain a set of subjects and their corresponding subject types. Subsequently, under each category's preset relation, objects related to the subject are identified. For example, the word vectors corresponding to the start and end of the subject are averaged to obtain the subject's feature vector. The subject's feature vector is then added to each word vector to obtain the input feature vector for object recognition. Using the preset relationship of each category as prior knowledge, a binary classifier (e.g., sigmoid activation function) is used to perform binary classification on the input feature vector under the preset relationship of each category to identify the start and end of the object. Subsequently, the start and end of the identified object are paired using the nearest matching principle to obtain the object, thereby obtaining a set of four-tuples (subject type, subject, preset relationship, object).

[0111] In this embodiment, while identifying the subject, the identification of the subject type is also incorporated. Under the identified subject type, the object under the preset relationship is identified, which can directly obtain a quadruple containing the subject type, the subject, the preset relationship, and the object, resulting in higher processing efficiency.

[0112] The multiple models in the solution of this invention share the same feature semantic vector, thus avoiding operational complexity.

[0113] The entity relation extraction apparatus provided by the present invention is described below. The entity relation extraction apparatus described below and the entity relation extraction method described above can be referred to in correspondence.

[0114] like Figure 3 As shown, this embodiment provides an entity relationship extraction device, including:

[0115] Clause acquisition module 301 is used to acquire N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0116] The relation extraction module 302 is used to extract the semantic feature vector of each clause, extract entity relations based on the semantic feature vector of the clause, and obtain all tuples corresponding to the clause. The tuples include at least a subject, a preset relation, and an object.

[0117] The tuple combination module 303 is used to obtain all tuple combinations based on all the tuples corresponding to the N clauses; each tuple combination contains N tuples, and the N tuples correspond to different clauses respectively.

[0118] The consistency determination module 304 is used to determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0119] The result acquisition module 305 is used to obtain the entity relation extraction result of the text sentence to be extracted based on the combination of the N tuples that have a consistent relationship.

[0120] In an exemplary embodiment, the consistency determination module 304 is specifically used for:

[0121] The tuple combination is input into the consistency model to obtain the result of whether there is a consistency relationship among the N tuples contained in the tuple combination output by the consistency model;

[0122] The consistency model is trained based on tuple-group combined samples and corresponding sample labels.

[0123] In an exemplary embodiment, the semantic feature vector of the clause includes a sentence vector and a character vector;

[0124] Consistency determination module 304 is specifically used for:

[0125] The sentence vectors of the N sentences and the word vectors corresponding to the entities in the tuple combination are input into the consistency model.

[0126] In an exemplary embodiment, the semantic feature vector of the clause includes a sentence vector and a character vector;

[0127] The tuple is a quadruple, which includes the subject type, the subject, the preset relationship, and the object;

[0128] The relation extraction module 302 is specifically used for:

[0129] The semantic feature vector of the clause is input into the first entity relation extraction model corresponding to the clause to obtain all triples corresponding to the clause output by the first entity relation extraction model. The triples include the subject, the preset relation and the object.

[0130] Input the sentence vector and the character vector corresponding to the subject in the triple into the first classification model to obtain the subject type of the subject output by the first classification model;

[0131] Based on all the triples and the subject type of the subject in the triples, obtain all the quadruples corresponding to the clause.

[0132] In an exemplary embodiment, the tuple is a quadruple, which includes a subject type, the subject, the preset relationship, and the object;

[0133] The relation extraction module 302 is specifically used for:

[0134] The semantic feature vector of the clause is input into the second entity relation extraction model corresponding to the sentence to obtain all the quadruplets output by the second entity relation extraction model.

[0135] In an exemplary embodiment, the semantic feature vector includes sentence vectors and word vectors;

[0136] The relation extraction module 302 is specifically used for:

[0137] Input all the word vectors in the semantic feature vector of the clause into the second classification model to obtain the subject and subject type of the clause output by the second classification model;

[0138] Under the subject type of the subject, based on all the word vectors in the word vectors corresponding to the subject and the semantic feature vectors of the clause, the object under each preset relation is identified to obtain the quadruple.

[0139] In an exemplary embodiment, the tuple combination module 303 is specifically used for:

[0140] By using the Cartesian product to combine all the tuples corresponding to the N clauses, all combinations of the tuples are obtained.

[0141] In an exemplary embodiment, the relation extraction module 302 is specifically used for:

[0142] The clause is input into a pre-trained model to obtain the semantic feature vector of the clause output by the pre-trained model, wherein the pre-trained model is pre-trained based on a corpus.

[0143] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute an entity relation extraction method, which includes:

[0144] Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0145] For each clause, a semantic feature vector of the clause is extracted. Based on the semantic feature vector of the clause, entity relations are extracted from the clause to obtain all tuples corresponding to the clause. Each tuple contains at least a subject, a preset relation, and an object.

[0146] Based on all the tuples corresponding to the N clauses, all combinations of tuples are obtained; each combination of tuples contains N tuples, and the N tuples correspond to different clauses respectively;

[0147] Determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0148] Based on the combination of N tuples that have a consistent relationship, the entity relation extraction result of the text sentence to be extracted is obtained.

[0149] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0150] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the entity relation extraction method provided by the above methods, the method comprising:

[0151] Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0152] For each clause, a semantic feature vector of the clause is extracted. Based on the semantic feature vector of the clause, entity relations are extracted from the clause to obtain all tuples corresponding to the clause. Each tuple contains at least a subject, a preset relation, and an object.

[0153] Based on all the tuples corresponding to the N clauses, all combinations of tuples are obtained; each combination of tuples contains N tuples, and the N tuples correspond to different clauses respectively;

[0154] Determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0155] Based on the combination of N tuples that have a consistent relationship, the entity relation extraction result of the text sentence to be extracted is obtained.

[0156] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the entity relation extraction methods provided above, the method comprising:

[0157] Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1;

[0158] For each clause, a semantic feature vector of the clause is extracted. Based on the semantic feature vector of the clause, entity relations are extracted from the clause to obtain all tuples corresponding to the clause. Each tuple contains at least a subject, a preset relation, and an object.

[0159] Based on all the tuples corresponding to the N clauses, all combinations of tuples are obtained; each combination of tuples contains N tuples, and the N tuples correspond to different clauses respectively;

[0160] Determine whether there is a consistency relationship among the N tuples contained in the tuple combination;

[0161] Based on the combination of N tuples that have a consistent relationship, the entity relation extraction result of the text sentence to be extracted is obtained.

[0162] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0163] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for extracting entity relations, characterized in that, include: Obtain the N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1; For each clause, a semantic feature vector of the clause is extracted. Based on the semantic feature vector of the clause, entity relations are extracted from the clause to obtain all tuples corresponding to the clause. Each tuple contains at least a subject, a preset relation, and an object. Based on all the tuples corresponding to the N clauses, all combinations of tuples are obtained; each combination of tuples contains N tuples, and the N tuples correspond to different clauses respectively; Determining whether there is a consistency relationship among the N tuples contained in the tuple combination includes: inputting the sentence vectors of the N sentences and the character vectors corresponding to the entities in the tuple combination into a consistency model, and obtaining the result of the consistency model outputting whether there is a consistency relationship among the N tuples contained in the tuple combination; wherein, the consistency model is trained based on the tuple combination samples and the corresponding sample labels; the consistency model adopts a binary classification model; Based on the combination of N tuples that have a consistent relationship, the entity relation extraction result of the text sentence to be extracted is obtained.

2. The entity relation extraction method according to claim 1, characterized in that, The semantic feature vector of the clause includes sentence vector and word vector.

3. The entity relation extraction method according to claim 1, characterized in that, The semantic feature vector of the clause includes sentence vector and word vector; The tuple is a quadruple, which includes the subject type, the subject, the preset relationship, and the object; The entity relation extraction is performed on the clause based on its semantic feature vector to obtain all tuples corresponding to the clause, including: The semantic feature vector of the clause is input into the first entity relation extraction model corresponding to the clause to obtain all triples corresponding to the clause output by the first entity relation extraction model. The triples include the subject, the preset relation and the object. Input the sentence vector and the character vector corresponding to the subject in the triple into the first classification model to obtain the subject type of the subject output by the first classification model; Based on all the triples and the subject type of the subject in the triples, obtain all the quadruples corresponding to the clause.

4. The entity relation extraction method according to claim 1, characterized in that, The tuple is a quadruple, which includes the subject type, the subject, the preset relationship, and the object; The entity relation extraction is performed on the clause based on its semantic feature vector to obtain all tuples corresponding to the clause, including: The semantic feature vector of the clause is input into the second entity relation extraction model corresponding to the sentence to obtain all the quadruplets output by the second entity relation extraction model.

5. The entity relation extraction method according to claim 4, characterized in that, The semantic feature vector includes sentence vectors and character vectors; Obtaining all the quadruplets output by the second entity relation extraction model includes: Input all the word vectors in the semantic feature vector of the clause into the second classification model to obtain the subject and subject type of the clause output by the second classification model; Under the subject type of the subject, based on all the word vectors in the word vectors corresponding to the subject and the semantic feature vectors of the clause, the object under each preset relation is identified to obtain the quadruple.

6. The entity relation extraction method according to claim 1, characterized in that, The process of obtaining all combinations of tuples based on all the tuples corresponding to the N clauses includes: By using the Cartesian product to combine all the tuples corresponding to the N clauses, all combinations of the tuples are obtained.

7. The entity relation extraction method according to any one of claims 1 to 6, characterized in that, The extraction of the semantic feature vector of the clause includes: The clause is input into a pre-trained model to obtain the semantic feature vector of the clause output by the pre-trained model, wherein the pre-trained model is pre-trained based on a corpus.

8. An entity relation extraction device, characterized in that, include: The clause retrieval module is used to retrieve N clauses corresponding to the text sentence to be extracted, where N is a positive integer greater than 1; The relation extraction module is used to extract the semantic feature vector of each clause, extract entity relations based on the semantic feature vector of the clause, and obtain all tuples corresponding to the clause. The tuples include at least a subject, a preset relation, and an object. The tuple combination module is used to obtain all tuple combinations based on all the tuples corresponding to the N clauses; each tuple combination contains N tuples, and the N tuples correspond to different clauses respectively; A consistency determination module is used to determine whether there is a consistency relationship among the N tuples contained in the tuple combination, including: inputting the sentence vectors of the N sentences and the character vectors corresponding to the entities in the tuple combination into a consistency model, and obtaining the result of the consistency model outputting whether there is a consistency relationship among the N tuples contained in the tuple combination; wherein, the consistency model is trained based on the tuple combination samples and the corresponding sample labels; the consistency model adopts a binary classification model; The result acquisition module is used to obtain the entity relation extraction result of the text sentence to be extracted based on the combination of the N tuples that have a consistent relationship.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the entity relation extraction method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Entity relationship determination method and device, computing equipment and storage medium

    CN112463960A

  • Entity and relation joint extraction method for airport emergency plan text

    CN113051891A