Entity relationship extraction method and device
By extracting sentences from professional data in the medical field and screening templates, adjusting the BERT model, solving the problem of relying on rules or labeling data in existing technologies, and realizing efficient physical relationship extraction.
Patent Information
- Application Number
- CN202010648089.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-07
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2040-07-07
AI Technical Summary
Existing entity relationship extraction methods rely on the quality of rules or require a large amount of labeled data, resulting in high cost, time-consuming and poor flexibility.
By drawing sentences containing physical pairs from professional data in the medical field, and screening the sentence templates for the relationship between the relationship based on the initial BERT model, adjust the bert model to adapt to various data.
Improving the efficiency of data labeling and feature matching, reducing dependence on a large amount of manpower and cost, and adapting to various data in the medical field.
Smart Images

Figure CN111798987B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data relationship extraction, and in particular to an entity relationship extraction method and device. Background Art
[0002] At present, for medical entities such as diseases and symptoms, diseases and surgeries, it is necessary to extract the relationship between entities. There are two existing extraction methods: one is based on rule extraction, and the other is based on supervised learning. The rule-based extraction method uses pre-defined rules to extract corresponding entities from the text or determine whether there is a corresponding relationship between entities, while the supervised learning method trains the classifier after annotating a large amount of data to determine whether there is a corresponding relationship between entities. Both of these current solutions have some problems:
[0003] The rule-based approach relies on the quality of rule-making, which requires a lot of manpower in the early stages. Moreover, the manually formulated rules may not cover all types of relationships, resulting in a poor recall rate. The supervised learning approach requires a large amount of labeled data, which is costly, time-consuming, and labor-intensive. Moreover, if new relationships need to be extracted, the data needs to be labeled again, which results in poor flexibility.
[0004] Therefore, a better method is now needed to solve the problems encountered in entity relationship extraction. Summary of the invention
[0005] In view of the defects in the prior art, the present invention proposes a method and device for entity relationship extraction. Through this solution, data is extracted from professional data in the medical field, and sentence templates for representing relationships are screened out based on the extracted sentences, thereby improving the work efficiency of data annotation and feature matching, and can adapt to various data in the medical field, without relying on a large amount of manpower, saving costs.
[0006] Specifically, the present invention proposes the following specific embodiments:
[0007] The embodiment of the present invention provides a method for extracting entity relationships, including:
[0008] Acquire an entity pair data set containing a preset relationship; wherein the entity pair data set contains a plurality of entity pairs;
[0009] Extracting sentences containing the entity pairs from professional data in the medical field;
[0010] Filtering a sentence template for representing the relationship from the sentence based on the initial BERT model;
[0011] The initial BERT model is adjusted based on the sentence template and the entity pair data set, so as to perform relation extraction on the entity pair data set of the to-be-extracted relation through the adjusted BERT model.
[0012] In a specific embodiment, the professional data in the medical field includes medical record data.
[0013] In a specific embodiment, there is a preset relationship between the entities in each of the entity pairs;
[0014] The “extracting sentences containing the entity pairs from professional data in the medical field” includes:
[0015] Sentences with a preset length and containing entities in the entity pairs with a preset interval value are extracted from professional data in the medical field.
[0016] In a specific embodiment, the “selecting a sentence template for representing the relationship from the sentence based on the initial BERT model” includes:
[0017] generating an initial sentence template based on the sentence, wherein more than a preset proportion of the sentences constructed based on the initial sentence template satisfy the relationship;
[0018] Perform usability scoring on each of the initial sentence templates using a BERT model;
[0019] The initial sentence templates are screened according to the usability scores to select sentence templates for representing the relationship.
[0020] In a specific embodiment,
[0021] The “using the BERT model to perform usability scoring on each of the initial sentence templates” includes:
[0022] For each of the initial sentence templates, constructing a sentence with spaces based on the initial sentence template and each entity in the entity pair data set;
[0023] Predicting spaces in the sentence based on the BERT model to obtain a prediction result;
[0024] A score of the initial sentence template is determined based on the prediction result.
[0025] In a specific embodiment, the availability score is determined based on the following formula:
[0026]
[0027] Among them, the score(φ i ) is the sentence template φi Usability rating;
[0028] In s j ∈S ij When 1, When is 0;
[0029] In t j ∈T ij When 1, When is 0;
[0030] T ij With S ij The sentences φ i (s j ,_) and sentence φ i (_,t j )’s top-k predictions;.
[0031] s j With t j is the entity in a pair of entities.
[0032] In a specific embodiment, the “adjusting the initial BERT model based on the sentence template and the entity pair dataset” includes:
[0033] Aggregating the sentence templates obtained after screening into a sentence template set;
[0034] Constructing positive example sentences on the sentence template set based on the entity pair dataset;
[0035] Constructing counterexample sentences on the sentence template set based on some entity pairs in the entity pair dataset and the anti-entity pair dataset; the anti-entity pair dataset has the same entities as the entity pair dataset, and the order of entities in the entity pairs is reversed;
[0036] The BERT model is adjusted based on the positive example sentence and the negative example sentence so as to pass the adjusted BERT model.
[0037] In a specific embodiment, it also includes:
[0038] When it is necessary to determine whether a specified entity pair satisfies a given relationship, the multiple sentences to be predicted are predicted by the adjusted BERT model; the sentences to be predicted are generated based on the specified entity pair and the sentence template set;
[0039] If the average value of the obtained prediction results is greater than a set threshold, it is determined that the specified entity pair satisfies a given relationship.
[0040] The embodiment of the present invention further provides a device for extracting entity relationships, including:
[0041] An acquisition module, used to acquire an entity pair data set containing a preset relationship; wherein the entity pair data set contains a plurality of entity pairs;
[0042] An extraction module, used for extracting sentences containing the entity pairs from professional data in the medical field;
[0043] A screening module, used for screening sentence templates for representing the relationship from the sentences based on the initial BERT model;
[0044] A processing module is used to adjust the initial BERT model based on the sentence template and the entity pair data set, so as to perform relationship extraction on the entity pair data set of the to-be-extracted relationship through the adjusted BERT model.
[0045] In a specific embodiment, the professional data in the medical field includes medical record data. Therefore, an embodiment of the present invention proposes a method and device for entity relationship extraction, the method comprising: obtaining an entity pair data set containing a preset relationship; wherein the entity pair data set contains multiple entity pairs; extracting sentences containing the entity pairs from the professional data in the medical field; filtering out sentence templates for representing the relationship from the sentences based on the initial BERT model; adjusting the initial BERT model based on the sentence templates and the entity pair data set, so as to perform relationship extraction on the entity pair data set for the extracted relationship through the adjusted BERT model. Through this solution, data is extracted from professional data in the medical field, and sentence templates for representing the relationship are filtered out based on the extracted sentences, which improves the work efficiency of data annotation and feature matching, and can adapt to various data in the medical field, does not need to rely on a large amount of manpower, and saves costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 A schematic diagram of a flow chart of an entity relationship extraction method proposed in an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of a process framework of an entity relationship extraction method proposed in an embodiment of the present invention;
[0049] Figure 3 A schematic diagram of the structure of an entity relationship extraction device proposed in an embodiment of the present invention;
[0050] Figure 4 A schematic diagram of the structure of an entity relationship extraction device proposed in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In the following, various embodiments of the present disclosure will be described more fully. The present disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of the present disclosure to the specific embodiments disclosed herein, but rather the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives that fall within the spirit and scope of the various embodiments of the present disclosure.
[0052] The terms used in the various embodiments of the present disclosure are only used for the purpose of describing specific embodiments and are not intended to limit the various embodiments of the present disclosure. As used herein, the singular form is intended to also include the plural form, unless the context clearly indicates otherwise. Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the meanings commonly understood by ordinary technicians in the field to which the various embodiments of the present disclosure belong. The terms (such as the terms defined in the generally used dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning, unless clearly defined in the various embodiments of the present disclosure.
[0053] Example 1
[0054] Embodiment 1 of the present invention discloses a method for extracting entity relationships, such as Figure 1 As shown, the following steps are included:
[0055] Step 101: Obtain an entity pair data set containing a preset relationship; wherein the entity pair data set contains a plurality of entity pairs.
[0056] Specifically, given a set of entity pairs with relationships For example, a dataset of entity pairs of diseases and symptoms {(hepatitis, hepatomegaly), (rubella, headache)}. A specific entity pair may be (rubella, headache), where "rubella" and "headache" are both entities in the entity pair.
[0057] Step 102: extracting sentences containing the entity pairs from professional data in the medical field;
[0058] Specifically, the professional data in the medical field includes medical record data.
[0059] In a specific embodiment, there is a preset relationship between the entities in each of the entity pairs;
[0060] The “extracting sentences containing the entity pairs from professional data in the medical field” includes:
[0061] Sentences with a preset length and containing entities in the entity pairs with a preset interval value are extracted from professional data in the medical field.
[0062] In this way, all sentences containing entity pairs in R are extracted from the medical records, of which only sentences with a length of L (for example, 15 characters or other numbers, the specific length can be), s i and t i The interval is W (it can also be measured in characters or other ways, such as 8 characters, etc. The specific interval can be flexibly set according to the actual situation). m (x m ,y m ) represents all the extracted sentences.
[0063] Step 103: Filter out sentence templates for representing the relationship from the sentences based on the initial BERT model.
[0064] Specifically, the initial sentence template φ is selected from the extracted sentences j (x j ,y j ), so that the sentence set φ constructed with it j (s1, t1), ..., φ j (s n , t n ) can satisfy the relationship to be extracted. For example, the initial sentence template "suffering from _ will show _" can be used to represent the relationship between most diseases and symptoms.
[0065] In a specific embodiment, in order to filter out sentence templates that better meet the requirements,
[0066] “Selecting a sentence template for representing the relationship from the sentence based on the initial BERT model” includes:
[0067] generating an initial sentence template based on the sentence, wherein more than a preset proportion of the sentences constructed based on the initial sentence template satisfy the relationship;
[0068] Perform usability scoring on each of the initial sentence templates using a BERT model;
[0069] The initial sentence templates are screened according to the usability scores to select sentence templates for representing the relationship.
[0070] In addition, the “using the BERT model to perform usability scoring on each of the initial sentence templates” includes:
[0071] For each of the initial sentence templates, constructing a sentence with spaces based on the initial sentence template and each entity in the entity pair data set;
[0072] Predicting spaces in the sentence based on the BERT model to obtain a prediction result;
[0073] A score of the initial sentence template is determined based on the prediction result.
[0074] Use the original BERT model to judge a template φ i The availability of the sentence φ is constructed using the dataset R. i (s1, _), ..., φ i (s n , _) and φ i (_, t1), ..., φ i (_, t n ), where the underscore _ represents a space. For example, when constructing the sentence "If you have hepatitis, you will show _", use the BERT model to predict the space part and count the corresponding t1,…,t n and s1,…,s n Whether it is in the top-k of the predicted results. Use T ij , S ij Respectively represent the sentence φ i (s j ,_) and sentence φ i (_,t j ), then specifically, the availability score is determined based on the following formula:
[0075]
[0076] Among them, the score(φ i ) is the sentence template φ i Usability rating;
[0077] In s j ∈S ij When 1, When is 0;
[0078] In t j ∈T ij When 1, When is 0;
[0079] T ij With S ij The sentences φ i (s j ,_) and sentence φ i (_,t j )'s top-k predictions; where bert is used to predict the top K (top-K) prediction results of the underline (e.g., the predicted words);
[0080] s j With t j is the entity in a pair of entities.
[0081] In a specific embodiment, the “adjusting the initial BERT model based on the sentence template and the entity pair dataset” includes:
[0082] Aggregating the sentence templates obtained after screening into a sentence template set;
[0083] Constructing positive example sentences on the sentence template set based on the entity pair dataset;
[0084] Constructing counterexample sentences on the sentence template set based on some entity pairs in the entity pair dataset and the anti-entity pair dataset; the anti-entity pair dataset has the same entities as the entity pair dataset, and the order of entities in the entity pairs is reversed;
[0085] The BERT model is adjusted based on the positive example sentence and the negative example sentence so as to pass the adjusted BERT model.
[0086] Specifically, Figure 2 As shown, Ψ={ψ1,…,ψ c} represents the C template sentences after screening. To improve the prediction accuracy, we can use the dataset R = {(s1, t1),…, (s n ,t n )} Construct positive example sentences on the template set Ψ;
[0087] In addition, using the data set R' = {(t1,s1),…,(t n ,s n )}, and sample a batch of samples (s i ,t j ), i≠j, i,j∈[1,n], construct negative example sentences on the template set Ψ, and use the constructed positive and negative example sentences to finetune the original BERT model using a binary classification method.
[0088] Further, such as Figure 2 As shown, the method also includes:
[0089] When it is necessary to determine whether a specified entity pair satisfies a given relationship, the multiple sentences to be predicted are predicted by the adjusted BERT model; the sentences to be predicted are generated based on the specified entity pair and the sentence template set;
[0090] If the average value of the obtained prediction results is greater than a set threshold, it is determined that the specified entity pair satisfies a given relationship.
[0091] Specifically, after fine-tuning, BERT predicts whether (s, t) satisfies a given relationship. Since there are c sentence templates, c sentences can be constructed. The predicted results are: p1(s, t),…,pc(s, t). The threshold λ is set. When the average value of the predicted results is , the input (s, t) can be considered to satisfy the given relationship.
[0092] Example 2
[0093] Embodiment 2 of the present invention also discloses a device for extracting entity relationships, such as Figure 3 As shown, including:
[0094] The acquisition module 201 is used to acquire an entity pair data set containing a preset relationship; wherein the entity pair data set contains a plurality of entity pairs.
[0095] An extraction module 202, used to extract sentences containing the entity pairs from professional data in the medical field;
[0096] A screening module 203, configured to screen out sentence templates for representing the relationship from the sentences based on the initial BERT model;
[0097] The processing module 204 is used to adjust the initial BERT model based on the sentence template and the entity pair data set, so as to perform relationship extraction on the entity pair data set of the to-be-extracted relationship through the adjusted BERT model.
[0098] In a specific embodiment, the professional data in the medical field includes medical record data.
[0099] In a specific embodiment, there is a preset relationship between the entities in each of the entity pairs;
[0100] The extraction module 202 is used to:
[0101] Sentences with a preset length and containing entities in the entity pairs with a preset interval value are extracted from professional data in the medical field.
[0102] In a specific embodiment, the screening module 203 is used to
[0103] generating an initial sentence template based on the sentence, wherein more than a preset proportion of the sentences constructed based on the initial sentence template satisfy the relationship;
[0104] Perform usability scoring on each of the initial sentence templates using a BERT model;
[0105] The initial sentence templates are screened according to the usability scores to select sentence templates for representing the relationship.
[0106] In a specific embodiment, the screening module 203 performs usability scoring on each of the initial sentence templates through a BERT model, including:
[0107] For each of the initial sentence templates, constructing a sentence with spaces based on the initial sentence template and each entity in the entity pair data set;
[0108] Predicting spaces in the sentence based on the BERT model to obtain a prediction result;
[0109] A score of the initial sentence template is determined based on the prediction result.
[0110] In a specific embodiment, the availability score is determined based on the following formula:
[0111]
[0112] Among them, the score(φ i ) is the sentence template φ i Usability rating;
[0113] In s j ∈S ij When 1, When is 0;
[0114] In t j ∈T ij When 1, When is 0;
[0115] T ij With S ij The sentences φ i (s j ,_) and sentence φ i (_,t j )’s top-k predictions;.
[0116] sj With t j is the entity in a pair of entities.
[0117] In a specific embodiment, the processing module 204 is used to
[0118] Aggregating the sentence templates obtained after screening into a sentence template set;
[0119] Constructing positive example sentences on the sentence template set based on the entity pair dataset;
[0120] Constructing counterexample sentences on the sentence template set based on some entity pairs in the entity pair dataset and the anti-entity pair dataset; the anti-entity pair dataset has the same entities as the entity pair dataset, and the order of entities in the entity pairs is reversed;
[0121] The BERT model is adjusted based on the positive example sentence and the negative example sentence so as to pass the adjusted BERT model.
[0122] In a specific embodiment, Figure 4 As shown, it also includes: a judgment module 205, which is used
[0123] When it is necessary to determine whether a specified entity pair satisfies a given relationship, the multiple sentences to be predicted are predicted by the adjusted BERT model; the sentences to be predicted are generated based on the specified entity pair and the sentence template set;
[0124] If the average value of the obtained prediction results is greater than a set threshold, it is determined that the specified entity pair satisfies a given relationship.
[0125] Thus, an embodiment of the present invention proposes a method and device for entity relationship extraction, the method comprising: obtaining an entity pair data set containing a preset relationship; wherein the entity pair data set contains multiple entity pairs; extracting sentences containing the entity pairs from professional data in the medical field; filtering out sentence templates for representing the relationship from the sentences based on the initial BERT model; adjusting the initial BERT model based on the sentence templates and the entity pair data set, so as to perform relationship extraction on the entity pair data set for the extracted relationship through the adjusted BERT model. Through this solution, data is extracted from professional data in the medical field, and sentence templates for representing the relationship are filtered out based on the extracted sentences, which improves the work efficiency of data annotation and feature matching, and can adapt to various data in the medical field, does not need to rely on a large amount of manpower, and saves costs.
[0126] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present invention.
[0127] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.
[0128] The above serial numbers of the present invention are only for description and do not represent the advantages or disadvantages of the implementation scenarios.
[0129] The above disclosure is only a few specific implementation scenarios of the present invention, but the present invention is not limited thereto, and any changes that can be conceived by those skilled in the art should fall within the protection scope of the present invention.
Claims
1. A method for extracting entity relationships, characterized in that: include: Acquire an entity pair data set containing a preset relationship; wherein the entity pair data set contains a plurality of entity pairs; Extracting sentences containing the entity pairs from professional data in the medical field; Filtering a sentence template for representing the relationship from the sentence based on the initial BERT model; Adjusting the initial BERT model based on the sentence template and the entity pair dataset, so as to perform relationship extraction on the entity pair dataset of the to-be-extracted relationship through the adjusted BERT model; The “selecting a sentence template for representing the relationship from the sentence based on the initial BERT model” includes: generating an initial sentence template based on the sentence, wherein more than a preset proportion of the sentences constructed based on the initial sentence template satisfy the relationship; Perform usability scoring on each of the initial sentence templates using a BERT model; Screening the initial sentence templates according to the usability scores to select sentence templates for representing the relationship; "Using the BERT model to perform usability scoring on each of the initial sentence templates", including: For each of the initial sentence templates, constructing a sentence with spaces based on the initial sentence template and each entity in the entity pair data set; Predicting spaces in the sentence based on the BERT model to obtain a prediction result; A score of the initial sentence template is determined based on the prediction result.
2. A method for extracting entity relationships according to claim 1, characterized in that: The professional data in the medical field includes medical record data.
3. The method for extracting entity relationships according to claim 1, characterized in that: There is a preset relationship between the entities in each of the entity pairs; The “extracting sentences containing the entity pairs from professional data in the medical field” includes: Sentences with a preset length and containing entities in the entity pairs with a preset interval value are extracted from professional data in the medical field.
4. The method for extracting entity relationships according to claim 1, characterized in that: The availability score is determined based on the following formula: Among them, the score(φ i ) is the sentence template φ i Usability rating; In s j ∈S ij When 1, When is 0; In t j ∈T ij When 1, When is 0; T ij With S ij The sentences φ i (s j ,_) and sentence φ i (_,t j )’s top-k predictions; s j With t j is the entity in a pair of entities.
5. The method for extracting entity relationships according to claim 1, characterized in that: The “adjusting the initial BERT model based on the sentence template and the entity pair dataset” includes: Aggregating the sentence templates obtained after screening into a sentence template set; Constructing positive example sentences on the sentence template set based on the entity pair dataset; Constructing counterexample sentences on the sentence template set based on some entity pairs in the entity pair dataset and the anti-entity pair dataset; the anti-entity pair dataset has the same entities as the entity pair dataset, and the order of entities in the entity pairs is reversed; The BERT model is adjusted based on the positive example sentence and the negative example sentence so as to pass the adjusted BERT model.