CN115796161A - Entity relationship joint extraction method and system - Google Patents

Entity relationship joint extraction method and system Download PDF

Info

Publication number
CN115796161A
CN115796161A CN202211337121.6A CN202211337121A CN115796161A CN 115796161 A CN115796161 A CN 115796161A CN 202211337121 A CN202211337121 A CN 202211337121A CN 115796161 A CN115796161 A CN 115796161A
Authority
CN
China
Prior art keywords
entity
relationship
entities
candidate
statement
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211337121.6A
Other languages
Chinese (zh)
Inventor
张振强
胡茂华
李斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yiyaowang Technology Shanghai Co ltd
Original Assignee
Yiyaowang Technology Shanghai Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yiyaowang Technology Shanghai Co ltd filed Critical Yiyaowang Technology Shanghai Co ltd
Priority to CN202211337121.6A priority Critical patent/CN115796161A/en
Publication of CN115796161A publication Critical patent/CN115796161A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Machine Translation (AREA)

Abstract

The invention provides a method and a system for entity relationship joint extraction, which relate to the technical field of natural language processing and comprise the following steps: acquiring a plurality of training sentences, and correspondingly constructing a text matrix for each training sentence; respectively labeling entity types and relationship types corresponding to the entities in the training sentences, and configuring the corresponding entity types and relationship types in the text matrix according to the coordinates of the entities in the text matrix to form a labeling matrix; training according to each training statement and the corresponding label matrix to obtain an entity relationship joint extraction model; and inputting the statement to be extracted into the entity relationship joint extraction model to obtain entity information and relationship information of each entity contained in the statement to be extracted as an entity relationship joint extraction result. The method has the advantages that the entity identification task and the relation extraction task are unified into one task, so that the two tasks are mutually supplemented and mutually promoted, the interaction between the entity identification and the relation extraction is enhanced, and the accuracy is effectively improved.

Description

