A method and device for joint extraction of entity relations

By adding the recognition of non-entity and non-relational data in the entity relationship joint extraction model and using the BERT pre-trained model for pre-processing, the problem that the existing method does not consider the impact of text on entity relationships is solved, the recognition accuracy is improved, and the accurate extraction of complex text data is achieved.

CN112926332BActive Publication Date: 2025-03-11SHANZHEN (SHANGHAI) INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing joint extraction method of entity relationships does not consider the impact of text between entities on entity relationships, and does not fully recognize text semantic information, resulting in poor recognition accuracy and is not suitable for scenarios where entity relationships are complex and numerous.

Method used

A joint extraction method of entity relationships is provided, and the prediction text data is extracted through a pre-established joint extraction model of entity relationships, and the prediction word instance interval and the relationship type of entity phrases are selected. The model includes a preprocessing module and a classification module, which is preprocessed using BERT pretrained models, and predicts types and relationships through embedding layers, classifiers, and transition layers.

Benefits of technology

By increasing the recognition of non-entity and non-relational data, the recognition accuracy of the entity relationship joint extraction model is improved, and the entity phrase relationship types of complex text data can be extracted more accurately, thereby completing the extraction of useful information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112926332B_ABST
    Figure CN112926332B_ABST
Patent Text Reader

Abstract

This paper provides a method and device for entity-relationship joint extraction, wherein the method includes: obtaining text data to be predicted; extracting the text data to be predicted using a pre-established entity-relationship joint extraction model, predicting the type of word interval and the relationship type of entity phrase, the type of word interval includes entity type and non-entity type, the entity word is the word interval of entity type, and the relationship type of entity phrase includes relationship and non-relation; wherein the entity-relationship joint extraction model is used to preprocess the text data; predicting the type of word interval based on the information obtained from the preprocessing; predicting the relationship type of entity phrase based on the entity phrase and the text vectors between entity words in the entity phrase. This paper enriches the text semantic information by considering the text vectors between entity phrases and entity words in the entity phrase, and can accurately extract all entity phrase relationship types of complex text data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to the field of data processing, and in particular to a method and device for joint extraction of entity relationships. Background Art

[0002] With the continuous development of medical information technology, a large amount of unstructured text data in health and medical data such as health examination reports and electronic medical records urgently needs to be extracted and structured for useful information, so that these data can generate greater value in practical applications and production.

[0003] Entity relationship extraction of medical data is the core task of extracting unstructured text information in the medical field and building knowledge graphs in the health and medical field. There are two main methods for entity relationship extraction in the prior art: one is to extract entity relationships in series, that is, first perform named entity recognition to identify relevant medical entities in the text, and then use classification methods to obtain the relationship between two entities; the other method is the entity relationship joint extraction method, which can use a model to simultaneously identify medical entities in the text and determine the relationship category between two entities.

[0004] For the existing serial method of entity relationship extraction, it will cause error transmission and accumulation, and generate redundant information, which often has less than ideal results. For the existing entity relationship joint extraction method, although the existing entity relationship joint extraction method has significantly improved the effect compared with the first serial method, it does not consider the contextual semantic information of the text between the two entities. For text data with complex text structures (such as entity word parallel, entity overlap, relationship overlap, etc.), a large number of entities and relationships (up to hundreds), even with the assistance of some expert experience, the effect of entity relationship extraction is still not ideal. Summary of the invention

[0005] This paper aims to solve the problem that the entity relationship joint extraction method in the existing technology does not consider the impact of the text between entities on the entity relationship, does not fully recognize the text semantic information, has poor recognition accuracy, and is not suitable for scenarios with complex and numerous entity relationships (such as parallel entity words, overlapping entity words, overlapping relationships, etc.).

[0006] In order to solve the above technical problems, the first aspect of this paper provides a method for joint extraction of entity relationships, including:

[0007] Obtaining text data to be predicted;

[0008] The text data to be predicted is extracted using a pre-established entity-relationship joint extraction model to predict the type of the word example interval and the relationship type of the entity phrase, wherein the type of the word example interval includes an entity type and a non-entity type, the entity word is an entity type word example interval, and the relationship type of the entity phrase includes a relationship and a non-relationship;

[0009] Among them, the entity-relationship joint extraction model is used to preprocess text data to obtain word intervals, word interval vectors, word interval length vectors and text vectors; based on the information obtained from the preprocessing, the type of word interval is predicted; based on the entity phrases and the text vectors between the entity words in the entity phrases, the relationship type of the entity phrases is predicted.

[0010] In a further embodiment of this invention, the entity relationship joint extraction method further includes:

[0011] The relationship types of the predicted entity phrases are filtered according to the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs.

[0012] In a further embodiment of the present invention, the entity relationship joint extraction model includes: a preprocessing module and a classification module, wherein the classification module includes an embedding layer, a first classifier, a transition layer and a second classifier;

[0013] The preprocessing module is used to preprocess the text data to obtain a word example interval, a word example interval vector, a word example interval length vector and a text vector;

[0014] The embedding layer is connected to the preprocessing module and is used to construct a first vector according to the information obtained by the preprocessing;

[0015] The first classifier is connected to the embedding layer, and predicts the type of the word example interval according to the first vector;

[0016] The transition layer connects the first classifier and the second classifier to filter out the word example interval of the entity type to obtain the entity word; the entity phrase consisting of every two entity words and the text vectors between the entity words in the entity phrase are concatenated into a second vector;

[0017] The second classifier is used to predict the relationship type of the entity phrase according to the second vector.

[0018] In a further embodiment of the present invention, the preprocessing module processes the text data to obtain a word example interval, a word example interval vector, a word example interval length vector and a text vector, including:

[0019] Perform word / character segmentation on the text data to obtain a word example list;

[0020] The word list is processed using the BERT pre-trained model to obtain a text vector and a word vector corresponding to each word;

[0021] According to the example word list and the preset sliding window, obtaining the example word interval;

[0022] The word example vectors contained in the word example interval are subjected to a fusion function to obtain a word example interval vector;

[0023] According to the length of the word example interval, obtain the word example interval length vector.

[0024] In a further embodiment of the present invention, constructing a first vector according to the information obtained by the preprocessing includes:

[0025] The first vector is concatenated by the word example interval vector, or the word example interval vector and the text vector, or the word example interval vector and the word example interval length vector, or the word example interval vector, the word example interval length vector and the text vector.

[0026] In a further embodiment of the present invention, the first classifier includes: a first classification function unit and a first judgment unit, the first classification function unit is used to output a probability vector of a word example interval type, and the first judgment unit is used to determine the type of the word example interval according to the probability vector of the word example interval type;

[0027] The second classifier includes: a second classification function unit and a second judgment unit; the second classification function unit is used to output a probability vector of the relationship type of the entity phrase, and the second judgment unit is used to determine the relationship type of the entity phrase based on the probability vector of the relationship type of the entity phrase.

[0028] In a further embodiment of the present invention, the entity relationship joint extraction model is trained in the following manner:

[0029] Preprocessing the training text data using the preprocessing module to obtain word example intervals, word example interval vectors, word example interval length vectors and text vectors;

[0030] Obtain the entity type of the labeled word example interval and the association relationship between the entity phrases;

[0031] Constructing a first vector according to the information obtained by preprocessing;

[0032] Inputting the first vector into the first classifier to predict the type of the word example interval;

[0033] Filter out the word example interval of the entity type to obtain the entity words, and concatenate the entity phrases composed of every two entity words and the vectors composed of the text between the entity phrases into a second vector;

[0034] Inputting the second vector into the second classifier to predict the relationship type of the entity phrase;

[0035] The parameters in the entity-relationship joint extraction model are trained according to the predicted entity types of the word example interval and the relationship types of the entity phrases, and the labeled entity types of the word example interval and the relationship types of the entity phrases.

[0036] In a further embodiment of the present invention, before constructing the first vector according to the information obtained by preprocessing, the method further includes:

[0037] Compare the word interval with the pre-annotated entity words. If a word interval is the same as one of the pre-annotated entity words, then the word interval is a positive entity sample, otherwise it is a negative entity sample.

[0038] According to the first preset value, entity negative samples are sampled.

[0039] In a further embodiment of the present invention, before determining the second vector, the method further includes:

[0040] Determine whether each entity phrase conforms to the pre-annotated entity relationship; if an entity phrase conforms to the pre-annotated entity relationship, then the entity phrase is a positive example of the relationship, otherwise it is a negative example of the relationship;

[0041] According to the second preset value, the relationship negative sample is sampled.

[0042] The second aspect of the present invention also provides an entity relationship joint extraction device, comprising:

[0043] A receiving module, used for obtaining text data to be predicted;

[0044] An extraction module is used to extract the text data to be predicted by using a pre-established entity-relationship joint extraction model, and predict the type of the word example interval and the relationship type of the entity phrase, wherein the type of the word example interval includes an entity type and a non-entity type, the entity word is an entity type word example interval, and the relationship type of the entity phrase includes a relationship and a non-relationship;

[0045] Among them, the entity-relationship joint extraction model is used to preprocess text data to obtain word intervals, word interval vectors, word interval length vectors and text vectors; based on the information obtained from the preprocessing, the type of word interval is predicted; based on the entity phrases and the text vectors between the entity words in the entity phrases, the relationship type of the entity phrases is predicted.

[0046] The entity-relationship joint extraction method and device provided in this paper, by increasing the recognition of non-entity and non-relation data, enables the entity-relationship joint extraction model to extract non-entity type and non-relation type data, which can improve the accuracy of recognition of different data types. When identifying the entity-phrase relationship type, by considering the text vectors between entity words and entity words, the text semantic information is enriched, and all entity-phrase relationship types of complex text data can be accurately extracted, and then structured according to the obtained entity words and entity phrase relationship types to complete the extraction of useful information.

[0047] In order to make the above and other purposes, features and advantages of this article more obvious and easy to understand, the following specifically cites preferred embodiments and describes them in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of this article or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of this article. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 A schematic diagram of the structure of the entity relationship joint extraction model in the embodiment of this article is shown;

[0050] Figure 2 A first flow chart showing the entity relationship joint extraction model training process of the embodiment of this article is shown;

[0051] Figure 3 A second flow chart showing the entity relationship joint extraction model training process of the embodiment of this article;

[0052] Figure 4 A third flow chart of the entity relationship joint extraction model training process of the embodiment of this article is shown;

[0053] Figure 5 A first flow chart of the entity relationship joint extraction method according to the embodiment of this invention is shown;

[0054] Figure 6 A second flow chart of the entity relationship joint extraction method according to the embodiment of this invention is shown;

[0055] Figure 7 A first structural diagram of the entity relationship joint extraction device according to the embodiment of this invention is shown;

[0056] Figure 8 A second structural diagram of the entity relationship joint extraction device according to the embodiment of this invention is shown;

[0057] Fig. 9A structural diagram of a computer device according to an embodiment of the present invention is shown;

[0058] Fig.10 A schematic diagram of word example interval labeling results of a specific embodiment of this article is shown.

[0059] Description of the accompanying symbols:

[0060] 110. Preprocessing module;

[0061] 120. Classification module;

[0062] 121. Embedding layer;

[0063] 122. First classifier;

[0064] 123. Transition layer;

[0065] 124. Second classifier;

[0066] 710, receiving module;

[0067] 720, extraction module;

[0068] 730, filtering module;

[0069] 902. Computer equipment;

[0070] 904, processor;

[0071] 906. Memory;

[0072] 908, driving mechanism;

[0073] 910, input / output module;

[0074] 912. Input device;

[0075] 914. Output device;

[0076] 916. Presentation equipment;

[0077] 918. Graphical user interface;

[0078] 920, network interface;

[0079] 922, communication link;

[0080] 924. Communication bus. DETAILED DESCRIPTION

[0081] The following will be combined with the drawings in the embodiments of this article to clearly and completely describe the technical solutions in the embodiments of this article. Obviously, the described embodiments are only part of the embodiments of this article, not all of the embodiments. Based on the embodiments of this article, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this article.

[0082] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel.

[0083] The entity relationship joint extraction method proposed in this paper is suitable for the recognition of health and medical text data (including but not limited to health examination reports, electronic medical records, etc.), and can also be applied to the recognition of text data in other professional fields (such as legal documents, etc.). This paper does not make specific restrictions on the referenced fields.

[0084] The entity words mentioned in this article refer to words or phrases with descriptive meanings, which can usually be names of people, places, organizations, products, or content with a certain meaning in a certain field, such as diseases, drugs, names of organisms in the medical field, or specialized terms involved in law.

[0085] The entity word relationship described in this article refers to the mutual connection between different entities. Entities are not independent of each other, and there are often certain connections between them.

[0086] Although the entity relationship joint extraction method in the prior art can identify the relationship types of entity words and entity phrases to a certain extent, the existing entity relationship joint extraction method cannot realize the recognition of non-entity words and non-relationship type entity phrases, and does not consider the impact of the text between entities on the entity relationship, does not fully recognize the text semantic information, has poor recognition accuracy, and is not suitable for scenarios with complex and numerous entity relationships (such as parallel entity words, overlapping entity words, overlapping relationships, etc.).

[0087] In order to solve the above technical problems, this paper pre-establishes a new entity-relation joint extraction model, which is used to pre-process text data to obtain word intervals, word interval vectors, word interval length vectors and text vectors; based on the information obtained from the pre-processing, the type of word intervals is predicted; based on the text vectors between entity phrases and entity words in entity phrases, the relationship type of entity phrases is predicted. Among them, the types of word intervals include entity types and non-entity types, entity words are word intervals of entity types, word intervals of non-entity types are non-entity words, and the relationship types of entity phrases include relationship types and non-relationship types.

[0088] Specifically, Figure 1 As shown, the entity relationship joint extraction model includes: a preprocessing module 110 and a classification module 120, wherein the classification module 120 includes: an embedding layer 121, a first classifier 122, a transition layer 123 and a second classifier 124.

[0089] The preprocessing module 110 is used to preprocess the text data to obtain a word example interval, a word example interval vector, a word example interval length vector and a text vector;

[0090] The embedding layer 121 is connected to the preprocessing module and is used to construct a first vector according to the information obtained by the preprocessing;

[0091] The first classifier 122 is connected to the embedding layer 121, and predicts the type of the word example interval according to the first vector;

[0092] The transition layer 123 is connected to the first classifier 122 and the second classifier 124, and is used to filter out the word example interval of the entity type to obtain the entity word; concatenate the entity phrase composed of every two entity words and the text vectors between the entity words in the entity phrase into a second vector;

[0093] The second classifier 124 is used to predict the relationship type of the entity phrase according to the second vector, wherein the relationship type of the entity phrase includes relationship and non-relationship.

[0094] The entity relationship extraction model provided in this paper includes the learning of non-entity and non-relation categories, which can improve the recognition accuracy. In addition, when the entity relationship extraction model recognizes the entity-phrase relationship type, by considering the text vectors between entity words, the text semantic information is enriched, making the semantic information expression richer, and all entity-phrase relationship types of complex text data can be accurately extracted.

[0095] Specifically, the token interval described in this article is determined as follows: perform word / syllable segmentation on the text data to obtain a list of tokens; obtain the token interval according to the list of tokens and a preset sliding window. Among them, the list of tokens refers to the list of words (syllables) corresponding to the text data. For example, for the text data "The size of the liver is normal", the corresponding list of tokens is "The size of the liver is normal". The token interval includes positive entity examples (tokens that conform to the pre-annotated entity words, that is, the token intervals of entity types) and negative entity examples (words other than the pre-annotated entity words, that is, the token intervals of non-entity types), which can comprehensively divide the words in the list of tokens. The preset sliding window can be determined according to the maximum number of characters of the entity words in this article, and the specific value is not limited in this article. Assume that the size of the preset sliding window is 3, then the token intervals corresponding to the list of tokens "The size of the liver is normal" include: "The", "The size", "The size of", "size", "size of", "size of the", "of", "of the", "of the liver", "the", "the liver", "the liver is", "liver", "liver is", "liver is normal", "is", "is normal", "normal", "normal".

[0096] The token interval vector described in this article is a vector composed of all the word / syllable segments included in the token interval. For example, for the token interval "The size of", in terms of word segmentation, the corresponding token vector is the token vector corresponding to the tokens {"The size", "of"}, and in terms of syllable segmentation, the corresponding token vector is the token vector corresponding to {"The", "size", "of"}. In specific implementation, the token vectors included in the token interval are processed by a fusion function (such as the max pooling method) to obtain the token interval vector. The token interval length vector described in this article is mainly used to represent the text length information corresponding to the token interval. In specific implementation, according to the length information of the token interval, the token interval length vector can be obtained, which can be a vector randomly initialized with a parameter and having a fixed length, and the parameters in the vector can be learned through model training.

[0097] The text vector described in this article is the vector representation corresponding to the text data, which can be obtained by using pre-trained models such as BERT (Bidirectional Encoder Representations from Transformers) to process the list of tokens. Such pre-trained models include but are not limited to BERT. The implementation process of pre-trained models such as BERT can refer to the prior art and will not be elaborated in this article.

[0098] The entity phrase group described in this article refers to the phrase formed by any two entity words among all entity words. In specific implementation, the second vector is composed in the order of the first entity word, the text vector between the first entity word and the second entity word, and the second entity word.

[0099] The number of first vectors constructed by the embedding layer 121 is the same as the number of word example intervals. For example, if there are 100 word example intervals, there will be 100 corresponding first vectors.

[0100] If the processing capability of the first classifier 122 is relatively large, the first vector constructed by the embedding layer 121 may be input into the first classifier 122 at one time; if the processing capability of the first classifier 122 is relatively small, the first vector constructed by the embedding layer 121 may be input into the first classifier 122 in batches.

[0101] The second vector constructed by the transition layer 123 and the entity phrase number vector are specifically: (n-1), where n is the number of entity words.

[0102] If the processing capability of the second classifier 124 is relatively large, the second vector constructed by the transition layer 123 may be input into the second classifier 124 at once; if the processing capability of the second classifier 124 is relatively small, the second vector constructed by the transition layer 123 may be input into the second classifier 124 in batches.

[0103] In specific implementation, for different application scenarios, an entity relationship joint extraction model can be pre-established based on the training text data in the corresponding application scenario, and then the established entity relationship joint extraction model can be used to perform entity relationship prediction.

[0104] In one embodiment of this invention, according to the information obtained by preprocessing, the first vector can be constructed by one of the following methods:

[0105] (1) concatenating the word-example interval vectors into a first vector;

[0106] (2) concatenating the word-example interval vector and the text vector into a first vector;

[0107] (3) splicing a first vector from a word example interval vector and a word example interval length vector, wherein the word example interval length vector is output by the preprocessing module, and the word example interval length vector is used to limit the length of the entity word, for example, 8 characters, 10 characters, etc., and can be a vector with a random parameter initialization and a fixed length, and each parameter in the vector can be learned through model training;

[0108] (4) The first vector is concatenated by the word example interval vector, the word example interval length vector and the text vector.

[0109] Preferably, in order to enrich the text semantic information and improve the recognition accuracy of the word interval type, the first vector is determined by the method (4).

[0110] In one embodiment of this invention, the entity phrases composed of every two entity words and the text vectors between the entity words in the entity phrases are concatenated into a second vector, which is further:

[0111] It is formed by the concatenation of the first entity word vector (i.e., the instance interval vector) and the first entity word length vector (i.e., the instance interval length vector) in the entity phrase, the text vector composed of the text between the two entity words, the second entity word vector (i.e., the instance interval vector) and the second entity word length vector (i.e., the instance interval length vector) in the two entity words.

[0112] In a specific implementation, if the context between the first entity word and the second entity word is empty, the text vector between the first entity word and the second entity word is represented by a zero vector.

[0113] During specific implementation, in order to further enrich the text semantic information, a text vector may be added to the second vector.

[0114] In one embodiment of the present invention, in order to realize the recognition of entity type and non-entity type in the word example interval, the first classifier 122 includes: a first classification function unit and a first judgment unit. The first classification function unit is used to output the probability vector of the word example interval type, and a softmax function can be used. The word example interval type includes entity type and non-entity type. For example, the entity type includes 5 types, plus 1 non-entity type. The softmax function unit outputs a probability vector containing 6 elements, for example, {entity type 1 probability, entity type 2 probability, entity type 3 probability, entity type 4 probability, entity type 5 probability, non-entity type probability}, and the sum of all probabilities in the probability vector is 1.

[0115] The first judgment unit is used to determine the word instance interval type according to the probability vector of the word instance interval type. In specific implementation, the corresponding word instance interval type can be obtained according to the maximum probability value in the probability vector output by the softmax function unit. For example, the probability vector output by the softmax function unit is {entity type 1 probability 0.5, entity type 2 probability 0.25, entity type 3 probability 0.1, entity type 4 probability 0.1, entity type 5 probability 0.05, non-entity type probability 0}, then the word instance interval type determined by the first judgment unit is entity type 1.

[0116] In one embodiment of the present invention, in order to realize the recognition of the relationship type between entity words, the second classifier includes a second classification function unit and a second judgment unit. The second classification function unit is used to output the probability vector of the relationship type of the entity phrase. In order to solve the problem that there may be multiple relationships between two identical entity words, for example, in "Jay Chou composed and sang "Seven-Li Fragrance", there are 2 kinds of relationships: (Seven-Li Fragrance, singer, Jay Chou) and (Seven-Li Fragrance, composer, Jay Chou), for example, a sigmoid function can be used. The relationship type of the entity phrase includes a relationship type and a non-relationship type. The probability of the relationship type is relatively independent from the probability of the non-relationship type, and the sum is not 1. The second judgment unit is used to determine the relationship type of the entity phrase based on the probability vector of the relationship type of the entity phrase. In specific implementation, the relationship type of the entity phrase can be determined according to a pre-set probability upper limit.

[0117] In one embodiment of this invention, Figure 2 As shown, Figure 1 The entity-relation joint extraction model shown is trained as follows:

[0118] Step 210, preprocessing the training text data using a preprocessing module to obtain a word example interval, a word example interval vector, a word example interval length vector and a text vector;

[0119] Step 220, obtaining the entity type of the labeled word example interval and the association relationship between the entity phrases;

[0120] Step 230, constructing a first vector according to the information obtained by preprocessing;

[0121] Step 240, inputting the first vector into the first classifier to predict the type of the word example interval;

[0122] Step 250, filtering out the word example interval of the entity type to obtain the entity word;

[0123] Step 260, concatenating the entity phrases consisting of every two entity words and the text vectors between the entity words in the entity phrases into a second vector;

[0124] Step 270, inputting the second vector into the second classifier to predict the relationship type of the entity phrase;

[0125] Step 280: train the parameters of the entity-relationship joint extraction model based on the predicted entity type of the token interval and the relationship type of the entity phrase, and the labeled entity type of the token interval and the relationship type of the entity phrase. Substitute the model parameters finally obtained back into the preprocessing module and classification module of the entity-relationship joint extraction model, and combine the preprocessing module and the classification module to form the entity-relationship joint extraction model.

[0126] In detail, the training text data described in this article is historically generated data. Taking the analysis of health and medical text data as an example, the training text data is historically generated health and medical text data. The health and medical text data can be obtained from hospitals, physical examination institutions or patients. The method of obtaining training text data in this article is not limited. In specific implementation, the training text can be pre-processed into a training set, a validation set and a test set according to a certain ratio. The training set is used to train the entity relationship joint extraction model, the validation set is used to evaluate and adjust the parameters in the entity relationship joint extraction model, and the test set is used to test the generalization ability of the entity relationship joint extraction model.

[0127] The execution process of the above step 210 includes: performing word / character segmentation on the training text data to obtain a word list; using the BERT pre-trained model to process the word list to obtain a text vector and a word vector corresponding to each word; obtaining the word interval according to the word list and the preset sliding window; and obtaining the word vector contained in the word interval by a fusion function to obtain the word interval vector.

[0128] The entity types of the word example intervals annotated in the above step 220 and the association relationship between entity phrases can be achieved manually. During the specific implementation, the annotator can annotate according to the word example intervals generated in step 210, or directly analyze and annotate the training text data.

[0129] In the above step 230, the first vector may be constructed in one of the following ways: concatenating the word example interval vectors into the first vector, concatenating the word example interval vectors and the text vector into the first vector, concatenating the word example interval vectors and the word example interval length vectors into the first vector, or concatenating the word example interval vectors, the word example interval length vectors and the text vector into the first vector. The word example interval vectors and the word example interval length vectors contain parameters to be adjusted during the training phase, and are not fixed values.

[0130] The parameters in the first classifier used in the above step 240 are parameters to be adjusted during the training phase, and are not fixed values.

[0131] When the above step 260 is specifically implemented, the text vector and the word example interval length vector corresponding to each entity word in the entity phrase are also added to the second vector.

[0132] The parameters in the second classifier used in the above step 270 are parameters to be adjusted during the training phase.

[0133] The implementation process of step 280 includes: establishing a loss function L according to the predicted entity type of the word example interval and the relationship type of the entity phrase, and the labeled entity type of the word example interval and the relationship type of the entity phrase. The loss function L includes two parts, a first classifier loss L1 (cross entropy is used here) and a second classifier loss L2 (binarized cross entropy is used here). When the loss function is smaller, the accuracy of the model is higher, and the model can better extract the entity relationship combination in the text, which is defined as follows:

[0134]

[0135] Among them, y1 is the entity type of the labeled token interval, is the entity type of the predicted word interval, y2 is the relationship type of the annotated entity phrase, is the relationship type of the predicted entity phrase, and λ is a parameter.

[0136] In the specific implementation, the loss function is used to determine whether the predicted entity types of the word example interval and the relationship types of the entity phrases are infinitely close to the marked entity types of the word example interval and the relationship types of the entity phrases. If the judgment result is no, the parameters of the preprocessing module, the first classifier and the second classifier are adjusted by the step size. In the specific implementation, different parameter adjustment step sizes can be set for the preprocessing module, the first classifier and the second classifier.

[0137] In one embodiment of this invention, Figure 3 As shown, before constructing the first vector according to the information obtained by preprocessing, the above step 230 further includes:

[0138] Step 221, compare the word example interval with the pre-marked entity words. If a word example interval is the same as one of the pre-marked entity words, then the word example interval is an entity positive sample, otherwise it is an entity negative sample.

[0139] For example, the training text data is "liver size is normal", the pre-annotated entity words are "liver", "size" and "normal", and when the sliding window size is 3, the example interval is "liver", "liver", "big liver", "dirty", "dirty big", "dirty size", "big", "size", "size positive", "small", "small positive", "small normal", "positive", "normal", and "normal". By comparing the example interval with the pre-annotated entity words, it can be determined that the positive entity examples include "liver", "size" and "normal", and the negative entity examples include "liver", "big liver", "dirty", "dirty big", "dirty size", "big", "size positive", "small", "small positive", "small normal", "positive", and "normal".

[0140] Step 222, sampling entity negative samples according to the first preset value. After completing the entity negative sample sampling, continue to perform the subsequent step 230. Among them, the first preset value can be determined according to the computing power of the computing device, and this document does not make a specific limitation on this.

[0141] As can be seen from the example in the previous step, there are many entity negative samples. Therefore, in order to reduce the calculation amount of the model, step 222 is added. By randomly sampling the entity negative samples, entity negative samples that do not exceed the first preset value can be obtained. The entity types corresponding to these entity negative samples are non-entity types.

[0142] It should be noted here that the sampling process of entity negative samples only exists in the model training process. In the model prediction process, all word example intervals need to be retained to determine all possible entity words.

[0143] This embodiment takes into account the large number of entity negative samples, and by randomly sampling the entity negative samples, the calculation rate of the entity relationship extraction model can be improved.

[0144] In further embodiments herein, Figure 4 As shown, before the above step 260 determines the second vector, it also includes:

[0145] Step 251, determine whether each entity phrase conforms to a pre-labeled entity relationship; if an entity phrase conforms to a pre-labeled entity relationship, the entity phrase is a positive relationship example, otherwise it is a negative relationship example.

[0146] For example, the training text data is "Liver size is normal", and the pre-annotated entity words are "liver" (type is part), "size" (type is attribute) and "normal" (type is non-numerical result). The relationship types of the pre-annotated entity phrases are (size, modification, liver), (normal, modification, size), and the entity phrases include (size, liver), (normal, size), (liver, size), (liver, normal), (size, normal), (normal, liver). The analyzed positive relationship examples include (size, modification, liver), (normal, modification, size). The negative relationship examples include (liver, non-relationship, size), (liver, non-relationship, normal), (size, non-relationship, normal), (normal, non-relationship, liver)).

[0147] Step 252: sampling the relationship negative samples according to the second preset value.

[0148] Among them, the second preset value can be the same as the first preset value or different. During specific implementation, it can be determined according to the computing power of the computing device, and this document does not make specific limitations on this.

[0149] This embodiment obtains relationship negative samples that do not exceed a second preset value by randomly sampling relationship negative samples. The relationship types corresponding to these relationship negative samples are defined as "non-relationship" types, which can reduce the computational complexity of the entity relationship joint extraction model.

[0150] It should be noted here that the sampling process of negative relationship samples only exists in the model training process. In the model prediction process, all entity phrases need to be retained to determine all entity phrases that may have relationships.

[0151] After the entity relationship joint extraction model is established through the above-mentioned embodiment, it can be used for entity relationship recognition. Specifically, Figure 5 As shown in Figure 2, the entity relationship joint extraction method includes:

[0152] Step 510, obtaining text data to be predicted;

[0153] Step 520, extract the text data to be predicted using a pre-established entity-relationship joint extraction model, and predict the type of the word example interval and the relationship type of the entity phrase. The type of the word example interval includes entity type and non-entity type, the entity word is the word example interval of entity type, and the relationship type of the entity phrase includes relationship and non-relationship.

[0154] Among them, the entity-relationship joint extraction model is used to preprocess text data to obtain word example intervals, word example interval vectors, word example interval length vectors and text vectors; based on the information obtained from the preprocessing, the type of word example interval is predicted; based on the entity phrases and the text vectors between the entity words in the entity phrases, the relationship type of the entity phrases is predicted.

[0155] Specifically, the text data to be predicted is the text data generated by the entity-relationship joint extraction model in the applicable field. The structure and training process of the entity-relationship joint extraction model refer to the above-mentioned embodiment and will not be described in detail here. The type of word example interval and the relationship type of entity phrase can be output in the form of a list.

[0156] For example, the text data to be predicted is: the liver has normal shape and size, the echo distribution of the parenchyma is uniform, the vascular texture is clear, the right lobe of the liver is anechoic, the size is about 24×18mm, and the boundary is clear. Fig.10 As shown, the marked entity words include: liver, morphology, size, normal, substance, echo, distribution, uniform, blood vessel, texture, clear, liver, right lobe, see, no echo, size, 24×18mm, boundary, clear. Different line boxes in the figure correspond to entity words of different entity types, and there are relationships between the connected entity words.

[0157] The prediction results of the entity-relationship joint extraction model provided in this article are shown in the following output results, where entities represents entity words, end represents the end position of the entity word in the text, id represents the number of the entity word, start represents the starting position of the entity word in the text, type represents the entity word type and the relationship type of the entity phrase, and word represents the entity word text. Relations represents the relationship type between entity words, and head and tail represent the id numbers corresponding to the first entity word and the second entity word in the entity phrase.

[0158] As can be seen from the following output results, the prediction results of the entity-relationship joint extraction model are the same as the manual annotation results. This shows that this paper can accurately predict the type of word example intervals and the relationship type of entity phrases.

[0159]

[0160]

[0161]

[0162]

[0163]

[0164]

[0165] This embodiment increases the recognition of non-entity and non-relational data, so that the entity-relationship joint extraction model extracts non-entity and non-relational data, which can improve the accuracy of recognition of different data types. When identifying entity-phrase relationship types, by considering entity words and text vectors between entity words, the text semantic information is enriched, and all entity-phrase relationship types of complex text data can be accurately extracted, and then structured according to the obtained entity words and entity phrase relationship types to complete the extraction of useful information.

[0166] In further embodiments herein, Figure 6 As shown, the entity relationship joint extraction method includes, in addition to the above steps 510 and 520, further comprising:

[0167] Step 530 , filtering the relationship types of the predicted entity phrases according to the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs.

[0168] In detail, the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs is reviewed by professionals in the field, for example, an entity of attribute type cannot modify an entity of numerical type, etc. This article does not make specific restrictions on this.

[0169] This embodiment combines the recognition results of the entity relationship joint extraction model with the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs. The allowed relationship constraint dictionary of the field to which the text data to be predicted belongs can filter out entity phrases that do not comply with the allowed relationship constraints, thereby further improving the entity relationship extraction effect.

[0170] Based on the same inventive concept, this article also provides an entity relationship joint extraction device, as described in the following embodiments. Since the principle of solving the problem by the entity relationship joint extraction device is similar to that of the entity relationship joint extraction method, the implementation of the entity relationship joint extraction device can refer to the entity relationship joint extraction method, and the repeated parts will not be repeated.

[0171] The entity relationship joint extraction device provided in this embodiment includes multiple functional modules, all of which can be implemented by dedicated or general-purpose chips, and can also be implemented through software programs, which is not limited in this document.

[0172] Specifically, Figure 7 As shown, the entity relationship joint extraction device includes:

[0173] A receiving module 710 is used to obtain text data to be predicted;

[0174] An extraction module 720 is used to extract the text data to be predicted by using a pre-established entity-relationship joint extraction model, and predict the type of the word example interval and the relationship type of the entity phrase, wherein the type of the word example interval includes an entity type and a non-entity type, the entity word is an entity type word example interval, and the relationship type of the entity phrase includes a relationship and a non-relationship;

[0175] Among them, the entity-relationship joint extraction model is used to preprocess text data to obtain word example intervals, word example interval vectors, word example interval length vectors and text vectors; based on the information obtained from the preprocessing, the type of word example interval is predicted; based on the entity phrases and the text vectors between the entity words in the entity phrases, the relationship type of the entity phrases is predicted.

[0176] Further, such as Figure 8 As shown, the entity relationship joint extraction device also includes:

[0177] The filtering module 730 is used to filter the relationship types of the predicted entity phrases according to the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs.

[0178] Compared with the existing technology, the entity relationship joint extraction method and device provided in this article, by learning multiple training text data, jointly classifies entities and the relationships between entities, adds learning of "non-entity" and "non-relationship" categories in entity classification and relationship classification, and performs random sampling of non-entity samples and relationship negative samples in the text, taking into account both computational efficiency and model effect, and can better solve the problem of entity relationship extraction in texts with a large number of entities and relationships.

[0179] In the calculation of the first vector and the second vector, the text vector and the context vector between entity words are respectively added to enrich the text semantic information, which can well handle the entity relationship extraction under complex text structure (such as: parallel entity words, entity overlap, relationship overlap, etc.).

[0180] Finally, the allowed relationship constraint dictionary based on the domain to which it belongs is added after model prediction to filter out entity relationship combinations that do not conform to the allowed relationship constraints, which can further improve the entity relationship extraction effect.

[0181] In one embodiment of the present invention, the entity relationship joint extraction model training process and the entity relationship prediction process can be implemented by a computer device. Specifically, Fig. 9 As shown, the computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. The computer device 902 may also include any memory 906, which is used to store any kind of information such as code, settings, data, etc. In some embodiments, a computer program is stored in the memory 906. When the computer program is executed by the processor 904 of the computer device, the entity relationship joint extraction method or the entity relationship joint extraction model training method described in the above embodiment is executed. Non-limitingly, for example, the memory 906 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 902. In one case, when the processor 904 executes an associated instruction stored in any memory or a combination of memories, the computer device 902 may perform any operation of the associated instruction. The computer device 902 also includes one or more drive mechanisms 908 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0182] The computer device 902 may also include an input / output module 910 (I / O) for receiving various inputs (via input devices 912) and for providing various outputs (via output devices 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface 918 (GUI). In other embodiments, the input / output module 910 (I / O), the input device 912, and the output device 914 may not be included, and the computer device 902 may be used as a computer device in a network. The computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.

[0183] The communication link 922 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 922 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.

[0184] Corresponds to Figure 2-Figure 6 The method in this article also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.

[0185] The embodiment of the present invention also provides a computer readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 2 to 6 The method shown.

[0186] It should be understood that in the various embodiments of this document, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this document.

[0187] It should also be understood that in the embodiments of this article, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0188] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this article.

[0189] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0190] In the several embodiments provided herein, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or can be electrical, mechanical or other forms of connection.

[0191] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this article.

[0192] In addition, each functional unit in each embodiment of this invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional unit.

[0193] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this article is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this article. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0194] Specific embodiments are used in this article to illustrate the principles and implementation methods of this article. The description of the above embodiments is only used to help understand the methods and core ideas of this article. At the same time, for general technicians in this field, according to the ideas of this article, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on this article.

Claims

1. A method for joint extraction of entity relations, characterized in that: include: Obtaining text data to be predicted; The text data to be predicted is extracted using a pre-established entity-relationship joint extraction model, and the types of word example intervals and the relationship types of entity phrases are predicted, wherein the types of word example intervals include entity types and non-entity types, and entity words are word example intervals of entity types, and the entity words are words or phrases with descriptive meanings, or content with specified meanings in a specified field, and the relationship types of entity phrases include relationships and non-relationships; The entity-relationship joint extraction model is used to pre-process text data, including: performing word / character segmentation on the text data to obtain a word list; using the BERT pre-trained model to process the word list to obtain a text vector and a word vector corresponding to each word; obtaining a word interval according to the word list and a preset sliding window; obtaining a word interval vector by subjecting the word vector contained in the word interval to a fusion function; obtaining a word interval length vector according to the length of the word interval; predicting the type of the word interval according to the information obtained from the pre-processing; predicting the relationship type of the entity phrase according to the entity phrase and the text vectors between the entity words in the entity phrase; The entity relationship joint extraction model includes a preprocessing module and a classification module, wherein the classification module includes an embedding layer, a first classifier, a transition layer and a second classifier; The preprocessing module is used to preprocess the text data, including: performing word / character segmentation on the text data to obtain a word list; using the BERT pre-trained model to process the word list to obtain a text vector and a word vector corresponding to each word; obtaining a word interval according to the word list and a preset sliding window; obtaining a word interval vector by applying a fusion function to the word vectors contained in the word interval; and obtaining a word interval length vector according to the length of the word interval. The embedding layer is connected to the preprocessing module, and is used for concatenating the word example interval vector, or the word example interval vector and the text vector, or the word example interval vector and the word example interval length vector, or the word example interval vector, the word example interval length vector and the text vector into a first vector; The first classifier is connected to the embedding layer, and predicts the type of the word example interval according to the first vector; The transition layer connects the first classifier and the second classifier to filter out the word example interval of the entity type to obtain the entity word; the entity phrase consisting of every two entity words and the text vectors between the entity words in the entity phrase are concatenated into a second vector; The second classifier is used to predict the relationship type of the entity phrase according to the second vector.

