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

By filtering high-probability potential entity relationships in text and identifying target subjects and objects, the problem of false recall in entity relationship extraction from text is solved, improving the accuracy and efficiency of extraction.

CN113704392BActive Publication Date: 2025-12-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110393735.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-13
Publication Date
2025-12-12
Estimated Expiration
2041-07-02

Smart Images

  • Figure CN113704392B_ABST
    Figure CN113704392B_ABST
Patent Text Reader

Abstract

The application discloses an entity relationship extraction method and device in a text, equipment and a storage medium, and relates to the field of artificial intelligence. The method comprises the following steps: encoding a target text to obtain word vectors corresponding to each word in the target text; determining a potential entity relationship corresponding to the target text based on the word vectors corresponding to each word, wherein the probability of the target text having the potential entity relationship is higher than the probability of the target text having other candidate entity relationships; determining a target subject and a target object in the target text based on the potential entity relationship and the word vectors corresponding to each word, wherein the target subject and the target object belong to entities; and extracting an entity relationship triple from the target text based on the target subject, the potential entity relationship and the target object. The potential entity relationship is obtained by screening the candidate entity relationships, the false recall results caused by redundant entity relationships are reduced, the accuracy of entity relationship extraction in the text is improved, and the extraction efficiency of the entity relationship is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of artificial intelligence, and particularly relate to a method and apparatus for extracting entity relationships in text, a device, and a storage medium. BACKGROUND

[0002] Nature Language Processing (NLP) is an important direction in the field of computer science and artificial intelligence. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph, and other technologies.

[0003] When constructing a knowledge graph, a large amount of text needs to be structured, and unstructured data in the text needs to be converted into structured data and recalled. For example, when extracting entity relationships in text, the recalled structured data is a triple, which includes a subject, a relationship, and an object.

[0004] However, due to the complexity of the relationships between entities in the text, there are a large number of false recall results when extracting entity relationships in the text, resulting in poor accuracy of entity relationship extraction in the text. SUMMARY

[0005] Embodiments of the present application provide a method and apparatus for extracting entity relationships in text, a device, and a storage medium, which can reduce false recall results when extracting entity relationships and improve the accuracy of entity relationship extraction in text. The technical solution is as follows:

[0006] In one aspect, the present application provides a method for extracting entity relationships in text, the method comprising:

[0007] encoding a target text to obtain a word vector corresponding to each word in the target text;

[0008] determining a latent entity relationship corresponding to the target text based on the word vector corresponding to each word, the probability of the latent entity relationship existing in the target text being higher than the probability of other candidate entity relationships existing in the target text;

[0009] determining a target subject and a target object in the target text based on the latent entity relationship and the word vector corresponding to each word, the target subject and the target object belonging to an entity;

[0010] extracting an entity relationship triple from the target text based on the target subject, the latent entity relationship, and the target object.

[0011] In another aspect, an embodiment of the present application provides an entity relationship extraction device in a text, the device comprising:

[0012] an encoding module configured to encode a target text to obtain a word vector corresponding to each word in the target text;

[0013] a relationship determining module configured to determine a potential entity relationship corresponding to the target text based on the word vector corresponding to each word, a probability of existence of the potential entity relationship in the target text being higher than a probability of existence of other candidate entity relationships other than the potential entity relationship;

[0014] a subject and object determining module configured to determine a target subject and a target object in the target text based on the potential entity relationship and the word vector corresponding to each word, the target subject and the target object belonging to entities;

[0015] an extraction module configured to extract an entity relationship triple from the target text based on the target subject, the potential entity relationship, and the target object.

[0016] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory, the memory storing at least one instruction, the at least one instruction being loaded and executed by the processor to implement the entity relationship extraction method in a text according to the above aspect.

[0017] In another aspect, an embodiment of the present application provides a computer readable storage medium, the readable storage medium storing at least one instruction, the at least one instruction being loaded and executed by a processor to implement the entity relationship extraction method in a text according to the above aspect.

[0018] In another aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program comprising computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the entity relationship extraction method in a text according to the above aspect.

[0019] In the entity relation extraction process, first, based on the word vector obtained by encoding the target text, the potential entity relation with high probability existing in the target text is determined, and the candidate entity relation with low probability existing is filtered, then based on the determined potential entity relation and the word vector, the target subject and the target object are determined from the target text, and finally the entity relation triple containing the target subject, the potential entity relation and the target object is extracted from the target text; The scheme provided by the embodiment of the application can reduce the false recall result caused by the redundant entity relation irrelevant to the target text, improve the accuracy of entity relation extraction in the text, and help to improve the extraction efficiency of entity relation. BRIEF DESCRIPTION OF DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0021] Figure 1 The principle schematic diagram of the text entity relation extraction method provided by the embodiment of the present application is shown;

[0022] Figure 2 The schematic diagram of the implementation environment provided by the embodiment of the present application is shown;

[0023] Figure 3 The flowchart of the text entity relation extraction method provided by the embodiment of the present application is shown;

[0024] Figure 4 The flowchart of the text entity relation extraction method provided by another embodiment of the present application is shown;

[0025] Figure 5 The implementation schematic diagram of the entity relation extraction process is shown in an embodiment of the present application;

[0026] Figure 6 The flowchart of the entity relation triple generation process is shown in an embodiment of the present application;

[0027] Figure 7 The implementation schematic diagram of the entity relation extraction process is shown in another embodiment of the present application;

[0028] Figure 8 The flowchart of the entity relation extraction model training process provided by the embodiment of the present application is shown;

[0029] Figure 9 A flowchart of an entity relation extraction model training process provided by another example embodiment of the present application is shown;

[0030] Figure 10 A structural block diagram of an entity relation extraction apparatus provided by an example embodiment of the present application is shown;

[0031] Figure 11 A structural schematic diagram of a computer device provided by an example embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] For the purpose, technical solutions and advantages of the present application to be clearer, the embodiments of the present application will be described in further detail below with reference to the drawings.

[0033] For the convenience of understanding, the terms involved in the embodiments of the present application will be described first.

[0034] Entity relation triple: a triple composed of a subject, an object and a subject-object relation. The subject and the object are both entities in a specific field. Taking the medical field as an example, the subject can be a medical symptom, the subject-object relation can be the nature, position, time, etc. of the medical symptom, and the object is the entity corresponding to the attribute indicated by the subject-object relation. In an illustrative example, the entity relation triple is (dermatitis, position, leg) or (dermatitis, nature, moderate). The method provided by the embodiments of the present application is to extract an entity relation triple containing the relation between entities in a specific field from the text in the specific field.

[0035] Sequence tagging: a basic task in NLP, used to solve the problem of classifying characters, such as word segmentation, part-of-speech tagging, named entity recognition, relation extraction, etc. The sequence tagging in the embodiments of the present application is used to label the subject and the object in the text, and the BIO (Begin Inside Outside) labeling is used in the sequence tagging process, wherein the B label indicates that the word is at the beginning of the entity, the I label indicates that the word is inside the entity, and the O label indicates that the word does not belong to the entity.

