An entity relationship extraction method, device, equipment and storage medium

By introducing the fusion processing of entity relationship transition matrix and classification model in knowledge graph construction, the problems of high cost and low accuracy in knowledge graph construction are solved, and more efficient and accurate entity relationship prediction is achieved.

CN115238092BActive Publication Date: 2026-07-07LENOVO (BEIJING) LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LENOVO (BEIJING) LTD
Filing Date
2022-07-21
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing knowledge graphs are costly to build, have low accuracy in automated construction, and are difficult to apply widely.

Method used

By introducing the entity relationship transition matrix as prior knowledge and combining it with the entity relationship classification model, the entity relationship transition matrix is ​​generated by identifying entities and types in the text and using the ontology graph. The results of the first and second relationship classifications are then fused to improve prediction accuracy.

Benefits of technology

It effectively alleviates the problem of data sparsity, improves the prediction accuracy and robustness of the model, and enhances the predictive ability of entity relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115238092B_ABST
    Figure CN115238092B_ABST
Patent Text Reader

Abstract

The application discloses an entity relation extraction method, device and equipment and a storage medium. The method comprises the following steps: identifying a text to be identified, obtaining at least two entities in the text to be identified and types to which the two entities belong; obtaining an entity relation transition matrix used for predicting the relation between entities according to an ontology graph corresponding to the text to be identified, querying the entity relation transition matrix based on the types to which the two entities belong, and obtaining a first relation classification result of the two entities; and performing fusion processing on the first relation classification result and a second relation classification result to obtain a target relation classification result of the two entities, wherein the second relation classification result is obtained by identifying the text to be identified through an entity relation classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing, and includes, but is not limited to, a method, apparatus, device, and storage medium for extracting entity relationships. Background Technology

[0002] Among existing knowledge representation methods, knowledge graphs (KG), as a type of semantic network, have attracted widespread attention due to their strong expressive power and modeling flexibility. However, their widespread application has been hampered by high costs of manual construction and low accuracy of automated construction. Reducing the construction cost of KG and improving the accuracy of automated knowledge graph construction have been hot research topics in recent years. Summary of the Invention

[0003] In view of this, embodiments of this application provide an entity relationship extraction method, apparatus, device, and storage medium.

[0004] The technical solution of this application embodiment is implemented as follows:

[0005] In a first aspect, embodiments of this application provide an entity relation extraction method, the method comprising: identifying a text to be identified, obtaining at least two entities in the text to be identified and the types to which the two entities belong; obtaining an entity relation transition matrix for predicting the relationship between entities based on an ontology graph corresponding to the text to be identified, querying the entity relation transition matrix based on the types to which the two entities belong, and obtaining a first relation classification result for the two entities; and fusing the first relation classification result and a second relation classification result to obtain a target relation classification result for the two entities, wherein the second relation classification result is obtained by identifying the text to be identified through an entity relation classification model.

[0006] Secondly, embodiments of this application provide an entity relationship extraction apparatus, the apparatus comprising: an identification module, configured to identify text to be identified, and obtain at least two entities in the text to be identified and the types to which the two entities belong; a first obtaining module, configured to obtain an entity relationship transition matrix for predicting the relationship between entities based on the ontology graph corresponding to the text to be identified, query the entity relationship transition matrix based on the types to which the two entities belong, and obtain a first relationship classification result for the two entities; and a fusion module, configured to fuse the first relationship classification result and the second relationship classification result to obtain a target relationship classification result for the two entities, wherein the second relationship classification result is obtained by identifying the text to be identified through an entity relationship classification model.

[0007] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement the above-described method.

[0008] Fourthly, embodiments of this application provide a storage medium storing executable instructions for inducing a processor to execute the above-described method.

[0009] In this embodiment, the text to be identified is first identified to obtain at least two entities in the text and the types to which the two entities belong. Then, an entity relationship transition matrix for predicting the relationship between entities is obtained based on the ontology graph corresponding to the text. The entity relationship transition matrix is ​​queried based on the types to which the two entities belong to obtain a first relationship classification result for the two entities. Finally, the first relationship classification result and the second relationship classification result are fused to obtain a target relationship classification result for the two entities. The second relationship classification result is obtained by identifying the text through an entity relationship classification model. In this way, by introducing the entity relationship transition matrix as prior knowledge for entity relationship classification, the problem of sparse entity relationship samples in the data itself is effectively alleviated, and the model avoids poor prediction performance of some entity relationships due to data issues. This improves the overall prediction accuracy of the model and enhances the robustness of entity relationship prediction. Attached Figure Description

[0010] Figure 1 A schematic diagram illustrating the implementation process of an entity relation extraction method provided in this application embodiment;

[0011] Figure 2A This is a schematic diagram of relation extraction provided in an embodiment of this application;

[0012] Figure 2B A schematic diagram illustrating the determination of target relationship classification results provided in an embodiment of this application.

[0013] Figure 2C A schematic diagram illustrating the determination of target relationship classification results provided in an embodiment of this application;

[0014] Figure 3A A schematic diagram illustrating the implementation process of a method for obtaining an entity relationship transition matrix provided in this application embodiment;

[0015] Figure 3B A schematic diagram of an entity relationship transition matrix provided in an embodiment of this application;

