Entity relationship identification method, device, equipment and storage medium

By acquiring and updating the representation vectors of entity pairs, and utilizing a pre-trained language model and an axial attention model, the problem of the inability to identify entity relationships in different sentences in existing technologies is solved, achieving accurate entity relationship recognition and multi-hop relationship recognition.

CN114692617BActive Publication Date: 2025-01-14ALIBABA (CHINA) CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210199358.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-02
Publication Date
2025-01-14
Estimated Expiration
2042-03-02

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately identify entity relationships in different sentences, and are unable to identify the relationships between entities in different sentences.

Method used

By obtaining the representation vectors of multiple entities in the target text, combining them with the context vector, updating the representation vectors of entity pairs, and using a pre-trained language model, an axial attention model, and a classifier, the relationship between entity pairs is determined.

Benefits of technology

It can accurately identify entity relationships in different sentences, improving the accuracy of entity relationship identification and the performance of multi-hop relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114692617B_ABST
    Figure CN114692617B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an entity relationship recognition method, apparatus, device and storage medium. The present disclosure determines the representation vectors corresponding to a plurality of entities in a target text, and determines the representation vector of an entity pair consisting of any two entities according to the representation vectors corresponding to any two entities among the plurality of entities, and the representation vector of the context related to the any two entities. Further, the representation vector of the entity pair consisting of the any two entities is updated according to the representation vectors of the entity pairs consisting of the first entity among the any two entities and the other entities, and the representation vectors of the entity pairs consisting of the other entities and the second entity among the any two entities. Therefore, after updating the representation vector of the entity pair consisting of the any two entities with the help of other entities, the updated representation vector can accurately express the relationship between the any two entities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of information technology, and in particular to an entity relationship identification method, device, equipment and storage medium. Background Art

[0002] With the continuous development of science and technology, in some application scenarios, it is necessary to extract the relationship between different entities in the text, for example, extracting structured entity relationships from plain text. In addition, the entity relationship extraction task is an important subtask in data mining and information extraction. For example, entity relationship extraction is an important part of knowledge acquisition and knowledge reasoning, and has important research and business value for the construction of knowledge graphs and structured dialogues.

[0003] However, the inventors of the present application have discovered that most current entity relationship extraction methods can only extract the relationships between different entities in the same sentence, but cannot accurately identify the relationships between entities from different sentences. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an entity relationship recognition method, device, equipment and storage medium to accurately express the relationship between any two entities. Therefore, even if the two entities are from different sentences, the relationship between the two entities can be accurately identified by the method described in this embodiment.

[0005] In a first aspect, an embodiment of the present disclosure provides an entity relationship identification method, comprising:

[0006] Get the target text;

[0007] Determine representation vectors corresponding to a plurality of entities in the target text;

[0008] Determine a representation vector of an entity pair formed by any two entities among the multiple entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities;

[0009] Update the representation vector of the entity pair formed by the arbitrary two entities according to the representation vector of the entity pair formed by the first entity of the arbitrary two entities and each entity of the multiple entities, and the representation vector of the entity pair formed by each entity of the multiple entities and the second entity of the arbitrary two entities;

[0010] The relationship between the arbitrary two entities is determined according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0011] In a second aspect, an embodiment of the present disclosure provides an entity relationship identification device, comprising:

[0012] An acquisition module is used to acquire the target text;

[0013] A first determination module is used to determine the representation vectors corresponding to the multiple entities in the target text;

[0014] A second determination module, configured to determine a representation vector of an entity pair formed by any two entities among the plurality of entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities;

[0015] An updating module, configured to update a representation vector of an entity pair formed by the arbitrary two entities according to a representation vector of an entity pair formed by a first entity among the arbitrary two entities and each entity among the multiple entities, and a representation vector of an entity pair formed by each entity among the multiple entities and a second entity among the arbitrary two entities;

[0016] The third determination module is used to determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0017] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0018] Memory;

[0019] Processor; and

[0020] Computer programs;

[0021] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.

[0022] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.

[0023] The entity relationship recognition method, device, equipment and storage medium provided by the embodiments of the present disclosure determine the representation vectors corresponding to the multiple entities in the target text, and determine the representation vector of the entity pair composed of the arbitrary two entities according to the representation vectors corresponding to any two entities in the multiple entities, and the representation vector of the context related to the arbitrary two entities. Further, according to the representation vector of the entity pair composed of the first entity in the arbitrary two entities and each entity in the multiple entities, and the representation vector of the entity pair composed of each entity in the multiple entities and the second entity in the arbitrary two entities, the representation vector of the entity pair composed of the arbitrary two entities is updated. Since there may be an entity in the multiple entities that has a relationship with the arbitrary two entities at the same time, that is, the entity plays the role of an intermediate bridge in the process of building the relationship between the arbitrary two entities, therefore, after updating the representation vector of the entity pair composed of the arbitrary two entities with the help of the entity, the updated representation vector can accurately express the relationship between the arbitrary two entities. Therefore, even if the arbitrary two entities come from different sentences, the relationship between the arbitrary two entities can be accurately identified by the method described in this embodiment. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0026] Figure 1 A schematic diagram of a plain text provided for an embodiment of the present disclosure;

[0027] Figure 2 A flow chart of an entity relationship identification method provided by an embodiment of the present disclosure;

[0028] Figure 3 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;

[0029] Figure 4 A schematic diagram of a target text provided by an embodiment of the present disclosure;

[0030] Figure 5 A flow chart of an entity relationship identification method provided by another embodiment of the present disclosure;

[0031] Figure 6 A schematic diagram of entity pair relationships provided for another embodiment of the present disclosure;

[0032] Figure 7 A flow chart of an entity relationship identification method provided by another embodiment of the present disclosure;

[0033] Figure 8 A flow chart of an entity relationship identification method provided by another embodiment of the present disclosure;

[0034] Fig. 9 A schematic flow diagram of a student model training process provided for another embodiment of the present disclosure;

[0035] Fig.10 A schematic diagram of the structure of an entity relationship identification device provided in an embodiment of the present disclosure;

[0036] Fig.11 A schematic diagram of the structure of an electronic device embodiment provided by the present disclosure. DETAILED DESCRIPTION

[0037] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0038] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0039] Currently, most entity relation extraction methods can only extract the relationship between different entities in the same sentence, but cannot accurately identify the relationship between entities from different sentences.