[0036] Manual labeling: a process of labeling the ground-truth of the training samples in the training data set by the labeling personnel before training the neural network model. The labeling label obtained by manual labeling is used as the supervision of the output result of the model in the model training process, and accordingly, the process of model training is to adjust the model parameters so that the output result of the model tends to the labeling label. The manual labeling process involved in the embodiments of the present application includes labeling the subject, the object and the object relation in the sample text.

[0037] Loss function: also known as cost function, is a function used to evaluate the difference between the predicted value of the neural network model and the true value, the smaller the loss function, the better the performance of the neural network model, the training process of the model is to minimize the loss function by adjusting the model parameters. For different neural network models, the loss function used is also different, common loss functions include 0-1 loss function, absolute value loss function, logarithmic loss function, exponential loss function, perception loss function, cross-entropy loss function, etc.

[0038] Natural language processing is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph and other technologies. The entity relationship extraction method provided in the embodiments of the present application is applied in the field of knowledge graph.

[0039] Knowledge graph is a graph-based data structure composed of nodes and edges, each node represents an entity, and the edge between the nodes represents the relationship between entities. Therefore, in order to realize the construction of knowledge graph in a specific field, it is necessary to first extract the relationship between entities from the massive text data in the specific field. In related technologies, in order to improve the efficiency of entity relationship extraction, a neural network model is used for entity relationship extraction. Because the relationship between entities is complex and diverse, when extracting entity relationships, various entity relationships need to be discriminated one by one. However, it is found in actual application that for a piece of text, the entity relationship between entities in the text only accounts for a very small part of the total amount of entity relationship, and other redundant entity relationships not only affect the accuracy of entity relationship extraction, but also affect the efficiency of entity relationship extraction.

[0040] The embodiments of the present application provide an entity relationship extraction method in a text, which filters out potential entity relationships with high probability in the text from candidate entity relationships, reduces the influence of redundant entity relationships on entity relationship extraction, improves the accuracy of entity relationship extraction, and improves the efficiency of entity relationship extraction. Figure 1 The principle schematic diagram of the entity relationship extraction method in the text provided by the embodiments of the present application is shown.

[0041] As Figure 1As shown, the computer device first encodes the text 11 to obtain word vectors 12 corresponding to the n words in the text 11, and then screens potential entity relations 14 from m candidate entity relations 13 based on the word vectors 12, where the probability of the existence of the potential entity relations 14 in the text 11 is higher than that of other candidate entity relations. Further, the computer device determines the subject 15 and the object 16 in the text 11 based on the potential entity relations 14 and the word vectors 12, and then generates an entity relation triple 17 based on the subject 15, the object 16, and the potential entity relations 14 to complete the entity relation extraction of the text 11. Since the potential entity relations are screened before the subject and the object are determined, the calculation amount of the process of determining the subject and the object is reduced without traversing each candidate entity relation. Meanwhile, the entity relation triple finally extracted only contains the potential entity relations, avoiding the false recall caused by redundant entity relations, and improving the accuracy of the entity relation extraction.

[0042] The method for extracting entity relations in a text provided by the embodiments of the present application can be used in the construction process of a specific domain knowledge graph. Taking the construction process of a medical domain knowledge graph as an example, a developer first manually annotates part of the text corpus in the medical domain, and then trains an entity relation extraction model using the manually annotated text corpus, where the entity relation extraction model is used to output an entity relation triple based on an input text. After the trained entity relation extraction model is deployed on a computer device, the computer device inputs the unannotated text corpus in the medical domain text corpus into the entity relation extraction model to obtain the entity relation triple output by the entity relation extraction model. Based on the extracted massive entity relation triples, the computer device can further construct a medical domain knowledge graph.

[0043] Further, the constructed medical domain knowledge graph can be used in various downstream businesses. For example, an automatic question answering system in the medical domain can be designed based on the medical domain knowledge graph, and the automatic question answering system can be used to automatically reply to the medical questions of a user; or the medical domain knowledge graph can be used as background information of entities and entity relations in natural language understanding to improve the accuracy of natural language understanding; or the medical domain knowledge graph can be integrated into a recommendation system as auxiliary information to improve the accuracy of the recommendation result.

[0044] Of course, the method for extracting entity relations in a text provided by the embodiments of the present application can also be applied to the construction process of a knowledge graph in other domains, such as the customer service domain, the financial domain, and the like. The embodiments of the present application only take the medical domain as an example for illustrative description, but do not constitute a limitation in this regard.

[0045] Figure 2A schematic diagram of an implementation environment provided by an example embodiment of the present application is shown. The implementation environment includes a terminal 210 and a server 220. The terminal 210 and the server 220 communicate data through a communication network, which can be a wired network or a wireless network, and can be at least one of a local area network, a metropolitan area network, and a wide area network.

[0046] The terminal 210 is an electronic device for providing text corpus, which can be a smartphone, a tablet computer, or a personal computer, and the like, and the present embodiment is not limited thereto. Figure 2 In the present embodiment, the terminal 210 is taken as an example of a computer used by medical staff.

[0047] After the terminal 210 obtains the text corpus, the terminal 210 sends the text corpus to the server 220, and the server 220 extracts entity relationships for constructing a knowledge graph from the text corpus. As shown in Figure 2 After the medical staff enters the symptom description of the patient through the terminal 210, the terminal 210 sends the symptom description as text corpus in the medical field to the server 220.

[0048] The server 220 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, and the like.

[0049] In the present embodiment, the server 220 is provided with an entity relationship extraction model for extracting entity relationship triples containing entities and entity relationships from text in a specific field. Optionally, the entity relationship extraction model is pre-trained according to manually annotated text. In addition, the server 220 is configured to construct a knowledge graph in a specific field based on the extracted entity relationship triples. In a possible implementation, the text corpus and the extracted entity relationship triples can be saved on a blockchain.

[0050] As shown in Figure 2 After the server 220 receives the text corpus sent by the terminal 210, the server 220 inputs the medical text 221 in the text corpus into the entity relationship extraction model 222 to obtain the entity relationship triples 223 extracted by the entity relationship extraction model 222. When the data amount of the entity relationship triples 223 meets the requirements of knowledge graph construction (or updating), the server 220 constructs (or updates) the medical field knowledge graph 224 based on the entity relationship triples 223.

[0051] Of course, the server 220 can also capture text corpus from the network or obtain text corpus from a corpus in addition to obtaining text corpus from the terminal 210, and the embodiments are not limited in this regard.

[0052] In other possible embodiments, the entity relationship extraction model 222 can also be deployed on the terminal side, and the terminal extracts entity relationship triples from the text and reports the entity relationship triples to the server (to avoid the server directly obtaining the original text corpus) so that the server constructs a knowledge graph. The embodiments are not limited in this regard. For ease of description, each of the following embodiments is described by taking the method for extracting entity relationships in text as an example.

[0053] Figure 3 A flowchart of a method for extracting entity relationships in text provided by an example embodiment of the present application is shown. The embodiment takes the method for extracting entity relationships in text as an example for computer devices, and the method includes the following steps.

[0054] Step 301: encoding the target text to obtain word vectors corresponding to each word in the target text.

[0055] The target text is text corpus of a specific field, and the target text is composed of a plurality of tokens. When encoding the target text, the encoding is performed in units of tokens to obtain word vectors corresponding to each token. When the target text is English, the encoding of the target text obtains word vectors corresponding to each English word. When the target text is Chinese, the encoding of the target text obtains word vectors corresponding to each Chinese character. For ease of description, the embodiments of the present application take the target text as Chinese as an example.

[0056] Regarding the encoding method of the text, in one possible embodiment, the computer device inputs the target text into a pre-trained BERT (Bidirectional Encoder Representations from Transformers) model, encodes the target text by the BERT model, and outputs word vectors corresponding to each word. In other possible embodiments, the computer device can also use Word2Vec, Glove, RoBerta, etc. to encode the target text, and the embodiments of the present application do not limit the specific encoding method.

[0057] Illustratively, when the input target text is represented as S = {x1, x2, …, xn} (n is the length of the target text, i.e., the number of tokens), after encoding, the word vectors corresponding to each word can be represented as n wherein each word vector has a dimension of d. ​

[0058] At step 302, based on the word vectors corresponding to respective words, the computer device determines potential entity relationships corresponding to the target text, and the probability of the potential entity relationships existing in the target text is higher than the probability of other candidate entity relationships existing in the target text.

[0059] Optionally, before performing entity relationship extraction, the developer first sets candidate entity relationships between entities in a specific domain. Although the types of candidate entity relationships are various, the entity relationships existing in a single text only account for a small part of the total amount of candidate entity relationships (usually, the entity relationships existing in a single text are less than 5). Therefore, in order to avoid invalid and redundant entity relationships affecting the speed and accuracy of entity relationship extraction, in the embodiment, the computer device first screens at least one potential entity relationship from the candidate entity relationships, and the potential entity relationship is an entity relationship with a high probability of existing in the target text.

[0060] In the embodiment, the number of potential entity relationships corresponding to different texts can be different, and the types of potential entity relationships can be different.

[0061] In an illustrative example, when there are 100 candidate entity relationships between entities in a specific domain, the computer device determines two candidate entity relationships from the 100 candidate entity relationships as potential entity relationships corresponding to the target text based on the word vectors.

[0062] At step 303, based on the potential entity relationships and the word vectors corresponding to respective words, the computer device determines a target subject and a target object in the target text, and the target subject and the target object belong to entities.

[0063] Since the potential entity relationship with a high probability of existing has been screened, the subject and the object in the target text only need to be determined based on the potential entity relationship, and other candidate entity relationships with a low probability of existing do not need to be considered. On the one hand, the amount of calculation when determining the subject and the object can be reduced, and on the other hand, the false recall caused by the candidate entity relationships with a low probability of existing can be avoided. For example, when there are 100 candidate entity relationships, and the potential entity relationships corresponding to the target text are only two, the computer device only needs to determine the subject and the object based on the two potential entity relationships, and does not need to consider the other 98 candidate entity relationships.

[0064] In a possible implementation, the computer device combines the potential entity relationship and the word vectors corresponding to respective words to obtain a word vector assigned with a specific entity relationship, and then determines the target subject and the target object based on the word vector assigned with the specific entity relationship. In the embodiment, the target subject and the target object are entities in a specific domain, and the target subject is a subject with the potential entity relationship, and the target object is an object with the potential entity relationship.

[0065] In a possible implementation, when the target text is a medical field text, the target subject and the target object are medical text entities, and the entity relationship between the target subject and the target object includes at least one of a part, a time and a property.

[0066] For example, when the target subject is a symptom, the target object can include a part where the symptom occurs, a property (severity) of the symptom, a duration of the symptom, and the like.

[0067] In step 304, the entity relationship triple is extracted from the target text based on the target subject, the potential entity relationship and the target object.

[0068] After the target subject, the target object and the potential entity relationship are determined, the computer device combines the three to generate an entity relationship triple, wherein the target subject and the target object in the entity relationship triple have the potential entity relationship.

[0069] In a possible implementation, the computer device can combine the subject and the object by using a heuristic nearest neighbor method, that is, combine the nearest target subject and object and the potential entity relationship in the target text in time sequence to obtain the entity relationship triple.

[0070] In another possible implementation, the computer device determines a confidence degree when the target subject and the object are combined, and combines the target subject and the object based on the confidence degree to obtain the entity relationship triple, thereby improving the accuracy of the entity relationship between the subject and the object in the entity relationship triple.

[0071] In an illustrative example, the target text is "a patient has paroxysmal abdominal pain for two days, which is in the right lower abdomen and is in a dull pain state", the computer device determines that the potential entity relationship corresponding to the target text includes "property" and "part", and determines that the target subject includes abdominal pain, the target object includes paroxysmal and right lower part, and the extracted entity relationship triple includes: (abdominal pain, property, paroxysmal), (abdominal pain, part, right lower abdomen).

[0072] To sum up, in the embodiment of the present application, in the entity relationship extraction process, first, the potential entity relationship with a high probability of existing in the target text is determined based on the word vector obtained by encoding the target text, the candidate entity relationship with a low probability of existing is filtered, then the target subject and the target object are determined from the target text based on the determined potential entity relationship and the word vector, and finally the entity relationship triple containing the target subject, the potential entity relationship and the target object is extracted from the target text; by using the scheme provided in the embodiment of the present application, the potential entity relationship is obtained by screening the candidate entity relationship before the subject and the object are extracted, which can reduce the false recall results caused by the redundant entity relationship irrelevant to the target text, improve the accuracy of the entity relationship extraction in the text, and help to improve the extraction efficiency of the entity relationship.

[0073] In a possible implementation, the computer device performs entity relation triple extraction through a pre-trained entity relation extraction model, which is composed of an encoding layer, a latent relation judgment layer, and a relation-specific sequence labeling layer. The encoding layer is configured to encode the input text to obtain word vectors, the latent relation judgment layer is configured to determine the latent entity relation in the text based on the word vectors, and the relation-specific sequence labeling layer is configured to fuse the latent entity relation with the word vectors, so as to perform sequence labeling based on the word vectors with the latent entity relation, and determine the target subject and object. The following exemplary embodiments are described.

[0074] Figure 4 A flowchart of an entity relation extraction method provided by another exemplary embodiment of the present application is shown. The present embodiment is described by taking the method used in a computer device as an example, which includes the following steps.

[0075] In step 401, the target text is encoded to obtain word vectors corresponding to each word in the target text.

[0076] The implementation of the present step can refer to the above-described step 301, and the present embodiment will not be described here again.

[0077] As shown in the schematic diagram, Figure 5 As shown in the schematic diagram,

[0078] In step 402, the text vector corresponding to the target text is determined based on the word vectors corresponding to each word.

[0079] In the present embodiment, the determination process of the latent entity relation in the text is modeled as a multi-label binary classification problem based on the global representation of the text, so the computer device obtains the global representation of the target text, i.e., the text vector, based on the word vectors corresponding to each word.

[0080] In a possible implementation, the computer device performs average pooling processing on the word vectors corresponding to each word to obtain the text vector corresponding to the target text, which has the same dimension as the word vector, thereby realizing dimension reduction of the output of the encoding layer. As shown in the schematic diagram, the process of determining the text vector based on the word vector can be represented by the following formula:

[0081]

[0082] wherein, Avgpool is an average pooling method, i.e., the word vectors of each word are averaged in each dimension, and h is the word vector of each word in the target text.

[0083] Of course, in addition to average pooling word vectors, computer devices can also obtain the global representation of the target text in other ways, and this embodiment does not limit this.

[0084] Step 403: Classify the text vector through a fully connected layer to obtain the existence probability of various candidate entity relationships. The existence probability refers to the probability that a candidate entity relationship exists in the target text.

[0085] In one possible implementation, a fully connected (FC) layer is used as the latent relation determination layer in the entity relation extraction model. Correspondingly, the process of determining latent entity relations in the target text is equivalent to using the fully connected layer to perform multi-label binary classification of the text vector.

[0086] Optionally, the computer device inputs the text vector into a fully connected layer, which performs convolution processing on the text vector (e.g., using a 1×1 convolution kernel) to obtain the existence probability of each candidate entity relation. The higher the existence probability of a candidate entity relation, the more likely the entity in the target text is to possess that candidate entity relation. The existence probabilities of each candidate entity relation can be expressed as:

[0087] P rel =σ(W r h avg +b r )

[0088] Among them, h avg For text vectors, Here, σ represents the trainable weights (i.e., the weights of the fully connected layer), σ is the sigmoid function, and b... r This is a bias term.

[0089] Indicative, such as Figure 5 As shown, the computer device inputs the text vector (obtained by average pooling of word vector 53) into the latent relation judgment layer 54 to obtain the existence probability 541 corresponding to various candidate entity relationships.

[0090] Step 404: Determine potential entity relationships from candidate entity relationships based on their existence probability.

[0091] In one possible implementation, if the probability of existence of a candidate entity relationship is higher than a probability threshold, the computer device determines the candidate entity relationship as a potential entity relationship corresponding to the target text; if the probability of existence of a candidate entity relationship is lower than the probability threshold, the computer device filters the candidate entity relationship.

[0092] Indicative, such as Figure 5As shown, the computer device determines "property" and "part" as potential entity relationships based on the existence probability 541 corresponding to various candidate entity relationship correspondences.

[0093] At step 405, the word vector and the relationship vector corresponding to the potential entity relationship are fused to obtain a word vector with the potential entity relationship.

[0094] In a possible implementation, the computer device obtains a relationship vector corresponding to each potential entity relationship, and fuses the relationship vector with each word vector to obtain a word vector with the potential entity relationship. The relationship vector corresponding to the potential entity relationship has the same dimension as the word vector.

[0095] Illustratively, the word vector with the potential entity relationship can be represented as h i +u j where h i is the word vector of the i-th word in the target text, u j is the j-th potential entity relationship, and h i ,

[0096] At step 406, sequence labeling is performed based on the word vector with the potential entity relationship to determine the target subject and the target object in the target text.

[0097] In the embodiments of the present application, the process of extracting the subject and the object from the text is modeled as a sequence labeling task. When performing sequence labeling, the computer device uses the BIO label mode to assign labels representing the entity position and the category of each word in the text, where the entity position is used to represent the position of the word in the entity, and the category is used to represent the subject and the object.

[0098] In a possible implementation, the computer device performs sequence labeling based on the word vector with the potential entity relationship through a relationship-specific sequence labeling layer to obtain the target subject and the target object in the target text. The relationship-specific sequence labeling layer can use a recurrent neural network (RNN) or a long short-term memory (LSTM) network to implement sequence labeling, and the embodiments of the present application do not limit the specific network structure used in sequence labeling.

[0099] In order to ensure the accuracy of the extraction of the subject and the object, the sequence labeling of the subject and the object is performed separately in the embodiments of the present application. In a possible implementation, the present step can include the following sub-steps.

[0100] 1. Perform subject sequence annotation on word vectors with potential entity relationships to obtain subject annotation results, which are used to represent the first entity positions of word vectors with potential entity relationships. The first entity positions include the beginning of the subject, inside the subject, or outside the subject.

[0101] Optionally, the computer device performs subject sequence annotation on word vectors with potential entity relationships through a relationship-specific sequence annotation layer to obtain subject annotation results indicating the first entity positions corresponding to each word in the target text. Among them, the subject annotation results include: B-OBJ (indicating that the word belongs to the subject and is at the beginning of the subject), I-OBJ (indicating that the word belongs to the subject and is inside the subject), and O (indicating that the word is outside the subject).

[0102] Among them, the subject sequence annotation process can be expressed as:

[0103]

[0104] Among them, is the trainable weight, b sub [[ID=十六]]is the bias term, h i is the word vector of the i-th word in the target text, u j is the j-th potential entity relationship, and h i , <s

[0105] Schematically, as Figure 5 shown, the computer device inputs the word vector h output by the encoding layer 52 and the potential entity relationship r output by the potential relationship judgment layer 54 into the relationship-specific sequence annotation layer 55. The relationship-specific sequence annotation layer 55 concatenates the word vector h and the relationship vector corresponding to the entity relationship r, and performs subject annotation on the concatenated vector to obtain subject annotation results. Among them, the subject annotation result corresponding to "abdomen" is "B-SUB", the subject annotation result corresponding to "pain" is "I-SUB", and the subject annotation results corresponding to the remaining words are all "O".

[0106] 2. Perform object sequence annotation on word vectors with potential entity relationships to obtain object annotation results, which are used to represent the second entity positions of word vectors with potential entity relationships. The second entity positions include the beginning of the object, inside the object, or outside the object.

[0107] Optionally, the computer device performs object sequence annotation on word vectors with potential entity relationships through a relationship-specific sequence annotation layer to obtain object annotation results indicating the second entity positions corresponding to each word in the target text. Among them, the object annotation results include: B-SUB (indicating that the word belongs to the object and is at the beginning of the object), I-SUB (indicating that the word belongs to the object and is inside the object), O (indicating that the word is outside the object).

[0108] Among them, the process of object sequence annotation can be expressed as:

[0109]

[0110] Among them, is the trainable weight, b obj is the bias term, h i is the word vector of the i-th word in the target text, u j is the j-th potential entity relationship, and h i ,

[0111] Schematically, as Figure 5 shown, the relationship-specific sequence annotation layer 55 splices the word vector h and the relationship vector corresponding to the entity relationship r, and performs object annotation on the spliced vector to obtain the object annotation result. Among them, the subject annotation results corresponding to "array", "send", and "sex" are "B-OBJ", "I-OBJ", and "I-OBJ" in sequence, and the subject annotation results corresponding to "right", "lower", and "abdomen" are "B-OBJ", "I-OBJ", and "I-OBJ" in sequence, while the object annotation results corresponding to the remaining words are all "O".

[0112] Third, based on the subject annotation result and the object annotation result, determine the target subject and target object in the target text.

[0113] After completing the subject-object sequence annotation, the computer device determines the target subject and target object based on the subject annotation result and the object annotation result corresponding to each word in the target text. In a possible implementation manner, the computer determines the word corresponding to the start of the subject in the subject annotation result, and the words corresponding to the continuous inside of the subject as the target subject; determines the word corresponding to the start of the object in the object annotation result, and the words corresponding to the continuous inside of the object as the target object.

[0114] Schematically, as Figure 5 shown, the computer device determines the target subject as "abdominal pain" based on the words corresponding to "B-SUB" and "I-SUB"; determines the target objects as "paroxysmal" and "right lower abdomen" based on the words corresponding to "B-OBJ" and "I-OBJ".

[0115] Step 407, based on the target subject, the potential entity relationship, and the target object, extract the entity relationship triple from the target text.

[0116] Schematically, as Figure 5 shown, the computer device generates the entity relationship triple 56 based on the determined target subject, target object, and potential entity relationship.

[0117] In this embodiment, the computer device obtains the text vector corresponding to the target text by performing average pooling processing on the word vectors of each word in the target text, so as to filter out potential entity relationships from the candidate entity relationships based on the text vector, improve the efficiency of subsequent subject and object extraction, and avoid the influence of redundant entity relationships on the accuracy of subject and object extraction.

[0118] In addition, in this embodiment, the relationship vector corresponding to the word vector and the potential entity relationship is fused to obtain a plurality of relationship-specific text representations, and the subject and object sequence labeling are performed on the text representations, which helps to improve the accuracy of subject and object labeling, and further improve the accuracy of the generated entity relationship triple.

[0119] In one illustrative example, as shown in Table 1, when the related technical solution is used to perform entity relationship extraction on the text, the entity relationship triple containing the error entity relationship "property" is finally extracted due to the lack of potential entity relationship filtering. However, when the solution provided in the embodiment of the present application is used to perform entity relationship extraction, the entity relationship "property" can be filtered in the potential entity relationship filtering stage, so that the entity relationship triple finally extracted does not contain the entity relationship "property", thereby improving the accuracy of entity relationship extraction.

[0120] Table 1

[0121]

[0122] Since the heuristic nearest neighbor method is an idealized method, and the syntax of the text in the real scene has diversity, there is a large error when the heuristic nearest neighbor method is used to generate the entity relationship triple. In order to further improve the accuracy of entity relationship extraction, in one possible implementation, the entity relationship extraction model further includes a subject and object alignment layer, which is used to align the subject and object output by the relationship-specific sequence labeling layer, and output the entity relationship triple in combination with the potential entity relationship. Optionally, as shown in Figure 6 The step 407 can include the following steps:

[0123] Step 407A, combining the target subject and the target object with the same potential entity relationship to obtain at least one subject and object pair.

[0124] In one possible implementation, the computer device combines target subjects and target objects (i.e., those with the same potential entity relationship) extracted under the same potential entity relationship to obtain subject-object pairs. In an illustrative example, when the target subjects with the same potential entity relationship include subject A and subject B, and the target objects include object A and object B, the obtained subject-object pairs include: (subject A, object A), (subject A, object B), (subject B, object A), and (subject B, object B).

[0125] Step 407B: Determine the confidence level of each subject-object pair.

[0126] In one possible implementation, during the training phase, the computer device pre-learns a global correspondence matrix. When determining the confidence level of a subject-object pair, the computer device determines the confidence level between the target subject and the target object in the subject-object pair within the global correspondence matrix as the confidence level of the subject-object pair. This global correspondence matrix is ​​a matrix composed of confidence levels between different entities, that is, different positions in the global correspondence matrix correspond to the confidence levels between different entities. The higher the confidence level, the higher the probability that there is an entity relationship between the entities.

[0127] As an illustration, the confidence level at each position in the global correspondence matrix is ​​calculated using the following formula:

[0128]

[0129] in, These are the subject vector representation of the i-th word and the object vector representation of the j-th word, respectively. For trainable weights, σ ​​is the sigmoid function, and b g This is a bias term.

[0130] It should be noted that the global correspondence matrix is ​​learned before constructing relation-specific word vectors, meaning it is independent of entity relations and only focuses on the entities themselves.

[0131] Indicative, in Figure 5 On the basis of, such as Figure 7 As shown, the computer device determines the position of the target subject "abdominal pain" in the global correspondence matrix 571, as well as the positions of the target objects "paroxysmal" and "right lower abdomen" in the global correspondence matrix 571, thereby determining the confidence level of the subject-object pair (abdominal pain, paroxysmal) and the confidence level of the subject-object pair (abdominal pain, right lower abdomen).

[0132] Optionally, the computer device detects whether the confidence level of the subject-object pair is higher than the confidence level threshold. If it is higher, step 407C is executed to generate entity relation triples based on the subject-object pair and the potential entity relation. If the confidence level of the subject-object pair is lower than the confidence level threshold, the computer device filters the subject-object pair.

[0133] Step 407C: If the confidence level of the subject-object pair is higher than the confidence level threshold, generate an entity relationship triplet based on the target subject, target object, and potential entity relationship in the subject-object pair.

[0134] Indicative, such as Figure 7 As shown, the confidence levels of both the subject-object pair (abdominal pain, paroxysmal) and the subject-object pair (abdominal pain, right lower quadrant) are higher than the confidence threshold. Therefore, the computer device retains the subject-object pair and generates entity relation triplet 56 based on the subject-object pair and the potential entity relation "property" and "location".

[0135] In this embodiment, the computer device uses a pre-learned global correspondence matrix to determine the confidence level of the subject-object pair, thereby filtering out unreasonable subject-object pairs based on the confidence level, achieving subject-object alignment, and helping to improve the accuracy of the finally extracted entity relationship triples.

[0136] In an illustrative example, as shown in Figure 2, when using related technical solutions to extract entity relationships from text, the heuristic nearest neighbor method lacks constraints, resulting in numerous subject-object alignment errors (misaligning adjacent rashes and legs). However, when using the solution provided in this application for entity relationship extraction, subject-object alignment is constrained based on the confidence level of the subject-object pairs, filtering out incorrectly aligned subject-object pairs and improving the accuracy of the extraction results.

[0137] Table 2

[0138]

[0139] Based on real case data, entity relationships were extracted using relevant technologies and the scheme provided in the embodiments of this application. The F1-score of triple matching (a triple is considered correct when both the subject and object and the entity relationship between the subject and object are correct) was used as the evaluation index. The evaluation results are shown in Table 3.

[0140] Table 3

[0141] Accuracy Recall F1-score Related technical solutions 80.0% 88.2% 83.9% The embodiments of the present application provide solutions 91.8% 89.5% 90.6%

[0142] The evaluation results are shown in Table 4, which use the F1-score of entity relations in triples (ignoring the accuracy of subject and object) as the evaluation index.

[0143] Table 4

[0144] Accuracy Recall F1-score Related technical solutions 83.0% 93.1% 87.7% The embodiments of the present application provide solutions 92.8% 96.2% 94.5%

[0145] The evaluation results are shown in Table 5, taking the F1-score of the subject and object in the triple (ignoring the accuracy of the object relationship) as the evaluation index.

[0146] Table 5

[0147] Accuracy Recall F1-score Related technical solutions 83.0% 91.8% 87.1% The embodiments of the present application provide solutions 94.0% 92.3% 93.1%

[0148] It can be seen that, compared with the related technical solutions, the scheme provided by the embodiment of the application significantly improves the entity relationship extraction performance through potential relationship judgment and subject-object alignment, especially in terms of accuracy, which is significantly ahead of the related technical solutions.