[0016] Figure 4A A schematic diagram illustrating the implementation process of the method for training an entity relationship classification model provided in this application embodiment;

[0017] Figure 4B A schematic diagram illustrating the construction of target positive samples and target negative samples provided in an embodiment of this application;

[0018] Figure 5 This is a schematic diagram of the composition structure of an entity relationship extraction device provided in an embodiment of this application;

[0019] Figure 6 This is a schematic diagram of a hardware entity of an electronic device provided in an embodiment of this application. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the embodiments will be further described in detail below with reference to the accompanying drawings. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.

[0021] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0022] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0024] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0025] Knowledge graphs, known in library and information science as knowledge domain visualization or knowledge domain mapping maps, are a series of various graphics that display the development process and structural relationships of knowledge. They use visualization techniques to describe knowledge resources and their carriers, and to mine, analyze, construct, draw, and display knowledge and the interrelationships between them. This modern theory achieves multidisciplinary integration by combining theories and methods from applied mathematics, computer graphics, information visualization technology, and information science with bibliometric citation analysis and co-occurrence analysis. It uses visualized graphs to vividly display the core structure, development history, cutting-edge fields, and overall knowledge architecture of a discipline.

[0026] This application provides an entity relation extraction method, such as... Figure 1 As shown, the method includes:

[0027] Step S110: Identify the text to be identified, and obtain at least two entities in the text to be identified and the types to which the two entities belong;

[0028] Here, the text to be identified can be unstructured text. At least two entities need to be identified from the unstructured text first, and then the types of the two entities need to be identified based on the names of the entities.

[0029] In some embodiments, relation extraction can be based on dependency parsing, and a syntactic tree can be built according to the syntactic information contained in the sentence to extract the subject-verb-object relation, where the subject and object represent two entities.

[0030] In some embodiments, named entity recognition models can be used to extract entities from the text to be recognized.

[0031] For example, Figure 2A This application provides a schematic diagram of relation extraction, such as... Figure 2A The unstructured text shown can be used to identify the entities in the unstructured text: Zhang, M Company, K Series, Z and Wang. Then, it can be determined that Zhang is a person, M Company is an organization, K Series is a brand, Z is a product, and Wang is a person.

[0032] Step S120: Obtain the entity relationship transition matrix for predicting the relationship between entities based on the ontology graph corresponding to the text to be identified; query the entity relationship transition matrix based on the type to which the two entities belong to obtain the first relationship classification result of the two entities;

[0033] Here, the entity relationship transition matrix is ​​a matrix form of the ontology graph corresponding to the text to be identified. Using this entity relationship transition matrix, the relationship between two entities can be queried based on the types of at least two entities.

[0034] Step S130: The first relationship classification result and the second relationship classification result are fused to obtain the target relationship classification result of the two entities, wherein the second relationship classification result is obtained by recognizing the text to be identified through an entity relationship classification model.

[0035] During implementation, the text to be identified can be input into the entity relationship classification model to obtain a second relationship classification result. Then, the first and second relationship classification results can be fused to obtain the target relationship classification result for the two entities.

[0036] During implementation, there are no requirements on the order in which the first relation classification result and the second relation classification result are obtained. That is, the first relation classification result and the second relation classification result can be obtained in sequence, or they can be obtained simultaneously.

[0037] For example, Figure 2B This is a schematic diagram illustrating the determination of target relationship classification results provided in an embodiment of this application, such as... Figure 2B As shown, the schematic diagram includes the text to be identified 21, the entity relationship transition matrix 22, the entity relationship classification model 23, the first relationship classification result 24, the second relationship classification result 25, and the classification result 26, wherein,

[0038] Given the classification result 26, the context, people, and organizations can be determined from the text to be identified 21. Here, people and organizations are the types of entities, and the identified entities can be specific entities.

[0039] Then, the identified entities (including entities of the type of person and organization) are input into the entity relationship transition matrix 22 to obtain the first relationship classification result (entity relationship distribution) 24.

[0040] While using the entity relationship transition matrix 22 to determine the first relationship classification result 24, the unstructured text can be input into the entity relationship classification model 23 to obtain the second relationship classification result (predicted entity relationship distribution) 25.

[0041] The first relation classification result 24 and the second relation classification result 23 are merged to obtain the target relation classification result 26 for the two entities.

[0042] In this embodiment, the text to be identified is first identified to obtain at least two entities in the text and the types to which the two entities belong. Then, an entity relationship transition matrix for predicting the relationship between entities is obtained based on the ontology graph corresponding to the text. The entity relationship transition matrix is ​​queried based on the types to which the two entities belong to obtain a first relationship classification result for the two entities. Finally, the first relationship classification result and the second relationship classification result are fused to obtain a target relationship classification result for the two entities. The second relationship classification result is obtained by identifying the text through an entity relationship classification model. In this way, by introducing the entity relationship transition matrix as prior knowledge for entity relationship classification, the problem of sparse entity relationship samples in the data itself is effectively alleviated, and the model avoids poor prediction performance of some entity relationships due to data issues. This improves the overall prediction accuracy of the model and enhances the robustness of entity relationship prediction.

[0043] In some embodiments, the "fusion processing of the first relation classification result and the second relation classification result" in step S130 above includes at least one of the following:

[0044] A. Based on the first relation classification result, the second relation classification result is corrected;