[0040] For example Figure 1 As shown, the plain text includes 4 sentences, such as sentences [1]-[4]. Sentence [1] includes entity 10, entity 11 and entity 12. Sentence [4] includes entity 13. Among them, entity 10 can be the name of a song, entity 11 is the singer of the song, entity 12 is a music album to which the song belongs, and entity 13 is the producer of the album. At present, most entity relationship extraction methods can only extract the relationship between entity 10 and entity 11 in sentence [1], but cannot identify the relationship between entity 12 and entity 13, because entity 12 and entity 13 are not in the same sentence, and the relationship between entity 12 and entity 13 can only be inferred by combining sentence [1] and sentence [4].

[0041] To address this problem, an embodiment of the present disclosure provides an entity relationship identification method, which is introduced below in conjunction with a specific embodiment.

[0042] Figure 2 The flowchart of the entity relationship identification method provided by the embodiment of the present disclosure. The method can be executed by an entity relationship identification device, which can be implemented in software and / or hardware, and the device can be configured in an electronic device, such as a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer, etc. The method can be applied to Figure 3 In the application scenario shown, for example, the terminal 31 can send a target text to the server 32, and the target text can be a plain text. The server 32 can identify the relationship between different entities in the target text and send the relationship between different entities in the target text to the terminal 31. Alternatively, the terminal 31 can directly identify the relationship between different entities in the target text. The following is a schematic description using the example of the server 32 identifying the relationship between different entities in the target text. Figure 2 As shown, the specific steps of this method are as follows:

[0043] S201, obtaining target text.

[0044] For example, the server 32 may receive the target text from the terminal 31 .

[0045] S202: Determine representation vectors corresponding to a plurality of entities in the target text.

[0046] For example, the target text is a plain text, and the target text includes multiple sentences, each sentence consists of multiple words. Further, each word in each sentence is identified to determine whether the word is an entity. Figure 1 The plain text shown is the target text, and entity 10, entity 11, entity 12 and entity 13 are multiple entities in the target text. Further, representation vectors corresponding to the multiple entities can be obtained.

[0047] S203: Determine a representation vector of an entity pair formed by any two entities among the multiple entities according to the representation vectors respectively corresponding to any two entities and the representation vector of the context related to the any two entities.

[0048] For example, after obtaining the representation vectors corresponding to entity 10, entity 11, entity 12, and entity 13, respectively, entities 10, entity 11, entity 12, and entity 13 can be arbitrarily combined in pairs. For example, taking entity 12 and entity 13 as examples, the representation vector of the entity pair consisting of entity 12 and entity 13 is determined based on the representation vector of entity 12, the representation vector of entity 13, and the representation vector of the context related to entity 12 and entity 13. Among them, the representation vector of the context related to entity 12 and entity 13 can be obtained by calculating the representation vectors of several words before and after entity 12 and the representation vectors of several words before and after entity 13 according to a preset calculation method. Similarly, the representation vector of the entity pair consisting of any two entities among entity 10, entity 11, entity 12, and entity 13 can be calculated.

[0049] S204. Update the representation vector of the entity pair formed by the arbitrary two entities according to the representation vector of the entity pair formed by the first entity among the arbitrary two entities and each entity among the multiple entities, and the representation vector of the entity pair formed by each entity among the multiple entities and the second entity among the arbitrary two entities.

[0050] For example, taking entity 12 and entity 13 as examples, entity 12 can be recorded as the first entity and entity 13 can be recorded as the second entity. Further, according to the representation vectors of the entity pairs formed by entity 12 and entity 10, entity 11, entity 12, and entity 13, and the representation vectors of the entity pairs formed by each entity in entity 10, entity 11, entity 12, and entity 13 and entity 13, the representation vector of the entity pair formed by entity 12 and entity 13 is updated. It can be understood that in the same target text, different entities may or may not be related. Therefore, one or more entities among entity 10, entity 11, entity 12, and entity 13 may be related to entity 12, and the remaining entities are not related to entity 12. Similarly, one or more entities among entity 10, entity 11, entity 12, and entity 13 may be related to entity 13, and the remaining entities are not related to entity 13. Thus, it is possible to analyze which entities are related to both entity 12 and entity 13. Therefore, those entities that are related to both entity 12 and entity 13 can serve as a bridge for building the relationship between entity 12 and entity 13. For example, assuming that entity 10 is related to both entity 12 and entity 13, then the representation vector of the entity pair formed by entity 12 and entity 10, and the representation vector of the entity pair formed by entity 10 and entity 13 may play a key role in the update process.

[0051] For example Figure 4The sentence [1] shown is "Song a is sung by singer b and it is a song from album c", entity 10 is "song a", entity 11 is "singer b", and entity 12 is "album c". Figure 4 The sentence [4] shown is "Song a was produced by producer d", entity 10 is "Song a", and entity 13 is "Producer d". For example, the relationship between entity 12 and entity 10 is that entity 10 belongs to entity 12, it is assumed that there is no relationship between entity 12 and entity 11, entity 12 and entity 12 are in the same relationship, and the relationship between entity 12 and entity 13 is to be determined. The relationship between entity 10 and entity 13 is a production relationship, it is assumed that there is no relationship between entity 11 and entity 13, the relationship between entity 12 and entity 13 is to be determined, and entity 13 and entity 13 are in the same relationship. It can be seen that there is a relationship between entity 12 and entity 10, and there is a relationship between entity 10 and entity 13. Therefore, entity 10 plays a bridging role between entity 12 and entity 13. Specifically, since entity 10 is a part of entity 12 and entity 10 is produced by entity 13, it can be inferred that entity 12 is produced by entity 13, that is, the relationship between entity 12 and entity 13 is also a production relationship.

[0052] That is to say, the representation vector of the entity pair consisting of entity 12 and entity 13 determined in S203 may not be sufficient to accurately express the relationship between entity 12 and entity 13. However, after the representation vector obtained in S203 is updated in S204, the relationship between entity 12 and entity 13 can be accurately determined by the updated representation vector. Since the updating process combines the representation vector of the entity pair consisting of entity 12 and other entities (such as entity 10), and the representation vector of the entity pair consisting of other entities (such as entity 10) and entity 13, the representation vector of the entity pair consisting of entity 12 and other entities (such as entity 10) can accurately express the relationship between entity 12 and entity 10, and the representation vector of the entity pair consisting of other entities (such as entity 10) and entity 13 can accurately express the relationship between entity 10 and entity 13. Therefore, according to the representation vector of the entity pair formed by entity 12 and other entities (such as entity 10), and the representation vector of the entity pair formed by other entities (such as entity 10) and entity 13, after updating the representation vector of the entity pair formed by entity 12 and entity 13, the updated representation vector can accurately express the relationship between entity 12 and entity 13.