[0149] The above embodiment describes the entity relationship extraction process. Before implementing the entity relationship extraction, the developer first needs to complete the entity relationship extraction model training using sample text. The following exemplary embodiments describe the training process of the entity relationship extraction model.

[0150] Figure 8 A flowchart of the training process of the entity relationship extraction model provided by an exemplary embodiment of the application is shown. The embodiment takes the method for computer equipment as an example for description, and the method includes the following steps.

[0151] Step 801, encoding the sample text to obtain sample word vectors corresponding to each word in the sample text.

[0152] Optionally, the computer device inputs the sample text into the encoding layer of the entity relationship extraction model to obtain sample word vectors corresponding to each word in the sample text. The encoding process of the encoding layer on the sample text can refer to the above embodiments, which will not be repeated here.

[0153] Step 802, determining the sample potential entity relationship corresponding to the sample text based on the sample word vectors corresponding to each word.

[0154] Similarly to the application process, optionally, the computer device inputs the sample word vectors corresponding to each word into the potential relationship judgment layer of the entity relationship extraction model to obtain the sample potential entity relationship corresponding to the sample text. The process of determining the sample potential entity relationship based on the sample word vectors by the potential relationship judgment layer can refer to the above embodiments, which will not be repeated here.

[0155] Step 803, determining the sample subject and sample object in the sample text based on the sample potential entity relationship and the sample word vectors corresponding to each word.

[0156] Similar to the application process, optionally, the computer device inputs the sample potential entity relationship and the sample word vector corresponding to each word into the relationship-specific sequence labeling layer of the entity relationship extraction model to obtain the sample subject and the sample object in the sample text. The process of subject and object labeling by the relationship-specific sequence labeling layer can refer to the above embodiments, and will not be described here in this embodiment.

[0157] At step 804, the potential relationship judgment loss is determined based on the entity relationship label corresponding to the sample text and the sample potential entity relationship.

[0158] In order to determine the judgment loss of the potential relationship judgment layer, the computer device takes the entity relationship label corresponding to the sample text as supervision, and determines the difference between the entity relationship label and the sample potential entity relationship as the potential relationship judgment loss. Wherein, the entity relationship label is used to represent the entity relationship contained in the sample text.

[0159] In one possible implementation, the computer device determines the multi-label binary classification cross-entropy loss between the entity relationship label and the sample potential entity relationship as the potential relationship judgment loss. The potential relationship judgment loss can be represented as:

[0160]

[0161] Wherein, n r is the number of candidate entity relationships, y i is the entity relationship label corresponding to the sample text, P rel is the existence probability of the potential entity relationship in the sample text.

[0162] At step 805, the subject and object judgment loss is determined based on the sample subject, the sample object, and the word label corresponding to each word in the sample text.

[0163] In order to determine the judgment loss of the relationship-specific subject and object labeling layer, the computer device takes the word label corresponding to each word in the sample text as supervision, and determines the difference between the entity relationship label and the sample potential entity relationship as the potential relationship judgment loss. Wherein, the word label is the BIO label manually labeled, and the entity relationship label includes at least one of the following: B-SUB label, I-SUB label, B-OBJ label, I-OBJ label and O label.

[0164] In one possible implementation, the computer device determines the multi-classification cross-entropy loss as the subject and object judgment loss. The subject and object judgment loss can be represented as:

[0165]

[0166] Wherein, is the number of potential entity relationships, n is the length of the sample text, is an entity relation label, is a probability that the i-th word vector belongs to the subject or object under the j-th potential entity relation.

[0167] At step 806, the entity relation extraction model is trained based on the potential relation judgment loss and the subject-object judgment loss. The entity relation extraction model is used to output an entity relation triple based on an input text.

[0168] In one possible implementation, the computer device adopts a joint training strategy to jointly optimize the gradient descent optimal solution of the potential relation judgment layer and the loss of the relation-specific sequence labeling layer, that is, the entity relation extraction model is trained using the total loss of the potential relation judgment loss and the subject-object judgment loss. The total loss of the entity relation extraction model can be expressed as:

[0169]

[0170] wherein a and β are loss weights.

[0171] In summary, in the embodiments of the present application, the entity relation extraction model is trained based on the potential relation judgment loss of the potential relation judgment layer and the subject-object judgment loss of the relation-specific subject-object labeling layer, so that the entity relation extraction model can learn how to filter potential entity relations and how to perform subject-object labeling during the training process. Subsequently, when the entity relation extraction model obtained by training is used for entity relation extraction, the potential entity relations can be filtered to reduce the false recall results caused by redundant entity relations, improve the accuracy of entity relation extraction in the text, and further improve the extraction efficiency of entity relations.

[0172] In another possible implementation, when the entity relation extraction model includes a subject-object alignment layer, on the basis of Figure 8 , as shown in Figure 9 , after step 803, steps 807 to 809 can be further included, and step 806 can be replaced by step 8061.

[0173] At step 807, the sample subject and the sample object are combined into a sample subject-object pair.

[0174] Similar to the application process, the computer device combines the extracted sample subject and sample object (having the same sample potential entity relation) to obtain a sample subject-object pair.

[0175] At step 808, the sample confidence of the sample subject-object pair is determined.

[0176] In a possible implementation, the computer device determines a sample confidence of the sample subject-object pair according to the subject vector representation corresponding to the sample subject and the object vector representation corresponding to the sample object. The manner of calculating the sample confidence can refer to step 407B, and details are not described herein again.

[0177] In step 809, a global correspondence loss is determined based on the confidence label corresponding to the sample text and the sample confidence.

[0178] To determine the judgment loss of the subject-object alignment layer, the computer device takes the confidence label (i.e., the manually annotated subject-object pair) of the subject-object pair in the sample text as supervision, and determines the difference between the sample confidence and the confidence label as the global correspondence loss. In a possible implementation, the computer device determines a multi-label binary cross-entropy loss between the confidence label and the sample confidence as the global correspondence loss. The global correspondence loss can be represented as:

[0179]

[0180] wherein n is the length of the sample text, y i,j is the confidence label of the subject-object pair (i-th word, j-th word), is the sample confidence of (i-th word, j-th word).

[0181] In step 8061, the entity relation extraction model is trained based on the latent relation judgment loss, the subject-object judgment loss, and the global correspondence loss.

[0182] In a possible implementation, the computer device adopts a joint training strategy to jointly optimize the gradient descent optimal solution of the loss of the latent relation judgment layer, the relation-specific sequence labeling layer, and the subject-object alignment layer, that is, the entity relation extraction model is trained by using the total loss of the latent relation judgment loss, the subject-object judgment loss, and the global correspondence loss. Optionally, the loss weights corresponding to the latent relation judgment loss, the subject-object judgment loss, and the global correspondence loss are the same. The total loss of the entity relation extraction model can be represented as:

[0183]

[0184] wherein a, b, and g are loss weights.

[0185] In this embodiment, the global correspondence loss is taken as part of the total loss of the entity relation extraction model, so that the global correspondence matrix can be learned in the training process, thereby filtering unreasonable subject-object pairs in the subsequent process, aligning the subject-object pairs, and helping to improve the entity relation extraction accuracy of the entity relation extraction model.

[0186] Figure 10 is a structural block diagram of an entity relationship extraction device in a text provided by an example embodiment of the present application, and the device comprises:

[0187] The encoding module 1001 is configured to encode a target text to obtain word vectors corresponding to each word in the target text.

[0188] The relationship determining module 1002 is configured to determine a latent entity relationship corresponding to the target text based on the word vectors corresponding to each word, and the probability of the existence of the latent entity relationship in the target text is higher than the probability of the existence of other candidate entity relationships except the latent entity relationship.

[0189] The subject-object determining module 1003 is configured to determine a target subject and a target object in the target text based on the latent entity relationship and the word vectors corresponding to each word, and the target subject and the target object belong to entities.

[0190] The extraction module 1004 is configured to extract an entity relationship triple from the target text based on the target subject, the latent entity relationship and the target object.

[0191] Optionally, the relationship determining module 1002 comprises:

[0192] The text vector determining unit is configured to determine a text vector corresponding to the target text based on the word vectors corresponding to each word.

[0193] The classification unit is configured to classify the text vector through a full connection layer to obtain existence probabilities corresponding to various candidate entity relationships, and the existence probability refers to the probability of the existence of the candidate entity relationship in the target text.

[0194] The relationship determining unit is configured to determine the latent entity relationship from the candidate entity relationships based on the existence probabilities.

[0195] Optionally, the text vector determining unit is configured to:

[0196] perform average pooling processing on the word vectors corresponding to each word to obtain the text vector corresponding to the target text, and the text vector has the same dimension as the word vector.

[0197] Optionally, the subject-object determining module 1003 comprises:

[0198] The fusion unit is configured to fuse a relationship vector corresponding to the word vector and the latent entity relationship to obtain a word vector with a latent entity relationship.

[0199] The labeling unit is configured to perform sequence labeling based on the word vector with the potential entity relationship, and determine the target subject and the target object in the target text.

[0200] Optionally, the labeling unit is configured to:

[0201] perform subject sequence labeling based on the word vector with the potential entity relationship, to obtain a subject labeling result, the subject labeling result being used to represent a first entity position of the word vector with the potential entity relationship, the first entity position including a subject beginning, a subject inside or a subject outside;

[0202] perform object sequence labeling based on the word vector with the potential entity relationship, to obtain an object labeling result, the object labeling result being used to represent a second entity position of the word vector with the potential entity relationship, the second entity position including an object beginning, an object inside or an object outside;

[0203] determine the target subject and the target object in the target text based on the subject labeling result and the object labeling result.

[0204] Optionally, the extraction module 1004 includes:

[0205] The combination unit is configured to combine the target subject and the target object with the same potential entity relationship, to obtain at least one subject-object pair.

[0206] The confidence determination unit is configured to determine a confidence of each of the subject-object pairs.

[0207] The generation unit is configured to generate the entity relationship triple based on the target subject, the target object and the potential entity relationship in the subject-object pair, if the confidence of the subject-object pair is higher than a confidence threshold.

[0208] Optionally, the confidence determination unit is configured to:

[0209] determine, as the confidence of the subject-object pair, a confidence between the target subject and the target object in the subject-object pair in a global corresponding relationship matrix, the global corresponding relationship matrix being a matrix composed of confidences between different entities.

[0210] Optionally, the apparatus further includes:

[0211] The filtering module is configured to filter the subject-object pair, if the confidence of the subject-object pair is lower than the confidence threshold.

[0212] Optionally, the apparatus further includes a training module configured to:

[0213] encode the sample text to obtain a sample word vector corresponding to each word in the sample text;

[0214] determine a sample latent entity relationship corresponding to the sample text based on the sample word vector corresponding to each word;

[0215] determine a sample subject and a sample object in the sample text based on the sample latent entity relationship and the sample word vector corresponding to each word;

[0216] determine a latent relationship judgment loss based on the entity relationship label corresponding to the sample text and the sample latent entity relationship;

[0217] determine a subject-object judgment loss based on the sample subject, the sample object, and the word label corresponding to each word in the sample text;

[0218] train an entity relationship extraction model based on the latent relationship judgment loss and the subject-object judgment loss, the entity relationship extraction model being configured to output an entity relationship triple based on an input text.

[0219] Optionally, the training module is further configured to:

[0220] combine the sample subject and the sample object into a sample subject-object pair;

[0221] determine a sample confidence of the sample subject-object pair;

[0222] determine a global corresponding relationship loss based on the confidence label corresponding to the sample text and the sample confidence;

[0223] train the entity relationship extraction model based on the latent relationship judgment loss, the subject-object judgment loss, and the global corresponding relationship loss.

[0224] Optionally, the loss weights corresponding to the latent relationship judgment loss, the subject-object judgment loss, and the global corresponding relationship loss are the same.

[0225] Optionally, the target subject and the target object are medical text entities, and the entity relationship between the target subject and the target object includes at least one of a part, a time, and a property.

[0226] In summary, in the embodiment of this application, during the entity relation extraction process, firstly, based on the word vectors obtained by encoding the target text, high-probability potential entity relations in the target text are determined, and low-probability candidate entity relations are filtered out. Then, based on the determined potential entity relations and word vectors, the target subject and target object are determined from the target text. Finally, entity relation triples containing the target subject, potential entity relations, and target object are extracted from the target text. By adopting the scheme provided in this embodiment of the application, potential entity relations are obtained by screening candidate entity relations before subject and object extraction. This can reduce the false recall results caused by redundant entity relations unrelated to the target text, improve the accuracy of entity relation extraction in the text, and help improve the efficiency of entity relation extraction.

[0227] It should be noted that the apparatus provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the apparatus can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and their implementation process can be found in the method embodiments, which will not be repeated here.

[0228] Please refer to Figure 11 This illustration shows a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Specifically, the computer device 1300 includes a Central Processing Unit (CPU) 1301, a system memory 1304 including a random access memory 1302 and a read-only memory 1303, and a system bus 1305 connecting the system memory 1304 and the CPU 1301. The computer device 1300 also includes a basic input / output system (I / O system) 1306 that facilitates the transfer of information between various devices within the computer, and a mass storage device 1307 for storing the operating system 1313, application programs 1314, and other program modules 1315.

[0229] The basic input / output system 1306 includes a display 1308 for displaying information and an input device 1309 for user input, such as a mouse or keyboard. Both the display 1308 and the input device 1309 are connected to the central processing unit 1301 via an input / output controller 1310 connected to the system bus 1305. The basic input / output system 1306 may also include the input / output controller 1310 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1310 also provides output to a display screen, printer, or other types of output devices.

[0230] The mass storage device 1307 is connected to the central processing unit(s) 1301 through a mass storage controller (not shown) connected to the system bus 1305. The mass storage device 1307 and its associated computer readable media provide nonvolatile storage for computer device 1300. That is, the mass storage device 1307 can include a computer readable medium (not shown) such as a hard drive or drive array, and the system memory 1304 and mass storage device 1307 together comprise computer readable media.

[0231] Without loss of generality, the computer readable media can include computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), flash memory or other solid state memory, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD), or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. It should be understood that computer storage media does not include communication media. The system memory 1304 and mass storage device 1307 described above can be collectively referred to as memory.

[0232] The memory stores one or more programs configured to be executed by the one or more central processing units 1301, the one or more programs containing instructions for implementing the above-described methods, and the central processing unit(s) 1301 executes the one or more programs to implement the methods provided by the various embodiments described above.

[0233] According to various embodiments of the present application, the computer device 1300 can also operate in the capacity of a remote computer through a network such as the Internet. The computer device 1300 can communicate with a remote computer via the network 1312, which is connected to a network interface unit 1311 connected to the system bus 1305. The network interface unit 1311 can also connect to other types of networks or remote computer systems (not shown).

[0234] The memory also includes one or more programs stored therein, which one or more programs contain the steps executed by the computer device in the methods provided by the embodiments of the present application.

[0235] The embodiment of the present application further provides a computer readable storage medium, and the readable storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the entity relationship extraction method in the text according to any of the above embodiments.

[0236] Optionally, the computer readable storage medium can include ROM, RAM, solid state disk (SSD, Solid State Drives) or optical disk, etc. Wherein, the RAM can include resistance random access memory (ReRAM, Resistance Random Access Memory) and dynamic random access memory (DRAM, Dynamic Random Access Memory).

[0237] The embodiment of the present application provides a computer program product or computer program, and the computer program product or computer program includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the entity relationship extraction method in the text according to the above embodiments.

[0238] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructing relevant hardware to complete, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk.

[0239] The above is only optional embodiments of the present application, and does not limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An entity relation extraction method in text, characterized in that, The method comprises: encoding a target text to obtain word vectors corresponding to each word in the target text; determining a text vector corresponding to the target text based on the word vectors corresponding to each word; classifying the text vector through a latent relationship judgment layer to obtain existence probabilities of various candidate entity relationship pairs, the existence probability indicating a probability that the candidate entity relationship exists in the target text; determining a latent entity relationship from the candidate entity relationship based on the existence probability, a probability that the latent entity relationship exists in the target text being higher than probabilities that other candidate entity relationships exist in the target text; determining a target subject and a target object in the target text based on the latent entity relationship and the word vectors corresponding to each word through a relationship-specific sequence labeling layer, the target subject and the target object belonging to entities; combining the target subject and the target object having the same latent entity relationship to obtain at least one subject-object pair; determining a confidence between the target subject and the target object in the subject-object pair in a global corresponding relationship matrix as a confidence of the subject-object pair, the global corresponding relationship matrix being a matrix composed of confidences between different entities, the global corresponding relationship matrix being obtained by joint training of the latent relationship judgment layer and the relationship-specific sequence labeling layer; generating an entity relationship triple based on the target subject, the target object and the latent entity relationship in the subject-object pair if the confidence of the subject-object pair is higher than a confidence threshold.

2. The method of claim 1, wherein, The method comprises: performing average pooling processing on the word vectors corresponding to each word to obtain the text vector corresponding to the target text, the text vector having the same dimension as the word vector.

3. The method according to any one of claims 1 to 2, characterized in that, The method comprises: fusing the word vectors and relationship vectors corresponding to the latent entity relationship to obtain word vectors having the latent entity relationship; performing sequence labeling based on the word vectors having the latent entity relationship to determine the target subject and the target object in the target text.

4. The method of claim 3, wherein, The method comprises: performing subject sequence labeling based on the word vectors having the latent entity relationship to obtain a subject labeling result, the subject labeling result being used to represent a first entity position of the word vectors having the latent entity relationship, the first entity position including a subject beginning, a subject inside or a subject outside; performing object sequence labeling based on the word vectors having the latent entity relationship to obtain an object labeling result, the object labeling result being used to represent a second entity position of the word vectors having the latent entity relationship, the second entity position including an object beginning, an object inside or an object outside; determine the target subject and the target object in the target text based on the subject annotation result and the object annotation result.

5. The method according to any one of claims 1 to 2, characterized in that, The method further includes: filtering the subject-object pair if the confidence of the subject-object pair is lower than the confidence threshold.

6. The method of any one of claims 1 to 2, wherein, The method further includes: encoding a sample text to obtain a sample word vector corresponding to each word in the sample text; determining a sample latent entity relationship corresponding to the sample text based on the sample word vector corresponding to each word; determining a sample subject and a sample object in the sample text based on the sample latent entity relationship and the sample word vector corresponding to each word; determining a latent relationship judgment loss based on the entity relationship label corresponding to the sample text and the sample latent entity relationship; determining a subject-object judgment loss based on the sample subject, the sample object, and a word label corresponding to each word in the sample text; training an entity relationship extraction model based on the latent relationship judgment loss and the subject-object judgment loss, the entity relationship extraction model being configured to output an entity relationship triple based on an input text.

7. The method of claim 6, wherein, After determining the sample subject and the sample object in the sample text, the method further includes: combining the sample subject and the sample object into a sample subject-object pair; determining a sample confidence of the sample subject-object pair; determining a global corresponding relationship loss based on the confidence label corresponding to the sample text and the sample confidence; The training of the entity relationship extraction model based on the latent relationship judgment loss and the subject-object judgment loss includes: training the entity relationship extraction model based on the latent relationship judgment loss, the subject-object judgment loss, and the global corresponding relationship loss.

8. The method of claim 7, wherein, The loss weights corresponding to the latent relationship judgment loss, the subject-object judgment loss, and the global corresponding relationship loss are the same.

9. The method of any one of claims 1 to 2, wherein, The target subject and the target object are medical text entities, and the entity relationship between the target subject and the target object includes at least one of a part, a time, and a property.

10. A device for extracting entity relations from text, characterized in that, The device includes: an encoding module configured to encode a target text to obtain a word vector corresponding to each word in the target text; a relationship determining module configured to determine a text vector corresponding to the target text based on the word vector corresponding to each word; classify the text vector through a latent relationship judgment layer to obtain an existence probability corresponding to each candidate entity relationship, the existence probability indicating a probability that the candidate entity relationship exists in the target text; determine a latent entity relationship from the candidate entity relationships based on the existence probability, the probability that the latent entity relationship exists in the target text being higher than the probability that other candidate entity relationships exist in the target text; a subject-object determining module configured to determine a target subject and a target object in the target text based on the latent entity relationship and the word vector corresponding to each word through a relationship-specific sequence labeling layer, the target subject and the target object being entities; an extraction module configured to combine the target subject and the target object having the same latent entity relationship to obtain at least one subject-object pair. The confidence between the target subject and the target object in the subject-object pair is determined as the confidence of the subject-object pair in a global correspondence matrix, the global correspondence matrix being a matrix composed of confidence between different entities, and the global correspondence matrix is obtained by joint training of the potential relationship judgment layer and the relationship-specific sequence labeling layer; If the confidence of the subject-object pair is higher than a confidence threshold, an entity relationship triple is generated based on the target subject, the target object and the potential entity relationship in the subject-object pair.

11. A computer device, comprising: The computer device comprises a processor and a memory, and the memory stores at least one instruction, which is loaded and executed by the processor to implement the entity relationship extraction method in the text according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The readable storage medium stores at least one instruction, which is loaded and executed by the processor to implement the entity relationship extraction method in the text according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and device for generating information

    CN111241209A

  • Entity relationship extraction method, device and equipment and storage medium thereof

    CN111709240A

  • Text information extraction method, device and equipment

    CN111967242A