Method, device, terminal and storage medium for extracting relational features in remote supervision
By inserting labels identifying relationship characteristics between entities in the remote supervision method, generating sentence vectors and outputting the relationship feature extraction results, the problem of inaccurate relationship extraction caused by ignoring sentence structure in the prior art is solved, and more accurate feature extraction is achieved.
Patent Information
- Application Number
- CN202110579264.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-26
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2041-05-26
AI Technical Summary
The existing remote supervision method ignores the sentence structure during the relationship extraction process, resulting in the loss of the structural information of the sentence itself and the attribute information of the entity pair, making it difficult to ensure the accuracy of the relationship extraction.
By inserting labels identifying relationship characteristics between entities in the to-process corpus, the model generate sentence vector is represented using text, and the relationship feature extraction results are output through the classification model. This method embeds tags in the corpus, labels the relationship characteristics between entities pairs, improves the representation of sentence vectors, and captures the relationship between entities.
The representation method of sentence vector features has been effectively improved, better capture the relationship between entities, and improve the accuracy of prediction results during feature extraction.
Smart Images

Figure CN113626576B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and in particular, relates to a method, device, terminal and storage medium for extracting relational features in remote supervision. Background Art
[0002] Distant supervision is a common approach in relation extraction. It is a method of annotating plain text through existing entity relationships in the knowledge graph. The main idea of this method is that if a pair of entities has a relationship in an existing database, then all training corpora containing this pair of entities are considered to represent this relationship to some extent.
[0003] However, in actual processing, many corpora containing entity pairs do not have sentence relationships consistent with the entity pairs contained. Therefore, a lot of noise will appear when extracting features through remote supervision.
[0004] To solve this problem, in the application of remote supervision methods, the approach usually adopted is: by marking the corpus, all corpora containing the same entity pairs are put into one package, and based on the knowledge graph, the relationship between the corpora placed in the package is marked as the relationship between the entity pairs. In this way, many packages are obtained, and the word representations in the sentences (i.e., corpora) in each package are obtained through convolutional neural networks and recursive neural networks, and the sentence vector representation is obtained through pooling, and the vector representation of the entire package is obtained based on the sentence vector.
[0005] This method is mainly based on the generation of word vectors and sentence vectors for the corpus to achieve the extraction of sentence features and improve the noise in the training data. These corpus feature representation methods can achieve good results, but this method also ignores the sentence structure, loses the structural information of the sentence itself and the attribute information of the entity pairs contained in the sentence, and it is difficult to truly ensure the accuracy of relationship extraction during remote supervision. Summary of the invention
[0006] The embodiments of the present application provide a method, device, terminal and storage medium for extracting relational features in remote supervision to solve the problem that the sentence structure is ignored in the application of existing remote supervision methods, the structural information of the sentence itself and the attribute information of the entity pairs contained in the sentence are lost, and it is difficult to truly ensure the accuracy of relation extraction in the remote supervision process.
[0007] A first aspect of an embodiment of the present application provides a method for extracting relational features in remote supervision, comprising:
[0008] Get the corpus to be processed containing entity pairs;
[0009] In the corpus to be processed, inserting labels for identifying the relationship features between entities into the initial position and the final position of each entity in the entity pair respectively;
[0010] Based on the corpus to be processed after the tag is inserted, generating a sentence vector corresponding to the corpus to be processed through a text representation model; wherein the sentence vector is obtained by concatenating the vector representations corresponding to the tag in the output result of the text representation model;
[0011] According to the sentence vector, the relation feature extraction result is output through the classification model.
[0012] A second aspect of an embodiment of the present application provides a remote supervision relation feature extraction device, comprising:
[0013] An acquisition module is used to obtain the corpus to be processed containing entity pairs;
[0014] A label insertion module, used to insert labels for identifying the relationship features between entities at the initial position and the final position of each entity in the entity pair in the corpus to be processed;
[0015] A generation module is used to generate a sentence vector corresponding to the corpus to be processed through a text representation model based on the corpus to be processed after the tag is inserted; wherein the sentence vector is obtained by concatenating the vector representations corresponding to the tag in the output result of the text representation model;
[0016] The extraction module is used to output the relation feature extraction result through the classification model according to the sentence vector.
[0017] A third aspect of an embodiment of the present application provides a terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0018] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0019] A fifth aspect of the present application provides a computer program product, which, when executed on a terminal, enables the terminal to execute the steps of the method described in the first aspect.
[0020] As can be seen from the above, in the embodiment of the present application, by obtaining a corpus to be processed containing entity pairs, in the corpus to be processed, the labels for identifying the relationship features between entities are respectively inserted at the initial position and the final position of each entity in the entity pair, and based on the corpus to be processed after the labels are inserted, a sentence vector corresponding to the corpus to be processed is generated through a text representation model, wherein the sentence vector is obtained by concatenating the vector representations corresponding to the labels in the output results of the text representation model, and the relationship feature extraction results are output through a classification model based on the sentence vector. This scheme embeds labels in the corpus to be processed to achieve the annotation of relevant information between entity pairs, which effectively improves the overall representation of sentence vector features, better captures the relationships between entities, and improves the accuracy of prediction results during feature extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 This is the process of the method for extracting relational features in remote supervision provided in the embodiment of the present application. Figure 1 ;
[0023] Figure 2 This is the process of the method for extracting relational features in remote supervision provided in the embodiment of the present application. Figure 2 ;
[0024] Figure 3 is an example diagram of a mask matrix provided in an embodiment of the present application;
[0025] Figure 4 It is a structural diagram of a relation feature extraction device in remote supervision provided in an embodiment of the present application;
[0026] Figure 5 It is a structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0028] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0030] It should be further understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0031] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0032] In a specific implementation, the terminal described in the embodiments of the present application includes, but is not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with touch-sensitive surfaces (e.g., touch screen displays and / or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., touch screen displays and / or touch pads).
[0033] In the following discussion, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse and / or joystick.
[0034] The terminal supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a game application, a telephone application, a video conferencing application, an email application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital camcorder application, a web browsing application, a digital music player application, and / or a digital video player application.
[0035] Various applications that can be executed on the terminal can use at least one common physical user interface device such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the terminal can be adjusted and / or changed between applications and / or within corresponding applications. In this way, the common physical architecture of the terminal (e.g., the touch-sensitive surface) can support various applications with user interfaces that are intuitive and transparent to the user.
[0036] It should be understood that the size of the serial numbers of the steps in this embodiment does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0037] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0038] See also Figure 1 , Figure 1 This is the process of the method for extracting relational features in remote supervision provided in the embodiment of the present application. Figure 1 .like Figure 1 As shown, a method for extracting relational features in remote supervision includes the following steps:
[0039] Step 101, obtaining a corpus to be processed containing entity pairs.
[0040] The corpus to be processed is specifically a sentence containing entity pairs. The entity pairs are specific words contained in the sentence.
[0041] Whether a sentence contains an entity can be realized by using the Named Entity Recognition (NER) method.
[0042] The task of named entity recognition is to identify three major categories (entity category, time category and number category) and seven minor categories (personal name, organization name, place name, time, date, currency and percentage) of named entities in the text to be processed.
[0043] For example, in the sentence "Xiao Ming goes to school at 8 o'clock in the morning", named entity recognition can be performed to extract the following information:
[0044] Name: Xiao Ming; Time: 8 am; Location: school.
[0045] In this step, it is necessary to obtain the entity pairs contained in the corpus to be processed. When the corpus to be processed is a training corpus, the entity pairs can be the entity pairs that have been set up. When the corpus to be processed is in the model application stage, it is necessary to extract and identify the current corpus to be processed based on the trained model to obtain the entity pairs contained therein.
[0046] Through this entity pair, we can assume that the sentence containing this entity pair contains a certain relationship corresponding to the entity pair.
[0047] For example, the sentence "Zhang San is the factory director" includes the entity pair "Zhang San" and "factory director", so the sentence containing this entity pair is considered to contain the information that Zhang San is the factory director. Or, the sentence "Zhang San's fellow villager Li Si was elected as the new factory director" contains the entity pair "Zhang San" and "factory director", so this sentence is also considered to contain the information that Zhang San is the factory director, which is obviously inconsistent with the meaning of the sentence. Then, the sentence will bring noise to the remote supervision process. Therefore, a subsequent process is needed to process it to eliminate or reduce the noise.
[0048] In this step, what types of entity pairs are included in the corpus to be processed and what kind of sentence information the sentence containing the entity pairs will be considered to have needs to be specifically set according to the actual remote supervision needs.
[0049] Step 102: In the corpus to be processed, insert labels for identifying the relationship features between entities into the initial position and the final position of each entity in the entity pair.
[0050] The label is a label pair inserted corresponding to the first and last positions of each entity, that is, the labels at the first and last positions of each entity together form an identification of the entity, forming a label pair, and one entity corresponds to one label pair.
[0051] The tag is used to mark the entities in the entity pair, such as marking the subject and object information, entity type information, and the addition of the tag indicates the sentence structure of the entity in the sentence or indicates the word type of the entity, such as people, work, animals, etc. The tag annotated with each entity is used to identify the relationship features between the entity pairs contained in the sentence, such as the structural association features in the sentence structure, or the semantic association features between the sentence meanings.
[0052] The purpose of setting labels in this step is to annotate the relationships between entities in entity pairs in the sentence, so that the entity pairs after label setting can reflect their relationships in the corpus to be processed.
[0053] Step 103: Based on the corpus to be processed after the tags are inserted, a sentence vector corresponding to the corpus to be processed is generated through a text representation model.
[0054] The sentence vector is obtained by concatenating the vector representations corresponding to the labels in the output results of the text representation model.
[0055] For example, if the vector dimension of label 1 is 11, the vector dimension of label 2 is 15, the vector dimension of label 3 is 20, and the vector dimension of label 4 is 18, the dimension of the concatenated vector is 11+15+20+18, that is, 64 dimensions. The dimension of the concatenated vector is the sum of the dimensions represented by the vectors corresponding to each label.
[0056] The text representation model can be a BERT (Bidirectional Encoder Representations from Transformers) model, which can capture the relevance of surrounding words for each word in the corpus to be processed. Specifically, the BERT model essentially learns a good feature representation for a word by running a self-supervised learning method based on a massive corpus. Self-supervised learning refers to supervised learning that runs on data that has not been manually annotated. BERT provides a model for transfer learning of other tasks. This model acts as a feature extractor. In subsequent specific NLP (Natural Language Processing) tasks, we can directly use BERT's features to represent the word embedding features of subsequent tasks.
[0057] Differently, the text representation model may also be an LSTM (Long Short-Term Memory) model, which may be specifically selected as needed.
[0058] When the text representation model is used to process the corpus to be processed to obtain a sentence vector, the output result of the text representation model includes a vector representation part corresponding to each label in the corpus to be processed and a vector representation part corresponding to each character of the corpus content in the corpus to be processed. In this step, it is necessary to select the content of the output result of the text representation model, specifically select the vector representation part corresponding to each label, and concatenate the content to obtain a vector representation as the sentence vector corresponding to the corpus to be processed.
[0059] Therefore, in this step, the association relationship information between entity pairs is embedded in the corpus to be processed through the labels that have been inserted in the corpus to be processed, and the information restrictions on the entity pairs are added. When generating the sentence vector corresponding to the corpus to be processed, the label is input into the model as a part of the corpus to be processed for text feature extraction. Finally, the vector representation content corresponding to the label is directly extracted, and the sentence vector corresponding to the corpus to be processed is formed after splicing. The feature information of the label of the entity pair represents the feature representation of the entire corpus to be processed, which improves the representation method of the overall sentence vector feature, better captures the relationship between entity types, and improves the accuracy of the extraction task results.
[0060] Step 104: Output the relation feature extraction result through the classification model according to the sentence vector.
[0061] The classification model is specifically a model for realizing category judgment of input data.
[0062] In specific applications, the classification model can capture the association between entity pairs in the corpus to be processed based on the input sentence vector, and then predict whether the entity pairs contained in the corpus to be processed express other information that is different from the set information.
[0063] For example, in the sentence "Zhang San is the factory director", "Zhang San" in the entity pair is the subject, and "factory director" is the object. At this time, the sentence containing this entity pair contains the information that Zhang San is the factory director. In the sentence "Zhang San's fellow villager Li Si was elected as the new factory director", "Zhang San" is the attributive and "factory director" is the object. When remote supervision is performed on this sentence, in order to predict whether the sentence containing the entity pair of "Zhang San" and "factory director" also contains the information that Zhang San is the factory director, the sentence structure association features or semantic association features between the entity pairs are identified by inserting the labels at the beginning and end of "Zhang San" and the labels at the beginning and end of "factory director", so that in this step, based on the sentence vector formed by splicing the vector representations corresponding to the labels, the classification model can be used to realize the probability prediction of whether the entity pair in the current sentence actually contains the information that Zhang San is the factory director, thereby realizing the remote supervision processing process of the corpus.
[0064] When the classification model performs feature extraction, it can perform an extraction operation based on a single sentence vector, or it can perform batch processing on multiple sentence vectors as a group each time. This process can correspond to the model training process or the model application process after the model is trained, which is not specifically limited here.
[0065] Furthermore, the corpus to be processed and / or the result of relational feature extraction are stored in the blockchain.
[0066] In all embodiments of the present application, uploading the corpus to be processed and / or the results of the relational feature extraction to the blockchain can ensure its security and fairness and transparency to users. The user device can download the corpus to be processed and the results of the relational feature extraction from the blockchain to verify whether the relevant information has been tampered with. The blockchain referred to in this example is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each of which contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain may include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0067] In an embodiment of the present application, by obtaining a corpus to be processed containing entity pairs, in the corpus to be processed, the labels for identifying the relationship features between entities are respectively inserted at the initial position and the final position of each entity in the entity pair, and based on the corpus to be processed after the labels are inserted, a sentence vector corresponding to the corpus to be processed is generated through a text representation model, wherein the sentence vector is obtained by concatenating the vector representations corresponding to the labels in the output results of the text representation model, and the relationship feature extraction results are output through a classification model based on the sentence vector. This solution embeds labels in the corpus to be processed to achieve the annotation of relevant information between entity pairs, which effectively improves the representation of sentence vector features as a whole, better captures the relationships between entities, and improves the accuracy of prediction results during feature extraction.
[0068] The embodiments of the present application also provide different implementation methods of the relationship feature extraction method in remote supervision.
[0069] See also Figure 2 , Figure 2 This is the process of the method for extracting relational features in remote supervision provided in the embodiment of the present application. Figure 2 .like Figure 2 As shown, a method for extracting relational features in remote supervision includes the following steps:
[0070] Step 201, extract entity pairs with set association relationships from the pre-built knowledge graph.
[0071] Extracting several entity pairs with preset association relationships from a pre-constructed knowledge graph can be done by obtaining triples from a given knowledge graph, where each triple corresponds to an entity pair with a set association relationship. The preset association relationship is specifically the association relationship between the entity pairs contained in different triples.
[0072] The process of forming triples is to extract each sentence from the text and then extract the components in the sentence that conform to the triple (subject+relation+object), where:
[0073] 1. Subject: The subject in the triple, indicating the initiator of the action;
[0074] 2. relation: the relationship between subject and object in the triple;
[0075] 3. object: The recipient of the relation action in the triple.
[0076] The subject and object determined by the triple determine what the entities in the entity pair are and what the relationship, or relation, is between the entities in the entity pair.
[0077] Specifically, the association relationship can be a sentence structure association relationship such as subject-object, active, etc. For example, in the sentence "Zhang San is the factory director", the association relationship between "Zhang San" and "factory director" can be extracted as a subject-object association relationship with a word order structure; or it can be a semantic association relationship between fixed noun pairs. For example, in the sentence "Zhang San is the factory director", the association relationship between "Zhang San" and "factory director" can be extracted as a person-job semantic association relationship.
[0078] In this step, the entity pairs with set association relationships can also be extracted based on vocabulary collocation information such as fixed word collocations that have been set and stored in the pre-constructed knowledge graph.
[0079] Step 202: based on the entity pair, extract the target sentence containing the entity pair from the corpus text.
[0080] Step 203: group the sentences in the target sentence that contain the same entity pair into the same corpus bag.
[0081] The corpus text may be an unstructured text, and whether the entity pair involved in the triple exists in the unstructured text is searched, and if so, the text (sentence) containing the same entity pair is put into the same corpus bag.
[0082] In this process, there needs to be enough sentences with entity pairs and relationship annotations to classify all sentences with the same entity pairs into the same group to form a whole, namely a corpus bag.
[0083] Step 204: The divided corpus packages are grouped and the sentences contained in the corpus packages are determined as corpus to be processed.
[0084] Among them, a corpus package corresponds to a set of corpora to be processed. Each sentence in each corpus package contains the same entity pair.
[0085] Step 205: In the corpus to be processed, insert the start position and end position of each entity in the entity pair with tags for identifying the relationship features between entities respectively.
[0086] The implementation process of this step is the same as that of step 102 in the foregoing embodiment, and will not be elaborated here.
[0087] Step 206: Based on the corpus to be processed after inserting tags, obtain the word vectors and position vectors corresponding to each character in the corpus to be processed.
[0088] Among them, the position vector value of the start character of each entity in the entity pair is the same as the position vector value of the tag inserted at the start position of the entity, and the position vector value of the end character of each entity is the same as the position vector value of the tag inserted at the end position of the entity.
[0089] Specifically, the position vector is used to indicate the position of each character in the sentence. Among them, after the tags are inserted into the corpus to be processed, the tags also become part of the sentence. In this step, the tags will also generate word vectors and position vectors.
[0090] For example, for "Zhang San is the factory director", the sentence after inserting tags is " <s:person>Zhang San< / s:person> is <o:job>Factory Director< / o:job> ".
[0091] Then, the characters included in this sentence are respectively: " <s:person>", "Zhang", "San"< / s:person> ", "is", " <o:job>", "Factory", "Director"< / o:job> ". Generate the word vectors and position vectors corresponding to these characters respectively.
[0092] It is necessary to make the position vector value of the start character of each entity the same as the position vector value of the tag inserted at the start position of the entity, and the position vector value of the end character of each entity the same as the position vector value of the tag inserted at the end position of the entity.
[0093] That is, set the value of " <s:person>" is set to have the same value in the position vector as "Zhang" in the position vector, "< / s:person> " in the position vector to be the same as the value of "San" in the position vector, and the same for others, so that the inserted tags do not substantially change the position features of each character in the corpus to be processed before inserting the tags, and ensure that the newly introduced tags do not affect the normal structural features of the sentence itself while adding information annotation of the entities in the sentence.
[0094] Specifically, the generation method of the word vectors is the same as the existing method for generating word vectors. The generation of the position vectors can also be achieved by existing means.
[0095] The word vector and the position vector may be initialized vector representations, which are gradually trained and optimized as the model is executed.
[0096] Step 207, after concatenating the word vector and the position vector, input them into the text representation model to generate a sentence vector corresponding to the corpus to be processed.
[0097] The sentence vector is obtained by concatenating the vector representations corresponding to the labels in the output results of the text representation model.
[0098] Before inputting data into the text representation model, the word vector and the position vector need to be concatenated. Specifically, the word vector and the position vector corresponding to the same character are concatenated in dimension. The concatenated vector representation is input into the text representation model for calculation to generate the sentence vector corresponding to the entire sentence.
[0099] This process embeds the relevant information between entities and adds entity information restrictions, which improves the representation of sentence vector features as a whole, better captures the relationships between entities, and improves the accuracy of the results of the extraction task.
[0100] As an optional implementation, the word vector and the position vector are concatenated and then input into a text representation model to generate a sentence vector corresponding to the corpus to be processed, including:
[0101] Construct a mask matrix based on the corpus to be processed after inserting labels;
[0102] Wherein, in the mask matrix, the matrix element value of the label row to the label column is set to the first value, the matrix element value of the label row to the text column is set to the first value, the matrix element value of the text row to the text column is set to the first value, and the matrix element value of the text row to the label column is set to the second value;
[0103] The word vector and the position vector are concatenated to obtain a feature vector, which is input into the text representation model. The feature vector is convolved with a mask matrix to obtain an output vector of the text representation model.
[0104] The vector representations corresponding to the labels in the output vector are concatenated to obtain the sentence vector corresponding to the corpus to be processed.
[0105] In this process, a mask matrix is introduced, and the masking effect in the operation process is realized by setting the element values in the mask matrix. Specifically, the matrix element values of the text row to the label column are set to numerical values that are different from the matrix element values of the label row to the label column, the matrix element values of the label row to the text column, and the matrix element values of the text row to the text column in the mask matrix. Through this setting operation, the convolution processing of the text token (word segmentation) and the label token combination in the convolution processing process is realized by using discriminative processing to change the degree to which the words in the sentence are affected by the inserted labels during the convolution processing.
[0106] Optionally, the first value and the second value are taken from 0 and 1, and the first value is different from the second value.
[0107] As a more specific implementation, the element values 0 and 1 in the mask matrix can be set to 1 for the matrix element values of the label row to the label column, the matrix element values of the label row to the text column, the matrix element values of the text row to the text column, and the matrix element values of the text row to the label column. 0, that is, the first value is set to 1, and the second value is set to 0. Figure 3 As shown in the figure, for the sentence "Zhang San is the factory director", the label " <s:person>"Line pair" <s:person>"The matrix element value of the column is 1, <s:person>The matrix element value of the "row pair" for the "Zhang" column is 1, and the "Zhang" row pair <s:person>The matrix element value of the "column" is 0, and the matrix element value of the "Zhang" row and the "Zhang" column is 1.
[0108] The setting of this mask matrix realizes that during the convolution operation, the text tokens (word segmentation) in the corpus to be processed only pay attention to the text tokens, while masking the label tokens, but the label tokens pay attention to all tokens including text and labels. While the label can learn the features of the words in the sentence, the words in the sentence are not affected by the inserted labels, and the relationship features of the sentence itself can be better captured.
[0109] Step 208: Generate a vector representation of the corpus packet based on this sentence vector.
[0110] A corpus packet contains a set of sentences (i.e., the corpus to be processed), and each sentence corresponds to a sentence vector. When generating the vector representation of the corpus packet based on the sentence vector, it can be obtained by summing the sentence vectors.
[0111] As an optional implementation manner, the generating a vector representation of the corpus packet based on the sentence vector includes:
[0112] Multiply the sentence vector of each statement in the corpus packet by the corresponding relationship feature element in the relationship feature matrix and then perform normalization processing to obtain the weight of each statement in the corpus packet in the corpus packet; sum the product of each weight and the corresponding statement's sentence vector to obtain the vector representation of the corpus packet.
[0113] The sentences in each corpus packet contain the same entity pairs, but the sentences containing the same entity pairs do not necessarily have the relationship features corresponding to the entity pairs. Therefore, it is necessary to form the corpus to be processed, extract the relationship features of the sentences in it with each packet as the object, reasonably obtain the weights of the sentences in the packet, and maximize the elimination of noise interference.
[0114] This relationship feature matrix is specifically a feature matrix recording relationship features, and the elements in this matrix correspond one by one to the statements in the corpus packet. This relationship feature matrix can be initialized first and continuously updated and optimized during the model training process.
[0115] Multiply the sentence vector corresponding to the corpus to be processed by the relationship feature, and normalize the result after multiplication to obtain the weight feature vector of each sentence in the packet within the packet. Multiply the weight by the sentence vector of each sentence in the packet and sum to obtain the vector representation of the entire packet. The dimension of the packet vector is the same as that of the sentence vector.
[0116] Compared with the existing methods, by capturing sentence features in these ways, in the process of model processing, data with the same semantic and syntactic structures will obtain closer weights for the same sentence patterns. Therefore, the weight information of all sentences in the packet can be calculated better, so as to improve the accuracy of the subsequent vector representation of the packet features.
[0117] Step 209 , annotating the vector representation according to the relationship features between the entities to obtain the annotated vector representation of the corpus bag.
[0118] The labeling process may correspond to a model training operation. The vector representation of the obtained corpus package is labeled with relational features, that is, all the corpus in a corpus package are regarded as a whole, and the vector representation of the entire corpus package is labeled with sample features of the relationship between entity pairs contained in the corpus.
[0119] Step 210, input the annotated vector representation into the classification model, and output the relational feature extraction result corresponding to the corpus bag.
[0120] After the annotated vector representation is input into the classification model, the classification model can be combined with the vector representation of the input corpus package and its annotation information to realize model training and parameter optimization.
[0121] During the training process, the model training operation may be performed in units of corpus packages.
[0122] In an embodiment of the present application, by obtaining a corpus to be processed containing entity pairs, the corpus to be processed is divided into corpus packages, and in the corpus to be processed, the labels for identifying the relationship features between entities are respectively inserted into the initial position and the final position of each entity in the entity pair, and the word vector and position vector corresponding to each character in the corpus to be processed are obtained, and the concatenated feature vector is convoluted using a mask matrix to obtain a sentence vector, and the relationship feature extraction result is output through a classification model based on the sentence vector. This scheme embeds labels in the corpus to be processed to annotate the relevant information between entity pairs, and the introduction of the mask matrix enables the labels to learn the features of the words in the sentence while preventing the words in the sentence from being affected by the inserted labels, so as to better capture the relationship features of the sentence itself, and effectively improves the overall representation of the sentence vector features, better captures the relationships contained between entities, and improves the accuracy of the prediction results in the feature extraction process.
[0123] See also Figure 4 , Figure 4 This is a structural diagram of a relational feature extraction device in remote supervision provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0124] The remote supervision relation feature extraction device 400 comprises:
[0125] An acquisition module 401 is used to acquire a corpus to be processed containing entity pairs;
[0126] A label inserting module 402 is used to insert labels for identifying the relationship features between entities at the initial position and the final position of each entity in the entity pair in the corpus to be processed;
[0127] A generating module 403 is used to generate a sentence vector corresponding to the corpus to be processed through a text representation model based on the corpus to be processed after the tag is inserted; wherein the sentence vector is obtained by concatenating the vector representations corresponding to the tag in the output result of the text representation model;
[0128] The extraction module 404 is used to output the relationship feature extraction result through the classification model according to the sentence vector.
[0129] Among them, the generation module is specifically used for:
[0130] Based on the corpus to be processed after inserting the tag, a word vector and a position vector corresponding to each character in the corpus to be processed are obtained; wherein the position vector value of the first character of each entity in the entity pair is the same as the position vector value of the tag inserted at the first position of the entity, and the position vector value of the last character of each entity is the same as the position vector value of the tag inserted at the last position of the entity;
[0131] After the word vector and the position vector are concatenated, the concatenation is input into the text representation model to generate a sentence vector corresponding to the corpus to be processed.
[0132] Among them, the generation module is more specifically used to:
[0133] Constructing a mask matrix based on the corpus to be processed after inserting tags;
[0134] Wherein, in the mask matrix, the matrix element value of the label row to the label column is set to the first value, the matrix element value of the label row to the text column is set to the first value, the matrix element value of the text row to the text column is set to the first value, and the matrix element value of the text row to the label column is set to the second value;
[0135] Concatenating the word vector with the position vector to obtain a feature vector, inputting the feature vector into the text representation model, and performing convolution processing on the feature vector using the mask matrix to obtain an output vector of the text representation model;
[0136] The vector representations corresponding to the labels in the output vectors are concatenated to obtain sentence vectors corresponding to the corpus to be processed.
[0137] Wherein, the acquisition module 401 is specifically used for:
[0138] Extract entity pairs with set association relationships from the pre-built knowledge graph;
[0139] Based on the entity pair, extracting a target sentence containing the entity pair from the corpus text;
[0140] Grouping the target sentences containing the same entity pairs into the same corpus bag;
[0141] The corpus packages obtained by the division are grouped, and the sentences contained in the corpus packages are determined as the corpus to be processed.
[0142] The extraction module 404 is specifically used for:
[0143] Based on the sentence vector, generate a vector representation of the corpus bag;
[0144] Annotating the vector representation according to the relationship features between the entities to obtain the annotated vector representation of the corpus package;
[0145] The annotated vector representation is input into the classification model, and the relational feature extraction result corresponding to the corpus bag is output.
[0146] The extraction module 404 is more specifically used for:
[0147] The sentence vector of each sentence in the corpus package is multiplied by the corresponding relational feature element in the relational feature matrix and then normalized to obtain the weight of each sentence in the corpus package;
[0148] Each of the weights is multiplied by the sentence vector of the corresponding sentence and the sum is calculated to obtain a vector representation of the corpus package.
[0149] The corpus to be processed and / or the relationship feature extraction result are stored in the blockchain.
[0150] The device for extracting relational features in remote supervision provided in the embodiment of the present application can implement each process of the embodiment of the method for extracting relational features in remote supervision described above, and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0151] Figure 5 is a structural diagram of a terminal provided in an embodiment of the present application. As shown in the figure, the terminal 5 of this embodiment includes: at least one processor 50 ( Figure 5 Only one is shown in the figure), a memory 51, and a computer program 52 stored in the memory 51 and executable on the at least one processor 50, wherein the processor 50 implements the steps of any of the above-mentioned method embodiments when executing the computer program 52.
[0152] The terminal 5 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal 5 may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that Figure 5 It is only an example of terminal 5 and does not constitute a limitation on terminal 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal may also include input and output devices, network access devices, buses, etc.
[0153] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0154] The memory 51 may be an internal storage unit of the terminal 5, such as a hard disk or memory of the terminal 5. The memory 51 may also be an external storage device of the terminal 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal 5. Further, the memory 51 may also include both an internal storage unit of the terminal 5 and an external storage device. The memory 51 is used to store the computer program and other programs and data required by the terminal. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0155] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0156] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0157] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0158] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0161] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0162] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be implemented through a computer program product. When the computer program product runs on a terminal, the terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0163] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.< / s:person> < / s:person> < / s:person> < / s:person>
Claims
1. A method for extracting relational features in remote supervision, characterized in that: include: Get the corpus to be processed containing entity pairs; In the corpus to be processed, inserting labels for identifying the relationship features between entities into the initial position and the final position of each entity in the entity pair respectively; Based on the corpus to be processed after inserting the tag, a word vector and a position vector corresponding to each character in the corpus to be processed are obtained; wherein the position vector value of the first character of each entity in the entity pair is the same as the position vector value of the tag inserted at the first position of the entity, and the position vector value of the last character of each entity is the same as the position vector value of the tag inserted at the last position of the entity; Constructing a mask matrix based on the corpus to be processed after inserting tags; Wherein, in the mask matrix, the matrix element value of the label row to the label column is set to the first value, the matrix element value of the label row to the text column is set to the first value, the matrix element value of the text row to the text column is set to the first value, and the matrix element value of the text row to the label column is set to the second value; the first value is 1, and the second value is 0; Concatenating the word vector with the position vector to obtain a feature vector, inputting the feature vector into a text representation model, and performing convolution processing on the feature vector using the mask matrix to obtain an output vector of the text representation model; Concatenate the vector representations corresponding to the labels in the output vector to obtain a sentence vector corresponding to the corpus to be processed; According to the sentence vector, the relation feature extraction result is output through the classification model.
2. The method for extracting relational features according to claim 1, characterized in that: The obtaining of the to-be-processed corpus containing entity pairs includes: Extract entity pairs with set association relationships from the pre-built knowledge graph; Based on the entity pair, extracting a target sentence containing the entity pair from the corpus text; Grouping the target sentences containing the same entity pairs into the same corpus bag; The corpus packages obtained by the division are grouped, and the sentences contained in the corpus packages are determined as the corpus to be processed.
3. The method for extracting relational features according to claim 2, characterized in that: Outputting the relationship feature extraction result through the classification model according to the sentence vector includes: Based on the sentence vector, generate a vector representation of the corpus bag; Annotating the vector representation according to the relationship features between the entities to obtain the annotated vector representation of the corpus package; The annotated vector representation is input into the classification model, and the relational feature extraction result corresponding to the corpus bag is output.
4. The method for extracting relational features according to claim 3, characterized in that: The step of generating a vector representation of the corpus package based on the sentence vector includes: The sentence vector of each sentence in the corpus package is multiplied by the corresponding relational feature element in the relational feature matrix and then normalized to obtain the weight of each sentence in the corpus package; Each of the weights is multiplied by the sentence vector of the corresponding sentence and the sum is calculated to obtain a vector representation of the corpus package.
5. The method for extracting relational features according to claim 1, characterized in that: The corpus to be processed and / or the relationship feature extraction result are stored in the blockchain.
6. A device for extracting relational features in remote supervision, characterized in that: include: An acquisition module is used to obtain the corpus to be processed containing entity pairs; A label insertion module, used to insert labels for identifying the relationship features between entities at the initial position and the final position of each entity in the entity pair in the corpus to be processed; A generation module, used to generate a sentence vector corresponding to the corpus to be processed through a text representation model based on the corpus to be processed after the tags are inserted; The sentence vector is obtained by concatenating the vector representations corresponding to the labels in the output results of the text representation model; An extraction module, used for outputting a relation feature extraction result through a classification model according to the sentence vector; The generating module is specifically used for: Based on the corpus to be processed after inserting the tag, a word vector and a position vector corresponding to each character in the corpus to be processed are obtained; wherein the position vector value of the first character of each entity in the entity pair is the same as the position vector value of the tag inserted at the first position of the entity, and the position vector value of the last character of each entity is the same as the position vector value of the tag inserted at the last position of the entity; After concatenating the word vector and the position vector, the concatenated word vector and the concatenated word vector are input into the text representation model to generate a sentence vector corresponding to the corpus to be processed; The generation module is more specifically used for: Constructing a mask matrix based on the corpus to be processed after inserting tags; Wherein, in the mask matrix, the matrix element value of the label row to the label column is set to the first value, the matrix element value of the label row to the text column is set to the first value, the matrix element value of the text row to the text column is set to the first value, and the matrix element value of the text row to the label column is set to the second value; the first value is 1, and the second value is 0; Concatenating the word vector with the position vector to obtain a feature vector, inputting the feature vector into the text representation model, and performing convolution processing on the feature vector using the mask matrix to obtain an output vector of the text representation model; The vector representations corresponding to the labels in the output vectors are concatenated to obtain sentence vectors corresponding to the corpus to be processed.
7. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Entity relationship extraction method and device, computer equipment and storage medium
CN110059320A
Training statement acquisition method and device, storage medium and electronic equipment
CN111144120A