Attribute extraction method, device and storage medium
By combining the BERT model and Bi-LSTM, using the multi-head attention mechanism and word boundary feature enhancement, the problem of long-distance dependence and insufficient generalization ability in attribute extraction is solved, the accuracy and generalization ability of attribute extraction are improved, and it can be better Identify unregistered words and understand sentence structure.
Patent Information
- Application Number
- CN202210458635.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-04-15
AI Technical Summary
In the existing technology, attribute extraction methods have problems of long-distance dependence and insufficient generalization capabilities, resulting in information loss and the inability to effectively extract new attribute values.
The BERT model is combined with the bidirectional long short-term memory layer Bi-LSTM. Through the multi-head attention mechanism and word boundary feature enhancement, the pre-processed text is processed to improve the model generalization ability, identify attribute value boundaries, and use automatic word segmentation tools to obtain word segmentations. Results and word segmentation vectors, feature representations are added to enhance the model's lexical information capture capability.
It effectively improves the accuracy and generalization ability of attribute extraction, can identify more unregistered words and improve sentence structure understanding, and alleviates the problem of difficult extraction of unanswered data and unregistered words in the machine reading comprehension model.
Smart Images

Figure CN114817564B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field, and in particular to an attribute extraction method, equipment, device and computer storage medium. Background Art
[0002] Among the existing technologies, e-commerce, film and television, medical and other fields have begun to build high-quality knowledge graphs in their fields. The attribute extraction task is one of the important links in building knowledge graphs. This task is aimed at unstructured text in vertical fields and aims to extract entity-related attributes and their attribute values. Taking e-commerce data as an example, given a product category "sweater" and its description text "Foreign Trade Men's Autumn Hooded Sweater Excellent Splicing Brushed Cloth Hip-Hop Sweater Large Size Jacket", the goal is to extract attributes and attribute values related to "sweater" from the description text, such as "Material-Brushed Cloth", "Style-Hip-Hop", "Material" and "Style" are the attributes of "sweater", and "Brushed Cloth" and "Hip-Hop" are the corresponding attribute values. The attribute extraction task can improve the completeness of the expression of the entity nodes of the knowledge graph and enhance the interactive experience of users and the knowledge graph.
[0003] Existing attribute extraction methods are mainly divided into rule-based methods, traditional machine learning-based methods, and deep learning-based methods. Rule-based methods require manual construction of domain-related rule templates, and use the constructed rule templates to match the attributes and attribute values corresponding to entities in natural language texts. This method formulates domain-related rules based on a single domain, and has the problem of poor applicability. When the scale of rules becomes larger, it will make the entire rule set difficult to maintain. At the same time, once a text that cannot be covered by new rules appears, additional rule design is required, which is a time-consuming and labor-intensive process. Traditional machine learning-based methods usually use supervised learning strategies. This method requires a large amount of annotated corpus to train the model so that the model can fully learn the attribute characteristics contained in the data.
[0004] In recent years, deep learning methods have been widely used in various information extraction tasks in natural language processing, and have achieved good results in tasks such as named entity recognition, event extraction, relationship extraction, and entity relationship joint extraction. For example, Recurrent Neural Network (RNN), Long Short-Term Memory (LSTM), and Gated Recurrent Unit (GRU) have outstanding performance in information extraction from natural text. In addition, some researchers have combined the attention mechanism with BiLSTM-CRF to capture the intrinsic semantic connection of product titles, so that the model can better extract the attributes and attribute values corresponding to the product titles. At present, pre-trained language models have become the mainstream encoders for information extraction tasks such as attribute extraction due to their excellent encoding capabilities, such as BERT, ALBERT, RoBERTa, ELECTRA, XLNet, etc.
[0005] The existing technologies related to attribute extraction have the following disadvantages:
[0006] 1. Feature extraction method based on manual templates Manual filtering of data is time-consuming and labor-intensive, and the fuzzy matching method is difficult to guarantee the extraction quality. Templates built based on expert knowledge are expensive, and the coverage of templates is limited and cannot be applied flexibly. This method cannot extract new attribute values that do not appear in the data.
[0007] 2. The feature extraction method based on bidirectional long short-term memory neural network is difficult to solve the long-distance dependency problem and is prone to information loss.
[0008] 3. The method based on pre-trained language model does not fully consider vocabulary information, and there are problems such as difficulty in judging entity boundaries and insufficient generalization ability. Summary of the invention
[0009] Therefore, the technical problem to be solved by the present invention is to overcome the problems of long-distance dependence and insufficient generalization ability in the prior art.
[0010] In order to solve the above technical problems, the present invention provides an attribute extraction method, device, apparatus and computer storage medium, including:
[0011] Input the preprocessed questions and text into the pre-trained attribute extraction model. The question is the triple after the head and tail entities are replaced by MASK tags, which is the structured information.
[0012] The BERT model is used to calculate the global vector representation of the question and the global vector representation of the first text, and the first text global vector representation is encoded by a bidirectional long short-term memory layer Bi-LSTM to obtain the second text global vector representation;
[0013] Using a multi-head attention mechanism, the second text global vector representation interacts with the question global vector representation to obtain a text global vector representation with generalized characteristics of question structured information;
[0014] Input the text into an automatic word segmentation tool to obtain a word segmentation result and a word segmentation vector representation of the text;
[0015] According to the absolute position index of the first and last labels of the words in the word segmentation result, the word segmentation vector representation is added to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information to obtain the final text vector representation;
[0016] Predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
[0017] Preferably, the step of calculating the problem global vector representation and the first text global vector representation using the BERT model, and encoding the first text global vector representation through a bidirectional long short-term memory layer Bi-LSTM to obtain the second text global vector representation includes:
[0018] The question Q and the text S are segmented, and each word is represented by a labeled word vector TE (w i ), distinguish the word vector SE(w i ), and the position word vector PE(w i ) to obtain the vector representation of the question and the text;
[0019] The vector representation of the question and the text is input into the BERT model to obtain the encoded global vector representation of the question And the first global vector representation of the text in The vector representation of each character in the question after BERT encoding, The vector representation of each character in the text after BERT encoding;
[0020] The first text global vector representation X is represented by the bidirectional long short-term memory layer Bi-LSTM s Encode to obtain the second text global vector representation in Vector representation of each character in the text after Bi-LSTM encoding.
[0021] Preferably, the bidirectional long short-term memory layer Bi-LSTM is used to represent the first text global vector X s Encode to obtain the second text global vector representation include:
[0022] Calculate the first text global vector X s The hidden state representation of the second text is obtained by encoding the global vector representation of the second text
[0023] The hidden state o at each moment i i From the hidden state of the forward LSTM and the hidden state of the backward LSTM The calculation formula is as follows:
[0024]
[0025]
[0026]
[0027] Preferably, the step of adding the word segmentation vector representation to the corresponding position of the global vector representation of the text having the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result to obtain the final text vector representation comprises:
[0028] The word position in the text segmentation result is expressed as:
[0029] P[a i ,t i ]={p 1 [a 1 ,t 1 ],p 2 [a 2 ,t 2 ]…p n [a n ,t n ]}, where a i ,t i Respectively represent the absolute position index of the first and last tags of each word in the text, p n Indicates the nth word;
[0030] In the global vector representation of text with generalized characteristics of question structured information The word segmentation vector representation V containing the word temporal features after Bi-LSTM and normalization is added to the corresponding position of the word segmentation vector representation V to obtain the final text vector representation H v .
[0031] Preferably, predicting the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value comprises:
[0032] Two linear layers are used to predict the probability of each word in the final text vector as the starting position s and the ending position e respectively:
[0033] s i =sigmoid(FNN(H v ))
[0034] e i =sigmoid(FNN(H v )
[0035] Among them, s i represents the probability that the i-th word in the text is the starting position of the attribute value, e i Indicates the probability that the i-th word in the text is the end position of the attribute value;
[0036] The starting position and its corresponding ending position are used as the coordinates of the target attribute value.
[0037] Preferably, the training process of the attribute extraction model includes an attribute value boundary prediction task, and the specific steps of the attribute value boundary prediction task are:
[0038] Construct the corresponding training set;
[0039] The model is trained using the training set until the loss function converges, wherein the loss function includes the loss of each word as the starting position. s and the loss at the end position e :
[0040]
[0041]
[0042] in, and It is a boundary representation of the true attribute value.
[0043] Preferably, the training process of the attribute extraction model includes a text attribute type classification task, and the specific steps of the text attribute type classification task are:
[0044] The text and questions in the training set are represented in the CLS Token output of the BRET model and As text feature representation and attribute type feature representation;
[0045] Using the multi-head attention mechanism and Interact to obtain comprehensive classification features h Att ;
[0046] The classifier is used to judge whether there is the attribute value to be extracted related to the attribute type to be extracted in the text according to the comprehensive classification feature training, so that the model can pay more attention to the attribute value related to the attribute to be extracted in the text. The loss function is:
[0047]
[0048] Among them, y j Represents the true value of the true category, P j Represents the predicted value of the j-th attribute type.
[0049] The present invention also provides a device for attribute extraction, comprising:
[0050] An input module is used to input the preprocessed questions and text into a pre-trained attribute extraction model. The question is a triple after the head and tail entities are replaced by MASK tags, which is structured information;
[0051] An encoding module, used to calculate a global vector representation of the question and a global vector representation of the first text using a BERT model, and encode the first global vector representation of the text using a bidirectional long short-term memory layer Bi-LSTM to obtain a second global vector representation of the text;
[0052] An interaction module, configured to use a multi-head attention mechanism to interact the second text global vector representation with the question global vector representation to obtain a text global vector representation having a generalized feature of question structured information;
[0053] The word segmentation module is used to input the text into the automatic word segmentation tool to obtain the word segmentation result and word segmentation vector representation of the text;
[0054] A word boundary enhancement module, for adding the word segmentation vector representation to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result, to obtain the final text vector representation;
[0055] The extraction module is used to predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
[0056] The present invention also provides a device for attribute extraction, comprising:
[0057] The memory is used to store computer programs; the processor is used to implement the above-mentioned attribute extraction steps when executing the computer program.
[0058] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned attribute extraction method are implemented.
[0059] The above technical solution of the present invention has the following advantages compared with the prior art:
[0060] The present invention transforms the attribute extraction task into a fragment extraction reading comprehension task. The model uses BERT-Bi-LSTM as the encoding module, encodes the input text and the question respectively, and annotates the head and tail entities in the triple with mask tags. While using context information, the label is not exposed. This structured information is used as a question to enhance the generalization ability of the model; and the bidirectional long short-term memory layer can integrate the forward and reverse information of the text, so that the model fully captures the temporal characteristics and semantic characteristics of the text; the word boundary feature enhancement method is used to help the model capture the boundary characteristics of the attribute value. The word boundary feature enhancement method is based on the word segmentation result, and the complete vocabulary information is added to the starting and ending positions of the vocabulary. Then, the multi-head attention mechanism is used to make the word segmentation vector interact with the global features of the text to integrate the vocabulary information. The word boundary feature strengthens the model's judgment on the head and tail positions of the attribute value, deepens the model's control over the attribute value boundary, helps the model understand the sentence structure, and helps the model recognize more unregistered words. The present invention utilizes word boundary information and text attribute features to alleviate the problem that no-answer data is difficult to use in machine reading comprehension models and that unregistered words are difficult to extract in attribute extraction tasks, thereby effectively improving the effect of entity attribute extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0062] Figure 1 It is a flow chart for realizing attribute extraction of the present invention;
[0063] Figure 2 is a specific structural diagram of the vocabulary enhancement module of the present invention;
[0064] Figure 3 It is the overall structure diagram of the attribute extraction model of the present invention;
[0065] Figure 4 It is a structural block diagram of an attribute extraction device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The core of the present invention is to provide a method, device, equipment and computer storage medium for attribute extraction, which can fully obtain context information and improve the generalization ability of the model.
[0067] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0068] Please refer to Figure 1 , Figure 1 This is a flowchart for implementing the attribute extraction provided by the present invention; the specific operation steps are as follows:
[0069] S101: Input the preprocessed question and text into a pre-trained attribute extraction model, wherein the question is a triple after the head and tail entities are replaced by MASK tags, i.e., structured information;
[0070] The questions and texts will be pre-processed into the form of "[CLS]+text+[SEP]", "[CLS]+question+[SEP]" before input;
[0071] The triple is head entity-attribute-tail entity (attribute value);
[0072] The question is replaced by the MASK mark with the head and tail entities as "[CLS]+[mask] attribute[mask]+[SEP]".
[0073] S102: using the BERT model to calculate and obtain a global vector representation of the question and a global vector representation of the first text, and encoding the first global vector representation of the text through a bidirectional long short-term memory layer Bi-LSTM to obtain a second global vector representation of the text;
[0074] BERT uses a stacked 12-layer Transformer Encoder architecture that can obtain global features of text from different angles. Each layer consists of two substructures: a multi-head attention layer and a feedforward neural network. The output of each substructure is respectively connected by residual connections and layer normalization. Multi-head attention can obtain self-attention vectors of multiple subspaces, and concatenate the vectors of all subspaces to obtain the output of multi-head attention. U represents the multi-head attention vector, which represents the attention vector of the subspace. The feedforward neural network projects the output of the multi-head attention layer.
[0075] U = Concat(u 1 ,u 2 …u h )W u ,
[0076] FFN(x)=max(0,xW 1+b 1 )W 2 +b 2 ,
[0077] The question Q and the text S are segmented. The output after Chinese word segmentation is characters, and these characters are converted into corresponding IDs as the input of the model. Each character is represented by a labeled word vector TE (w i ), distinguish the word vector SE(w i ), and the position word vector PE(w i ), that is, E(w i )=TE(w i )+SE(w i )+PE(w i ), get the vector representation of the question and text;
[0078] The vector representation of the question and the text is input into the BERT model to obtain the encoded global vector representation of the question And the first global vector representation of the text in The vector representation of each character in the question after BERT encoding, The vector representation of each character in the text after BERT encoding;
[0079] Considering that recurrent neural networks are suitable for modeling serialized data, they have the problem of gradient vanishing or gradient exploding during training, and are difficult to handle long-distance dependencies. Therefore, Bi-LSTM is used to further integrate the temporal features of text. The bidirectional long short-term memory layer Bi-LSTM is used to represent the first text global vector X. s Encode to obtain the second text global vector representation in The vector representation of each character in the text after Bi-LSTM encoding;
[0080] Calculate the first text global vector X s The hidden state representation of the second text is obtained by encoding the global vector representation of the second text
[0081] The hidden state o at each moment i i From the hidden state of the forward LSTM and the hidden state of the backward LSTM The calculation formula is as follows:
[0082]
[0083]
[0084]
[0085] S103: using a multi-head attention mechanism to interact the second text global vector representation with the question global vector representation to obtain a text global vector representation with generalized characteristics of question structured information;
[0086] S104: Inputting the text into an automatic word segmentation tool to obtain a word segmentation result and a word segmentation vector representation of the text;
[0087] S105: adding the word segmentation vector representation to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result to obtain the final text vector representation;
[0088] The word position in the text segmentation result is expressed as:
[0089] [a i ,t i ]={p 1 [a 1 ,t 1 ],p 2 [a 2 ,t 2 ]…p n [a n ,t n ]}, where a i ,t i Respectively represent the absolute position index of the first and last tags of each word in the text, p n Indicates the nth word;
[0090] In the global vector representation of text with generalized characteristics of question structured information The word segmentation vector representation V containing the word temporal features after Bi-LSTM and normalization is added to the corresponding position of the word segmentation vector representation V to obtain the final text vector representation H v .
[0091] The decoding operation of the model depends on locating the starting and ending positions of the attribute value to complete the extraction of the attribute value. Therefore, the word boundary feature enhancement method uses the enhanced attribute value head and tail boundary features to help the model determine the attribute value boundary. The vocabulary enhancement module aims to incorporate vocabulary information on the basis of BERT-Bi-LSTM encoding to improve the model's grasp of the attribute value boundary. The vocabulary enhancement module consists of two parts, namely word boundary feature enhancement and text-segmentation information interaction. The word boundary feature enhancement method adds complete vocabulary information to the starting and ending positions of the vocabulary based on the segmentation results. The text-segmentation information interaction mainly uses the multi-head attention mechanism to make the segmentation vector interact with the global features of the text to incorporate vocabulary information.
[0092] S106: Predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
[0093] Two linear layers are used to predict the probability of each word in the final text vector being the starting position s and the ending position e respectively. The closer the probability value is to 1, the greater the possibility that the word is the starting position or the ending position:
[0094] s i =sigmoid(FNN(H v ))
[0095] e i =sigmoid(FNN(H v )
[0096] Among them, s i represents the probability that the i-th word in the text is the starting position of the attribute value, e i Indicates the probability that the i-th word in the text is the end position of the attribute value, and is calculated by a fully connected layer with the same structure but different parameters. By classifying each word individually to determine whether it is the start position, multiple start positions can be obtained, and similarly, multiple end positions can also be obtained;
[0097] The starting position and its corresponding ending position are used as the coordinates of the target attribute value.
[0098] The present invention transforms the attribute extraction task into a fragment extraction reading comprehension task. The model uses BERT-Bi-LSTM as the encoding module, encodes the input text and the question respectively, and annotates the head and tail entities in the triple with mask tags. While using context information, the label is not exposed. This structured information is used as a question to enhance the generalization ability of the model; and the bidirectional long short-term memory layer can integrate the forward and reverse information of the text, so that the model fully captures the temporal characteristics and semantic characteristics of the text; the word boundary feature enhancement method is used to help the model capture the boundary characteristics of the attribute value. The word boundary feature enhancement method is based on the word segmentation result, and the complete vocabulary information is added to the starting and ending positions of the vocabulary. Then, the multi-head attention mechanism is used to make the word segmentation vector interact with the global features of the text to integrate the vocabulary information. The word boundary feature strengthens the model's judgment on the head and tail positions of the attribute value, deepens the model's control over the attribute value boundary, helps the model understand the sentence structure, and helps the model recognize more unregistered words. The present invention utilizes word boundary information and text attribute features to alleviate the problem that no-answer data is difficult to use in machine reading comprehension models and that unregistered words are difficult to extract in attribute extraction tasks, thereby effectively improving the effect of entity attribute extraction.
[0099] Based on the above embodiments, this embodiment further describes the word enhancement module of S104-S105 in detail, as follows:
[0100] The word segmentation vector is input into Bi-LSTM and normalized to obtain the word segmentation vector representation V containing the temporal features of the words. Then, based on the absolute position index of the first and last labels of the words, the vector representation enhanced by the boundary features of the lexical information words is added to the corresponding position of the global feature vector.
[0101] by Figure 2 For example, the input text is "beige sweater". First, the input text is encoded by the BERT-Bi-LSTM module. At the same time, LTP is used to segment the text, and the segmentation result {"beige", "sweater"} and its corresponding segmentation vector representation V = {v 1 ,v 2 Then, in order to determine the actual position of the word boundary in the text, the absolute position representation P[s i ,e i ]={p 1 [1,2],p 2 [3,5]}. Finally, based on the absolute position of the word boundary, the complete vocabulary vector is added to the corresponding text feature vector to obtain the final text vector representation
[0102] Based on the above embodiments, this embodiment further describes the training process of the model of the present invention in detail, as follows:
[0103] Training the attribute extraction model includes the attribute value boundary prediction task:
[0104] Clean the corpus and build the corresponding training set;
[0105] The model is trained using the training set until the loss function converges, wherein the loss function includes the loss of each word as the starting position. s and the loss at the end position e :
[0106]
[0107]
[0108] in, and It is a boundary representation of the true attribute value.
[0109] Since existing technologies fail to combine external knowledge to enhance the model's understanding of attribute types, we train the attribute extraction model to also include the text attribute type classification task:
[0110] The text and questions in the training set are represented in the CLS Token output of the BRET model and As text feature representation and attribute type feature representation;
[0111] Using the multi-head attention mechanism and Interact to obtain comprehensive classification features h Att ;
[0112] The classifier is used to judge whether there is the attribute value to be extracted related to the attribute type to be extracted in the text according to the comprehensive classification feature training, so that the model can pay more attention to the attribute value related to the attribute to be extracted in the text. The loss function is:
[0113]
[0114] Among them, y j Represents the true value of the true category, P j Represents the predicted value of the j-th attribute type.
[0115] Using the joint training of attribute value boundary prediction task and text attribute type classification task, the loss is Loss = loss class +loss s +loss e .
[0116] We run the model on the test set (such as Figure 3By comparing with other baseline models, it is found that the method based on word boundary feature enhancement achieves the best effect, and the generalization ability of the model is significantly improved.
[0117] The present invention transforms the attribute extraction task into a fragment extraction reading comprehension task, and adopts a multi-task model for joint training of attribute extraction and text attribute judgment. The model uses BERT-Bi-LSTM as the encoding module, encodes the input text and the question respectively, and uses structured information as the question to enhance the generalization ability of the model. Then, the word boundary feature enhancement method is used to help the model capture the boundary features of the attribute value, and the vocabulary features are integrated on the basis of the global vector features in combination with the multi-head attention mechanism. At the same time, a text feature interaction method is designed to determine whether there is an attribute value corresponding to the question in the text. This method is jointly trained as an auxiliary task with the attribute value boundary prediction task. On the one hand, the word boundary feature of the present invention strengthens the model's judgment on the first and last positions of the attribute value, deepens the model's control over the attribute value boundary, and can help the model identify more unregistered words; on the other hand, combined with the text attribute feature perception task auxiliary model, it further helps the model improve its sensitivity to the attribute type, solves the problem of insufficient understanding of the attribute type by the model, and enables the model to pay more attention to the attribute values related to the attributes to be extracted in the text. In summary, the overall performance of the attribute extraction system is beneficially improved.
[0118] Please refer to Figure 4 , Figure 4 A structural block diagram of an attribute extraction device provided by an embodiment of the present invention; the specific device may include:
[0119] An input module 100 is used to input the preprocessed question and text into a pre-trained attribute extraction model. The question is a triple after the head and tail entities are replaced by MASK tags, that is, structured information;
[0120] The encoding module 200 is used to calculate the question global vector representation and the first text global vector representation by using the BERT model, and encode the first text global vector representation by a bidirectional long short-term memory layer Bi-LSTM to obtain a second text global vector representation;
[0121] An interaction module 300 is used to use a multi-head attention mechanism to interact the second text global vector representation with the question global vector representation to obtain a text global vector representation with generalized characteristics of question structured information;
[0122] The word segmentation module 400 is used to input the text into an automatic word segmentation tool to obtain the word segmentation result and word segmentation vector representation of the text;
[0123] The word boundary enhancement module 500 is used to add the word segmentation vector representation to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result to obtain the final text vector representation;
[0124] The extraction module 600 is used to predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
[0125] The machine vision-based surface defect detection device of this embodiment is used to implement the aforementioned attribute extraction method. Therefore, the specific implementation method of the attribute extraction device can be seen in the embodiment part of the aforementioned attribute extraction method. For example, the input module 100, the encoding module 200, the interaction module 300, the word segmentation module 400, the word boundary enhancement module 500, and the extraction module 600 are respectively used to implement steps S101, S102, S103, S104, S105 and S106 in the aforementioned attribute extraction method. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part, which will not be repeated here.
[0126] A specific embodiment of the present invention further provides a device for attribute extraction, comprising: a memory for storing a computer program; and a processor for implementing the steps of the above-mentioned attribute extraction method when executing the computer program.
[0127] A specific embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned attribute extraction method are implemented.
[0128] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0129] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0132] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A method for extracting attributes, characterized in that: include: Input the preprocessed questions and text into the pre-trained attribute extraction model. The question is the triple after the head and tail entities are replaced by MASK tags, which is the structured information. The BERT model is used to calculate the global vector representation of the question and the global vector representation of the first text, and the first text global vector representation is encoded by a bidirectional long short-term memory layer Bi-LSTM to obtain the second text global vector representation; Using a multi-head attention mechanism, the second text global vector representation interacts with the question global vector representation to obtain a text global vector representation with generalized characteristics of question structured information; Input the text into an automatic word segmentation tool to obtain a word segmentation result and a word segmentation vector representation of the text; According to the absolute position index of the first and last labels of the words in the word segmentation result, the word segmentation vector representation is added to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information to obtain the final text vector representation; Predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
2. The attribute extraction method according to claim 1, characterized in that: The method of using the BERT model to calculate the problem global vector representation and the first text global vector representation, and encoding the first text global vector representation through a bidirectional long short-term memory layer Bi-LSTM to obtain the second text global vector representation includes: The question Q and the text S are segmented, and each word is represented by a labeled word vector TE (w i ), distinguish the word vector SE(w i ), and the position word vector PE(w i ) to obtain the vector representation of the question and the text; The vector representation of the question and the text is input into the BERT model to obtain the encoded global vector representation of the question And the first global vector representation of the text in The vector representation of each character in the question after BERT encoding, The vector representation of each character in the text after BERT encoding; The first text global vector representation X is represented by the bidirectional long short-term memory layer Bi-LSTM s Encode to obtain the second text global vector representation in Vector representation of each character in the text after Bi-LSTM encoding.
3. The attribute extraction method according to claim 2, characterized in that: The first text global vector representation X is represented by the bidirectional long short-term memory layer Bi-LSTM s Encode to obtain the second text global vector representation include: Calculate the first text global vector X s The hidden state representation of the second text is obtained by encoding the global vector representation of the second text The hidden state o at each time i i From the hidden state of the forward LSTM and the hidden state of the backward LSTM The calculation formula is as follows:
4. The attribute extraction method according to claim 1, characterized in that: The step of adding the word segmentation vector representation to the corresponding position of the global vector representation of the text having the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result to obtain the final text vector representation includes: The word position in the text segmentation result is expressed as: P[a i ,t i ]={p1[a1,t1],p2[a2,t2]…p n [a n ,t n ]}, where a i ,t i , respectively represents the absolute position index of the first and last tags of each word in the text, p n Indicates the nth word; In the global vector representation of text with generalized characteristics of question structured information The word segmentation vector representation V containing the word temporal features after Bi-LSTM and normalization is added to the corresponding position of the word segmentation vector representation V to obtain the final text vector representation H v .
5. The attribute extraction method according to claim 4, characterized in that: The predicting the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value comprises: Two linear layers are used to predict the probability of each word in the final text vector as the starting position s and the ending position e respectively: s i =sigmoid(FNN(H v )) it i =sigmoid(FNN(H v ) Among them, s i represents the probability that the i-th word in the text is the starting position of the attribute value, e i Indicates the probability that the i-th word in the text is the end position of the attribute value; The starting position and its corresponding ending position are used as the coordinates of the target attribute value.
6. The attribute extraction method according to claim 5, characterized in that: The training process of the attribute extraction model includes an attribute value boundary prediction task, and the specific steps of the attribute value boundary prediction task are: Construct the corresponding training set; The model is trained using the training set until the loss function converges, wherein the loss function includes the loss of each word as the starting position. s and the loss at the end position e : in, and It is a boundary representation of the true attribute value.
7. The attribute extraction method according to claim 6, characterized in that: The training process of the attribute extraction model includes a text attribute type classification task, and the specific steps of the text attribute type classification task are: The text and questions in the training set are represented in the CLS Token output of the BERT model and As text feature representation and attribute type feature representation; Using the multi-head attention mechanism and Interact to obtain comprehensive classification features h Att ; The classifier is used to judge whether there is the attribute value to be extracted related to the attribute type to be extracted in the text according to the comprehensive classification feature training, so that the model can pay more attention to the attribute value related to the attribute to be extracted in the text. The loss function is: Among them, y j Represents the true value of the true category, P j Represents the predicted value of the j-th attribute type.
8. A device for extracting attributes, characterized in that: include: An input module is used to input the preprocessed questions and text into a pre-trained attribute extraction model. The question is a triple after the head and tail entities are replaced by MASK tags, which is structured information; An encoding module, used to calculate a global vector representation of the question and a global vector representation of the first text using a BERT model, and encode the first global vector representation of the text using a bidirectional long short-term memory layer Bi-LSTM to obtain a second global vector representation of the text; An interaction module, configured to use a multi-head attention mechanism to interact the second text global vector representation with the question global vector representation to obtain a text global vector representation having generalized characteristics of question structured information; A word segmentation module, used for inputting the text into an automatic word segmentation tool to obtain a word segmentation result and a word segmentation vector representation of the text; A word boundary enhancement module, used for adding the word segmentation vector representation to the corresponding position of the global vector representation of the text with the generalized feature of the question structured information according to the absolute position index of the first and last labels of the words in the word segmentation result, to obtain the final text vector representation; The extraction module is used to predict the boundary of the attribute value to be extracted in the final text vector representation to obtain the target attribute value.
9. A device for extracting attributes, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of a method for attribute extraction as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the attribute extraction method as claimed in any one of claims 1 to 7 are implemented.