[0045] Here, the correction can be made by first comparing the first and second relation classification results, and then correcting the second classification result based on the comparison results. For example, in the second classification result, the probability of the relation being "investment" is 56%, and the probability of the relation being "employed" is 44%. In the first classification result, the probability of determining the relation as "employed" is 80%. Therefore, based on the first relation classification result, the second relation classification result can be corrected to determine the relation as "employed".

[0046] B. Perform a weighted summation on the first relation classification result and the second relation classification result.

[0047] During implementation, a first weighted value corresponding to the first relation classification result and a second weighted value corresponding to the second relation classification result can be set based on the actual situation. In this way, the first relation classification result can be multiplied by the first weighted value, and then the second relation classification result can be multiplied by the second weighted value to determine the final classification result.

[0048] For example, Figure 2C This is a schematic diagram illustrating the determination of target relationship classification results provided in an embodiment of this application, such as... Figure 2C As shown, the schematic diagram includes the text to be identified 21, the entity relationship transition matrix 22, the entity relationship classification model 23, the first relationship classification result 24, the second relationship classification result 25, and the classification result 26, wherein,

[0049] Given the classification result 26, the context, people, and organizations can be determined from the text to be identified 21. Here, people and organizations are the types of entities, and the identified entities can be specific entities.

[0050] Then, the identified entities (including entities of the type of person and organization) are input into the entity relationship transition matrix 22 to obtain the first relationship classification result 24, that is, the relationship between the two implementations: employed 0.5, invested 0.5, belonged to 0, owned 0, produced 0 and purchased 0.

[0051] While using the entity relationship transition matrix 22 to determine the first relationship classification result 24, the unstructured text can be input into the entity relationship classification model 23 to obtain the second relationship classification result 25, that is, the relationship between the two realizations: employed 0.4, invested 0.3, belonged to 0, owned 0.1, produced 0.1 and bought 0.1.

[0052] In some embodiments, the weighting parameters of both the entity relationship transition matrix and the entity relationship classification model can be set to 1. This results in classification results of: 0.9 for "employed", 0.8 for "invested", 0 for "belonging", 0.1 for "owning", 0.1 for "producing", and 0.1 for "buying". Therefore, the relationship between the two entities in the text to be identified, one being a person and the other an organization, can be determined as "employed".

[0053] In this way, by using prior entity relationship distribution weighting, we can reduce the likelihood of the entity relationship classification model predicting entity relationships outside the ontology definition, and provide better prior knowledge for entity relationship categories with sparse samples. This improves the overall prediction accuracy of the entity relationship classification model.

[0054] In this embodiment of the application, the fusion processing of the first relation classification result and the second relation classification result includes at least one of the following: modifying the second relation classification result based on the first relation classification result; and performing a weighted summation processing on the first relation classification result and the second relation classification result. In this way, the first relation classification result can be used as a priori condition to modify or weight the second classification result, thereby obtaining a more accurate classification result.

[0055] This application provides a method for obtaining an entity relationship transition matrix, such as... Figure 3A As shown, it includes the following steps:

[0056] Step S310: Determine the domain of the text to be identified;

[0057] Here, the domain of the text to be identified may include at least one of the following: finance, education, company, historical figures, entertainment industry, etc.

[0058] During implementation, the domain of the text to be identified can be determined based on the text content of the text to be identified and / or the knowledge graph to be generated.

[0059] Step S320: Determine the ontology graph corresponding to the text to be identified based on the domain of the text to be identified;

[0060] Here, ontology graphs can be used to describe different types of entities and the relationships between them.

[0061] During implementation, since each domain corresponds to a basic ontology graph, the ontology graph corresponding to the text to be identified can be determined based on the domain of the text to be identified.

[0062] Step S330: Determine the entity relationship transition matrix based on the ontology graph.

[0063] Here, the entity relationship transition matrix is ​​a matrix representation of the ontology graph, and the corresponding entity relationship transition matrix can be determined based on the ontology graph.

[0064] In this embodiment, the domain of the text to be identified is first determined; then, the ontology graph corresponding to the text to be identified is determined based on the domain of the text to be identified; finally, the entity relation transition matrix is ​​determined based on the ontology graph. In this way, the entity relation transition matrix corresponding to the text to be identified can be effectively determined based on the domain of the text to be identified.

[0065] In some embodiments, step S320 above, "determining the ontology graph corresponding to the text to be identified based on the domain of the text to be identified," can be implemented through the following steps:

[0066] Step 321: Determine the relationships between N entity types and M entity types in the domain of the text to be identified, where N is an integer greater than or equal to 2 and M is an integer greater than or equal to 1;

[0067] During implementation, the N types of entities and M types of entity relationships in the domain can be determined first based on the entity relationship identification requirements.

[0068] Step 322: Define the ontology graph based on the relationships between the N entity types and the M entity types.

[0069] Here, the ontology graph can be expressed using the following formula (1):

[0070] K =<T,R> (1);

[0071] in,

[0072] T = {t1, t2, ..., t} N Each element represents an entity type in the ontology graph, and there are a total of N entity types.

[0073] R = {r1, r2, ..., r} M Each element represents a relationship between two entity categories in the ontology graph, and there are a total of M entity relationships.

[0074] In this embodiment of the application, N entity types and M entity type relationships in the domain of the text to be identified are first determined, and then an ontology graph can be effectively defined based on the N entity types and M entity type relationships.

[0075] In some embodiments, the above step S330 "determine the entity relationship transition matrix based on the ontology graph" can be implemented through the following steps:

[0076] Step 331: Define the probability distribution P of the relationship between any two entity types among the N entity types. ti,tj , where P ti,tj It includes M probability distribution data, each of which corresponds to a certain entity type relationship probability, where i and j are both integers less than or equal to N;

[0077] During implementation, the following formula (2) can be used to define the set of probability distributions of relationships between every two entity types in N entity types:

[0078] P = {P} t1,t1 P t1,t2 ...P ti,tj ...P tN,tN} (i, j <= N) (2);

[0079] Among them, P ti,tj The data includes M probability distributions, representing the probability distributions of M types of entity relationships between entity type ti (starting entity category) and tj (ending entity category).

[0080] Step 332: Based on the N entity types, the M entity type relationships, and the relationship probability distribution P ti,tj Define the entity relationship transition matrix.

[0081] In this embodiment of the application, the probability distribution P of the relationship between each pair of entity types among the N entity types is first defined. ti,tj Then, based on the N entity types, the M entity type relationships, and the relationship probability distribution P ti,tj It can effectively define entity relationship transition matrices.

[0082] Figure 3B This is a schematic diagram of an entity relationship transition matrix provided in an embodiment of this application, as shown below. Figure 3BAs shown in the diagram, the schematic includes: an entity relationship transition matrix A and an entity relationship distribution P, where,

[0083] Two of the three edges of the entity relationship transition matrix A represent N entity types, and the other edge represents M entity type relationships.

[0084] By extracting the relationship between any two entities in the entity relationship transition matrix A, we can obtain the pairwise entity relationship assignment P. Each entity relationship assignment P includes M probability distribution data, representing each probability corresponding to each of the M entity relationships between the two entities.

[0085] During implementation, the initial probability parameters in the entity relationship transition matrix can be trained together with the entity relationship extraction model. Through gradient descent, the actual distribution of the probability parameters is gradually fitted and stored in the entity relationship transition matrix. In the model prediction stage, the entity relationship transition matrix participates in entity relationship discrimination, thereby improving the accuracy of the entity relationship extraction model.

[0086] In some embodiments, step 332 above, "based on the N entity types, the M entity type relationships, and the relationship probability distribution P", ti,tj The definition of the entity relationship transition matrix in "Defining the entity relationship transition matrix" includes at least one of the following:

[0087] A. If it is determined that there is no entity relationship between entity category ti and entity category tj, then the probability distribution P of the relationship is... ti,tj All values ​​in the value set to -X, where X is a positive integer;

[0088] For example, X can be set to 1. Then, assuming there is no entity relationship between entity category ti and entity category tj, the probability distribution P of the relationship can be... ti,tj All M probability values ​​are set to -1, which means that there is no entity relationship between the two entities.

[0089] During implementation, the size of X can be adjusted based on the actual situation.

[0090] B. If it is determined that there is one entity relationship between entity category ti and entity category tj, set the probability distribution value of the existence of one entity relationship to X, and set the probability distribution value of the other relationships to 0.

[0091] For example, the value of X can be set to 1. If it is determined that there is an entity relationship between entity category ti and entity category tj, the probability distribution value of the entity relationship is set to 1, and the probability distribution values ​​of the other relationships are set to 0. That is, among the M probability values, the probability value of the entity relationship is 1, and the probability values ​​of the M minus 1 other entities that do not have a relationship are 0.

[0092] C. If it is determined that there are K types of entity relationships between entity category ti and entity category tj, set the relationship probability distribution value corresponding to each of the K types of entity relationships to 1 / K, and set the probability distribution values ​​of the remaining relationships to 0.

[0093] In this application embodiment, three methods are provided for setting the entity relationship distribution P in the entity relationship transition matrix, so as to effectively define the entity relationship transition matrix based on the relationship and relationship probability between pairs of entities.

[0094] This application provides a method for training an entity relationship classification model, such as... Figure 4A As shown, it includes the following steps:

[0095] Step S410: Obtain unstructured text for training the entity relationship classification model;

[0096] Here, unstructured text can be obtained from a sample library corresponding to the domain of the text to be identified, and used to train the entity relationship classification model.

[0097] Step S420: Extract a training sample set from the unstructured text based on the named entity recognition model;

[0098] In entity relation extraction tasks, entities in unstructured text must first be identified, and then the entity relation extraction module determines the relationships between pairs of entities. During implementation, a named entity recognition model can be used to extract the relationships between entities from the unstructured text. The relationships between entities are then compiled into a training sample set, which includes both positive and negative samples used to train the entity relation extraction model.

[0099] Step S430: Determine the target negative sample and the target positive sample from the training sample set based on the entity relationship transition matrix;

[0100] During implementation, the ontology or entity relationship transition matrix can be used to determine the target negative samples and target positive samples for training the entity relationship classification model from the training samples.

[0101] Step S440: Train the entity relationship classification model based on the target negative sample and the target positive sample.

[0102] In some embodiments, during the training of the entity relationship classification model, the classification results can be fused using the entity relationship transition matrix to obtain more accurate classification results, thereby improving the training efficiency and effectiveness of the entity relationship classification model.

[0103] In this embodiment, unstructured text for training the entity relationship classification model is first obtained; then, a training sample set is extracted from the unstructured text based on a named entity recognition model; target negative samples and target positive samples are determined from the training sample set based on the entity relationship transition matrix; finally, the entity relationship classification model is trained based on the target negative samples and the target positive samples. Thus, in the training sample construction stage, an ontology-based sample construction enhancement strategy is implemented. By using the ontology (entity relationship transition matrix) as prior knowledge, a construction strategy for building target negative samples and target positive samples is proposed, which effectively alleviates the imbalance and redundancy of the sample data itself while reducing the model's training time.

[0104] Figure 4B This is a schematic diagram illustrating the construction of target positive samples and target negative samples provided in an embodiment of this application, as shown below. Figure 4B As shown, the diagram includes a head entity 1 and a tail entity 2 with relation 1 extracted from unstructured text, wherein the head entity 1 belongs to entity type 1 and the tail entity 1 belongs to entity type 2; and a head entity 2 and a tail entity 2 with relation 2, wherein the head entity 2 belongs to entity type 3 and the tail entity 2 belongs to entity type 4.

[0105] During implementation, the correspondence between head entity 1 and tail entity 1 is defined as positive samples. Head entity 1 and non-entity type 2 entities, non-entity type 1 entities and tail entity 1, and head entity 2 and tail entity 2 can be combined as difficult negative samples of the correspondence between head entity 1 and tail entity 1. Head entity 2 is combined with other entities as general negative samples of relation 1.

[0106] Here, the existing method for determining the training sample set is as follows: In the original entity relation extraction scheme, when there are n entities in a sentence, all entities are paired up to form... The training data (with directional relationships) is severely imbalanced and redundant.

[0107] Here, negative samples refer to two predicted entities that have no entity relationship or have a relationship other than the target entity relationship. Hard negative samples are those that, when constructing a training dataset for a certain entity relationship, are selected from the negative samples that are similar to positive samples but do not have the target entity relationship. Examples include samples that only retain the head or tail entities of the positive samples, or samples that meet the positive sample conditions for other entity relationship categories. Other types of negative samples are general negative samples.

[0108] The sample screening strategy provided in this application starts from the ontology and, based on an exhaustive list of all samples, such as... Figure 4B The diagram shows that all negative samples are divided into two categories: difficult negative samples and ordinary negative samples.

[0109] The ontology-based sample construction strategy, used for training entity relationship classification models, involves creating a training dataset by mixing difficult and general negative samples with positive samples in a specific ratio. This ensures the model encounters general negative samples during training, making it easier to identify them during prediction and enhancing its robustness.

[0110] In some embodiments, step S430, "determining target negative samples and target positive samples from the training sample set based on the entity relationship transition matrix," can be achieved through the following steps:

[0111] Step 431: Determine the target relationship, wherein the target relationship is the relationship between the positive sample head entity and the positive sample tail entity;

[0112] like Figure 4B As shown, relation 1 is defined as the target relation, that is, the target relation is the relationship between head entity 1 and tail entity 1.

[0113] Step 432: Using the entity relationship transition matrix, determine the target positive sample from the training sample set based on the target relationship;

[0114] During implementation, the entity relationship transition matrix can be used to determine the correspondence between head entity 1 and tail entity 1 from the training sample set based on relationship 1.

[0115] Step 433: Using the entity relationship transition matrix, determine difficult negative samples and general negative samples based on the positive sample head entity and the positive sample tail entity;

[0116] Step 434: Select the difficult negative samples and the general negative samples according to the ratio to obtain the target negative samples.

[0117] In this embodiment of the application, the sample construction enhancement strategy based on the entity relationship transition matrix proposed in this solution solves the problems of imbalance between positive and negative samples and data redundancy, while avoiding the model spending too much training time on general negative samples, thus reducing the training time of the model.

[0118] In some embodiments, step 433 above, "using the entity relationship transition matrix to determine difficult negative samples and general negative samples based on the positive sample head entity and the positive sample tail entity," can be achieved through the following steps:

[0119] Step 4331: Based on the entity relationship transition matrix, determine the head entities in the unstructured text other than the positive sample head entities as negative sample head entities, and determine the tail entities in the unstructured text other than the positive sample tail entities as negative sample tail entities.

[0120] Here, as Figure 4B As shown, based on the entity relationship transition matrix, entities of the head entity type other than head entity 1 can be identified as negative sample head entities, and entities of the tail entity type other than tail entity 1 can be identified as negative sample tail entities.

[0121] Step 4332: The positive sample head entity and the negative sample tail entity are combined to obtain the first difficult negative sample; the negative sample head entity and the positive sample tail entity are combined to obtain the second difficult negative sample; the negative sample head entity and the negative sample tail entity with other relationships are combined to obtain the third difficult negative sample.

[0122] During implementation, the positive sample head entity and the negative sample tail entity are combined to obtain the first difficult negative sample, such as... Figure 4B As shown, the first difficult negative sample is obtained by combining head entity 1 with non-entity type 2 entity.

[0123] Combining the negative sample head entity with the positive sample tail entity yields the second difficult negative sample, such as... Figure 4B As shown, the combination of non-entity type 1 entity and tail entity 1 yields the second difficult negative sample.