[0053] S205: Determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0054] For example, after the representation vector of the entity pair formed by entity 12 and entity 13 is updated according to S204, the relationship between entity 12 and entity 13 can be accurately determined according to the updated representation vector.

[0055] The disclosed embodiment determines the representation vectors corresponding to the multiple entities in the target text, and determines the representation vector of the entity pair composed of the arbitrary two entities according to the representation vectors corresponding to any two entities in the multiple entities, and the representation vector of the context related to the arbitrary two entities. Further, according to the representation vector of the entity pair composed of the first entity in the arbitrary two entities and each entity in the multiple entities, and the representation vector of the entity pair composed of each entity in the multiple entities and the second entity in the arbitrary two entities, the representation vector of the entity pair composed of the arbitrary two entities is updated. Since there may be entities in the multiple entities that are related to the arbitrary two entities at the same time, that is, the entity plays the role of an intermediate bridge in the process of building the relationship between the arbitrary two entities, therefore, after updating the representation vector of the entity pair composed of the arbitrary two entities with the help of the entity, the updated representation vector can accurately express the relationship between the arbitrary two entities. Therefore, even if the arbitrary two entities come from different sentences, the relationship between the arbitrary two entities can be accurately identified by the method described in this embodiment.

[0056] Based on the above embodiment, the method is performed by a first relationship extraction model, which includes a pre-trained language model, an axial attention model and a classifier.

[0057] For example Figure 5 As shown, the first relation extraction model includes a pre-trained language model, an axial attention model and a classifier. The entity relation identification method described in the embodiment of the present disclosure can be executed by the first relation extraction model.

[0058] Specifically, the pre-trained language model is used to determine the representation vectors corresponding to multiple entities in the target text; the axial attention model is used to update the representation vectors of the entity pair formed by the arbitrary two entities based on the representation vectors of the entity pair formed by the first entity of the arbitrary two entities and each entity of the multiple entities, and the representation vectors of the entity pair formed by each entity of the multiple entities and the second entity of the arbitrary two entities; the classifier is used to determine the relationship between the arbitrary two entities based on the updated representation vectors of the entity pair formed by the arbitrary two entities.

[0059] For example, the input of the pre-trained language model is the target file, and the output of the pre-trained language model is the representation vector corresponding to each entity in the target file. Figure 5 The black circle 51 shown represents a representation vector of any entity. The specific process of calculating the representation vector of an entity is introduced below.

[0060] For example, first identify the entities in the target text, and add a special symbol "*" before and after each entity as a mark. Then input the target text with special symbols into a pre-trained language model (Pre-trained Language Model, PrLM), which can specifically be a pre-trained language representation model (Bidirectional Encoder Representation from Transformers, BERT). The pre-trained language model can extract the representation vector of the target text, as shown in the following formula (1):

[0061] H = PrLM([x1, ..., x l ])=[h1,...,h l ]) (1)

[0062] Wherein, H represents the representation vector of the target text. x represents each word in the target text, wherein each special symbol "*" can be regarded as a word. h represents the representation vector of each word. Here, the representation vector of the special symbol "*" in front of each entity is used as the representation vector of the entity. In this embodiment, the representation vector can also be recorded as a text representation.

[0063] It is understandable that in some scenarios, an entity may have multiple entity names, that is, multiple entity names can refer to the same entity, which is a co-reference relationship between entities. For example, if "alcohol" and "ethanol" appear in the same target text, then "alcohol" and "ethanol" refer to the same entity. In the Document-level Relation Extraction Dataset (DocRED), this co-reference relationship is part of the input. In this embodiment, the representation vectors of all entity names referring to the same entity can be LogSumExp summed to obtain the representation vector of the entity.

[0064] The summation process is shown in the following formula (2):

[0065]

[0066] in, A representation vector representing the entity. Indicates the total number of different entity names corresponding to the entity. A representation vector representing the entity name.

[0067] After determining the representation vector of each entity, further, any two entities can be combined arbitrarily so that any two entities can form an entity pair, and the representation vector of the context related to the entity pair is calculated.

[0068] For example Figure 5 As shown, the rectangular box 52 represents a combination of any two entities, wherein the black circle 521 represents the representation vector of the first entity, the black circle 523 represents the representation vector of the second entity, and the white circle 522 represents the representation vector of the context related to the first entity and the second entity. Here, the first entity can be denoted as the subject (s for short), and the second entity can be denoted as the object (o for short), that is, the subject and the object constitute an entity pair (s, o). The representation vector of the context related to the entity pair (s, o) can be calculated by the following formulas (3) and (4):

[0069]

[0070] c (s,o) =H T q (s,o) (4)

[0071] Among them, c (s,o) The representation vector of the context associated with the entity pair (s, o). H in formula (3) is a constant, which represents the number of self-attention heads. H in formula (4) has the same meaning as H in formula (1). represents the ith self-attention head of the self-attention matrix of the first entity s, Represents the i-th self-attention head of the self-attention matrix of the second entity o. (s,o) It represents the intermediate value connecting formula (3) and formula (4).

[0072] It is understandable that each entity pair can correspond to a context representation vector. The context representation vector can reflect the information of an entity pair in a specific context. For example, the same entity pair has different relationships in different contexts, so the context representation vector is very important for the relationship extraction of entity pairs. Therefore, when calculating the representation vector of an entity pair, not only the representation vector of each entity in the entity pair should be considered, but also the representation vector of the context related to the entity pair.

[0073] After calculating the representation vector of the context related to the entity pair (s, o), we can also use c (s,o) Update the representation vector of the first entity s It can be calculated by using formula (2). The update process can be implemented by the following formula (5):

[0074]

[0075] Among them, W s and W c They represent the parameters of the first relation extraction model. s represents the updated representation vector of the first entity s. That is, the representation vector of the first entity s is With c (s,o) By combining linear transformations, the updated representation vector of the first entity s can be obtained. Similarly, in formula (5), the updated representation vector of the first entity s can be obtained according to c (s,o) Update the representation vector of the second entity o, thereby obtaining the updated representation vector z of the second entity o o .

