A Cascade Linear Entity Relationship Extraction Method for Social Text
Through the cascade linear entity relationship extraction method, BERT and decoders are used to process overlapping triples in social texts, which solves the problem of difficulty in extracting overlapping triples in the existing technology and improves the accuracy and evaluation of entity relationship extraction. Indicators provide effective information extraction support for the social field.
Patent Information
- Application Number
- CN202111609226.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-12-27
AI Technical Summary
Existing entity relationship extraction methods are difficult to effectively handle overlapping triples in social text, resulting in a decline in the evaluation index of the relationship extraction task and high manual annotation costs.
The cascaded linear entity relationship extraction method is adopted, the pre-trained model BERT is used for data preprocessing and encoding, and the relationship decoder and entity decoder are combined to solve the overlapping triplet problem through the cascaded linear extraction method to achieve accurate entities. Relation extraction.
It improves the evaluation index of entity relationship extraction tasks, detects relationships through semantic information and guides entity extraction, achieves more accurate entity relationship extraction, and provides strong support for the social field.
Smart Images

Figure CN114282537B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing information extraction, and in particular to a cascade linear entity relationship extraction method for social text. Background Art
[0002] The knowledge graph is a structured semantic knowledge base that aims to describe concepts, entities, and their relationships in the objective world in a structured form, and to express Internet information in a form that is easy for humans to recognize. The basic unit of the knowledge graph is the entity-relationship triple, which is in the form of (head entity, relationship, tail entity), so entity relationship extraction is the key technology for building the knowledge graph.
[0003] Entity relationship extraction is to extract entities and their semantic relations from unstructured text, that is, given a natural language text, its task is to extract entity relationship triplets in the text. Existing entity relationship extraction methods mainly include pipeline methods and joint extraction methods. The traditional pipeline method divides the extraction into two independent entity recognition and relationship classification subtasks. This method ignores the potential interactive information between the two subtasks and may suffer from the influence of error propagation. The joint extraction method has been widely popular in recent years and is also a hot topic of research. This method jointly extracts entities and relations in a single model. Entity relationship extraction tasks usually encounter the problem of overlapping triplets, that is, the same entities are shared in different relationship triplets contained in a text. For example, the text "Maria was born in Leipzig, Germany, and has been living here." contains the following triples: (Maria, Born_in, Leipzig), (Maria, Live_in, Leipzig), (Leipzig, Located_in, Germany), where the relations "Born_in" and "Live_in" share the same entity pair "(Maria, Leipzig)", and the relations "Live_in" and "Located_in" share the same entity "Leipzig". The extraction of overlapping triples is an important factor affecting the evaluation index of the relation extraction task, and is also a problem that needs to be solved in the entity relation extraction task.
[0004] There are complex entity relationships in the field of social text, and overlapping triples are relatively common. Manual annotation is time-consuming, labor-intensive and costly. However, extracting structured social information is not only a key prerequisite for building a social knowledge graph, but also can provide powerful assistance for friend recommendations in social apps. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a cascade linear entity relationship extraction method for social text.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is: a cascade linear entity relationship extraction method for social text, which specifically includes the following steps:
[0007] Step 1: Obtain a public entity relationship extraction dataset with overlapping entity relationships to simulate social texts with overlapping entity relationships, and preprocess the obtained public dataset;
[0008] The method for preprocessing the public data set is as follows:
[0009] Step 1.1: Use the BertTokenizer in the pre-trained model BERT to segment each sentence in the dataset and convert the words in the segmented sentences into ID numbers;
[0010] Step 1.2: Divide the word-segmented dataset into batches randomly, and align the sentences in each batch of datasets with the length of the longest sentence in the batch.
[0011] Step 2: Use the pre-trained model BERT as the basic encoder and encode the sentences in the batch dataset to obtain the contextual semantic vector of the sentence and the word vector representation in the sentence. The process is as follows:
[0012] Step 2.1: Use the pre-trained model BERT as the base encoder;
[0013] Step 2.2: The word IDs corresponding to the sentences in the batch dataset are used as input to the word embedding layer, which maps the word IDs to word vectors.
[0014] Step 2.3: After being mapped into a word vector by the word embedding layer, the sentence is input into the pre-trained model BERT. The output of BERT is the final word vector representation after the sentence is encoded;
[0015] Step 2.4: Take the word vector corresponding to the special word "[CLS]" at the beginning of the sentence from the output of the pre-trained model BERT, pass the word vector through the pooling layer, and use the output vector of the pooling layer as the contextual semantic vector of the sentence.
[0016] Step 3: Construct a relation decoder, whose structure includes a linear layer and a Sigmoid layer. Use the relation decoder to detect the potential relations contained in the sentence and obtain the vector representation of the potential relations. The process is as follows:
[0017] Step 3.1: After the context semantic vector of the sentence obtained in step 2 passes through the linear layer and the Sigmoid layer, the potential relationship contained in the current sentence is classified;
[0018] Step 3.2: Define a relationship embedding layer and input the ID of the potential relationship classified in step 3.1 into the relationship embedding layer. The output of the relationship embedding layer is the vector representation of the potential relationship.
[0019] Step 4: construct an entity decoder, which consists of a head entity extractor and a tail entity extractor;
[0020] The structures of the head entity extractor and the tail entity extractor both include: a bidirectional LSTM layer, a linear layer and a Softmax layer; according to the cascaded linear extraction method of first extracting the relationship, then extracting the head entity, and finally extracting the tail entity, the head entity extractor is used to extract the head entity corresponding to the potential relationship detected in step 3, and the specific process is as follows:
[0021] Step 4.1: Detect the starting position of the head entity, concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2 with the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the starting position of the head entity;
[0022] Step 4.2: Pass the hidden layer vector of the start position of the head entity through the linear layer and the Softmax layer to predict the start position of the potential head entity in the current sentence;
[0023] Step 4.3: Detect the end position of the head entity, concatenate the hidden layer vector of the start position of the potential head entity in step 4.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the head entity;
[0024] Step 4.4: Pass the hidden layer vector of the end position of the head entity through the linear layer and the Softmax layer to predict the end position of the potential head entity in the current sentence;
[0025] Step 4.5: Decode the start position and end position of the potential head entity obtained in step 4.2 and step 4.4 according to the principle that the end position cannot be before the start position, and obtain a set of potential head entities corresponding to the relationship.
[0026] Step 5: Use the tail entity extractor in the entity decoder to detect the tail entity corresponding to each potential relation and head entity. The specific process is as follows:
[0027] Step 5.1: Detect the starting position of the tail entity, concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2, the potential relationship vector in step 3, the hidden layer vector at the starting position of the head entity in step 4.1, and the hidden layer vector at the end position of the head entity in step 4.3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector at the starting position of the tail entity;
[0028] Step 5.2: Pass the hidden layer vector of the start position of the tail entity through the linear layer and the Softmax layer to predict the start position of the potential tail entity in the current sentence;
[0029] Step 5.3: Detect the end position of the tail entity, concatenate the hidden layer vector of the start position of the potential tail entity in step 5.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the tail entity;
[0030] Step 5.4: Pass the hidden layer vector of the end position of the tail entity through the linear layer and the Softmax layer to predict the end position of the potential tail entity in the current sentence;
[0031] Step 5.5: Decode the start position and end position of the potential tail entity obtained in step 5.2 and step 5.4 according to the principle that the end position cannot be before the start position, and obtain the potential tail entity corresponding to the potential relationship and the head entity.
[0032] Step 6: Get the entity relationship triple and add the triple to the collection. The specific method is as follows:
[0033] The potential relations existing in each sentence and the head entity and tail entity corresponding to the relations are obtained through the relation decoder and entity decoder, and (head entity, relation, tail entity) is added to the triple set, and the entity relation extraction task is decoded and completed.
[0034] The beneficial effects of adopting the above technical solution are:
[0035] 1. The method provided by the present invention first detects the relationship contained in the text according to the semantic information of the text, and then regards the extracted relationship as an additional feature to guide the extraction process of entity pairs (head entity, tail entity), that is, the problem of overlapping triples can be solved through a cascaded linear extraction method, and a more accurate entity relationship extraction method is implemented, providing strong support for the social field.
[0036] 2. The method provided by the present invention designs two cascade decoders, a relation decoder and an entity decoder. Entity relation triples are obtained through these two decoders, thereby improving the evaluation index of the entity relation extraction task. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of a cascade linear entity relationship extraction method for social text in an embodiment of the present invention;
[0038] Figure 2 is a schematic diagram of a cascade linear model in an embodiment of the present invention;
[0039] Figure 3 Schematic diagram of a physical decoder in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0041] like Figure 1 As shown, the cascade linear entity relationship extraction method for social text in this embodiment is described as follows.
[0042] The public entity relationship extraction datasets used in this embodiment are NYT and WebNLG datasets.
[0043] Step 1: Obtain a public entity relationship extraction dataset with overlapping entity relationships to simulate social texts with overlapping entity relationships, and preprocess the obtained public dataset;
[0044] The method for preprocessing the public data set is as follows:
[0045] Step 1.1: Use the BertTokenizer in the pre-trained model BERT to segment each sentence in the dataset and convert the words in the segmented sentences into ID numbers;
[0046] In this embodiment, the sentence X is defined as "x 1 x 2 x 3 …x n ", the sentence after word segmentation is X = {[CLS], x 1 ,x 2 ,…,x m ,[SEP]}, where "[CLS]" and "[SEP]" are special words added to the beginning and end of sentences by the pre-trained model BERT, "[CLS]" is a special word used for classification, and "[SEP]" is a special word used to separate different sentences. After the sentence in the dataset completes the word segmentation operation, each word in the sentence is converted into a corresponding ID number according to the word library table in the pre-trained model BERT.
[0047] Step 1.2: Divide the word-segmented dataset into batches randomly, and align the sentences in each batch of datasets with the length of the longest sentence in the batch.
[0048] In this embodiment, the sentences in the entire data set are randomly divided into batches of 8, and each batch of data sets is filled with the longest sentence length in the batch of data sets, and the filling method is to fill with ID sequence number 0.
[0049] Step 2: Use the pre-trained model BERT as the basic encoder and encode the sentences in the batch dataset to obtain the contextual semantic vector of the sentence and the word vector representation in the sentence. The process is as follows:
[0050] Step 2.1: Use the pre-trained model BERT as the base encoder;
[0051] Step 2.2: The word IDs corresponding to the sentences in the batch dataset are used as input to the word embedding layer, which maps the word IDs to word vectors.
[0052] Step 2.3: After the sentence is mapped into a word vector through the word embedding layer, it is input into the pre-trained model BERT. The output of BERT is the final word vector representation after the sentence is encoded, denoted as h i ;
[0053] Step 2.4: Take the word vector corresponding to the special word "[CLS]" at the beginning of the sentence from the output of the pre-trained model BERT, pass the word vector through the pooling layer, and use the output vector of the pooling layer as the contextual semantic vector of the sentence, denoted as h p .
[0054] Step 3: Construct a relation decoder, whose structure includes a linear layer and a Sigmoid layer. Use the relation decoder to detect the potential relations contained in the sentence and obtain the vector representation of the potential relations. The process is as follows:
[0055] In this embodiment, there is a predefined relationship set in the public data set, and the relationship set R is defined as {r 1 ,r 2 ,...r j ,...,r k}, where r j represents the jth relation in the relation set, and k is the total number of relations. For a given sentence X, the goal of the relation decoder is to predict the subset of potential relations in the relation set R that belong to sentence X.
[0056] Step 3.1: The contextual semantic vector h of the sentence obtained in step 2 p After the linear layer and the Sigmoid layer, the potential relationship contained in the current sentence is classified;
[0057] The relevant formula is as follows:
[0058]
[0059] Among them, Linear(·) represents the linear layer, Sigmoid(·) represents the activation function, Represents the score of the i-th relation in the relation set R. The contextual semantic vector h of the sentence p After the linear layer and activation function, the score value corresponding to each relationship in the relationship set is between 0 and 1. If the score of is higher than a given threshold, the relation decoder will regard the ith relation as one of the potential relations of the current sentence X. In the specific implementation of the present invention, the threshold set is 0.5.
[0060] Step 3.2: Define a relationship embedding layer and input the ID of the potential relationship classified in step 3.1 into the relationship embedding layer. The output of the relationship embedding layer is the vector representation of the potential relationship.
[0061] In this embodiment, for a set of k relations R = {r 1 ,r 2 ,...r j ,...,r k}, define the relationship vector lookup table corresponding to R as To find the relationship corresponding to the relationship vector lookup table V r The dimension of the vector in is 300.
[0062] Step 4: Construct an entity decoder, which consists of a head entity extractor and a tail entity extractor, such as Figure 3 As shown;
[0063] The structures of the head entity extractor and the tail entity extractor both include: a bidirectional LSTM layer, a linear layer and a Softmax layer; according to first extracting the relationship, then extracting the head entity, and finally extracting the tail entity, this cascade linear extraction method, such as Figure 2 As shown, the head entity extractor is used to extract the head entity corresponding to the potential relationship detected in step 3. The specific process is as follows:
[0064] Step 4.1: Detect the starting position of the head entity, concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2 with the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the starting position of the head entity, which is recorded as
[0065] The relevant formula is as follows:
[0066]
[0067] Among them, Concat(·) represents the vector concatenation operation, and BiLSTM(·) represents the bidirectional LSTM model.
[0068] Step 4.2: Pass the hidden layer vector of the start position of the head entity through the linear layer and the Softmax layer to predict the start position of the potential head entity in the current sentence;
[0069] The relevant formula is as follows:
[0070]
[0071] Among them, Linear(·) represents the linear layer, Softmax(·) represents the activation function, Indicates whether each word is predicted as the starting position score. For each word in the sentence, the corresponding The dimension is 2, index 0 and index 1 represent "the starting position that does not belong to the potential head entity" and "the starting position that belongs to the potential head entity" respectively, and the index position with the largest value in these two indexes is selected, that is, index 0 is selected to indicate that the current word in the sentence is not the starting position of the potential head entity, and index 1 is selected to indicate that the current word in the sentence is the starting position of the potential head entity.
[0072] Step 4.3: Detect the end position of the head entity, concatenate the hidden layer vector of the start position of the potential head entity in step 4.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the head entity;
[0073] The method of detecting the end position and the start position is similar. The difference is that the start position of the potential head entity is hidden in the vector information when inputting. With potential relationship vector and position vector information After concatenation, it is input into the bidirectional LSTM. The relevant formula is as follows:
[0074]
[0075] in, It is the position vector information, which represents the relative distance vector between the word at the i-th position in the sentence and the potential head entity start position closest to the i-th position. The specific implementation method is that if there is no potential head entity start position within a distance of 10 before the current i-th position, the relative distance value of the current i-th position is set to 499, otherwise it is set to the actual relative distance value of the potential head entity start position closest to the current i-th position. After obtaining the relative distance value of each position in the sentence, the relative distance value is mapped into a relative distance vector through the position embedding layer. The position embedding layer is a randomly initialized position vector lookup table that will be continuously updated during the training process.
[0076] Step 4.4: Pass the hidden layer vector of the end position of the head entity through the linear layer and the Softmax layer to predict the end position of the potential head entity in the current sentence;
[0077] The relevant formula is as follows:
[0078]
[0079] in, Indicates the score of whether each word is predicted as the end position of the potential head entity. Similar to predicting the start position of the potential head entity, for each word in the sentence, select the index position with the largest value between index 0 and index 1, that is, select index 0 to indicate that the current word in the sentence is not the end position of the potential head entity, and select index 1 to indicate that the current word in the sentence is the end position of the potential head entity.
[0080] Step 4.5: Decode the start and end positions of the potential head entities obtained in steps 4.2 and 4.4 according to the principle that the end position cannot be before the start position, and obtain the set of potential head entities corresponding to the relationship, denoted as EntityH = {e 1 ,e 2 ,...,e h}.
[0081] The specific decoding algorithm is as follows:
[0082] 1) Define the sentence sequence length as N, and each position number is 1 to N; the potential sequence of the word in the sentence as the starting position of the potential head entity is {HS}, and the potential sequence of the word in the sentence as the ending position of the potential head entity is {HE};
[0083] 2) Define i as 1 in its initial value, and loop from 1 to N in the start position sequence {HS}. If the value of position index i in {HS} is 1, it means that the word at the current position is the start position of the potential head entity, and go to 3) to execute. Otherwise, add 1 to i and continue looping. After the {HS} loop is finished, go to 4);
[0084] 3) Define the initial value of j as i, which means that j loops from i to N in the end position sequence {HE} to find the end position of the potential head entity. Similarly, if the value of position index j in {HE} is 1, it means that the word at the current position is the end position of the potential head entity. After finding the end position, add the word between i and j as the head entity to the potential head entity set EntityH; if the value of position index j in {HE} is 0, j is added by 1 and the loop continues. After the {HE} loop ends, go to 2);
[0085] 4) The {HS} loop ends, indicating that all potential header entities have been decoded and added to the potential header entity set EntityH, and the potential header entity decoding algorithm ends.
[0086] Step 5: Use the tail entity extractor in the entity decoder to detect the tail entity corresponding to each potential relation and head entity. The specific process is as follows:
[0087] Step 5.1: Detect the starting position of the tail entity. Concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2, the potential relationship vector in step 3, the hidden layer vector at the starting position of the head entity in step 4.1, and the hidden layer vector at the end position of the head entity in step 4.3. The concatenated vector passes through the bidirectional LSTM layer to obtain the hidden layer vector at the starting position of the tail entity, which is recorded as
[0088] The relevant formula is as follows:
[0089]
[0090]
[0091] Among them, Sum(·) represents the vector summation operation, is the vector information of the head entity, and It is the hidden layer vector of the start position and end position of the i-th head entity in the head entity set EntityH, and the sum of the two is taken as the vector information of the i-th head entity.
[0092] Step 5.2: Pass the hidden layer vector of the start position of the tail entity through the linear layer and the Softmax layer to predict the start position of the potential tail entity in the current sentence;
[0093] The relevant formula is as follows:
[0094]
[0095] Among them, Linear(·) represents the linear layer, and Softmax(·) represents the activation function. Similar to the starting position of the prediction head entity, Indicates whether each word is predicted as the score of the starting position of the potential tail entity. For each word in the sentence, the corresponding The dimension is 2, index 0 and index 1 represent "the starting position that does not belong to the tail entity" and "the starting position that belongs to the tail entity" respectively, and the index position with the largest value between these two indexes is selected, that is, index 0 is selected to indicate that the current word in the sentence is not the starting position of the potential tail entity, and index 1 is selected to indicate that the current word in the sentence is the starting position of the potential tail entity.
[0096] Step 5.3: Detect the end position of the tail entity, concatenate the hidden layer vector of the start position of the potential tail entity in step 5.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the tail entity;
[0097] When detecting the end position, the starting position of the potential tail entity should be hidden vector information With potential relationship vector and position vector information After concatenation, it is input into the bidirectional LSTM. The relevant formula is as follows:
[0098]
[0099] Likewise, It is the position vector information, which represents the relative distance vector between the word at the ith position in the sentence and the potential tail entity start position closest to the ith position. The specific implementation method is that if there is no potential tail entity start position within a distance of 10 before the current ith position, the relative distance value of the current ith position is set to 499, otherwise it is set to the actual relative distance value of the potential tail entity start position closest to the current ith position. After obtaining the relative distance value of each position in the sentence, the relative distance value is mapped into a relative distance vector through the position embedding layer.
[0100] Step 5.4: Pass the hidden layer vector of the end position of the tail entity through the linear layer and the Softmax layer to predict the end position of the potential tail entity in the current sentence;
[0101] The relevant formula is as follows:
[0102]
[0103] in, A score vector indicating whether each word is predicted to be the end position of a potential tail entity.
[0104] Likewise, select The index position with the largest index value in the sentence is selected as 0, indicating that the current word in the sentence is not the end position of the potential tail entity; the index 1 is selected to indicate that the current word in the sentence is the end position of the potential tail entity.
[0105] Step 5.5: Decode the start position and end position of the potential tail entity obtained in step 5.2 and step 5.4 according to the principle that the end position cannot be before the start position, and obtain the potential tail entity corresponding to the potential relationship and the head entity.
[0106] The specific decoding algorithm is as follows:
[0107] 1) Define the length of the sentence sequence as N, and each position number is 1 to N; the potential sequence of the words in the sentence as the starting position of the potential tail entity is {TS}, and the potential sequence of the words in the sentence as the ending position of the potential tail entity is {TE}; define an empty entity relationship triple set Triple = {};
[0108] 2) Define i as 1 in its initial value, and loop from 1 to N in the start position sequence {TS}. If the value of position index i in {TS} is 1, it means that the word at the current position is the start position of the potential tail entity, and go to 3) to execute. Otherwise, add 1 to i and continue looping. After the {TS} loop ends, go to 4);
[0109] 3) Define the initial value of j as i, which means that j loops from i to N in the end position sequence {TE} to find the end position of the potential tail entity. Similarly, if the value of position index j in {TE} is 1, it means that the word at the current position is the end position of the potential tail entity. After finding the end position, the word between i and j is recorded as the tail entity as t l , the entity relationship triplet at this time is recorded as (e i ,r j ,t l ), (e i ,r j ,t l ) is added to the triple set Triple; if the value of position index j in {TE} is 0, j is increased by 1 and the loop continues. After the {TE} loop ends, go to 2);
[0110] 4) The {TS} loop ends, indicating that all potential tail entities and entity relationship triplets have been decoded and added to the potential set Triple, and the potential tail entity decoding algorithm ends.
[0111] Step 6: Get the entity relationship triple and add the triple to the collection. The specific method is as follows:
[0112] The potential relations existing in each sentence and the head entity and tail entity corresponding to the relations are obtained through the relation decoder and entity decoder, and (head entity, relation, tail entity) is added to the triple set, and the entity relation extraction task is decoded and completed.
[0113] Table 1 is a comparison of the test results of the entity relationship joint extraction model of this embodiment. Considering that the entities in social texts are complete, this embodiment uses the NYT dataset and WebNLG dataset with complete annotation entities. According to the test results, it can be seen that in the NYT dataset and WebNLG dataset with complete annotation entities, compared with the existing CaseRel model, the F1 score of the entity relationship joint extraction using the method of the present invention is higher, and the effect of extracting triples is better.
[0114] Table 1 Comparison of test results
[0115] Model NYT WebNLG CaseRel F1 score = 89.2% F1 score = 86.3% Our F1 score = 90.6% F1 score = 88.4%
Claims
1. A cascade linear entity relationship extraction method for social text, characterized in that: The steps include: Step 1: Obtain a public entity relationship extraction dataset with overlapping entity relationships to simulate social texts with overlapping entity relationships, and preprocess the obtained public dataset; Step 2: Use the pre-trained model BERT as the basic encoder and encode the sentences in the batch dataset to obtain the contextual semantic vector of the sentence and the word vector representation in the sentence; Step 3: Construct a relation decoder, whose structure includes a linear layer and a sigmoid layer. Use the relation decoder to detect the potential relations contained in the sentence and obtain the vector representation of the potential relations. Step 4: construct an entity decoder, which consists of a head entity extractor and a tail entity extractor; The structures of the head entity extractor and the tail entity extractor each include: a bidirectional LSTM layer, a linear layer, and a Softmax layer; according to the cascaded linear extraction method of first extracting the relationship, then extracting the head entity, and finally extracting the tail entity, the head entity extractor is used to extract the head entity corresponding to the potential relationship detected in step 3; Step 5: Use the tail entity extractor in the entity decoder to detect the tail entities corresponding to each potential relation and head entity; Step 6: Get the entity-relationship triple and add the triple to the collection.
2. The cascade linear entity relationship extraction method for social text according to claim 1 is characterized in that: The method for preprocessing the obtained public data set is as follows: Step 1.1: Use the BertTokenizer in the pre-trained model BERT to segment each sentence in the dataset and convert the words in the segmented sentences into ID numbers; Step 1.2: Divide the word-segmented dataset into batches randomly, and align the sentences in each batch of datasets with the length of the longest sentence in the batch.
3. The cascade linear entity relationship extraction method for social text according to claim 1 is characterized in that: The process of step 2 is as follows: Step 2.1: Use the pre-trained model BERT as the base encoder; Step 2.2: The word IDs corresponding to the sentences in the batch dataset are used as input to the word embedding layer, which maps the word IDs to word vectors. Step 2.3: After being mapped into a word vector by the word embedding layer, the sentence is input into the pre-trained model BERT. The output of BERT is the final word vector representation after the sentence is encoded; Step 2.4: Take the word vector corresponding to the special word "[CLS]" at the beginning of the sentence from the output of the pre-trained model BERT, pass the word vector through the pooling layer, and use the output vector of the pooling layer as the contextual semantic vector of the sentence.
4. The cascade linear entity relationship extraction method for social text according to claim 1 is characterized in that: The process of step 3 is as follows: Step 3.1: After the context semantic vector of the sentence obtained in step 2 passes through the linear layer and the Sigmoid layer, the potential relationship contained in the current sentence is classified; Step 3.2: Define a relationship embedding layer, input the ID of the potential relationship classified in step 3.1 into the relationship embedding layer, and the output of the relationship embedding layer is the vector representation of the potential relationship.
5. The cascade linear entity relationship extraction method for social text according to claim 1 is characterized in that: The process of step 4 is as follows: Step 4.1: Detect the starting position of the head entity, concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2 with the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the starting position of the head entity; Step 4.2: Pass the hidden layer vector of the start position of the head entity through the linear layer and the Softmax layer to predict the start position of the potential head entity in the current sentence; Step 4.3: Detect the end position of the head entity, concatenate the hidden layer vector of the start position of the potential head entity in step 4.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the head entity; Step 4.4: Pass the hidden layer vector of the end position of the head entity through the linear layer and the Softmax layer to predict the end position of the potential head entity in the current sentence; Step 4.5: Decode the start position and end position of the potential head entity obtained in step 4.2 and step 4.4 according to the principle that the end position cannot be before the start position, and obtain a set of potential head entities corresponding to the relationship.
6. The cascade linear entity relationship extraction method for social text according to claim 5 is characterized in that: The process of step 5 is as follows: Step 5.1: Detect the starting position of the tail entity, concatenate the word vector after sentence encoding output by the pre-trained model BERT in step 2, the potential relationship vector in step 3, the hidden layer vector at the starting position of the head entity in step 4.1, and the hidden layer vector at the end position of the head entity in step 4.3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector at the starting position of the tail entity; Step 5.2: Pass the hidden layer vector of the start position of the tail entity through the linear layer and the Softmax layer to predict the start position of the potential tail entity in the current sentence; Step 5.3: Detect the end position of the tail entity, concatenate the hidden layer vector of the start position of the potential tail entity in step 5.1 and the potential relationship vector obtained in step 3, and pass the concatenated vector through the bidirectional LSTM layer to obtain the hidden layer vector of the end position of the tail entity; Step 5.4: Pass the hidden layer vector of the end position of the tail entity through the linear layer and the Softmax layer to predict the end position of the potential tail entity in the current sentence; Step 5.5: Decode the start position and end position of the potential tail entity obtained in step 5.2 and step 5.4 according to the principle that the end position cannot be before the start position, and obtain the potential tail entity corresponding to the potential relationship and the head entity.
7. The cascade linear entity relationship extraction method for social text according to claim 1 is characterized in that: The specific method of step 6 is as follows: The potential relations existing in each sentence and the head entity and tail entity corresponding to the relations are obtained through the relation decoder and entity decoder, and (head entity, relation, tail entity) is added to the triple set, and the entity relation extraction task is decoded and completed.
Citation Information
Patent Citations
Multi-entity relationship joint extraction method and device based on text generation
CN110196913A
Text conceptual graph construction method
CN110532328A
Entity relationship extraction method based on ordered structure coding pointer network decoding
CN113553850A
Multi-triplet extraction method based on entity-relation joint extraction model
US20200073933A1
Entity and relationship joint extraction method oriented to software bug knowledge
US20210240603A1