[0124] Combining the negative sample head entity with the negative sample tail entity that have other relationships yields the third hard negative sample, such as... Figure 4B As shown, the combination of head entity 2 and tail entity 2 yields the third difficult negative sample.

[0125] Step 4333: Determine the difficult negative sample based on the first difficult negative sample, the second difficult negative sample, and the third difficult negative sample;

[0126] like Figure 4B As shown, the first difficult negative sample is obtained by combining the head entity 1 with the non-entity type 2 entity, the second difficult negative sample is obtained by combining the non-entity type 1 entity with the tail entity 1, and the third difficult negative sample is obtained by combining the head entity 2 with the tail entity 2. These are identified as difficult negative samples.

[0127] Step 4334: Combine the negative sample head entity and the negative sample tail entity that have no relationship to obtain the general negative sample.

[0128] like Figure 4B As shown, combining head entity 2 with other entities yields a general negative sample.

[0129] In this embodiment, based on the entity relationship transition matrix as prior knowledge, three strategies for constructing difficult negative samples are proposed, which effectively alleviate the imbalance and redundancy of the data itself while reducing the training time of the model.

[0130] Knowledge graphs store knowledge in a structured form using triples, where each triple consists of two entities and one relation. Automating the construction of a knowledge graph requires first building an ontology file, and then automatically extracting entities and entity relations from the text based on that ontology file. During extraction, entities generally appear explicitly in the text, while entity relations are usually more abstract and require dependency syntax or deep learning models to determine them. Improving the accuracy of relation extraction has become one of the key factors limiting the automated construction of knowledge graphs.

[0131] There are two existing solutions:

[0132] Method 1: Relation extraction based on dependency parsing. A syntactic tree is built based on the syntactic information contained in the sentence, and the subject-verb-object relation is extracted from it. The subject and object represent two entities, and the verb represents the relationship between the two entities.

[0133] Method 2: Relation extraction based on deep learning models.

[0134] A) Joint Extraction Model: Employs a multi-task learning framework to simultaneously extract entities and relationships from text. The two tasks share parameters, mutually reinforcing each other for joint extraction.

[0135] B) Pipeline-based relation extraction model: This model treats entity extraction and relation extraction as two distinct tasks. First, a named entity recognition model is used to extract entities from the text. Then, the extraction results are used as input to a relation model to extract the relationships between entities.

[0136] The two existing solutions have three problems:

[0137] Problem 1: The relation extraction method using dependency parsing has limitations and cannot handle cases with complex sentence structures or where two entities are far apart.

[0138] Question 2: Both deep learning-based solutions focus on improving the model's structure, neglecting the impact of the data itself on model performance. In these solutions, the data is constructed by exhaustively listing all entity relations in a sentence, while only a small portion of these relations truly belong to the ontology definition (positive samples). This leads to data redundancy and an imbalance between positive and negative samples, resulting in excessively long model training times.

[0139] Question 3: Both deep learning-based solutions first randomly initialize model parameters, learn the feature distribution of the data, and then determine entity relationships. The problem with this approach is that not all relationships in the ontology appear in the training samples. For entity relationship types that appear less frequently or not at all in the training data, the model struggles to identify them, leading to a decrease in overall model accuracy.

[0140] This application proposes an entity relation extraction enhancement method based on ontology knowledge in relation extraction scenarios. It reduces the training time of the relation extraction model and improves the accuracy of the model by enhancing the construction of training samples and strengthening the prediction of entity relation models.

[0141] In the training sample construction stage, an ontology-based sample construction enhancement strategy is proposed. Using ontology files as prior knowledge, three strategies for constructing difficult negative samples are proposed, effectively alleviating data imbalance and redundancy while reducing model training time.

[0142] In the entity relationship prediction stage, an ontology-based entity relationship classification enhancement strategy is proposed. Introducing ontology information as prior knowledge for entity relationship classification effectively alleviates the problem of sparse entity relationship samples in the data itself, preventing the model from performing poorly in predicting some entity relationships due to data issues. This improves the overall accuracy of the model's predictions.

[0143] The entity relation extraction enhancement method based on ontology knowledge proposed in this application includes an ontology-based sample construction enhancement strategy and an entity relation classification enhancement strategy. This solution not only addresses the issues of data redundancy and imbalance, but also allows for flexible integration with previous solutions and application in various deep learning-based entity relation prediction models. Therefore, this solution possesses good practicality and effectiveness.

[0144] Based on the foregoing embodiments, this application provides an entity relationship extraction device. The device includes various modules, each module includes sub-modules, and each sub-module includes units. It can be implemented by a processor in an electronic device; of course, it can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0145] Figure 5 This is a schematic diagram of the composition structure of the entity relationship extraction device provided in the embodiments of this application, as shown below. Figure 5 As shown, the device 500 includes:

[0146] The recognition module 510 is used to recognize the text to be recognized and obtain at least two entities in the text to be recognized and the types to which the two entities belong;

[0147] The first obtaining module 520 is used to obtain an entity relationship transition matrix for predicting the relationship between entities based on the ontology graph corresponding to the text to be identified, and to query the entity relationship transition matrix based on the type to which the two entities belong to obtain the first relationship classification result of the two entities;

[0148] The fusion module 530 is used to fuse the first relationship classification result and the second relationship classification result to obtain the target relationship classification result of the two entities, wherein the second relationship classification result is obtained by recognizing the text to be identified through an entity relationship classification model.

[0149] In some embodiments, the fusion module 530 includes a correction submodule and a weighted summation submodule, wherein the correction submodule is used to correct the second relation classification result based on the first relation classification result; and the weighted summation submodule is used to perform weighted summation on the first relation classification result and the second relation classification result.

[0150] In some embodiments, the apparatus further includes a first determining module, a second determining module, and a third determining module, wherein the first determining module is configured to determine the domain of the text to be identified; the second determining module is configured to determine the ontology graph corresponding to the text to be identified based on the domain of the text to be identified; and the third determining module is configured to determine the entity relationship transition matrix based on the ontology graph.

[0151] In some embodiments, the second determining module includes a first determining submodule and a first defining submodule, wherein the first determining submodule is used to determine N entity types and M entity type relationships in the domain of the text to be identified, wherein N is an integer greater than or equal to 2 and M is an integer greater than or equal to 1; the first defining submodule is used to define the ontology graph based on the N entity types and M entity type relationships.

[0152] In some embodiments, the third determining module includes a second defining submodule and a third defining submodule, wherein the second defining submodule is used to define the probability distribution P of the relationship between every two entity types among the N entity types. ti,tj , where P ti,tj The system includes M probability distribution data points, each corresponding to a relationship probability of an entity type, where i and j are integers less than or equal to N. The third definition submodule is used to define the relationships based on the N entity types, the M entity type relationships, and the relationship probability distribution P. ti,tj Define the entity relationship transition matrix.

[0153] In some embodiments, the third definition submodule includes a first setting unit, a second setting unit, and a third setting unit, wherein the first setting unit is configured to, when it is determined that entity category ti and entity category tj do not have an entity relationship, set the relationship probability distribution P. ti,tj The first setting unit sets all values ​​to -X, where X is a positive integer; the second setting unit is used to set the probability distribution value of the existence of one entity relationship to X and the probability distribution values ​​of the remaining relationships to 0 when it is determined that there is one entity relationship between entity category ti and entity category tj; the third setting unit is used to set the relationship probability distribution value corresponding to each of the K entity relationships to 1 / k and the probability distribution values ​​of the remaining relationships to 0 when it is determined that there are K entity relationships between entity category ti and entity category tj.

[0154] In some embodiments, the apparatus further includes a second obtaining module, an extraction module, a fourth determining module, and a training module, wherein the second obtaining module is used to obtain unstructured text for training the entity relationship classification model; the extraction module is used to extract a training sample set from the unstructured text based on a named entity recognition model; the fourth determining module is used to determine target negative samples and target positive samples from the training sample set based on the entity relationship transition matrix; and the training module is used to train the entity relationship classification model based on the target negative samples and the target positive samples.

[0155] In some embodiments, the fourth determining module includes a second determining submodule, a third determining submodule, a fourth determining submodule, and a proportioning selection submodule. The second determining submodule is used to determine a target relationship, wherein the target relationship is the relationship between a positive sample head entity and a positive sample tail entity. The third determining submodule is used to determine the target positive sample from the training sample set based on the target relationship using the entity relationship transition matrix. The fourth determining submodule is used to determine difficult negative samples and general negative samples based on the positive sample head entity and the positive sample tail entity using the entity relationship transition matrix. The proportioning selection submodule is used to select the difficult negative samples and the general negative samples proportionally to obtain the target negative sample.

[0156] In some embodiments, the fourth determining submodule includes a first determining unit, a second determining unit, and a combining unit, wherein the first determining unit is used to determine, based on the entity relationship transition matrix, that the head entities in the unstructured text other than the positive sample head entities are negative sample head entities, and to determine that the tail entities in the unstructured text other than the positive sample tail entities are negative sample tail entities.

[0157] Wherein, the positive sample head entity and the negative sample tail entity are combined to obtain a first difficult negative sample; the negative sample head entity and the positive sample tail entity are combined to obtain a second difficult negative sample; the negative sample head entity and the negative sample tail entity with other relationships are combined to obtain a third difficult negative sample; the second determining unit is used to determine the difficult negative sample based on the first difficult negative sample, the second difficult negative sample and the third difficult negative sample; the combining unit is used to combine the negative sample head entity and the negative sample tail entity with no relationship to obtain the general negative sample.

[0158] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0159] It should be noted that, in the embodiments of this application, if the above methods are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause electronic devices (such as mobile phones, tablets, laptops, desktop computers, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0160] Correspondingly, embodiments of this application provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the entity relation extraction method provided in the above embodiments.

[0161] Correspondingly, embodiments of this application provide an electronic device, Figure 6 A schematic diagram of a hardware entity of an electronic device provided in an embodiment of this application, such as... Figure 6 As shown, the hardware entity of the device 600 includes a memory 601 and a processor 602. The memory 601 stores a computer program that can run on the processor 602. When the processor 602 executes the program, it implements the steps in the entity relationship extraction method provided in the above embodiments.

[0162] The memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data and video communication data) of the processor 602 and various modules in the electronic device 600, and can be implemented by flash memory or random access memory (RAM).

[0163] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0164] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0165] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0166] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0167] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0168] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0169] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0170] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, 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 an electronic device (which may be a mobile phone, tablet computer, laptop computer, desktop computer, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.

[0171] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0172] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0173] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

[0174] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for extracting entity relations, characterized in that, The method includes: Identify the text to be identified, and obtain at least two entities in the text to be identified and the types to which the two entities belong; Based on the ontology graph corresponding to the text to be identified, an entity relationship transition matrix is ​​obtained to predict the relationship between entities. The entity relationship transition matrix is ​​queried based on the type to which the two entities belong to, and the first relationship classification result of the two entities is obtained. The first relationship classification result and the second relationship classification result are fused to obtain the target relationship classification result of the two entities, wherein the second relationship classification result is obtained by recognizing the text to be identified through an entity relationship classification model; The ontology graph is used to describe different types of entities and the relationships between them.

2. The method as described in claim 1, wherein the fusion processing of the first relation classification result and the second relation classification result includes at least one of the following: Based on the first relation classification result, the second relation classification result is corrected. The first relation classification result and the second relation classification result are weighted and summed.

3. The method of claim 1, further comprising: Determine the domain of the text to be identified; The ontology graph corresponding to the text to be identified is determined based on the domain of the text to be identified; The entity relationship transition matrix is ​​determined based on the ontology graph.

4. The method of claim 3, wherein determining the ontology graph corresponding to the text to be identified based on the domain of the text to be identified includes: Determine the relationships between N entity types and M entity types in the domain of the text to be identified, where N is an integer greater than or equal to 2 and M is an integer greater than or equal to 1; The ontology graph is defined based on the relationships between the N entity types and the M entity types.

5. The method of claim 4, wherein determining the entity relationship transition matrix based on the ontology graph comprises: Define the probability distribution P of the relationship between any two entity types among the N entity types. ti,tj , where P ti,tj It includes M probability distribution data, each of which corresponds to a certain entity type relationship probability, where i and j are both integers less than or equal to N; Based on the N entity types, the M entity type relationships, and the relationship probability distribution P ti,tj Define the entity relationship transition matrix.

6. The method as described in claim 5, wherein the step of basing the N entity types, the M entity type relationships, and the relationship probability distribution P... ti,tj The entity relationship transition matrix is ​​defined, including at least one of the following: If it is determined that there is no entity relationship between entity category ti and entity category tj, then the relationship probability distribution P is... ti,tj All values ​​in the value set to -X, where X is a positive integer; If it is determined that there is one entity relationship between entity category ti and entity category tj, the probability distribution value of the existence of one entity relationship is set to X, and the probability distribution values ​​of the other relationships are set to 0. Given that there are K types of entity relationships between entity categories ti and tj, the probability distribution value of each of the K types of entity relationships is set to 1 / k, and the probability distribution values ​​of the remaining relationships are set to 0.

7. The method of claim 1, further comprising: Obtain unstructured text for training the entity relationship classification model; A training sample set is extracted from the unstructured text based on the named entity recognition model; Based on the entity relationship transition matrix, target negative samples and target positive samples are determined from the training sample set; The entity relationship classification model is trained based on the target negative sample and the target positive sample.

8. The method of claim 7, wherein determining the target negative sample and the target positive sample from the training sample set based on the entity relationship transition matrix comprises: Determine the target relationship, wherein the target relationship is the relationship between the positive sample head entity and the positive sample tail entity; Using the entity relationship transition matrix, the target positive sample is determined from the training sample set based on the target relationship; Using the entity relationship transition matrix, difficult negative samples and general negative samples are determined based on the positive sample head entity and the positive sample tail entity; The target negative sample is obtained by selecting the difficult negative sample and the general negative sample in proportion.

9. The method of claim 8, wherein determining difficult negative samples and general negative samples based on the positive sample head entity and the positive sample tail entity using the entity relationship transition matrix comprises: Based on the entity relationship transition matrix, the head entities in the unstructured text other than the positive sample head entities are determined to be negative sample head entities, and the tail entities in the unstructured text other than the positive sample tail entities are determined to be negative sample tail entities. Wherein, the positive sample head entity and the negative sample tail entity are combined to obtain a first difficult negative sample; the negative sample head entity and the positive sample tail entity are combined to obtain a second difficult negative sample; and the negative sample head entity and the negative sample tail entity with other relationships are combined to obtain a third difficult negative sample. The difficult negative sample is determined based on the first difficult negative sample, the second difficult negative sample, and the third difficult negative sample; The negative sample head entity and the negative sample tail entity that have no relation are combined to obtain the general negative sample.

10. An entity relation extraction device, characterized in that, The device includes: The recognition module is used to recognize the text to be recognized and obtain at least two entities in the text to be recognized and the types to which the two entities belong; The first obtaining module is used to obtain an entity relationship transition matrix for predicting the relationship between entities based on the ontology graph corresponding to the text to be identified, and to query the entity relationship transition matrix based on the type to which the two entities belong to obtain the first relationship classification result of the two entities; The fusion module is used to fuse the first relationship classification result and the second relationship classification result to obtain the target relationship classification result of the two entities, wherein the second relationship classification result is obtained by recognizing the text to be identified through an entity relationship classification model; The ontology graph is used to describe different types of entities and the relationships between them.