[0076] After obtaining the updated representation vectors corresponding to the first entity s and the second entity o, respectively, the representation vector of the entity pair consisting of the first entity and the second entity can be determined according to the updated representation vector of the first entity, the updated representation vector of the second entity, and the representation vector of the context related to the first entity and the second entity. For example, in this embodiment, the representation vector of the entity pair consisting of the first entity s and the second entity o can be obtained through a grouped bilinear transformation, as shown in the following formula (6):

[0077]

[0078] Among them, g (s,o) g represents the entity pair consisting of the first entity s and the second entity o. (s,o) There are d dimensions, among which, Indicates g (s,o) k represents the i-th dimension of z s , z o are divided into k groups. Representation and The corresponding model parameters. Indicates z s The corresponding j-th group among the k groups. express The corresponding j-th group among the k groups. Indicates z o The jth group among the corresponding k groups. T represents transposition. b i Represents a constant.

[0079] like Figure 5As shown, assuming that the first entity is e1 and the second entity is e2, the small square 53 represents the representation vector of the entity pair composed of the first entity and the second entity. In other words, a small square represents the representation vector of the entity pair composed of two entities. Assuming that there are 8 entities in the target text, for example, e1 to e8, similar to the calculation method of the representation vector of the entity pair composed of the first entity s and the second entity o, the representation vector of the entity pair composed of any two entities among the 8 entities can be calculated here.

[0080] Furthermore, the axial attention model can update the representation vector of an entity pair consisting of any two entities. The update process can be implemented by the following formulas (7) and (8):

[0081]

[0082]

[0083] Among them, g (s,o) represents the representation vector of the entity pair (s, o) obtained according to formula (6), Represents the axial attention model for g (s,o) The updated result. n represents the number of entities in the target text. p represents the pth entity among n entities. q (s,o) It is for g (s,o) After deformation. (p,o) It is for g (p,o) Obtained after deformation. (p,o) Also for g (p,o) Obtained after deformation. It is the intermediate value connecting formula (7) and formula (8). (s,p) It is for g (s,p) Obtained after deformation. (s,p) Also for g (s,p) Obtained after deformation.

[0084] like Figure 6 Each small square shown represents a representation vector of an entity pair. For example, the first entity s is e3, the second entity o is e6, and the small square 54 represents the representation vector g of the entity pair (s, o) (s,o) For example, when n=8, when p changes from 1 to n, g (p,o) is the representation vector of the entity pair represented by each small square in the column to which the small square 54 belongs. Figure 6 Similarly, when p changes from 1 to n, g (s,p) is the representation vector of the entity pair represented by each small square in the row to which the small square 54 belongs. Figure 6 Box 61 is shown.

[0085] Specifically, the axial attention model can update the representation vector of the entity pair composed of e3 and e6 based on the representation vector of the entity pair composed of e3 and e1, the representation vector of the entity pair composed of e3 and e2, ..., the representation vector of the entity pair composed of e3 and e8, and the representation vector of the entity pair composed of e1 and e6, the representation vector of the entity pair composed of e2 and e6, ..., the representation vector of the entity pair composed of e8 and e6. In other words, the axial attention model can update the representation vector of the entity pair represented by the small square 54 based on the representation vector of the entity pair represented by each small square in the row to which the small square 54 belongs, and the representation vector of the entity pair represented by each small square in the column to which the small square 54 belongs. Figure 5 The small square 55 shown represents the updated representation vector of the entity pair consisting of e3 and e6. Similarly, the axial attention model can update the representation vector of the entity pair consisting of any two entities. Figure 5 As shown, the embodiment of the present disclosure uses small squares without shading to represent the representation vector of the entity pair before updating, and uses small squares with shading to represent the representation vector of the entity pair after updating.

[0086] like Figure 6 As shown, the row to which the small square 54 belongs includes the small square 54, and the column to which the small square 54 belongs also includes the small square 54. When updating the representation vector of the entity pair represented by the small square 54, the small square 54 can be excluded from the row to which the small square 54 belongs, and the small square 54 can be excluded from the column to which the small square 54 belongs. That is, the representation vectors of the entity pairs represented by the other small squares except the small square 54 in the frame 61 and the other small squares except the small square 54 in the frame 62 are used to update the representation vector of the entity pair represented by the small square 54.

[0087] like Figure 6 As shown, for entities e3 and e6, the axial attention model can be used to extract e3 and e6 using the axial attention mechanism. x The representation vector of the entity pair, and e x and e6, where for e3, e x It can be any entity from e1 to e8 except e3. For e6, e xIt can be any entity other than e6 from e1 to e8. In this way, the logical path of the multi-hop relationship (for example, the two-hop relationship) can be extracted. For example, e3 is the entity 12 described in the above embodiment, and e6 is the entity 13 described in the above embodiment. The representation vector of the entity pair (e3, e6) obtained according to formula (6) may not accurately express the relationship between entity e3 and entity e6. However, by extracting the representation vector of the entity pair consisting of entity 12 and entity 10, and the representation vector of the entity pair consisting of entity 10 and entity 13, and updating the representation vector of the entity pair consisting of entity e3 and entity e6, the relationship between entity e3 and entity e6 can be accurately obtained. Therefore, applying axial attention to the natural language processing (NLP) task of relationship extraction can significantly improve the performance of the model on multi-hop relationships.

[0088] Further, if Figure 5 The classifier shown can determine the relationship between any two entities based on the updated representation vector of the entity pair formed by the two entities. For example, the classifier can determine the relationship between e3 and e6 based on the updated representation vector of the entity pair represented by the small square 55. For example, the updated representation vector of the entity pair represented by the small square 55 is The classifier may be a feed forward network (FFN) classifier. Specifically, the classifier is a fully connected layer of a neural network. In this embodiment, multiple preset relationships may be provided, and the multiple preset relationships may include multiple target relationships and no relationship. For example, 97 preset relationships may be provided, including 96 target relationships and no relationship. Specifically, the classifier may be based on The relationship between the first entity s and the second entity o is predicted to be the probability of each of the 97 preset relationships, thereby obtaining 97 probability values, which constitute a probability distribution. Specifically, the probability distribution can be calculated by the following formula (9):

[0089]

[0090] Among them, l (s,o) represents the probability distribution composed of the 97 probability values. l and b l The 97 probability values ​​include the probability value of each of the 96 target relationships between the first entity s and the second entity o, and the probability value of no relationship between the first entity s and the second entity o. Here, the probability value of no relationship between the first entity s and the second entity o is recorded as If the probability value of the relationship between the first entity s and the second entity o is a certain target relationship is greater than The target relationship is taken as the relationship between the first entity s and the second entity o. It is understandable that there may be more than one target relationship that meets the condition. If there are multiple such target relationships, the multiple target relationships are taken together as the relationship between the first entity s and the second entity o.

[0091] It can be understood that the process described above is the reasoning process or the use process of the first relation extraction model, that is, the target text described above is the input of the first relation extraction model in the reasoning process or the use process. Before the reasoning process or the use process, the first relation extraction model needs to be trained. Here, the first relation extraction model can be recorded as a student model.

[0092] like Figure 7 As shown, the first relation extraction model is trained by the following steps:

[0093] S701: Process the sample text by using the first relationship extraction model to obtain a first probability distribution that the relationship between any two entities in the sample text is a plurality of preset relationships.

[0094] For example, in the process of training the first relation extraction model, the sample text can be used as the input of the first relation extraction model, so that the first relation extraction model can process the sample text. It can be understood that the process of the first relation extraction model processing the sample text is similar to the process of the first relation extraction model processing the target text as described above. Specifically, the sample text can be distant supervision data. After the sample text is processed by the first relation extraction model, a first probability distribution can be obtained in which the relationship between any two entities in the sample text is a plurality of preset relationships. The first probability distribution is similar to l in formula (9): (s,o) Here, the first probability distribution can be recorded as

[0095] S702: Determine a first loss function according to the first probability distribution.

[0096] For example, according to the first probability distribution, a first loss function is determined, and the first loss function can be expressed as

[0097] S703. Process the sample text through a second relationship extraction model to obtain a second probability distribution in which the relationship between any two entities in the sample text is a plurality of preset relationships. The second relationship extraction model has the same structure as the first relationship extraction model, and the second relationship extraction model is obtained by training with labeled data.

[0098] For example, the second relationship extraction model has the same structure as the first relationship extraction model. However, the second relationship extraction model is a model that is pre-trained with labeled data, and the labeled data can be manually labeled data. Manually labeled data is more accurate than remote supervision data. The second relationship extraction model can be referred to as the teacher model here. That is to say, when training the student model, the teacher model is a trained and fixed model. When training the first relationship extraction model, the same remote supervision data can be input into the first relationship extraction model and the second relationship extraction model. After processing the remote supervision data through the second relationship extraction model, a second probability distribution can be obtained in which the relationship between any two entities in the remote supervision data is a plurality of preset relationships. The second probability distribution is also similar to the l in formula (9). (s ,o) Here, the second probability distribution can be recorded as

[0099] S704. Determine a second loss function according to the first probability distribution and the second probability distribution, where the first loss function and the second loss function constitute a third loss function.

[0100] For example, according to the first probability distribution and the second probability distribution Determine the second loss function, which can be written as It can be calculated by the following formula (10):

[0101]

[0102] Here, MSE stands for mean square error.

[0103] Further, according to the first loss function and the second loss function The third loss function can be constructed. The specific construction process is shown in the following formula (11):

[0104]

[0105] in, Represents the third loss function.

[0106] S705: Training the first relationship extraction model according to the third loss function.

[0107] For example, the third loss function is the loss function of the first relationship extraction model during the training process, so that the first relationship extraction model can be trained through the third loss function and a large amount of remote supervision data.

[0108] Optionally, after training the first relationship extraction model according to the third loss function, the method further includes: re-training the first relationship extraction model according to the labeled data.

[0109] For example, after the first relation extraction model is trained by the third loss function and a large amount of remote supervision data, the first relation extraction model can be further trained again using manually annotated data. Among them, the process of training the first relation extraction model by the third loss function and a large amount of remote supervision data can be regarded as coarse-tuning the parameters of the first relation extraction model. The process of retraining the first relation extraction model using manually annotated data can be regarded as fine-tuning the parameters of the first relation extraction model. The first relation extraction model after fine-tuning can be applied to the reasoning stage or the use stage.

[0110] Optionally, the plurality of preset relationships include a plurality of target relationships, and no relationship between any two entities. For example, 97 preset relationships may be provided, including 96 target relationships and no relationship.

[0111] As described above, S702 determines a first loss function according to the first probability distribution, including: Figure 8 The following steps are shown:

[0112] S801. According to the first probability distribution, the multiple target relationships are divided into a first type of target relationship and a second type of target relationship, a first probability that the relationship between any two entities is the first type of target relationship is greater than a second probability that there is no relationship between the any two entities, and a third probability that the relationship between any two entities is the second type of target relationship is less than the second probability.

[0113] For example, the first probability distribution It includes 97 probability values. The entity pair (s, o) here is an entity pair composed of any two entities in the sample text. The 97 probability values ​​include the probability value that the relationship of the entity pair (s, o) is each of the 96 target relationships, and the probability value that the entity pair (s, o) has no relationship. Here, the probability value that the entity pair (s, o) has no relationship is recorded as the second probability. If the probability value of the relationship of the entity pair (s, o) is a certain target relationship greater than the second probability, then the target relationship is used as the output relationship of the entity pair (s, o), that is, the positive relationship, and here, the probability value of the positive relationship is recorded as the first probability. If the probability value of the relationship of the entity pair (s, o) is a certain target relationship less than the second probability, then the target relationship is used as the negative relationship of the entity pair (s, o), and here, the probability value of the negative relationship is recorded as the third probability. Thus, the 96 target relationships are divided into positive and negative relationships of the entity pair (s, o). Among them, the positive relationship of the entity pair (s, o) can be recorded as the first type of target relationship, and the negative relationship of the entity pair (s, o) can be recorded as the second type of target relationship. In addition, if no target relationship has a probability value greater than the second probability, that is, the probability values ​​of the 96 target relationships are all less than the second probability, that is, the second probability is the largest among the 97 probability values, then it is determined that the entity pair (s, o) has no relationship. Here, the set of 96 target relationships is recorded as The set of positive class relations is recorded as The set of negative class relations is recorded as In addition, the positive and negative class relationships of the entity pair (s, o) can also be determined by the following formula (12).