Entity relationship joint extraction method and system
Technical Field
The invention relates to the technical field of natural language processing, in particular to a method and a system for entity relationship joint extraction.
Background
The objective of relationship extraction is to extract triple data in the form of < head entity, relationship, tail entity > from unstructured text, with the primary objective of identifying entities from text and extracting semantic relationships between entities. The relation extraction solves the problem of relation classification between corresponding target head and tail entities, is one of important steps for constructing a knowledge graph, and can provide technical support for automatic question answering, machine translation and a search engine.
With the wide application of machine learning in the field of relationship extraction, relationship extraction is further widely focused and deeply studied in the biomedical field. In recent years, the number of biomedical documents has been growing at a high rate. On one hand, massive biomedical resources become valuable resources of biomedical experts, and on the other hand, the efficiency of biomedical research is limited to a certain extent due to time and labor consumption of manually extracting useful information. Based on this, biomedical text mining technology appears in due time and solves this problem. Biomedical entity relationship extraction is one of the important tasks in text mining.
However, the current mainstream relationship extraction technology is to extract by using a pipeline relationship extraction algorithm, specifically, firstly, entity recognition is performed on a sentence, then, relationship classification is performed on pairwise combinations of the recognized entities, and finally, entity pairs with relationships are output as triples.
However, such an approach has the following disadvantages: 1. and (3) error accumulation: errors in entity identification can affect the following relationship classification performance; 2. physical redundancy: no related entity pair can bring redundant information, the error rate is improved, and the efficiency of the whole extraction process is reduced; 3. insufficient information utilization: the entity identification and the relation classification in the Pipeline relation extraction algorithm are relatively independent, and the internal relation and the dependency relationship of the two subtasks cannot be effectively utilized.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides an entity relationship joint extraction method, which comprises the following steps:
s1, acquiring a plurality of training sentences, and distributing each word in the training sentences in sequence according to rows and columns respectively aiming at each training sentence so as to correspondingly construct a text matrix;
s2, respectively labeling entity types and relationship types corresponding to the entities in the training sentences, and configuring the corresponding entity types and the relationship types as element values of the coordinates in the text matrix to form a labeling matrix according to the coordinates of the entities in the training sentences in the text matrix;
s3, training according to each training sentence and the corresponding label matrix to obtain an entity relation joint extraction model;
and S4, obtaining a statement to be extracted, inputting the statement to be extracted into the entity relationship joint extraction model to obtain entity information of each entity and relationship information among the entities contained in the statement to be extracted as an entity relationship joint extraction result of the statement to be extracted.
Preferably, in step S2, the coordinates include a start position and an end position of the entity on the text matrix;
the entity type is configured at the end position of the entity on the text matrix;
the relationship types are respectively configured at an intersection position of the starting positions of the two entities of the text matrix, an intersection position of the ending positions of the two entities, an intersection position of the starting position of one of the entities and the ending position of the other entity, and an intersection position of the ending position of one of the entities and the starting position of the other entity.
Preferably, the entity type is configured at the end position of the entity in an upper triangular area of the text matrix, and the relationship type is respectively configured at each intersection position of the upper triangular area of the text matrix.
Preferably, the entity-relationship joint extraction model includes a BERT module, a dual affine classifier, and a decoding module, which are connected in sequence, and then the step S4 includes:
step S41, inputting the statement to be extracted into the BERT module to carry out semantic recognition on the statement to be extracted so as to obtain the representation of the statement to be extracted;
step S42, inputting the representation into the double affine classifier to calculate and obtain the entity type and the predicted score of the relationship type at the corresponding position in the text matrix corresponding to the sentence to be extracted;
step S43, inputting each prediction score into the decoding module, and processing the prediction score to obtain the entity information of each entity included in the statement to be extracted and the relationship information between the entities as the entity relationship joint extraction result of the statement to be extracted.
Preferably, the step S43 includes:
step S431, screening each of the prediction scores of the corresponding location including the entity type, and respectively determining whether the highest prediction score in the corresponding location is the entity type and the starting location of the associated entity is not greater than the ending location:
if yes, the associated entity is taken as a candidate entity, and then the process goes to step S432;
if not, returning to the step S431;
step S432, for each two candidate entities, respectively determining whether the predicted scores of the relationship types corresponding to the intersection positions of the starting positions of the two candidate entities, the intersection positions of the ending positions of the two candidate entities, the intersection position of the starting position of one of the candidate entities and the ending position of the other candidate entity, and the intersection position of the ending position of one of the candidate entities and the starting position of the other candidate entity are all greater than a preset threshold:
if not, returning to the step S432;
if so, constructing a triple according to the two corresponding candidate entities and the relationship type, outputting the triple as the relationship information, and outputting the entity information of the entity type of each candidate entity, the initial position and the end position of each candidate entity and each candidate entity.
Preferably, the expression of the loss function of the entity-relationship joint extraction model is as follows:
Figure BDA0003915669150000041
loss is used for representing the loss function, K is used for representing type attributes, K is used for representing the entity type, S is used for representing the relation type, O is used for representing a non-entity non-relation type, g is used for representing the prediction score, A k The prediction score, B, representing the location of all the type attributes k in the corresponding text matrix k The prediction score is used for representing the position of all the type attributes in the corresponding text matrix, wherein the type attribute is not k.
The invention also provides an entity relationship joint extraction system, which applies the entity relationship joint extraction method and comprises the following steps:
the matrix construction module is used for acquiring a plurality of training sentences and distributing each word in the training sentences according to rows and columns in turn respectively aiming at each training sentence so as to correspondingly construct a text matrix;
the data labeling module is connected with the matrix construction module and is used for labeling entity types and relationship types corresponding to the entities in the training sentences respectively and configuring the corresponding entity types and relationship types as element values of the coordinates in the text matrix to form a labeling matrix according to the coordinates of the entities in the training sentences in the text matrix;
the model training module is respectively connected with the matrix construction module and the data labeling module and is used for training according to each training statement and the corresponding labeling matrix to obtain an entity relation joint extraction model;
and the relation extraction module is connected with the model training module and used for acquiring the statement to be extracted, inputting the statement to be extracted into the entity relation joint extraction model to obtain the entity information of each entity and the relation information between the entities contained in the statement to be extracted as the entity relation joint extraction result of the statement to be extracted.
Preferably, in the data labeling module, the coordinates include a start position and an end position of the entity on the text matrix;
the entity type is configured at the end position of the entity on the text matrix;
the relationship types are respectively configured at an intersection position of the starting positions of the two entities of the text matrix, an intersection position of the ending positions of the two entities, an intersection position of the starting position of one of the entities and the ending position of the other entity, and an intersection position of the ending position of one of the entities and the starting position of the other entity.
Preferably, the entity relationship joint extraction model comprises a BERT module, a double affine classifier and a decoding module which are connected in sequence;
the BERT module is used for performing semantic recognition on the statement to be extracted to obtain the representation of the statement to be extracted;
the double affine classifier is used for calculating and obtaining the entity type and the predicted score of the relationship type of the corresponding position in the text matrix corresponding to the sentence to be extracted according to the representation;
the decoding module is configured to obtain, according to each prediction score, the entity information of each entity included in the statement to be extracted and the relationship information between the entities, which are used as the entity relationship joint extraction result of the statement to be extracted.
Preferably, the decoding module includes:
a first determining unit, configured to filter each of the prediction scores of the corresponding location including the entity type, and determine that the highest of the prediction scores in the corresponding location is the entity type and the start location of the associated entity is not greater than the end location, and use the associated entity as a candidate entity;
a second determining unit, connected to the first determining unit, configured to determine, for each two candidate entities, an intersection point position of the start positions of the two candidate entities, an intersection point position of the end positions of the two candidate entities, an intersection point position of the start position of one candidate entity and the end position of the other candidate entity, and when the prediction scores of the relationship types corresponding to the intersection points of the end position of one candidate entity and the start position of the other candidate entity are greater than a preset threshold, construct a triple according to the corresponding two candidate entities and the relationship types, output the triple as the relationship information, and output the entity information of the entity types of each candidate entity, the start position and the end position of each candidate entity.
The technical scheme has the following advantages or beneficial effects:
1) Based on a text matrix and by utilizing potential information between entity identification and relationship extraction, an entity identification task and a relationship extraction task are unified into one task, so that the two tasks are mutually supplemented and mutually promoted, the interaction between the entity identification and the relationship extraction is enhanced, the accuracy is effectively improved, and the problems of error accumulation, entity redundancy and insufficient information utilization existing in the traditional Pipeline relationship extraction algorithm are solved;
2) The vector representation of each position in the obtained text matrix does not need to be displayed, so the display memory occupation is smaller than that of other methods.
Drawings
FIG. 1 is a flow chart illustrating a method for extracting entity relationship association according to a preferred embodiment of the present invention;
FIG. 2 is a diagram illustrating a text matrix according to a preferred embodiment of the present invention;
FIG. 3 is a schematic diagram of a label matrix according to a preferred embodiment of the present invention;
FIG. 4 is a flowchart illustrating step S4 according to a preferred embodiment of the present invention;
FIG. 5 is a flowchart illustrating the step S43 according to the preferred embodiment of the present invention;
FIG. 6 is a schematic diagram of a system for extracting entity relationship combinations according to a preferred embodiment of the present invention;
FIG. 7 is a schematic diagram of a structure of a entity-relationship joint extraction model according to a preferred embodiment of the present invention.
Detailed Description
The invention is described in detail below with reference to the figures and specific embodiments. The present invention is not limited to the embodiment, and other embodiments may be included in the scope of the present invention as long as the gist of the present invention is satisfied.
In a preferred embodiment of the present invention, based on the above problems in the prior art, there is provided a method for extracting entity relationship jointly, as shown in fig. 1, including:
s1, acquiring a plurality of training sentences, and distributing each character in the training sentences according to rows and columns in turn for each training sentence so as to correspondingly construct a text matrix;
s2, respectively labeling entity types and relationship types corresponding to the entities in the training sentences, and configuring the corresponding entity types and relationship types as element values of coordinates in a text matrix according to the coordinates of the entities in the training sentences in the text matrix to form a labeling matrix;
s3, training according to each training sentence and the corresponding label matrix to obtain an entity relationship combined extraction model;
and S4, obtaining the statement to be extracted, inputting the statement to be extracted into the entity relation joint extraction model to obtain entity information of each entity contained in the statement to be extracted and relation information among the entities as an entity relation joint extraction result of the statement to be extracted.
Specifically, in this embodiment, taking an example that a training sentence is "beijing university in hai lake district", each sub-matrix is sequentially distributed according to rows and columns, so as to construct a text matrix with 8 rows and 8 columns, where the correspondingly constructed text matrix is shown in fig. 2, where 0 to 7 in the figure are used to show the number of rows and columns of each word in the text matrix, and the text matrix is marked for easy understanding, and does not include the content when actually constructing the text matrix.
When the blank text matrix shown in fig. 2 is constructed, the entity type and the relationship type need to be correspondingly labeled, in the preferred embodiment of the present invention, in step S2, the coordinates include the initial position and the end position of the entity on the text matrix;
the entity type is configured at the ending position of the entity on the text matrix;
the relationship types are respectively configured at the intersection point position of the starting positions of the two entities, the intersection point position of the ending positions of the two entities, the intersection point position of the starting position of one entity and the ending position of the other entity, and the intersection point position of the ending position of one entity and the starting position of the other entity of the text matrix.
Specifically, in the present embodiment, based on fig. 2, the training sentence "beijing university in hai lake area" includes "beijing" (start position is 0, end position is 1, and coordinates are represented by (0,1) "," beijing university "(start position is 0, end position is 3, and coordinates are represented by (0,3)", "hailake area" (start position is 5, end position is 7, and coordinates are represented by (5,7) "). Then, respectively configuring the entity types on the text matrix, taking entity "beijing" as an example, where the ending position is 1, the entity type is a city and may be represented by letter c, then c may be filled into the first row and the first column of the text matrix, and may also be filled into the first row and the zeroth column of the text matrix.
Similarly, the entity type of the entity "Beijing university" is university, and may be represented by the letter u, and the ending position is 3, and the third column of the zeroth row of the text matrix is filled in. The entity type of the entity "Haihe district" is a prefecture administrative unit, and can be represented by a letter d, the starting position is 5, the ending position is 7, and the fifth row and the seventh column of the text matrix are filled in.
Further, the relationship between the entity "beijing" and the entity "hai lake" may be represented by (beijing, inclusive, hai lake district) using a triplet, and the relationship between the entity "beijing university" and the entity "hai lake district" may be represented by (beijing university, located, hai lake district) using a triplet, where "inclusive" is the type of relationship corresponding to the entity "beijing" and the entity "hai lake district" may be represented by the letter B, and "located" is the type of relationship corresponding to the entity "beijing university" and the "hai lake district" may be represented by the letter L.
Preferably, for labeling the relation types, a head-head, tail-tail, head-tail and tail-head relation labeling mode is adopted, wherein the head represents a starting position, and the tail represents an ending position.
For the triplets (beijing, including, the hai lake zone), head-to-head, tail-to-tail, head-to-tail, tail-to-head positions are represented as (0,5), (1,7), (0,7), (1,5), respectively, based on which the letter B can be filled in the zeroth row, the fifth column, the first row, the seventh column, the zeroth row, the seventh column, and the first row, the fifth column, respectively, of the text matrix.
Similarly, for the triplets (beijing university, located in the hai lake area), the head-head, tail-tail, head-tail, and tail-head positions are represented as (0,5), (3,7), (0,7), (3,5), respectively, based on which the letter L can be filled in the fifth column of the zeroth row, the seventh column of the third row, the seventh column of the zeroth row, and the fifth column of the third row of the text matrix, respectively, to finally form the labeling matrix as shown in fig. 3.
It can be seen that there may be more than one label at a position in the labeling matrix, for example, the fifth column in the zeroth row contains both the relationship type L and the relationship type B, so that label prediction at each position in the labeling matrix is a multi-label prediction task.
By analogy, for each training sentence, a corresponding label matrix is correspondingly generated respectively, the label matrix comprises each entity in the training sentence, the initial position and the end position of each entity, and the entity type and the relationship type of each entity, so that the entity identification and the relationship identification are unified into one label matrix, further, an entity relationship joint extraction model which takes the sentence as input and takes each entity in the sentence, the initial position and the end position of each entity, and the entity type and the relationship type of each entity as an entity relationship joint extraction result can be obtained according to the training sentences and the label matrix corresponding to the training sentences. The method has the advantages that the entity recognition task and the relationship extraction task are unified into one task based on the text matrix and by utilizing the potential information between the entity recognition and the relationship extraction, so that the two tasks are mutually supplemented and mutually promoted, the interaction between the entity recognition and the relationship extraction is enhanced, the accuracy is effectively improved, and the problems of error accumulation, entity redundancy and insufficient information utilization existing in the traditional Pipeline relationship extraction algorithm are solved; and the vector representation of each position in the obtained text matrix does not need to be displayed, so the display memory occupation is smaller than that of other methods.
In a preferred embodiment of the present invention, the entity-relationship joint extraction model includes a BERT module, a dual affine classifier and a decoding module, which are connected in sequence, as shown in fig. 4, then step S4 includes:
s41, inputting the statement to be extracted into a BERT module to carry out semantic recognition on the statement to be extracted so as to obtain the representation of the statement to be extracted;
s42, inputting the representation into a double affine classifier to calculate and obtain the entity type and the predicted score of the relation type of the corresponding position in the text matrix corresponding to the sentence to be extracted;
and S43, inputting each prediction score into a decoding module to be processed to obtain entity information of each entity contained in the statement to be extracted and relationship information among the entities as an entity relationship joint extraction result of the statement to be extracted.
In a preferred embodiment of the present invention, as shown in fig. 5, step S43 includes:
step S431, screening each prediction score of the corresponding position including the entity type, and respectively determining whether the highest prediction score in the corresponding position is the entity type and the start position of the associated entity is not greater than the end position:
if yes, the associated entity is taken as a candidate entity, and then the process goes to step S432;
if not, returning to the step S431;
step S432, for every two candidate entities, respectively determining whether the intersection point positions of the starting positions of the two candidate entities, the intersection point positions of the ending positions of the two candidate entities, the intersection point position of the starting position of one candidate entity and the ending position of the other candidate entity, and the prediction scores of the relationship types corresponding to the intersection point positions of the ending position of one candidate entity and the starting position of the other candidate entity are all greater than a preset threshold:
if not, returning to the step S432;
if so, constructing a triple according to the two corresponding candidate entities and the relationship type, outputting the triple as relationship information, and outputting the entity type entity information of each candidate entity, the initial position and the end position of each candidate entity and each candidate entity.
Specifically, in this embodiment, during model prediction, the entity position is determined first, and as long as the corresponding position in the text matrix is predicted to be positive in entity type and the starting position is not greater than the ending position, the corresponding entity may be used as a candidate entity. More specifically, as can be seen from the above labeling process, each position in the text matrix may correspond to multiple tags, such as an entity type and a relationship type, and each tag corresponds to a prediction score during prediction, and for each position, if the position includes both the entity type and the relationship types, and the prediction score of the entity type is higher than the prediction score of each relationship type, that is, the prediction score of the entity type is the highest, it is considered that the position is predicted as positive in the entity type.
After the candidate entities are determined, the relationship between each two candidate entities needs to be determined, in this embodiment, by combining each two candidate entities, as long as the head-head, tail-tail, head-tail, and tail-head positions of the candidate entities simultaneously give predictions of the same relationship type, it is considered that the triples of the two candidate entities in the combination and the corresponding relationship type are established. Preferably, in this embodiment, the predicted result of the relationship type is confirmed by comparing the predicted score of the relationship type with a preset threshold, where the preset threshold may be configured by user according to needs, and is preferably 0.5.
In the preferred embodiment of the present invention, the expression of the loss function of the entity-relationship joint extraction model is as follows:
Figure BDA0003915669150000131
wherein loss is used for representing loss function, K is used for representing type attribute, K is used for representing entity type, S is used for representing relationship type, O is used for representing non-entity non-relationship type, g is used for representing prediction score, a k Prediction score for a position representing all types of attributes k in the corresponding text matrix, B k And the prediction scores are used for representing the positions of all types of attributes in the corresponding text matrix, wherein the attributes are not k.
Specifically, in this embodiment, the entity type tag includes K types, the relationship type tag includes S types, and the non-entity non-relationship tag is "O", so that each possible tag at each position on each text matrix includes K + S +1 possibilities. In the existing model, a multi-classification task is usually converted into a plurality of two-classification tasks, and then cross entropy loss is calculated respectively, but in the embodiment, label distribution is quite unbalanced, and the optimization effect of the sampling cross entropy loss model cannot meet the requirement. By using the loss function, the differentiation of the scores between the categories is encouraged, which is equivalent to only one task instead of converting the prediction of a plurality of labels into a plurality of second categories, so that the problem of unbalanced data distribution is avoided, and the optimization effect of the model is effectively improved.
As a preferred embodiment, the technical solution can be applied to a medical AI scenario, extracting unstructured and semi-structured medical texts to construct a medical knowledge map to serve downstream subtasks. The unstructured medical texts, such as each natural paragraph of medical teaching materials, subjects under each disease in clinical practice, chief complaints, current medical history, differential diagnosis and the like in the electronic medical record data are all composed of sentences or sentence sets. And when the relationship extraction is carried out, the potential information between the entity identification and the relationship extraction is utilized, and the entity identification task and the relationship extraction task are unified into one task, so that the two tasks are mutually supplemented and mutually promoted, the interaction between the entity identification and the relationship extraction is enhanced, the accuracy is effectively improved, and the problems of error accumulation, entity redundancy and insufficient information utilization existing in the traditional Pipeline relationship extraction algorithm are solved.
Preferably, when the technical scheme is applied to a medical AI scene, the corresponding entity types can commonly include diseases, medicines, examination and inspection, and body parts; the relationship types may include treatment relationship, side effect relationship, contraindication relationship, and interaction relationship.
The present invention further provides an entity relationship joint extraction system, which applies the above entity relationship joint extraction method, as shown in fig. 6, the entity relationship joint extraction system includes:
the matrix construction module 1 is used for acquiring a plurality of training sentences, and for each training sentence, distributing each word in the training sentence in sequence according to rows and columns respectively so as to correspondingly construct a text matrix;
the data labeling module 2 is connected with the matrix construction module 1 and is used for labeling entity types and relationship types corresponding to the entities in the training sentences respectively and configuring the corresponding entity types and relationship types serving as element values of coordinates in a text matrix to form a labeling matrix according to the coordinates of the entities in the training sentences in the text matrix;
the model training module 3 is respectively connected with the matrix construction module 1 and the data labeling module 2 and is used for training according to each training sentence and the corresponding labeling matrix to obtain an entity relationship combined extraction model;
and the relation extraction module 4 is connected with the model training module 3 and is used for acquiring the statement to be extracted, inputting the statement to be extracted into the entity relation joint extraction model to obtain entity information of each entity contained in the statement to be extracted and relation information among the entities as an entity relation joint extraction result of the statement to be extracted.
In the preferred embodiment of the present invention, in the data labeling module 2, the coordinates include the starting position and the ending position of the entity on the text matrix;
the entity type is configured at the ending position of the entity on the text matrix;
the relationship types are respectively configured at the intersection point position of the starting positions of the two entities, the intersection point position of the ending positions of the two entities, the intersection point position of the starting position of one entity and the ending position of the other entity, and the intersection point position of the ending position of one entity and the starting position of the other entity of the text matrix.
In a preferred embodiment of the present invention, as shown in fig. 7, the entity-relationship joint extraction model includes a BERT module 5, a dual affine classifier 6 and a decoding module 7 connected in sequence;
the BERT module 5 is used for performing semantic recognition on the statement to be extracted to obtain the representation of the statement to be extracted;
the double affine classifier 6 is used for obtaining the entity type and the predicted score of the relationship type of the corresponding position in the text matrix corresponding to the sentence to be extracted according to the representation calculation;
and the decoding module 7 is used for processing the entity information of each entity contained in the statement to be extracted and the relationship information among the entities according to each prediction score to obtain an entity relationship joint extraction result of the statement to be extracted.
In a preferred embodiment of the present invention, the decoding module 7 comprises:
a first determining unit 71, configured to filter each prediction score of a corresponding position including an entity type, and determine that the highest prediction score in the corresponding position is an entity type and the associated entity is a candidate entity when the initial position of the associated entity is not greater than the end position;
and the second judging unit 72 is connected to the first judging unit 71, and is configured to respectively judge, for every two candidate entities, an intersection point position of the starting positions of the two candidate entities, an intersection point position of the ending positions of the two candidate entities, an intersection point position of the starting position of one candidate entity and the ending position of the other candidate entity, and a prediction score of a relationship type corresponding to the intersection point position of the ending position of one candidate entity and the starting position of the other candidate entity are greater than a preset threshold, construct a triple according to the corresponding two candidate entities and the relationship type, output the triple as relationship information, and output entity type entity information of each candidate entity, the starting position and the ending position of each candidate entity, and each candidate entity.
While the invention has been described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.

Claims (10)

1. An entity relationship joint extraction method is characterized by comprising the following steps:
s1, acquiring a plurality of training sentences, and distributing each word in the training sentences in sequence according to rows and columns respectively aiming at each training sentence so as to correspondingly construct a text matrix;
s2, respectively labeling entity types and relationship types corresponding to the entities in the training sentences, and configuring the corresponding entity types and the relationship types as element values of the coordinates in the text matrix to form a labeling matrix according to the coordinates of the entities in the training sentences in the text matrix;
s3, training according to each training sentence and the corresponding label matrix to obtain an entity relation joint extraction model;
and S4, obtaining a statement to be extracted, inputting the statement to be extracted into the entity relationship joint extraction model to obtain entity information of each entity and relationship information among the entities contained in the statement to be extracted as an entity relationship joint extraction result of the statement to be extracted.
2. The entity relationship joint extraction method as claimed in claim 1, wherein in the step S2, the coordinates include a start position and an end position of the entity on the text matrix;
the entity type is configured at the end position of the entity on the text matrix;
the relationship types are respectively configured at an intersection position of the starting positions of the two entities of the text matrix, an intersection position of the ending positions of the two entities, an intersection position of the starting position of one of the entities and the ending position of the other entity, and an intersection position of the ending position of one of the entities and the starting position of the other entity.
3. The method as claimed in claim 2, wherein the entity type is configured at the end position of the entity in the upper triangular region of the text matrix, and the relationship types are respectively configured at the intersection positions of the upper triangular region of the text matrix.
4. The entity-relationship joint extraction method according to claim 2, wherein the entity-relationship joint extraction model includes a BERT module, a dual-affine classifier and a decoding module, which are connected in sequence, then the step S4 includes:
step S41, inputting the statement to be extracted into the BERT module to carry out semantic recognition on the statement to be extracted so as to obtain the representation of the statement to be extracted;
step S42, inputting the representation into the double affine classifier to calculate and obtain the entity type and the predicted score of the relationship type at the corresponding position in the text matrix corresponding to the sentence to be extracted;
step S43, inputting each prediction score into the decoding module to be processed, so as to obtain the entity information of each entity included in the statement to be extracted and the relationship information between each entity, which are used as the entity relationship joint extraction result of the statement to be extracted.
5. The entity relationship joint extraction method as claimed in claim 4, wherein the step S43 includes:
step S431, screening each of the prediction scores of the corresponding location including the entity type, and respectively determining whether the highest prediction score in the corresponding location is the entity type and the starting location of the associated entity is not greater than the ending location:
if yes, the associated entity is taken as a candidate entity, and then the process goes to step S432;
if not, returning to the step S431;
step S432, for each two candidate entities, respectively determining whether the predicted scores of the relationship types corresponding to the intersection positions of the starting positions of the two candidate entities, the intersection positions of the ending positions of the two candidate entities, the intersection position of the starting position of one of the candidate entities and the ending position of the other candidate entity, and the intersection position of the ending position of one of the candidate entities and the starting position of the other candidate entity are all greater than a preset threshold:
if not, returning to the step S432;
if so, constructing a triple according to the two corresponding candidate entities and the relationship type, outputting the triple as the relationship information, and outputting the entity information of the entity type of each candidate entity, the initial position and the end position of each candidate entity and each candidate entity.
6. The entity relationship joint extraction method as claimed in claim 4, wherein the expression of the loss function of the entity relationship joint extraction model is as follows:
Figure FDA0003915669140000031
wherein loss is used to represent the loss function, K is used to represent a type attribute, K is used to represent the entity type, S is used to represent the relationship type, O is used to represent a non-entity non-relationship type, g is used to represent the prediction score, a k The prediction score, B, representing the location of all the type attributes k in the corresponding text matrix k The prediction score is used for representing the position of all the type attributes in the corresponding text matrix, wherein the type attribute is not k.
7. An entity relationship joint extraction system, which is characterized by applying the entity relationship joint extraction method according to any one of claims 1-6, and comprises:
the matrix construction module is used for acquiring a plurality of training sentences and distributing each word in the training sentences according to rows and columns in turn respectively aiming at each training sentence so as to correspondingly construct a text matrix;
the data labeling module is connected with the matrix construction module and is used for labeling entity types and relationship types corresponding to the entities in the training sentences respectively and configuring the corresponding entity types and relationship types as element values of the coordinates in the text matrix to form a labeling matrix according to the coordinates of the entities in the training sentences in the text matrix;
the model training module is respectively connected with the matrix construction module and the data labeling module and is used for training according to each training statement and the corresponding labeling matrix to obtain an entity relation joint extraction model;
and the relation extraction module is connected with the model training module and used for acquiring the statement to be extracted, inputting the statement to be extracted into the entity relation joint extraction model to obtain the entity information of each entity and the relation information between the entities contained in the statement to be extracted as the entity relation joint extraction result of the statement to be extracted.
8. The system of claim 7, wherein in the data labeling module, the coordinates include a start position and an end position of the entity on the text matrix;
the entity type is configured at the end position of the entity on the text matrix;
the relationship types are respectively configured at an intersection position of the starting positions of the two entities of the text matrix, an intersection position of the ending positions of the two entities, an intersection position of the starting position of one of the entities and the ending position of the other entity, and an intersection position of the ending position of one of the entities and the starting position of the other entity.
9. The entity-relationship joint extraction system of claim 8, wherein the entity-relationship joint extraction model comprises a BERT module, a dual-affine classifier and a decoding module which are connected in sequence;
the BERT module is used for performing semantic recognition on the statement to be extracted to obtain the representation of the statement to be extracted;
the double affine classifier is used for calculating and obtaining the entity type and the predicted score of the relation type of the corresponding position in the text matrix corresponding to the sentence to be extracted according to the representation;
the decoding module is configured to obtain, according to each prediction score, the entity information of each entity included in the statement to be extracted and the relationship information between the entities, which are used as the entity relationship joint extraction result of the statement to be extracted.
10. The entity relationship joint extraction system according to claim 9, wherein the decoding module comprises:
a first determining unit, configured to filter each of the prediction scores of the corresponding location including the entity type, and determine that the highest of the prediction scores in the corresponding location is the entity type and the start location of the associated entity is not greater than the end location, and use the associated entity as a candidate entity;
and a second judging unit, connected to the first judging unit, configured to respectively judge, for every two candidate entities, an intersection position of the starting positions of the two candidate entities, an intersection position of the ending positions of the two candidate entities, an intersection position of the starting position of one of the candidate entities and the ending position of the other candidate entity, and when the prediction scores of the relationship types corresponding to the intersection positions of the ending position of one of the candidate entities and the starting position of the other candidate entity are greater than a preset threshold, construct a triplet according to the corresponding two candidate entities and the relationship types, and output the triplet as the relationship information, and output the entity information of the entity types of each candidate entity, the starting positions and the ending positions of each candidate entity, and the entity information of each candidate entity.
CN202211337121.6A 2022-10-28 2022-10-28 Entity relationship joint extraction method and system Pending CN115796161A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211337121.6A CN115796161A (en) 2022-10-28 2022-10-28 Entity relationship joint extraction method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211337121.6A CN115796161A (en) 2022-10-28 2022-10-28 Entity relationship joint extraction method and system

Publications (1)

Publication Number Publication Date
CN115796161A true CN115796161A (en) 2023-03-14

Family

ID=85434276

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211337121.6A Pending CN115796161A (en) 2022-10-28 2022-10-28 Entity relationship joint extraction method and system

Country Status (1)

Country Link
CN (1) CN115796161A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118113792A (en) * 2024-04-23 2024-05-31 生命奇点(北京)科技有限公司 System for acquiring entity and entity relationship

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118113792A (en) * 2024-04-23 2024-05-31 生命奇点(北京)科技有限公司 System for acquiring entity and entity relationship
CN118113792B (en) * 2024-04-23 2024-09-13 生命奇点(北京)科技有限公司 System for acquiring entity and entity relationship

Similar Documents

Publication Publication Date Title
CN112001177B (en) Electronic medical record named entity recognition method and system integrating deep learning and rules
CN112597774B (en) Chinese medical named entity recognition method, system, storage medium and equipment
CN113095415B (en) Cross-modal hashing method and system based on multi-modal attention mechanism
CN110442840B (en) Sequence labeling network updating method, electronic medical record processing method and related device
CN111310470B (en) Chinese named entity recognition method fusing word and word features
CN112364174A (en) Patient medical record similarity evaluation method and system based on knowledge graph
CN109670179A (en) Case history text based on iteration expansion convolutional neural networks names entity recognition method
CN110277167A (en) The Chronic Non-Communicable Diseases Risk Forecast System of knowledge based map
CN106909783A (en) A kind of case history textual medical Methods of Knowledge Discovering Based based on timeline
CN111400455A (en) Relation detection method of question-answering system based on knowledge graph
CN116682553A (en) Diagnosis recommendation system integrating knowledge and patient representation
CN112420151A (en) Method, system, equipment and medium for structured analysis after ultrasonic report
CN111046272A (en) Intelligent question-answering system based on medical knowledge map
CN108021682A (en) Open information extracts a kind of Entity Semantics method based on wikipedia under background
CN109815478A (en) Medicine entity recognition method and system based on convolutional neural networks
CN110444261A (en) Sequence labelling network training method, electronic health record processing method and relevant apparatus
CN117577254A (en) Method and system for constructing language model in medical field and structuring text of electronic medical record
US20220300710A9 (en) Method and apparatus for recognizing medical entity in medical text
CN115796161A (en) Entity relationship joint extraction method and system
CN113380360B (en) Similar medical record retrieval method and system based on multi-mode medical record map
CN110969005B (en) Method and device for determining similarity between entity corpora
CN112800244B (en) Method for constructing knowledge graph of traditional Chinese medicine and national medicine
CN114118092A (en) Quick-start interactive relation labeling and extracting framework
CN114707615B (en) Ancient character similarity quantification method based on duration Chinese character knowledge graph
CN113744891B (en) Medicine knowledge graph representation learning method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination