A method, device and apparatus for extracting relations between entities

By using BERT network and mapping network, combining the label value and influence of semantic units, the problem of extracting entity relationships in the prior art requires a large amount of manual annotation, and efficient and accurate entity relationship extraction is achieved.

CN114218952BActive Publication Date: 2025-03-28QIAN XINTIAN GUANGHUITONG TECHNOLOGY (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111556200.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2025-03-28
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

In the prior art, when extracting relationships between entities, a large amount of manual marking corpus is required, which consumes manpower and time, and the extraction effect is not good.

Method used

Using a method based on BERT network and mapping network, by determining the label value and influence of semantic units, we can judge whether there is a target relationship between entities in the to-process corpus, and reduce the need for manual annotation.

Benefits of technology

It realizes convenient and accurate extraction of relationships between entities, improves information processing efficiency, reduces the cost of manual labeling, and improves the extraction effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114218952B_ABST
    Figure CN114218952B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus and device for extracting relations between entities. In the method, a BERT network and a mapping network are used, and the concept of influence of semantic units of a subject and object of a relationship is introduced. Reasonable preset conditions for judging whether a target relationship exists are set according to a sufficiently rich training corpus. Based on the influence of semantic units of a subject and object of a relationship and whether the label values ​​of each semantic unit meet the preset conditions, it is accurately determined whether a target relationship exists between a pair of subjects and objects in the corpus. Without a large amount of manual annotation, the relationship between entities can be conveniently and accurately extracted, thereby improving information processing efficiency and facilitating people to extract effective information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device and apparatus for extracting relationships between entities. Background Art

[0002] With the development of Internet technology, there is a huge amount of information to be processed. How to extract effective information that people are concerned about from text has become an important issue in the field of natural language processing. Among the effective information that people are concerned about, the relationship between entities is often the focus of people's attention. For example, people will pay attention to whether there is a relationship between the birth time of two types of entities, such as people and dates, in a paragraph.

[0003] Currently, entity relationship extraction can be achieved through rule-based, traditional machine learning, or deep learning. However, no matter which method is used, a large amount of corpus needs to be manually labeled, which consumes manpower and time, and the extraction effect is not good.

[0004] Based on this, there is an urgent need to provide a technical solution for extracting the relationship between entities conveniently and accurately, improve information processing efficiency, and facilitate people in extracting effective information. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus and device for extracting relationships between entities, which can conveniently and accurately extract relationships between entities, improve information processing efficiency, and provide convenience for people to extract effective information.

[0006] In a first aspect, an embodiment of the present application provides a method for extracting relationships between entities, the method comprising:

[0007] Acquire a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit;

[0008] According to the transformer-based bidirectional encoder representation BERT network and the trained mapping network, determine a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, a fourth influence of the first semantic unit on the fourth semantic unit, a fifth influence of the third semantic unit on the first semantic unit, a sixth influence of the third semantic unit on the second semantic unit, a seventh influence of the fourth semantic unit on the first semantic unit, and an eighth influence of the fourth semantic unit on the second semantic unit;

[0009] If the first label value, the second label value, the third label value, the fourth label value and the average influence meet the preset conditions, then it is determined that there is a target relationship between the first relationship subject and the first relationship object, and the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence.

[0010] In some implementations, determining, according to the transformer-based bidirectional encoder representation BERT network and the trained mapping network, a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, and a fourth label value of the fourth semantic unit, comprises:

[0011] Inputting the corpus to be processed into the BERT network to obtain the embedded vector corresponding to each semantic unit in the corpus to be processed;

[0012] The embedded vector corresponding to each semantic unit in the corpus to be processed is input into the mapping network to obtain the label value corresponding to each semantic unit in the corpus to be processed, wherein the label value corresponding to each semantic unit in the corpus to be processed includes the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit and the fourth label value of the fourth semantic unit.

[0013] In some implementations, determining, according to a transformer-based bidirectional encoder representation BERT network and a mapping network, a first influence of the first semantic unit on the third semantic unit and a second influence of the first semantic unit on the fourth semantic unit includes:

[0014] Replacing the first semantic unit in the to-be-processed corpus with a target label to obtain an intermediate corpus;

[0015] Processing the intermediate corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the intermediate corpus, wherein the label value corresponding to each semantic unit in the intermediate corpus includes a fifth label value of the third semantic unit and a sixth label value of the fourth semantic unit;

[0016] The first influence is calculated according to the fifth label value and the third label value, and the second influence is calculated according to the sixth label value and the fourth label value.

[0017] As an example, calculating the first influence according to the fifth label value and the third label value includes:

[0018] An absolute value of a difference between the fifth label value and the third label value is calculated and recorded as the first influence.

[0019] In some implementations, the first label value, the second label value, the third label value, the fourth label value, and the influence average satisfy a preset condition, including:

[0020] At least one of the first label value and the second label value is greater than a first label threshold, and at least one of the third label value and the fourth label value is greater than a second label threshold, and the influence mean value represents the existence of the target relationship between the subject and the object.

[0021] As an example, the influence mean value represents the existence of the target relationship between the subject and the object, including:

[0022] Between the first influence threshold and the second influence threshold, the influence mean is closer to the second influence threshold, the first influence threshold indicates that the target relationship does not exist between the subject and the object, and the second influence threshold indicates that the target relationship exists between the subject and the object;

[0023] Alternatively, in the first influence range and the second influence range, the influence mean belongs to the second influence range, the first influence range indicates that the target relationship does not exist between the subject and the object, and the second influence range indicates that the target relationship exists between the subject and the object.

[0024] In some implementations, the method further includes:

[0025] The preset condition is determined according to the training corpus, the BERT network and the mapping network.

[0026] As an example, determining the preset condition according to the training data set, the BERT network, and the mapping network includes:

[0027] According to all positive examples in the training corpus, the BERT network and the mapping network, a first mean of all positive examples in the training corpus is obtained, wherein the positive example refers to a corpus in which a subject and an object have the target relationship.

[0028] According to all the counter-examples in the training corpus, the BERT network and the mapping network, a second mean of all the counter-examples in the training corpus is obtained, wherein the counter-example refers to a corpus in which the target relationship does not exist between a subject and an object;

[0029] The first influence threshold is determined according to the first mean value, and the second influence threshold is determined according to the second mean value; or, the first influence range and the second influence range are determined according to the first mean value and the second mean value.

[0030] Wherein, obtaining a first mean of all positive examples in the training corpus according to all positive examples in the training corpus, the BERT network and the mapping network comprises:

[0031] Determining the first mean value based on the influence of each positive example among all the positive examples, wherein determining the influence of the first positive example among all the positive examples includes:

[0032] Passing a first positive example in the training corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the first positive example, wherein the first positive example includes a second relation subject and a second relation object, the second relation subject includes a fifth semantic unit and a sixth semantic unit, and the second relation object includes a seventh semantic unit and an eighth semantic unit;

[0033] Replacing each semantic unit in the second relationship subject and the second relationship object with the target label respectively, and passing the replaced corpus through the BERT network and the mapping network, to obtain the ninth influence of the fifth semantic unit on the seventh semantic unit, the tenth influence of the fifth semantic unit on the eighth semantic unit, the eleventh influence of the sixth semantic unit on the seventh semantic unit, the twelfth influence of the sixth semantic unit on the eighth semantic unit, the thirteenth influence of the seventh semantic unit on the fifth semantic unit, the fourteenth influence of the seventh semantic unit on the sixth semantic unit, the fifteenth influence of the eighth semantic unit on the fifth semantic unit, and the sixteenth influence of the eighth semantic unit on the sixth semantic unit;

[0034] The influence of the first positive example is determined based on the ninth influence, the tenth influence, the eleventh influence, the twelfth influence, the thirteenth influence, the fourteenth influence, the fifteenth influence, and the sixteenth influence.

[0035] In some implementations, the training corpus includes a collected corpus and an extended corpus, and the extended corpus is a corpus obtained by performing subject-object replacement on positive examples and negative examples in the collected corpus.

[0036] As an example, the method further includes:

[0037] The training text is preprocessed to obtain the collected corpus.

[0038] In some implementations, preprocessing the training text to obtain the collected corpus includes:

[0039] Sentence the training text to obtain a number of corpora;

[0040] Using a named entity extraction tool, obtaining an entity type of each of the plurality of corpora;

[0041] Screening valid corpora from the plurality of corpora, and obtaining a relation subject and a relation object in each valid corpus, wherein the valid corpus is a corpus including a relation subject and a relation object corresponding to the target relation;

[0042] The collected corpus includes corpus in which the target relationship exists in the effective corpus as a positive example, and corpus in which the target relationship does not exist in the effective corpus as a negative example.

[0043] In some implementations, the method further includes:

[0044] Based on the training corpus, obtaining a training data set;

[0045] The initial mapping network is trained based on the training data set to obtain the above mapping network.

[0046] Wherein, obtaining a training data set based on the training corpus includes:

[0047] Input each corpus in the training corpus into the BERT network to obtain an embedded vector of each semantic unit of each corpus in the training corpus;

[0048] The semantic units included in the relation subject and the relation object in each corpus of the training corpus are assigned a label value of 1, and the other semantic units except the relation subject and the relation object in each corpus of the training corpus are assigned a label value of 0, so as to obtain the training samples in the training data set, wherein each training sample includes the semantic units in the corresponding training corpus, the embedded vector corresponding to the semantic unit and the label value corresponding to the semantic unit.

[0049] In a second aspect, an embodiment of the present application further provides a device for extracting relationships between entities, including:

[0050] A first acquisition unit is used to acquire a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit;

[0051] A first determining unit is used to determine, according to a transformer-based bidirectional encoder representation BERT network and a trained mapping network, a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, a fourth influence of the first semantic unit on the fourth semantic unit, a fifth influence of the third semantic unit on the first semantic unit, a sixth influence of the third semantic unit on the second semantic unit, a seventh influence of the fourth semantic unit on the first semantic unit, and an eighth influence of the fourth semantic unit on the second semantic unit;

[0052] A second determination unit is used to determine that there is a target relationship between the first relationship subject and the first relationship object if the first label value, the second label value, the third label value, the fourth label value and the average influence meet a preset condition, and the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence.

[0053] In some implementations, the first determining unit includes:

[0054] A first processing subunit is used to input the corpus to be processed into the BERT network to obtain an embedded vector corresponding to each semantic unit in the corpus to be processed;

[0055] The second processing sub-unit is used to input the embedded vector corresponding to each semantic unit in the corpus to be processed into the mapping network to obtain the label value corresponding to each semantic unit in the corpus to be processed, and the label value corresponding to each semantic unit in the corpus to be processed includes the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit and the fourth label value of the fourth semantic unit.

[0056] In some implementations, the first determining unit includes:

[0057] A first replacement subunit is used to replace the first semantic unit in the corpus to be processed with a target label to obtain an intermediate corpus;

[0058] A third processing subunit is used to process the intermediate corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the intermediate corpus, wherein the label value corresponding to each semantic unit in the intermediate corpus includes a fifth label value of the third semantic unit and a sixth label value of the fourth semantic unit;

[0059] A calculation subunit is used to calculate the first influence according to the fifth label value and the third label value, and calculate the second influence according to the sixth label value and the fourth label value.

[0060] As an example, the computing subunit is specifically used for:

[0061] An absolute value of a difference between the fifth label value and the third label value is calculated and recorded as the first influence.

[0062] In some implementations, the first label value, the second label value, the third label value, the fourth label value, and the influence average satisfy a preset condition, including:

[0063] At least one of the first label value and the second label value is greater than a first label threshold, and at least one of the third label value and the fourth label value is greater than a second label threshold, and the influence mean value represents the existence of the target relationship between the subject and the object.

[0064] As an example, the influence mean value represents the existence of the target relationship between the subject and the object, including:

[0065] Between the first influence threshold and the second influence threshold, the influence mean is closer to the second influence threshold, the first influence threshold indicates that the target relationship does not exist between the subject and the object, and the second influence threshold indicates that the target relationship exists between the subject and the object;

[0066] Alternatively, in the first influence range and the second influence range, the influence mean belongs to the second influence range, the first influence range indicates that the target relationship does not exist between the subject and the object, and the second influence range indicates that the target relationship exists between the subject and the object.

[0067] In some implementations, the apparatus further includes:

[0068] The third determining unit is used to determine the preset condition according to the training corpus, the BERT network and the mapping network.

[0069] As an example, the third determining unit includes:

[0070] a fourth processing subunit, configured to obtain a first mean of all positive examples in the training corpus according to all positive examples in the training corpus, the BERT network, and the mapping network, wherein the positive example refers to a corpus in which a subject and an object have the target relationship;

[0071] a fifth processing subunit, configured to obtain a second mean of all counterexamples in the training corpus according to all counterexamples in the training corpus, the BERT network, and the mapping network, wherein the counterexample refers to a corpus in which the target relationship does not exist between a subject and an object;

[0072] A determination subunit is used to determine the first influence threshold according to the first mean value, and determine the second influence threshold according to the second mean value; or, determine the first influence range and the second influence range according to the first mean value and the second mean value.

[0073] Wherein, the fourth processing subunit is used for:

[0074] The first mean is determined based on the influence of each positive example among all the positive examples, wherein the fourth processing subunit is used to determine the influence of the first positive example among all the positive examples, specifically to:

[0075] The first positive example in the training corpus is passed through the BERT network and the mapping network to obtain the label value corresponding to each semantic unit in the first positive example, wherein the first positive example includes a second relation subject and a second relation object, the second relation subject includes a fifth semantic unit and a sixth semantic unit, and the second relation object includes a seventh semantic unit and an eighth semantic unit; each semantic unit in the second relation subject and the second relation object is replaced with the target label, and the replaced corpus is passed through the BERT network and the mapping network to obtain the ninth influence of the fifth semantic unit on the seventh semantic unit and the tenth influence of the fifth semantic unit on the eighth semantic unit. , the eleventh influence of the sixth semantic unit on the seventh semantic unit, the twelfth influence of the sixth semantic unit on the eighth semantic unit, the thirteenth influence of the seventh semantic unit on the fifth semantic unit, the fourteenth influence of the seventh semantic unit on the sixth semantic unit, the fifteenth influence of the eighth semantic unit on the fifth semantic unit, and the sixteenth influence of the eighth semantic unit on the sixth semantic unit; based on the ninth influence, the tenth influence, the eleventh influence, the twelfth influence, the thirteenth influence, the fourteenth influence, the fifteenth influence and the sixteenth influence, determine the influence of the first positive example.

[0076] In some implementations, the training corpus includes a collected corpus and an extended corpus, and the extended corpus is a corpus obtained by performing subject-object replacement on positive examples and negative examples in the collected corpus.

[0077] As an example, the device further includes:

[0078] The second acquisition unit is used to preprocess the training text to obtain the collected corpus.

[0079] In some implementations, the second acquiring unit includes:

[0080] A sentence division unit is used to divide the training text into sentences to obtain a plurality of corpora;

[0081] An extraction subunit, used to obtain the entity type of each of the plurality of corpora using a named entity extraction tool;

[0082] A screening subunit, used to screen valid corpora from the plurality of corpora and obtain the relationship subject and relationship object in each valid corpus, wherein the valid corpus is a corpus including the relationship subject and relationship object corresponding to the target relationship;

[0083] The collected corpus includes corpus in which the target relationship exists in the effective corpus as a positive example, and corpus in which the target relationship does not exist in the effective corpus as a negative example.

[0084] In some implementations, the apparatus further includes:

[0085] A third acquisition unit, configured to obtain a training data set based on the training corpus;

[0086] A training unit is used to train an initial mapping network based on a training data set to obtain the mapping network involved in the first aspect above.

[0087] Wherein, the third acquisition unit includes:

[0088] A sixth processing subunit, configured to input each corpus in the training corpus into the BERT network to obtain an embedded vector of each semantic unit of each corpus in the training corpus;

[0089] The seventh processing sub-unit is used to assign a label value of 1 to the semantic units included in the relationship subject and the relationship object in each corpus of the training corpus, and assign a label value of 0 to other semantic units except the relationship subject and the relationship object in each corpus of the training corpus, so as to obtain the training samples in the training data set, wherein each training sample includes each semantic unit in the corresponding training corpus, the embedded vector corresponding to the semantic unit and the label value corresponding to the semantic unit.

[0090] It should be noted that the specific implementation method and effect achieved by the device for extracting relations between entities provided in the second aspect can refer to the description of the relevant embodiments of the method for extracting relations between entities shown in the first aspect.

[0091] In a third aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising a processor and a memory:

[0092] The memory is used to store computer programs;

[0093] The processor is used to execute the method provided in the first aspect according to the computer program.

[0094] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method provided in the first aspect above.

[0095] It can be seen that the embodiments of the present application have the following beneficial effects:

[0096] The embodiment of the present application provides a method for extracting relations between entities, the method comprising: obtaining a to-be-processed corpus including a first relation subject and a first relation object, assuming that the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit, then, according to a BERT network and a mapping network, a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, and a first influence of the first semantic unit on the fourth semantic unit can be determined. The fourth influence of the third semantic unit on the first semantic unit, the fifth influence of the third semantic unit on the second semantic unit, the sixth influence of the third semantic unit on the second semantic unit, the seventh influence of the fourth semantic unit on the first semantic unit, and the eighth influence of the fourth semantic unit on the second semantic unit; thereby, judging whether the first label value, the second label value, the third label value, the fourth label value and the average influence meet the preset conditions, and if so, determining that the first relationship subject and the first relationship object have a target relationship, wherein the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence. It can be seen that the method provided in the embodiment of the present application not only makes use of the BERT network and the mapping network, but also introduces the concept of the influence of the semantic units of the subject and object relationship, and sets reasonable preset conditions for judging whether there is a target relationship based on a sufficiently rich training corpus. Based on the influence of the semantic units of the subject and object relationship and whether the label values ​​of each semantic unit meet the preset conditions, it is accurately determined whether there is a target relationship between a pair of subjects and objects in the corpus. Without a large amount of manual annotation, the relationship between entities can be conveniently and accurately extracted, thereby improving information processing efficiency and providing convenience for people to extract effective information. BRIEF DESCRIPTION OF THE DRAWINGS

[0097] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0098] Figure 1 A flowchart of a method for extracting relationships between entities provided in an embodiment of the present application;

[0099] Figure 2A schematic diagram of the structure of a mapping network provided in an embodiment of the present application;

[0100] Figure 3 A schematic diagram of the structure of a device for extracting relationships between entities provided in an embodiment of the present application;

[0101] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0102] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It is understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. In addition, it should be noted that, for ease of description, only the parts related to the present application are shown in the accompanying drawings, not all structures.

[0103] The current rule-based entity relationship extraction technology mainly designs certain rules for matching based on the contextual features of the related entities in the text to obtain the entities and the types of relationships between them. This method requires the rule builder to have a deep understanding of the background and characteristics of the field involved. In other words, the designed rules are often only applicable to specific fields, and obviously have poor portability across fields. In addition, the cost of manual annotation is high and the recall rate is low.

[0104] The current entity relationship extraction technology based on traditional machine learning first extracts the semantic features of the entities with relationships in the text and their contexts, then trains the annotation or classification model based on the annotated data, and uses the model to predict the corpus. The current entity relationship extraction technology based on deep learning requires a large amount of training corpus to train a relatively complex deep learning network. It can use a pipeline extraction method to first mark the entities and then identify the relationships between the entities, or it can also use a joint method to directly identify the entities and the relationships between them. These methods, on the one hand, require a large amount of training corpus, and when extracting certain types of relationships in certain user-specified specific fields, there is often not enough corpus for training; on the other hand, they require a large amount of complex manual annotation, which consumes too much labor and time costs; in addition, directly extracting relational entities from text is equivalent to identifying semantic units containing specific semantic types from the entire semantic space, which often does not work well without a large amount of corpus training.

[0105] Based on this, an embodiment of the present application provides a method for conveniently and accurately extracting relations between entities. In the method, first, a corpus to be processed including a first relationship subject and a first relationship object is obtained. Assuming that the first relationship subject includes a first semantic unit and a second semantic unit, and the first relationship object includes a third semantic unit and a fourth semantic unit, then the method can determine the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, the fourth label value of the fourth semantic unit, the first influence of the first semantic unit on the third semantic unit, the second influence of the first semantic unit on the fourth semantic unit, the third influence of the second semantic unit on the third semantic unit, and the first semantic unit according to the BERT network and the mapping network. The fourth influence of the unit on the fourth semantic unit, the fifth influence of the third semantic unit on the first semantic unit, the sixth influence of the third semantic unit on the second semantic unit, the seventh influence of the fourth semantic unit on the first semantic unit, and the eighth influence of the fourth semantic unit on the second semantic unit; thereby, judging whether the first label value, the second label value, the third label value, the fourth label value and the influence average meet the preset conditions, and if so, determining that the first relationship subject and the first relationship object have a target relationship, wherein the influence average is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence.

[0106] It can be seen that the method provided in the embodiment of the present application not only makes use of the BERT network and the mapping network, but also introduces the concept of the influence of the semantic units of the subject and object relationship, and sets reasonable preset conditions for judging whether there is a target relationship based on a sufficiently rich training corpus. Based on the influence of the semantic units of the subject and object relationship and whether the label values ​​of each semantic unit meet the preset conditions, it is accurately determined whether there is a target relationship between a pair of subjects and objects in the corpus. Without a large amount of manual annotation, the relationship between entities can be conveniently and accurately extracted, thereby improving information processing efficiency and providing convenience for people to extract effective information.

[0107] It should be noted that the subject implementing the method for extracting the relationship between entities may be a device for extracting the relationship between entities provided in the embodiment of the present application, and the device may be carried in an electronic device or a functional module of an electronic device. The electronic device in the embodiment of the present application may be any device capable of implementing the method for extracting the relationship between entities in the embodiment of the present application.

[0108] To facilitate understanding of the specific implementation of the method for extracting relationships between entities provided in the embodiment of the present application, an illustration will be provided below with reference to the accompanying drawings.

[0109] Figure 1 A flow chart of a method for extracting relations between entities provided in an embodiment of the present application. The method is applied to a device for extracting relations between entities. It should be noted that the corpus to be processed in the embodiment of the present application may be a sentence, and the corpus to be processed may include at least one pair of relational subjects and objects, and the method for extracting relations for each pair of relational subjects and objects is the same; moreover, in the embodiment of the present application, a semantic unit refers to a Chinese character or an English word or a string of numbers, and a relational subject or a relational object includes at least one semantic unit, and the processing of multiple semantic units is implemented in the same steps in the method. In summary, in order to more clearly describe the embodiment of the present application, the following is an example of any pair of relational subjects and objects in the corpus to be processed (i.e., a first relational subject and a first relational object), each of which includes two semantic units (i.e., the first relational subject includes a first semantic unit and a second semantic unit, and the first relational object includes a third semantic unit and a fourth semantic unit).

[0110] like Figure 1 As shown, the method may include the following S101 to S103:

[0111] S101, obtaining a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit.

[0112] The corpus to be processed can be any corpus in the text to be analyzed that contains both the subject and object of the relationship that may have the target relationship. For example, if the target relationship is the date of birth, the subject of the relationship is the person, the object of the relationship is the date, and the text to be analyzed is "Zhang San, born in 1963. Zhang San is from County B, Province A. Zhang San graduated from University C in 1993." Then, the corpus to be processed can be "Zhang San, born in 1963." or "Zhang San graduated from University C in 1993."

[0113] In specific implementation, S101 may include: S11, sentence-segmenting the text to be analyzed to obtain a number of corpora; S12, extracting the named entities in each corpus using a general named entity extraction tool, and marking each entity type; S13, screening the valid corpora in the several corpora, and obtaining the relationship subject and relationship object in each valid corpus, wherein the valid corpora may include both the relationship subject and relationship object of the preset type that may have the target relationship. The valid corpora marked with the entity type can be considered as the corpus to be processed in S101. As an example, the target relationship is birth time, the relationship subject is a person, the relationship object is a date, and the text to be analyzed is "Zhang San, born in 1963. Zhang San is from County B, Province A. Zhang San graduated from University C in 1993." Then, after S11, three corpora can be obtained: Corpus 1, "Zhang San, born in 1963.", Corpus 2, "Zhang San is from County B, Province A." and Corpus 3, "Zhang San graduated from University C in 1993."; after S12, the following content can be obtained in Table 1:

[0114] Table 1

[0115]

[0116]

[0117] After S13, the following contents as shown in Table 2 can be obtained:

[0118] Table 2

[0119]

[0120] Then, the corpus to be processed in S101 can be Corpus 1 or Corpus 3 in Table 2. If the corpus to be processed is Corpus 1, then the first relation subject is Zhang San, the first relation object is 1963, the first semantic unit is Zhang, the second semantic unit is San, the third semantic unit is 1963, and the fourth semantic unit is Year. If the corpus to be processed is Corpus 3, then the first relation subject is Zhang San, the first relation object is 1993, the first semantic unit is Zhang, the second semantic unit is San, the third semantic unit is 1993, and the fourth semantic unit is Year.

[0121] S102, according to the BERT network and the trained mapping network, determine the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, the fourth label value of the fourth semantic unit, the first influence of the first semantic unit on the third semantic unit, the second influence of the first semantic unit on the fourth semantic unit, the third influence of the second semantic unit on the third semantic unit, the fourth influence of the first semantic unit on the fourth semantic unit, the fifth influence of the third semantic unit on the first semantic unit, the sixth influence of the third semantic unit on the second semantic unit, the seventh influence of the fourth semantic unit on the first semantic unit, and the eighth influence of the fourth semantic unit on the second semantic unit.

[0122] The input of the BERT network is the corpus to be processed, and the output is the embedded vector of each semantic unit in the corpus to be processed. The dimension of the embedded vector of each semantic unit can be 1*768.

[0123] The mapping network may be a model trained by the method provided in the embodiment of the present application and used to process the embedded vector output by BERT into a label value. The structure of the mapping network 1 may be as follows: Figure 2 As shown, it includes a fully connected layer 10 and a Sigmoid layer 20. The input dimension of the fully connected layer 10 can be equal to the dimension of the embedded vector output by the BERT network, for example, it can be 1*768. The output of the fully connected layer can be a real number of (-∞, +∞), and the output of the Sigmoid layer 20 is a real number of (0,1). The training of the mapping network can be carried out using the training samples in the training data set corresponding to the following training corpus. By inputting the input x in the training sample into the initial mapping network, the parameters in the initial mapping network are continuously adjusted by the difference between the output y' and the output y of the training sample, and the initial mapping network is updated. The updated initial mapping network is used as the object for training the next training sample until all training samples have been trained, or until the difference between the output y' of the mapping network and the output y of the training sample indicates that the mapping network at this time is sufficiently accurate (for example, the difference is less than a preset sufficiently small threshold, such as 0.05), and the initial mapping network at the end of the training is used as the mapping network used in S102.

[0124] It should be noted that the larger the tag value is, the more likely it is that the corpus containing the semantic unit includes the target relationship.

[0125] As an example, determining the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit in S102 may specifically include: S21, inputting the corpus to be processed into the BERT network to obtain the embedded vectors corresponding to each semantic unit in the corpus to be processed; S22, inputting the embedded vectors corresponding to each semantic unit in the corpus to be processed into the mapping network to obtain the label values ​​corresponding to each semantic unit in the corpus to be processed, the label values ​​corresponding to each semantic unit in the corpus to be processed include the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit.

[0126] Taking the corpus to be processed as Corpus 1 in the above example, after S21 and S22, the content shown in Table 3 can be obtained:

[0127] Table 3

[0128]

[0129]

[0130] As an example, in S102, the process of determining the influence degree of each semantic unit in the first relationship subject on each semantic unit in the first relationship object and determining the influence degree of each semantic unit in the first relationship object on each semantic unit in the first relationship subject is the same. That is, replace A with the target label (such as MASK) to obtain the intermediate corpus corresponding to the corpus to be processed. Pass the intermediate corpus through the BERT network and the mapping network to obtain the label values of each semantic unit in the intermediate corpus. Calculate the influence degree of A on B according to the label value of B in the corpus to be processed and the label value in the intermediate corpus. Among them, the influence degree of A on B can be equal to the absolute value of the difference between the label value of B in the corpus to be processed and the label value in the intermediate corpus. Taking the calculation of the first influence degree of the first semantic unit on the third semantic unit and the second influence degree of the first semantic unit on the fourth semantic unit as an example, S102 may include: S23, replace the first semantic unit in the corpus to be processed with the target label to obtain the intermediate corpus; S24, process the intermediate corpus through the BERT network and the mapping network to obtain the label values corresponding to each semantic unit in the intermediate corpus. The label values corresponding to each semantic unit in the intermediate corpus include the fifth label value of the third semantic unit and the sixth label value of the fourth semantic unit; S25, calculate the first influence degree according to the fifth label value and the third label value, and calculate the second influence degree according to the sixth label value and the fourth label value. Among them, in S25, the calculation of the first influence degree according to the fifth label value and the third label value may include: calculate the absolute value of the difference between the fifth label value and the third label value, and record it as the first influence degree.

[0131] Taking the above corpus 1 as an example, replace the first semantic unit "Zhang" in the corpus 1 "Zhang San, born in 1963." with "[MASK]", and the whole sentence becomes the intermediate corpus 1: "[MASK] San, born in 1963.". Input the intermediate corpus 1 into the BERT network to obtain the embedded vector of each semantic unit, and then input the newly obtained embedded vector into the trained mapping network to obtain the label value, as shown in Table 4 below:

[0132] Table 4

[0133] character Embedded Vector Tag value … … … 1963 [0.191,0.264,0.158,...] 0.134 Year [9.367,2.097,7.304,...] 0.164 … … …

[0134] Comparing Table 3 and Table 4, it can be seen that after replacing "Zhang" with "[MASK]", the influence degree on "1963" is |0.832 - 0.134| = 0.698, and the influence degree on "year" is |0.749 - 0.164| = 0.585.

[0135] After S102, the label value of each semantic unit and the influence between the semantic units are obtained, which provides a data basis for subsequent determination of whether there is a target relationship between the first relationship subject and the first relationship object in the corpus to be processed.

[0136] S103: If the first label value, the second label value, the third label value, the fourth label value and the average influence meet the preset conditions, then it is determined that there is a target relationship between the first relationship subject and the first relationship object, and the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence.

[0137] As an example, the first label value, the second label value, the third label value, the fourth label value and the influence mean meet preset conditions, which may include: at least one of the first label value and the second label value is greater than the first label threshold, and at least one of the third label value and the fourth label value is greater than the second label threshold, and the influence mean represents the existence of the target relationship between the subject and the object.

[0138] The first label threshold and the second label threshold may be the same or different, and the specific values ​​may be determined based on the analysis of the corpus in the following training corpus set.

[0139] The influence mean value indicates that the target relationship exists between the subject and the object, which may include: in the first influence threshold and the second influence threshold, the influence mean value is closer to the second influence threshold value, the first influence threshold value indicates that the target relationship does not exist between the subject and the object, and the second influence threshold value indicates that the target relationship exists between the subject and the object; or, in the first influence range and the second influence range, the influence mean value belongs to the second influence range, the first influence range indicates that the target relationship does not exist between the subject and the object, and the second influence range indicates that the target relationship exists between the subject and the object. The first influence threshold and the second influence threshold are different, the first influence range and the second influence range are different, the first influence threshold and the second influence threshold can be determined by analyzing the corpus in the following training corpus; or the first influence range and the second influence range can be determined by analyzing the corpus in the following training corpus. For example, the first influence threshold value is 0.1, the second influence threshold value is 0.7, the first influence range is (0, 0.4), and the second influence range is [0.4, 1).

[0140] In specific implementation, the method provided in the embodiment of the present application may further include: determining the preset condition based on the training corpus, the BERT network and the mapping network.

[0141] As an example, determining the preset condition based on the training data set, the BERT network and the mapping network may include: S31, obtaining a first mean of all positive examples in the training corpus based on all positive examples in the training corpus, the BERT network and the mapping network, wherein the positive example refers to the corpus in which the subject and the object have the target relationship; S32, obtaining a second mean of all negative examples in the training corpus based on all negative examples in the training corpus, the BERT network and the mapping network, wherein the negative example refers to the corpus in which the subject and the object do not have the target relationship; S33, determining the first influence threshold based on the first mean, and determining the second influence threshold based on the second mean; or, determining the first influence range and the second influence range based on the first mean and the second mean.

[0142] Wherein, S31 may, for example, include: determining the first mean based on the influence of each positive example among all the positive examples, and the first mean may be the average of the influences of all the positive examples. Wherein, determining the influence of the first positive example among all the positive examples includes: passing the first positive example in the training corpus through the BERT network and the mapping network to obtain label values ​​corresponding to each semantic unit in the first positive example, the first positive example includes a second relationship subject and a second relationship object, the second relationship subject includes a fifth semantic unit and a sixth semantic unit, and the second relationship object includes a seventh semantic unit and an eighth semantic unit; replacing each semantic unit in the second relationship subject and the second relationship object with the target label, respectively, and passing the replaced corpus through the BERT network and the mapping network to obtain the ninth influence of the fifth semantic unit on the seventh semantic unit, the fifth semantic unit on the eighth semantic unit, and the influence of the fifth semantic unit on the ninth semantic unit. The tenth influence of the eighth semantic unit, the eleventh influence of the sixth semantic unit on the seventh semantic unit, the twelfth influence of the sixth semantic unit on the eighth semantic unit, the thirteenth influence of the seventh semantic unit on the fifth semantic unit, the fourteenth influence of the seventh semantic unit on the sixth semantic unit, the fifteenth influence of the eighth semantic unit on the fifth semantic unit, and the sixteenth influence of the eighth semantic unit on the sixth semantic unit; based on the ninth influence, the tenth influence, the eleventh influence, the twelfth influence, the thirteenth influence, the fourteenth influence, the fifteenth influence and the sixteenth influence, determine the influence of the first positive example.

[0143] For example, assume that the target relationship to be extracted is "birth time", the type of the relationship subject in the valid corpus is "person", and the type of the relationship object is "date". The training corpus set includes: positive example 1: "Li Si, male, born in 1959, doctoral supervisor at University D."; positive example 2: "Wang Wu, male, born in 1997, doctoral supervisor at University D."; negative example 1: "Wang Wu won the first prize in literature in City E in 1997."; and negative example 2: "Li Si won the first prize in literature in City E in 1959." Then, the method for determining the preset conditions may include:

[0144] Part 1: Determine the average influence of all positive examples in the training corpus, which may include the following S41~ S47 :

[0145] S41, input positive example 1 into the BERT network to obtain the embedded vectors of each semantic unit in "Li Si" and "1959", and then input the embedded vectors of each semantic unit into the trained mapping network to obtain the label values corresponding to each semantic unit in positive example 1. The specific obtained content is shown in Table 5 below:

[0146] Table 5

[0147] character Embedded Vector Tag value plum [0.173,0.324,1.473,...] 0.923 Four [1.354,0.003,2.243,...] 0.854 … … … 1959 [9.333,0.202,1.278,...] 0.919 … … …

[0148] S42, replace each semantic unit in each relationship subject in positive example 1 with the target label [MASK] respectively, and then input the replaced corpus into the BERT network to obtain the embedded vectors of each semantic unit in the replaced corpus. Input these embedded vectors into the mapping network to obtain the label values of each semantic unit in the replaced corpus. Taking the replacement of "Li" with "[MASK]" as an example, the specific obtained content is shown in Table 6 below:

[0149] Table 6

[0150] character Embedded Vector Tag value Four [0.327,1.250,4.244,...] 0.245 … … … 1959 [0.006,2.327,2.333,...] 0.139 Year [9.858,2.373,9.924,...] 0.210 … … …

[0151] S43, calculate the absolute value of the difference in label values of "1959" in Table 5 and Table 6, denoted as the influence degree of "Li" on "1959", and calculate the absolute value of the difference in label values of "year" in Table 5 and Table 6, denoted as the influence degree of "Li" on "year". According to Table 5 and Table 6, after replacing "Li" with "[MASK]", the influence degree on "1959" is 0.780, and the influence degree on "year" is 0.709. Similarly, the influence degree of replacing "Si" with "[MASK]" on "1959" and the influence degree on "year" can be calculated.

[0152] S44. For each semantic unit in each relational object in the positive example 1, replace it with the target label [MASK], and then input it into the BERT network to obtain the embedded vector of each semantic unit in the corpus after replacement. Input these embedded vectors into the mapping network to obtain the label values of each semantic unit in the corpus after replacement. Taking the replacement of "1959" with "[MASK]" as an example, the specific obtained content is shown in Table 7 below:

[0153] Table 7

[0154] character Embedded Vector Tag value plum [0.739,2.573,3.429,...] 0.110 … … …

[0155] S45. Calculate the absolute value of the difference between the label values of "Li" in Table 5 and Table 7, denoted as the influence degree of "1959" on "Li". Calculate the absolute value of the difference between the label values of "Si" in Table 5 and Table 7, denoted as the influence degree of "1959" on "Si". According to Table 5 and Table 7, after replacing "1959" with "[MASK]", the influence degree on "Li" is 0.813. Similarly, the influence degree of replacing "year" with "[MASK]" on "Li" and on "Si" can be calculated.

[0156] S46. Take the average of the influence degrees between the semantic units of each relational subject and relational object calculated in the positive example 1 to obtain the average influence degree of the positive example 1, which can also be called the average value of the positive example 1.

[0157] S47. Perform the corresponding steps of S41 - S46 on the positive example 2 to obtain the average influence degree of the positive example 2. Thus, the average influence degrees of the positive example 1 and the positive example 2 can be averaged to obtain the average influence degree of all positive examples in the training corpus.

[0158] Part 2: Determine the average influence of all counterexamples in the training corpus, which may include the following S51~ S57:

[0159] S51. Input the negative example 1 into the BERT network to obtain the embedded vectors of each semantic unit in "Wang Wu" and "1997", and then input the embedded vectors of each semantic unit into the trained mapping network to obtain the label values corresponding to each semantic unit in the negative example 1. The specific obtained content is shown in Table 8 below:

[0160] Table 8

[0161] character Embedded Vector Tag value king [0.173,0.324,1.473,...] 0.009 five [1.354,0.003,2.243,...] 0.216 … … … 1997 [9.333,0.202,1.278,...] 0.198 Year [2.216,0.357,0.576,...] 0.035 … … …

[0162] S52. Replace each semantic unit in each relationship subject in Counterexample 1 with the target label [MASK], then input the replaced corpus into the BERT network to obtain the embedded vectors of each semantic unit in the replaced corpus. Input these embedded vectors into the mapping network to obtain the label values of each semantic unit in the replaced corpus. Taking the example of replacing "Wang" with "[MASK]", the specific content obtained is shown in Table 9 below:

[0163] Table 9

[0164] character Embedded Vector Tag value five [0.438,7.450,3.344,...] 0.030 … … … 1997 [7.306,4.494,4.843,...] 0.024 Year [8.438,1.473,6.464,...] 0.000 … … …

[0165] S53. Calculate the absolute value of the difference in the label values of "1997" in Table 8 and Table 9, denoted as the influence degree of "Wang" on "1997". Calculate the absolute value of the difference in the label values of "year" in Table 8 and Table 9, denoted as the influence degree of "Wang" on "year". According to Table 8 and Table 9, after replacing "Wang" with "[MASK]", the influence degree on "1997" is 0.174, and the influence degree on "year" is 0.035. Similarly, the influence degree of replacing "Five" with "[MASK]" on "1997" and on "year" can be calculated.

[0166] S54. Replace each semantic unit in each relationship object in Counterexample 1 with the target label [MASK], then input it into the BERT network to obtain the embedded vectors of each semantic unit in the replaced corpus. Input these embedded vectors into the mapping network to obtain the label values of each semantic unit in the replaced corpus. Taking the example of replacing "1997" with "[MASK]", the specific content obtained is shown in Table 10 below:

[0167] Table 10

[0168] character Embedded Vector Tag value king [0.090,0.085,0.063,...] 0.181 … … …

[0169] S55. Calculate the absolute value of the difference in the label values of "Wang" in Table 8 and Table 10, denoted as the influence degree of "1997" on "Wang". Calculate the absolute value of the difference in the label values of "Five" in Table 8 and Table 10, denoted as the influence degree of "1997" on "Five". According to Table 8 and Table 10, after replacing "1997" with "[MASK]", the influence degree on "Wang" is 0.172. Similarly, the influence degree of replacing "year" with "[MASK]" on "Wang" and on "Five" can be calculated.

[0170] S56. Take the average of the influence degrees between the semantic units of each relationship subject and relationship object calculated in Counterexample 1 to obtain the average influence degree of Counterexample 1, which can also be called the average value of Counterexample 1.

[0171] S57, subjecting counterexample 2 to the steps corresponding to S51 to S56 above to obtain the average influence of counterexample 2, thereby averaging the average influence of counterexample 1 and the average influence of counterexample 2 to obtain the average influence of all counterexamples in the training corpus.

[0172] Part III: Determine the average influence of all positive examples and all negative examples in the training corpus The preset conditions may specifically include the following S61 to S63:

[0173] S61, determine the first label threshold according to the label values ​​of the semantic units of the relationship subjects in all positive examples, for example, take the average of the maximum and minimum values ​​of the label values ​​of the semantic units of the relationship subjects in positive example 1 and positive example 2, and record it as the first label threshold. It should be noted that the first label threshold can also be determined according to the label values ​​of the semantic units of the relationship subjects in all negative examples, for example, take the maximum value of the label values ​​of the semantic units of the relationship subjects in negative example 1 and negative example 2, and record it as the first label threshold.

[0174] S62, determine the second label threshold according to the label values ​​of the semantic units of the relational objects in all positive examples, for example, take the average of the maximum and minimum values ​​of the label values ​​of the semantic units of the relational objects in positive example 1 and positive example 2, and record it as the second label threshold. It should be noted that the second label threshold can also be determined according to the label values ​​of the semantic units of the relational objects in all negative examples, for example, take the maximum value of the label values ​​of the semantic units of the relational objects in negative example 1 and negative example 2, and record it as the second label threshold.

[0175] S63, determine the second influence threshold according to the average influence of all positive examples, and determine the first influence threshold according to the average influence of all negative examples. Alternatively, determine the first influence range and the second influence range according to the average influence of all positive examples and the average influence of all negative examples. Specifically, the first influence range and the second influence range are determined according to the average influence of all positive examples and the average influence of all negative examples. Specifically, the second influence threshold is first determined according to the average influence of all positive examples, the first influence threshold is determined according to the average influence of all negative examples, and then the first influence range and the second influence range are determined according to the first influence threshold and the second influence threshold.

[0176] In this way, the preset conditions can be determined, and when the target relationship is extracted from the processed corpus, the judgment of S103 can be executed. When it is determined that the first label value, the second label value, the third label value, the fourth label value and the influence average meet the preset conditions, it can be determined that the first relationship subject and the first relationship object have a target relationship.

[0177] It should be noted that, whether determining the preset conditions or training the mapping network, a rich training corpus set is required. In order to overcome the problem that it is difficult to collect training corpora in some fields, it is difficult to collect a large amount of training corpora, the embodiment of the present application also provides a method for obtaining a training corpus set, which can specifically include: obtaining a number of collected corpora, replacing the subject and object of the positive examples and negative examples in the collected corpora to obtain a number of extended corpora, merging the collected corpora and the extended corpora to obtain a larger number of training corpora with richer content.

[0178] As an example, obtaining the collected corpus may refer to preprocessing the training text to obtain the collected corpus. The preprocessing of the training text to obtain the collected corpus may include: sentence segmenting the training text to obtain a number of corpora; using a named entity extraction tool to obtain the entity type of each of the several corpora; screening the valid corpora in the several corpora, and obtaining the relationship subject and relationship object in each valid corpus, wherein the valid corpus is a corpus that includes the relationship subject and relationship object corresponding to the target relationship; and determining that the collected corpus includes the corpus in which the target relationship exists in the valid corpus as a positive example, and the corpus in which the target relationship does not exist in the valid corpus as a negative example.

[0179] For example, suppose the target relationship to be extracted is "birth time", the relationship subject type of the effective corpus is "person", the relationship object type is "date", and the training text is: "Li Si, male, born in 1959, doctoral supervisor of D University. Li Si teaches and conducts research at F College. Wang Wu won the first prize of literature in E City in 1997." Then, the training text is divided into sentences, and each sentence is called a corpus to obtain 3 corpora as follows:

[0180] "Li Si, male, born in 1959, doctoral supervisor at D University."

[0181] "Li Si is engaged in teaching and research at F College."

[0182] "Wang Wu won the first prize in literature in E City in 1997."

[0183] Next, a general named entity extraction tool is used to extract and annotate the entity types in each corpus. The obtained content is shown in Table 11:

[0184] Table 11

[0185]

[0186] Filter out the valid corpus and mark it. The valid corpus is the corpus that contains both the relationship subject and the relationship object corresponding to the target relationship. The corpus contains the named entity type of the relationship subject and the named entity type of the relationship object. In this example, filter out the corpus that contains both the relationship subject type "person" and the relationship object type "date", and get 2 corpora, as shown in Table 12:

[0187] Table 12

[0188]

[0189]

[0190] Then, the corpus with the target relationship in the effective corpus is determined as a positive example, and the corpus without the target relationship in the effective corpus is determined as a negative example, and marked (for example, manually marked). The corpus in Table 12 is marked, and the results are shown in Table 13:

[0191] Table 13

[0192]

[0193] In this way, the collected corpus shown in Table 13 is obtained.

[0194] S71, extract the relationship subject and relationship object in each positive example, then randomly select a negative example, replace the relationship subject in the negative example with the relationship subject in the positive example, and replace the relationship object in the negative example with the relationship object in the positive example, to generate a new negative example. Taking the positive example 1 in Table 13 as an example, replace the relationship subject "Li Si" and the relationship object "1959" in the negative example 1 with the relationship subject "Wang Wu" and the relationship object "1997" respectively, to generate a new negative example 2, as shown in Table 14:

[0195] Table 14

[0196]

[0197]

[0198] S72, extract the relationship subject and relationship object in each negative example, then randomly select a positive example, replace the relationship subject in the positive example with the relationship subject in the negative example, and replace the relationship object in the positive example with the relationship object in the negative example, to generate a new positive example. Taking negative example 1 in Table 13 as an example, replace the relationship subject "Li Si" and relationship object "1959" in positive example 1 with its relationship subject "Wang Wu" and relationship object "1997" respectively, to generate a new positive example 2, as shown in Table 15:

[0199] Table 15

[0200]

[0201] S73, merging the collected corpus and the newly generated extended corpus to generate a training corpus set. In this example, Tables 13, 14, and 15 can be combined, and the obtained training corpus set can be shown in Table 16 below:

[0202] Table 16

[0203]

[0204]

[0205] In this way, through the methods corresponding to the above S71~S73, the number of training samples used to determine the preset conditions and for training the mapping network can be effectively expanded, providing a richer and more reliable data basis, making the determined preset conditions more reasonable and the mapping network obtained through training more ideal, thereby making the method for extracting the relationship between entities provided in the embodiment of the present application more accurate.

[0206] After obtaining the training corpus, the initial mapping network can also be trained based on the training data set corresponding to the training corpus to obtain the mapping network for extracting the relationship between entities in the embodiment of the present application. Before training the initial mapping network, it can also include: obtaining a training data set based on the training corpus.

[0207] As an example, obtaining a training data set based on the training corpus may include: inputting each corpus in the training corpus into the BERT network respectively to obtain the embedded vector of each semantic unit of each corpus in the training corpus; assigning a label value of 1 to the semantic units included in the relation subject and the relation object in each corpus in the training corpus, and assigning a label value of 0 to other semantic units except the relation subject and the relation object in each corpus in the training corpus, to obtain training samples in the training data set, wherein each training sample includes each semantic unit in the corresponding training corpus, the embedded vector corresponding to the semantic unit, and the label value corresponding to the semantic unit.

[0208] For example, taking the content of Table 16 in the above example as the training corpus set, each corpus in Table 16 can be segmented into semantic units, where English, numbers, etc. are segmented by words, and Chinese is segmented by characters. Then, for each semantic unit in the subject and object of the relationship in the positive example, a label value of 1.0 is assigned, and all other semantic units are assigned a label value of 0.0. Taking the segmentation and assignment of semantic units for positive example 1 as an example, the content obtained is shown in Table 17 below:

[0209] Table 17

[0210] Semantic Unit plum Four , male , 1959 Year born , Tag value 1.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 Semantic Unit D big study Bo scholar born guide division 。 Tag value 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

[0211] Then, each corpus in Table 16 can be input into the general BERT network to obtain an embedded vector corresponding to each semantic unit in each corpus. Taking the BERT network conversion of positive example 1 as an example, the content obtained is shown in the following Table 18:

[0212] Table 18

[0213] character Embedded Vector plum [0.173,0.324,1.473,…] Four [1.354,0.003,2.243,…] , [0.002,1.347,2.226,…] … … 1959 [9.333,0.202,1.278,…] … …

[0214] Combining the above-mentioned process of segmenting and assigning semantic units to each corpus in the training corpus, and the process of BERT network conversion, it is possible to construct training data (or training samples) corresponding to the training corpus in the training corpus. Each training sample includes a set of data for each semantic unit included in a training corpus. The data corresponding to each semantic unit may include the semantic unit, the embedded vector corresponding to the semantic unit, and the label value corresponding to the semantic unit. Taking the construction of training sample 1 corresponding to positive example 1 as an example, combined with the contents of Table 17 and Table 18, the constructed training sample 1 is shown in Table 19 below:

[0215] Table 19

[0216]

[0217]

[0218] In this way, sufficiently rich and reliable samples are provided for the training of the initial mapping network, making it possible for the mapping network in the embodiment of the present application to output a more accurate label value for each semantic unit.

[0219] It can be seen that the method provided by the embodiment of the present application not only makes use of the BERT network and the mapping network, but also introduces the concept of the influence of the semantic units of the subject and object relationship. According to a sufficiently rich training corpus, reasonable preset conditions for judging whether a target relationship exists are set. Based on the influence of the semantic units of the subject and object relationship and whether the label values ​​of each semantic unit meet the preset conditions, it is accurately determined whether a target relationship exists between a pair of subjects and objects in the corpus. Without a large amount of manual annotation, the relationship between entities can be conveniently and accurately extracted, thereby improving information processing efficiency and providing convenience for people to extract effective information.

[0220] Accordingly, the embodiment of the present application also provides a device 300 for extracting relationships between entities, see Figure 3 The device 300 includes:

[0221] A first acquisition unit 301 is used to acquire a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit;

[0222] A first determining unit 302 is used to determine, according to the transformer-based bidirectional encoder representation BERT network and the trained mapping network, a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, a fourth influence of the first semantic unit on the fourth semantic unit, a fifth influence of the third semantic unit on the first semantic unit, a sixth influence of the third semantic unit on the second semantic unit, a seventh influence of the fourth semantic unit on the first semantic unit, and an eighth influence of the fourth semantic unit on the second semantic unit;

[0223] The second determination unit 303 is used to determine that there is a target relationship between the first relationship subject and the first relationship object if the first label value, the second label value, the third label value, the fourth label value and the average influence meet a preset condition, and the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence.

[0224] In some implementations, the first determining unit 302 includes:

[0225] A first processing subunit is used to input the corpus to be processed into the BERT network to obtain an embedded vector corresponding to each semantic unit in the corpus to be processed;

[0226] The second processing sub-unit is used to input the embedded vector corresponding to each semantic unit in the corpus to be processed into the mapping network to obtain the label value corresponding to each semantic unit in the corpus to be processed, and the label value corresponding to each semantic unit in the corpus to be processed includes the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit and the fourth label value of the fourth semantic unit.

[0227] In some implementations, the first determining unit 302 includes:

[0228] A first replacement subunit is used to replace the first semantic unit in the corpus to be processed with a target label to obtain an intermediate corpus;

[0229] A third processing subunit is used to process the intermediate corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the intermediate corpus, wherein the label value corresponding to each semantic unit in the intermediate corpus includes a fifth label value of the third semantic unit and a sixth label value of the fourth semantic unit;

[0230] A calculation subunit is used to calculate the first influence according to the fifth label value and the third label value, and calculate the second influence according to the sixth label value and the fourth label value.

[0231] As an example, the computing subunit is specifically used for:

[0232] An absolute value of a difference between the fifth label value and the third label value is calculated and recorded as the first influence.

[0233] In some implementations, the first label value, the second label value, the third label value, the fourth label value, and the influence average satisfy a preset condition, including:

[0234] At least one of the first label value and the second label value is greater than a first label threshold, and at least one of the third label value and the fourth label value is greater than a second label threshold, and the influence mean value represents the existence of the target relationship between the subject and the object.

[0235] As an example, the influence mean value represents the existence of the target relationship between the subject and the object, including:

[0236] Between the first influence threshold and the second influence threshold, the influence mean is closer to the second influence threshold, the first influence threshold indicates that the target relationship does not exist between the subject and the object, and the second influence threshold indicates that the target relationship exists between the subject and the object;

[0237] Alternatively, in the first influence range and the second influence range, the influence mean belongs to the second influence range, the first influence range indicates that the target relationship does not exist between the subject and the object, and the second influence range indicates that the target relationship exists between the subject and the object.

[0238] In some implementations, the apparatus 300 further includes:

[0239] The third determining unit is used to determine the preset condition according to the training corpus, the BERT network and the mapping network.

[0240] As an example, the third determining unit includes:

[0241] a fourth processing subunit, configured to obtain a first mean of all positive examples in the training corpus according to all positive examples in the training corpus, the BERT network, and the mapping network, wherein the positive example refers to a corpus in which a subject and an object have the target relationship;

[0242] a fifth processing subunit, configured to obtain a second mean of all counterexamples in the training corpus according to all counterexamples in the training corpus, the BERT network, and the mapping network, wherein the counterexample refers to a corpus in which the target relationship does not exist between a subject and an object;

[0243] A determination subunit is used to determine the first influence threshold according to the first mean value, and determine the second influence threshold according to the second mean value; or, determine the first influence range and the second influence range according to the first mean value and the second mean value.

[0244] Wherein, the fourth processing subunit is used for:

[0245] The first mean is determined based on the influence of each positive example among all the positive examples, wherein the fourth processing subunit is used to determine the influence of the first positive example among all the positive examples, specifically to:

[0246] The first positive example in the training corpus is passed through the BERT network and the mapping network to obtain the label value corresponding to each semantic unit in the first positive example, wherein the first positive example includes a second relation subject and a second relation object, the second relation subject includes a fifth semantic unit and a sixth semantic unit, and the second relation object includes a seventh semantic unit and an eighth semantic unit; each semantic unit in the second relation subject and the second relation object is replaced with the target label, and the replaced corpus is passed through the BERT network and the mapping network to obtain the ninth influence of the fifth semantic unit on the seventh semantic unit and the tenth influence of the fifth semantic unit on the eighth semantic unit. , the eleventh influence of the sixth semantic unit on the seventh semantic unit, the twelfth influence of the sixth semantic unit on the eighth semantic unit, the thirteenth influence of the seventh semantic unit on the fifth semantic unit, the fourteenth influence of the seventh semantic unit on the sixth semantic unit, the fifteenth influence of the eighth semantic unit on the fifth semantic unit, and the sixteenth influence of the eighth semantic unit on the sixth semantic unit; based on the ninth influence, the tenth influence, the eleventh influence, the twelfth influence, the thirteenth influence, the fourteenth influence, the fifteenth influence and the sixteenth influence, determine the influence of the first positive example.

[0247] In some implementations, the training corpus includes a collected corpus and an extended corpus, and the extended corpus is a corpus obtained by performing subject-object replacement on positive examples and negative examples in the collected corpus.

[0248] As an example, the apparatus 300 further includes:

[0249] The second acquisition unit is used to preprocess the training text to obtain the collected corpus.

[0250] In some implementations, the second acquiring unit includes:

[0251] A sentence division unit is used to divide the training text into sentences to obtain a plurality of corpora;

[0252] An extraction subunit, used to obtain the entity type of each of the plurality of corpora using a named entity extraction tool;

[0253] A screening subunit, used to screen valid corpora from the plurality of corpora and obtain the relationship subject and relationship object in each valid corpus, wherein the valid corpus is a corpus including the relationship subject and relationship object corresponding to the target relationship;

[0254] The collected corpus includes corpus in which the target relationship exists in the effective corpus as a positive example, and corpus in which the target relationship does not exist in the effective corpus as a negative example.

[0255] In some implementations, the apparatus 300 further includes:

[0256] A third acquisition unit, configured to obtain a training data set based on the training corpus;

[0257] The training unit is used to train the initial mapping network based on the training data set to obtain the above Figure 1 The mapping network involved in the illustrated embodiment.

[0258] Wherein, the third acquisition unit includes:

[0259] A sixth processing subunit, configured to input each corpus in the training corpus into the BERT network to obtain an embedded vector of each semantic unit of each corpus in the training corpus;

[0260] The seventh processing sub-unit is used to assign a label value of 1 to the semantic units included in the relationship subject and the relationship object in each corpus of the training corpus, and assign a label value of 0 to other semantic units except the relationship subject and the relationship object in each corpus of the training corpus, so as to obtain the training samples in the training data set, wherein each training sample includes each semantic unit in the corresponding training corpus, the embedded vector corresponding to the semantic unit and the label value corresponding to the semantic unit.

[0261] In addition, the present application embodiment also provides an electronic device 400, such as Figure 4 As shown, the electronic device 400 includes a processor 401 and a memory 402:

[0262] The memory 402 is used to store computer programs;

[0263] The processor 401 is used to execute the method provided in the embodiment of the present application according to the computer program.

[0264] In addition, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method provided by the embodiment of the present application.

[0265] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.

[0266] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for system embodiments and device embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device and system embodiments described above are merely schematic, in which the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0267] The above is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. It should be noted that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the present application, and these improvements and modifications should also be regarded as the protection scope of the present application.

Claims

1. A method for extracting relationships between entities, characterized in that: include: Acquire a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit; According to the transformer-based bidirectional encoder representation BERT network and the trained mapping network, determine a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, a fourth influence of the second semantic unit on the fourth semantic unit, a fifth influence of the third semantic unit on the first semantic unit, a sixth influence of the third semantic unit on the second semantic unit, a seventh influence of the fourth semantic unit on the first semantic unit, and an eighth influence of the fourth semantic unit on the second semantic unit; If the first label value, the second label value, the third label value, the fourth label value and the average influence meet the preset conditions, then it is determined that the first relationship subject and the first relationship object have a target relationship, and the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence and the eighth influence; The method of representing the BERT network based on the transformer-based bidirectional encoder and the trained mapping network, determining the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit includes: Input the corpus to be processed into the BERT network to obtain the embedded vector corresponding to each semantic unit in the corpus to be processed; input the embedded vector corresponding to each semantic unit in the corpus to be processed into the mapping network to obtain the label value corresponding to each semantic unit in the corpus to be processed, wherein the label value corresponding to each semantic unit in the corpus to be processed includes the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit; Among them, according to the transformer-based bidirectional encoder representation BERT network and mapping network, determining the influence of one semantic unit on another semantic unit includes: The one semantic unit in the corpus to be processed is replaced with the target label to obtain an intermediate corpus; the intermediate corpus is processed by the BERT network and the mapping network to obtain a label value corresponding to the other semantic unit in the intermediate corpus; the influence of the one semantic unit on the other semantic unit is calculated according to the label value of the other semantic unit in the corpus to be processed and the label value in the intermediate corpus; The first label value, the second label value, the third label value, the fourth label value and the average value of the influence degree satisfy a preset condition, including: If at least one of the first label value and the second label value is greater than the first label threshold, and at least one of the third label value and the fourth label value is greater than the second label threshold, and the influence mean value indicates that the target relationship exists between the subject and the object.

2. The method according to claim 1, characterized in that The determining, according to the transformer-based bidirectional encoder representation BERT network and the mapping network, a first influence of the first semantic unit on the third semantic unit and a second influence of the first semantic unit on the fourth semantic unit comprises: Replacing the first semantic unit in the to-be-processed corpus with a target label to obtain an intermediate corpus; Processing the intermediate corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the intermediate corpus, wherein the label value corresponding to each semantic unit in the intermediate corpus includes a fifth label value of the third semantic unit and a sixth label value of the fourth semantic unit; The first influence is calculated according to the fifth label value and the third label value, and the second influence is calculated according to the sixth label value and the fourth label value.

3. The method according to claim 2, characterized in that The calculating the first influence according to the fifth label value and the third label value includes: An absolute value of a difference between the fifth label value and the third label value is calculated and recorded as the first influence.

4. The method according to claim 1, characterized in that: The influence mean value represents the existence of the target relationship between the subject and the object, including: Between the first influence threshold and the second influence threshold, the influence mean is closer to the second influence threshold, the first influence threshold indicates that the target relationship does not exist between the subject and the object, and the second influence threshold indicates that the target relationship exists between the subject and the object; Alternatively, in the first influence range and the second influence range, the influence mean belongs to the second influence range, the first influence range indicates that the target relationship does not exist between the subject and the object, and the second influence range indicates that the target relationship exists between the subject and the object.

5. The method according to claim 4, characterized in that The method further comprises: The preset condition is determined according to the training corpus, the BERT network and the mapping network.

6. The method according to claim 5, characterized in that The determining the preset condition according to the training corpus, the BERT network and the mapping network includes: According to all positive examples in the training corpus, the BERT network and the mapping network, a first mean of all positive examples in the training corpus is obtained, wherein the positive example refers to a corpus in which a subject and an object have the target relationship. According to all the counter-examples in the training corpus, the BERT network and the mapping network, a second mean of all the counter-examples in the training corpus is obtained, wherein the counter-example refers to a corpus in which the target relationship does not exist between a subject and an object; The first influence threshold is determined according to the first mean value, and the second influence threshold is determined according to the second mean value; or, the first influence range and the second influence range are determined according to the first mean value and the second mean value.

7. The method according to claim 6, characterized in that The obtaining, according to all positive examples in the training corpus, the BERT network and the mapping network, a first mean of all positive examples in the training corpus comprises: Determining the first mean value based on the influence of each positive example among all the positive examples, wherein determining the influence of the first positive example among all the positive examples includes: Passing a first positive example in the training corpus through the BERT network and the mapping network to obtain a label value corresponding to each semantic unit in the first positive example, wherein the first positive example includes a second relation subject and a second relation object, the second relation subject includes a fifth semantic unit and a sixth semantic unit, and the second relation object includes a seventh semantic unit and an eighth semantic unit; Replacing each semantic unit in the second relationship subject and the second relationship object with the target label respectively, and passing the replaced corpus through the BERT network and the mapping network, to obtain the ninth influence of the fifth semantic unit on the seventh semantic unit, the tenth influence of the fifth semantic unit on the eighth semantic unit, the eleventh influence of the sixth semantic unit on the seventh semantic unit, the twelfth influence of the sixth semantic unit on the eighth semantic unit, the thirteenth influence of the seventh semantic unit on the fifth semantic unit, the fourteenth influence of the seventh semantic unit on the sixth semantic unit, the fifteenth influence of the eighth semantic unit on the fifth semantic unit, and the sixteenth influence of the eighth semantic unit on the sixth semantic unit; The influence of the first positive example is determined based on the ninth influence, the tenth influence, the eleventh influence, the twelfth influence, the thirteenth influence, the fourteenth influence, the fifteenth influence, and the sixteenth influence.

8. The method according to claim 5, characterized in that The training corpus set includes collected corpus and extended corpus, and the extended corpus is the corpus obtained by replacing the subject and object according to the positive examples and negative examples in the collected corpus.

9. The method according to claim 8, characterized in that The method further comprises: The training text is preprocessed to obtain the collected corpus.

10. The method according to claim 9, characterized in that The preprocessing of the training text to obtain the collected corpus includes: Sentence the training text to obtain a number of corpora; Using a named entity extraction tool, obtaining an entity type of each of the plurality of corpora; Screening valid corpora from the plurality of corpora, and obtaining a relation subject and a relation object in each valid corpus, wherein the valid corpus is a corpus including a relation subject and a relation object corresponding to the target relation; The collected corpus includes corpus in which the target relationship exists in the effective corpus as a positive example, and corpus in which the target relationship does not exist in the effective corpus as a negative example.

11. The method according to claim 5, characterized in that The method further comprises: Based on the training corpus, obtaining a training data set; The initial mapping network is trained based on the training data set to obtain the mapping network.

12. The method according to claim 11, characterized in that The step of obtaining a training data set based on the training corpus includes: Input each corpus in the training corpus into the BERT network to obtain an embedded vector of each semantic unit of each corpus in the training corpus; The semantic units included in the relation subject and the relation object in each corpus of the training corpus are assigned a label value of 1, and the other semantic units except the relation subject and the relation object in each corpus of the training corpus are assigned a label value of 0, so as to obtain the training samples in the training data set, wherein each training sample includes the semantic units in the corresponding training corpus, the embedded vector corresponding to the semantic unit and the label value corresponding to the semantic unit.

13. A device for extracting relationships between entities, characterized in that: include: A first acquisition unit is used to acquire a corpus to be processed, wherein the corpus to be processed includes a first relation subject and a first relation object, wherein the first relation subject includes a first semantic unit and a second semantic unit, and the first relation object includes a third semantic unit and a fourth semantic unit; A first determining unit is used to determine, according to a transformer-based bidirectional encoder representation BERT network and a trained mapping network, a first label value of the first semantic unit, a second label value of the second semantic unit, a third label value of the third semantic unit, a fourth label value of the fourth semantic unit, a first influence of the first semantic unit on the third semantic unit, a second influence of the first semantic unit on the fourth semantic unit, a third influence of the second semantic unit on the third semantic unit, a fourth influence of the second semantic unit on the fourth semantic unit, a fifth influence of the third semantic unit on the first semantic unit, a sixth influence of the third semantic unit on the second semantic unit, a seventh influence of the fourth semantic unit on the first semantic unit, and an eighth influence of the fourth semantic unit on the second semantic unit; a second determining unit, configured to determine that a target relationship exists between the first relationship subject and the first relationship object if the first label value, the second label value, the third label value, the fourth label value, and an average influence satisfy a preset condition, wherein the average influence is determined based on the first influence, the second influence, the third influence, the fourth influence, the fifth influence, the sixth influence, the seventh influence, and the eighth influence; The first determining unit implements the step of determining the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit according to the transformer-based bidirectional encoder representation BERT network and the trained mapping network, and is specifically used to: Input the corpus to be processed into the BERT network to obtain the embedded vector corresponding to each semantic unit in the corpus to be processed; input the embedded vector corresponding to each semantic unit in the corpus to be processed into the mapping network to obtain the label value corresponding to each semantic unit in the corpus to be processed, wherein the label value corresponding to each semantic unit in the corpus to be processed includes the first label value of the first semantic unit, the second label value of the second semantic unit, the third label value of the third semantic unit, and the fourth label value of the fourth semantic unit; The first determination unit determines the influence of one semantic unit on another semantic unit according to the transformer-based bidirectional encoder representation BERT network and the mapping network, and is specifically used to: The one semantic unit in the corpus to be processed is replaced with the target label to obtain an intermediate corpus; the intermediate corpus is processed by the BERT network and the mapping network to obtain a label value corresponding to the other semantic unit in the intermediate corpus; the influence of the one semantic unit on the other semantic unit is calculated according to the label value of the other semantic unit in the corpus to be processed and the label value in the intermediate corpus; The first label value, the second label value, the third label value, the fourth label value and the average value of the influence degree satisfy a preset condition, including: If at least one of the first label value and the second label value is greater than the first label threshold, and at least one of the third label value and the fourth label value is greater than the second label threshold, and the influence mean value indicates that the target relationship exists between the subject and the object.

14. An electronic device, characterized in that: The electronic device comprises a processor and a memory: The memory is used to store computer programs; The processor is configured to execute the method according to any one of claims 1 to 12 according to the computer program.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Knowledge representation learning method and device, equipment and storage medium

    CN111475658A

  • Systems and methods for learning to extract relations from text via user feedback

    US20190179893A1