[0114]

[0115] Among them, r i Indicates the i-th target relationship among the 96 target relationships. TH indicates no relationship. Indicates the probability value that the relationship between entity pair (s, o) is the i-th target relationship, Indicates the probability value that the entity pair (s, o) has no relationship.

[0116] If P(r i |e s , e o ) is greater than 0.5, indicating Greater than Then the i-th target relationship is a positive relationship.

[0117] If P(r i |e s , e o ) is less than 0.5, indicating Less than Then the i-th target relationship is a negative relationship.

[0118] For example, when Greater than When is recorded as the first probability. Less than When Recorded as the third probability. Recorded as the second probability.

[0119] S802: Calculate a first part of the first loss function according to the first probability and the second probability.

[0120] For example, when P(r i |e s , e o ) is greater than 0.5, Recorded as the first probability. According to the first probability and the second probability A first part of a first loss function may be calculated.

[0121] Optionally, the first part of the first loss function is calculated according to the first probability and the second probability, including: calculating a first ratio according to the first probability and the second probability, the numerator of the first ratio is determined according to the first probability, and the denominator of the first ratio is determined according to the first probability and the second probability; calculating the first part of the first loss function according to the first ratio and the weight corresponding to the first ratio, the first ratio and the weight being inversely related.

[0122] For example, in P(r i |e s , e o ) is greater than 0.5, P(r i |e s , e o ) can be recorded as the first ratio. According to formula (12), the numerator of the first ratio is based on the first probability The denominator of the first ratio is based on the first probability and the second probability Sure.

[0123] Here, P(r i |e s , e o ) is simply recorded as P(r i ), P(r i ) is recorded as (1-P(r i )) γ , where P(ri ) and (1-P(r i )) γ Inversely, that is, P(r i ) is larger, (1-P(r i )) γ The smaller the size, the smaller the better and vice versa.

[0124] Further, according to P(r i ) and (1-P(r i )) γ The first part of the first loss function can be calculated and recorded as

[0125] S803: Calculate a second part of the first loss function according to the third probability and the second probability.

[0126] For example, when Less than When Recorded as the third probability. According to the third probability and the second probability The second part of the first loss function can be calculated.

[0127] Optionally, the second part of the first loss function is calculated based on the third probability and the second probability, including: calculating a second ratio based on the third probability and the second probability, the numerator of the second ratio is determined based on the second probability, and the denominator of the second ratio is determined based on the third probability and the second probability; calculating the second part of the first loss function based on the second ratio.

[0128] For example, according to the third probability and the second probability The second ratio can be calculated first. The calculation method of the second ratio is shown in the following formula (13):

[0129]

[0130] Among them, P(r TH |e s , e o ) represents the second ratio. N T |∪{TH} represents the set of negative class relations and no relations. j Represents a relationship in this collection. represents the second probability, that is and formula (12) Same meaning. The relationship between the entity pair (s, o) is r jThe probability value of .

[0131] According to formula (13), the numerator of the second ratio is determined according to the second probability, and the denominator of the second ratio is determined according to the third probability and the second probability.

[0132] Furthermore, the second ratio P(r TH |e s , e o ) is simply recorded as P(r TH ). According to P(r TH ) can be used to calculate the second part of the first loss function, which is recorded as log(P(r TH ))

[0133] S804: The first part and the second part constitute the first loss function.

[0134] For example, the first part of the first loss function The second part of the first loss function log(P(r TH )) constitutes the first loss function The calculation formula is shown in formula (14):

[0135]

[0136] The first part can be recorded as the positive class part of the first loss function, and the second part can be recorded as the negative class part of the first loss function.

[0137] This embodiment lists 96 target relationships. When judging the relationship between any two entities, if the probability value of the relationship between the two entities being predicted as a certain target relationship is greater than the probability value that the two entities have no relationship, the target relationship can be used as the relationship between the two entities, thereby outputting the target relationship. However, under normal circumstances, some of the 96 target relationships are more likely to be output, while some target relationships are less likely to be output. For example, when judging the relationship between any two entities, the target relationship that can be output is more likely to belong to the top 10 target relationships among the 96 target relationships, that is, one or more of the top 10 target relationships are very likely to be output, while the probability of one or more of the remaining 86 target relationships being output is relatively small. This leads to the problem of uneven distribution of target relationships. However, this imbalance problem is more significant in some data sets. For example, in the DocRED data set, the probability value of one or more of the top 10 target relationships being output reaches 59.4%. In view of this situation, this embodiment proposes an adaptive focal loss function (AFL) based on the adaptive threshold loss function (Adaptive Threshold Loss) to alleviate the problem of uneven distribution of target relationships. Specifically, the first 10 target relationships among the 96 target relationships can be recorded as high-frequency relationships, and the remaining 86 target relationships can be recorded as low-frequency relationships. The principle of solving this problem through Adaptive Focal Loss can be reflected by the above-mentioned formula (14).

[0138] For example, r in formula (14) i Indicates a positive relationship, which may be output.

[0139] P(r i ) and (1-P(r i )) γ Inversely, that is, P(r i ) is larger, (1-P(r i )) γ The smaller, that is The larger the r i The greater the probability of being output, The smaller the proportion in the first loss function, the smaller the weight, and vice versa.

[0140] That is to say, the probability of high-frequency relations being output is relatively high, but in this embodiment, their proportion in the first loss function will be reduced. The probability of low-frequency relations being output is relatively low, but in this embodiment, their proportion in the first loss function will be increased. This can effectively alleviate the problem of uneven distribution of target relations.

[0141] In addition, the disclosed embodiment also uses knowledge distillation (KD) to align remote supervision data and manually annotated data. Traditional knowledge distillation methods are mainly used in business scenarios such as model compression. The disclosed embodiment innovatively proposes to use knowledge distillation to extract the knowledge contained in the remote supervision data. The remote supervision data is obtained by machine aligning the entities in the Wikidata database and Wikipedia articles. Although the remote supervision data obtained in this way contains a large amount of knowledge in the Wikidata database, it also contains a large amount of noise. Manually annotated data is more accurate than remote supervision data, but the amount of manually annotated data is small. The disclosed embodiment first trains a second relationship extraction model based on the manually annotated data, and uses the trained second relationship extraction model as the teacher model. The second relationship extraction model is then used to predict the remote supervision data. In the prediction process, the output of the teacher model is not simply used as a pseudo-label, but the output of the teacher model is used as a pseudo-label. As a soft label. Further, based on the soft label and the output of the student model Calculate the second loss function. After obtaining the third loss function according to the first loss function and the second loss function, train the student model according to the third loss function. Among them, the second loss function is and The mean square error of the training data is reduced by 2.5%, and the effect of knowledge distillation is achieved by reducing the mean square error between the outputs of the teacher model and the student model. This allows the student model to learn from both manually labeled data and remote supervision data. Knowledge distillation is then used to align manually labeled data and remote supervision data.