2. The entity relationship joint extraction method according to claim 1, characterized in that: Also includes: The relationship types of the predicted entity phrases are filtered according to the allowed relationship constraint dictionary of the field to which the text data to be predicted belongs.

3. The entity relationship joint extraction method according to claim 1, characterized in that: The first classifier includes: a first classification function unit and a first judgment unit, the first classification function unit is used to output a probability vector of a word example interval type, and the first judgment unit is used to determine the type of the word example interval according to the probability vector of the word example interval type; The second classifier includes: a second classification function unit and a second judgment unit; the second classification function unit is used to output a probability vector of the relationship type of the entity phrase, and the second judgment unit is used to determine the relationship type of the entity phrase based on the probability vector of the relationship type of the entity phrase.

4. The entity relationship joint extraction method according to claim 1, characterized in that: The entity relationship joint extraction model is trained in the following way: Preprocessing the training text data using the preprocessing module to obtain word example intervals, word example interval vectors, word example interval length vectors and text vectors; Obtain the entity type of the labeled word example interval and the association relationship between the entity phrases; Constructing a first vector according to the information obtained by preprocessing; Inputting the first vector into the first classifier to predict the type of the word example interval; Filter out the word example interval of the entity type to obtain the entity words, and concatenate the entity phrases consisting of every two entity words and the text vectors between the entity words in the entity phrases into a second vector; Inputting the second vector into the second classifier to predict the relationship type of the entity phrase; The parameters in the entity-relationship joint extraction model are trained according to the predicted entity types of the word example interval and the relationship types of the entity phrases, and the labeled entity types of the word example interval and the relationship types of the entity phrases.

5. The entity relationship joint extraction method according to claim 4, characterized in that: According to the information obtained by preprocessing, before constructing the first vector, it also includes: Compare the word interval with the pre-annotated entity words. If a word interval is the same as one of the pre-annotated entity words, then the word interval is a positive entity sample, otherwise it is a negative entity sample. The entity negative samples are randomly sampled to obtain entity negative samples that do not exceed a first preset value.

6. The entity relationship joint extraction method according to claim 4, characterized in that: Before determining the second vector, it also includes: Determine whether each entity phrase conforms to the pre-annotated entity relationship; if an entity phrase conforms to the pre-annotated entity relationship, then the entity phrase is a positive example of the relationship, otherwise it is a negative example of the relationship; Randomly sample the relationship negative samples to obtain relationship negative samples that do not exceed a second preset value.

7. An entity relationship joint extraction device, characterized in that: include: A receiving module, used for obtaining text data to be predicted; An extraction module is used to extract the text data to be predicted by using a pre-established entity-relationship joint extraction model, and predict the type of the word example interval and the relationship type of the entity phrase, wherein the type of the word example interval includes an entity type and a non-entity type, the entity word is a word example interval of the entity type, and the entity word is a word or phrase with a descriptive meaning, or content with a specified meaning in a specified field, and the relationship type of the entity phrase includes a relationship and a non-relationship; The entity-relationship joint extraction model is used to pre-process text data, including: performing word / character segmentation on the text data to obtain a word list; using the BERT pre-trained model to process the word list to obtain a text vector and a word vector corresponding to each word; obtaining a word interval according to the word list and a preset sliding window; obtaining a word interval vector by subjecting the word vector contained in the word interval to a fusion function; obtaining a word interval length vector according to the length of the word interval; predicting the type of the word interval according to the information obtained from the pre-processing; predicting the relationship type of the entity phrase according to the entity phrase and the text vectors between the entity words in the entity phrase; The entity relationship joint extraction model includes a preprocessing module and a classification module, wherein the classification module includes an embedding layer, a first classifier, a transition layer and a second classifier; The preprocessing module is used to preprocess the text data, including: performing word / character segmentation processing on the text data to obtain a word list; using the BERT pre-training model to process the word list to obtain a text vector and a word vector corresponding to each word; obtaining a word interval according to the word list and a preset sliding window; subjecting the word vectors contained in the word interval to a fusion function to obtain a word interval vector; obtaining a word interval length vector according to the length of the word interval; the embedding layer is connected to the preprocessing module, and is used to splice the word interval vector, or the word interval vector and the text vector, or the word interval vector and the word interval length vector, or the word interval vector, the word interval length vector and the text vector into a first vector; the first classifier is connected to the embedding layer, and predicts the type of the word interval according to the first vector; The transition layer connects the first classifier and the second classifier to filter out the word example interval of the entity type to obtain the entity word; the entity phrase consisting of every two entity words and the text vectors between the entity words in the entity phrase are concatenated into a second vector; The second classifier is used to predict the relationship type of the entity phrase according to the second vector.

Citation Information

Patent Citations

  • Relational information extraction method and device, electronic equipment and readable storage medium

    CN111639185A