[0142] like Fig. 9 As shown, 91 represents the probability distribution of the student model output (e.g., ), 92 represents the probability distribution of the teacher model output (e.g., ). According to the probability distribution of the student model output, the AFL function can be obtained, which can be the first loss function in formula (11) or formula (14) In addition, according to the probability distribution of the student model output and the probability distribution of the teacher model output, the KD function can also be obtained. The KD function can be the second loss function in formula (10) or formula (11): Further, according to and We can also get the total loss function, which is the third loss function in formula (11):

[0143] In addition, in this embodiment, the method of training using knowledge distillation is recorded as KD, and the model that only uses remote supervision data for pre-training without using the knowledge distillation method is recorded as NA ( Adaptation).

[0144] The model obtained by using the AFL function, knowledge distillation, and axial attention in the disclosed embodiment has better performance than other models, and the model obtained by using the AFL function, knowledge distillation, and axial attention at the same time has achieved the first place in the DocRED ranking, named KD-Roberta, which specifically means using the Roberta language model and innovative solutions based on knowledge distillation. The following Table 1 shows the performance of each model compared with the F1 score as the evaluation indicator, where the F1 score refers to the harmonic mean of precision and recall.

[0145] Table 1

[0146]

[0147] According to Table 1, the model obtained by using the AFL function, knowledge distillation, and axial attention can improve the performance to 67.12 on the basis of the best existing technical level of 65.69, thus significantly breaking through the existing best technical level in document-level relationship extraction. In addition, the application of each of the AFL function, knowledge distillation, and axial attention in the model training process is a breakthrough application, which has played a positive role in the performance of the model.

[0148] Fig.10 The schematic diagram of the structure of the entity relationship identification device provided by the embodiment of the present disclosure. The entity relationship identification device provided by the embodiment of the present disclosure can execute the processing flow provided by the embodiment of the entity relationship identification method, such as Fig.10 As shown, the entity relationship identification device 100 includes:

[0149] An acquisition module 101 is used to acquire a target text;

[0150] A first determination module 102 is used to determine the representation vectors corresponding to the multiple entities in the target text;

[0151] A second determination module 103, configured to determine a representation vector of an entity pair formed by any two entities among the plurality of entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities;

[0152] An updating module 104, configured to update a representation vector of an entity pair formed by the arbitrary two entities according to a representation vector of an entity pair formed by a first entity of the arbitrary two entities and each entity of the plurality of entities, and a representation vector of an entity pair formed by each entity of the plurality of entities and a second entity of the arbitrary two entities;

[0153] The third determination module 105 is configured to determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0154] Optionally, the method is performed by a first relation extraction model, wherein the first relation extraction model includes a pre-trained language model, an axial attention model, and a classifier;

[0155] The pre-trained language model is used to determine the representation vectors corresponding to the multiple entities in the target text;

[0156] The axial attention model is used to update the representation vector of the entity pair formed by the any two entities according to the representation vector of the entity pair respectively formed by the first entity of the any two entities and each entity of the multiple entities, and the representation vector of the entity pair respectively formed by each entity of the multiple entities and the second entity of the any two entities;

[0157] The classifier is used to determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0158] Optionally, the entity relationship identification apparatus 100 further includes a training module 106, which is used to train the first relationship extraction model through the following steps:

[0159] Processing the sample text by using the first relationship extraction model to obtain a first probability distribution that the relationship between any two entities in the sample text is a plurality of preset relationships;

[0160] Determine a first loss function according to the first probability distribution;

[0161] Processing the sample text by a second relation extraction model to obtain a second probability distribution in which the relationship between any two entities in the sample text is a plurality of preset relationships, wherein the second relation extraction model has the same structure as the first relation extraction model, and the second relation extraction model is obtained by training with annotated data;

[0162] Determine a second loss function according to the first probability distribution and the second probability distribution, wherein the first loss function and the second loss function constitute a third loss function;

[0163] The first relationship extraction model is trained according to the third loss function.

[0164] Optionally, the multiple preset relationships include multiple target relationships, and there is no relationship between any two entities; when the training module 106 determines the first loss function according to the first probability distribution, it is specifically used to:

[0165] According to the first probability distribution, the multiple target relationships are divided into a first type of target relationship and a second type of target relationship, a first probability that the relationship between any two entities is the first type of target relationship is greater than a second probability that there is no relationship between the any two entities, and a third probability that the relationship between the any two entities is the second type of target relationship is less than the second probability;

[0166] Calculate a first part of the first loss function according to the first probability and the second probability;

[0167] Calculate a second part of the first loss function according to the third probability and the second probability;

[0168] The first part and the second part constitute the first loss function.

[0169] Optionally, when the training module 106 calculates the first part of the first loss function according to the first probability and the second probability, it is specifically used to:

[0170] Calculate a first ratio according to the first probability and the second probability, wherein the numerator of the first ratio is determined according to the first probability, and the denominator of the first ratio is determined according to the first probability and the second probability;

[0171] A first part of the first loss function is calculated based on the first ratio and the weight corresponding to the first ratio, and there is an inverse relationship between the first ratio and the weight.

[0172] Optionally, when the training module 106 calculates the second part of the first loss function according to the third probability and the second probability, it is specifically used to:

[0173] Calculate a second ratio according to the third probability and the second probability, wherein a numerator of the second ratio is determined according to the second probability, and a denominator of the second ratio is determined according to the third probability and the second probability;

[0174] A second part of the first loss function is calculated based on the second ratio.

[0175] Optionally, after training the first relationship extraction model according to the third loss function, the training module 106 is further used to: re-train the first relationship extraction model according to the labeled data.

[0176] Fig.10 The entity relationship identification device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0177] The internal functions and structure of the entity relationship identification device are described above, and the device can be implemented as an electronic device. Fig.11 This is a schematic diagram of the structure of an electronic device embodiment provided by the present disclosure. Fig.11 As shown, the electronic device includes a memory 111 and a processor 112 .

[0178] The memory 111 is used to store programs. In addition to the above-mentioned programs, the memory 111 can also be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.

[0179] The memory 111 may be implemented by any type of volatile or nonvolatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0180] The processor 112 is coupled to the memory 111 and executes the program stored in the memory 111 to:

[0181] Get the target text;

[0182] Determine representation vectors corresponding to a plurality of entities in the target text;

[0183] Determine a representation vector of an entity pair formed by any two entities among the multiple entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities;

[0184] Update the representation vector of the entity pair formed by the arbitrary two entities according to the representation vector of the entity pair formed by the first entity of the arbitrary two entities and each entity of the multiple entities, and the representation vector of the entity pair formed by each entity of the multiple entities and the second entity of the arbitrary two entities;

[0185] The relationship between the arbitrary two entities is determined according to the updated representation vector of the entity pair formed by the arbitrary two entities.

[0186] Further, if Fig.11 As shown, the electronic device may also include: a communication component 113, a power component 114, an audio component 115, a display 116 and other components. Fig.11 Only some components are shown schematically, which does not mean that the electronic device only includes Fig.11 Components shown.

[0187] The communication component 113 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 113 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 113 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0188] The power supply component 114 provides power to various components of the electronic device. The power supply component 114 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.

[0189] The audio component 115 is configured to output and / or input audio signals. For example, the audio component 115 includes a microphone (MIC), and when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 111 or sent via the communication component 113. In some embodiments, the audio component 115 also includes a speaker for outputting audio signals.

[0190] The display 116 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0191] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to implement the entity relationship identification method described in the above embodiment.

[0192] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0193] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for identifying entity relationships, wherein: The method comprises: Get the target text; Determine representation vectors corresponding to a plurality of entities in the target text, wherein the plurality of entities include entities in a plurality of sentences; Determine a representation vector of an entity pair formed by any two entities among the multiple entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities; Update the representation vector of the entity pair formed by the arbitrary two entities according to the representation vector of the entity pair formed by the first entity of the arbitrary two entities and each entity of the multiple entities, and the representation vector of the entity pair formed by each entity of the multiple entities and the second entity of the arbitrary two entities; The relationship between the arbitrary two entities is determined according to the updated representation vector of the entity pair formed by the arbitrary two entities.

2. The method according to claim 1, wherein: The method is performed by a first relation extraction model, the first relation extraction model comprising a pre-trained language model, an axial attention model and a classifier; The pre-trained language model is used to determine the representation vectors corresponding to the multiple entities in the target text; The axial attention model is used to update the representation vector of the entity pair formed by the any two entities according to the representation vector of the entity pair respectively formed by the first entity of the any two entities and each entity of the multiple entities, and the representation vector of the entity pair respectively formed by each entity of the multiple entities and the second entity of the any two entities; The classifier is used to determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

3. The method according to claim 2, wherein: The first relation extraction model is trained by the following steps: Processing the sample text by using the first relationship extraction model to obtain a first probability distribution that the relationship between any two entities in the sample text is a plurality of preset relationships; Determine a first loss function according to the first probability distribution; Processing the sample text by a second relation extraction model to obtain a second probability distribution in which the relationship between any two entities in the sample text is a plurality of preset relationships, wherein the second relation extraction model has the same structure as the first relation extraction model, and the second relation extraction model is obtained by training with annotated data; Determine a second loss function according to the first probability distribution and the second probability distribution, wherein the first loss function and the second loss function constitute a third loss function; The first relationship extraction model is trained according to the third loss function.

4. The method according to claim 3, wherein: The multiple preset relationships include multiple target relationships, and there is no relationship between any two entities; Determining a first loss function according to the first probability distribution includes: According to the first probability distribution, the multiple target relationships are divided into a first type of target relationship and a second type of target relationship, a first probability that the relationship between any two entities is the first type of target relationship is greater than a second probability that there is no relationship between the any two entities, and a third probability that the relationship between any two entities is the second type of target relationship is less than the second probability; Calculate a first part of the first loss function according to the first probability and the second probability; Calculate a second part of the first loss function according to the third probability and the second probability; The first part and the second part constitute the first loss function.

5. The method according to claim 4, wherein: Calculating a first part of the first loss function according to the first probability and the second probability includes: Calculate a first ratio according to the first probability and the second probability, wherein the numerator of the first ratio is determined according to the first probability, and the denominator of the first ratio is determined according to the first probability and the second probability; A first part of the first loss function is calculated based on the first ratio and the weight corresponding to the first ratio, and there is an inverse relationship between the first ratio and the weight.

6. The method according to claim 4, wherein: Calculating a second part of the first loss function according to the third probability and the second probability includes: Calculate a second ratio according to the third probability and the second probability, wherein a numerator of the second ratio is determined according to the second probability, and a denominator of the second ratio is determined according to the third probability and the second probability; A second part of the first loss function is calculated based on the second ratio.

7. The method according to claim 3, wherein: After training the first relationship extraction model according to the third loss function, the method further includes: The first relationship extraction model is retrained according to the labeled data.

8. An entity relationship recognition device, wherein: include: An acquisition module is used to acquire the target text; A first determination module is used to determine representation vectors corresponding to a plurality of entities in the target text, wherein the plurality of entities include entities in a plurality of sentences; A second determination module, configured to determine a representation vector of an entity pair formed by any two entities among the plurality of entities according to representation vectors respectively corresponding to any two entities and a representation vector of a context related to the any two entities; An updating module, configured to update a representation vector of an entity pair formed by the arbitrary two entities according to a representation vector of an entity pair formed by a first entity among the arbitrary two entities and each entity among the multiple entities, and a representation vector of an entity pair formed by each entity among the multiple entities and a second entity among the arbitrary two entities; The third determination module is used to determine the relationship between the arbitrary two entities according to the updated representation vector of the entity pair formed by the arbitrary two entities.

9. An electronic device, wherein: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Attention mechanism-based entity relationship extraction method and device, medium and equipment

    CN112800774A

  • Entity relationship type determination method, apparatus and device, and storage medium

    CN113761837A