Relationship extraction model construction method and device, computer equipment, storage medium and computer program product
By building a relationship extraction model in the power system and using language processing and feature extraction modules to train the target relationship extraction model, the problem of low accuracy of relationship extraction in the existing technology is solved and the efficiency of distribution network operation and maintenance is improved.
Patent Information
- Application Number
- CN202410847073.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies rely on manually specified rules in relation extraction in power systems, resulting in low accuracy in understanding the semantic information of power data and failing to effectively improve the efficiency of distribution network operation and maintenance.
A relationship extraction model construction method is adopted, by obtaining the entity pair text information and relationship category labels of the target distribution network system, combining the initial relationship extraction model and the relationship extraction model to be distilled, and using the language processing module, feature extraction module and classification module, Train the target relationship extraction model to improve the accuracy of relationship extraction.
It improves the accuracy of relationship extraction and the efficiency of distribution network operation and maintenance. It uses knowledge distillation and artificial intelligence technology to build a relationship extraction model of the target distribution network system, which is used to build a knowledge graph and enhances the operation and maintenance of the distribution network system. efficiency.
Smart Images

Figure CN118733697A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electric power operation and maintenance technology, and in particular to a method, device, computer equipment, storage medium and computer program product for constructing a relationship extraction model. Background Art
[0002] For the distribution network system in the power system, it is necessary to introduce a power knowledge graph to achieve the convenience of power information acquisition and the efficiency of distribution network operation and maintenance. In the process of constructing the power knowledge graph, it is necessary to extract the relationship between power entities in the distribution network system. The current relationship extraction technology relies on manually specified rules and cannot better understand the semantic information in the power data, and has the problem of low accuracy. Summary of the invention
[0003] Based on this, it is necessary to provide a method, device, computer equipment, storage medium and computer program product for building a relationship extraction model that can improve the accuracy of relationship extraction in response to the above technical problems.
[0004] In a first aspect, the present application provides a method for constructing a relationship extraction model. The method comprises:
[0005] Acquire multiple entity pair text information associated with the target distribution network system; the entity pair text information includes a pair of entity pairs and relationship category labels between the entity pairs;
[0006] The entity pair text information trains the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category label of each entity pair text information to obtain the initial relation extraction model;
[0007] The initial relation extraction model is used as the source model, and the to-be-trained distilled relation extraction model is used as the target model. According to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model is trained to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0008] In one of the embodiments, the initial relationship extraction model includes a first language processing module, a first feature extraction module and a first classification module;
[0009] The training of the initial relation extraction model to be trained to obtain the initial relation extraction model includes: inputting a plurality of entity pair text information into the initial relation extraction model to be trained, and determining and outputting the first text vector corresponding to each entity pair text information by the first language processing module in the initial relation extraction model; determining and outputting the first power feature corresponding to each entity pair text information by the first feature extraction module in the initial relation extraction model according to the first text vector output by the first language processing module; determining and outputting the initial relation category prediction result of each entity pair text information by the first classification module in the initial relation extraction model according to the first power feature output by the first feature extraction module; and training the initial relation extraction model to be trained according to the difference between the initial relation category prediction result and the relation category label to obtain the initial relation extraction model.
[0010] In one embodiment, the first language processing module in the initial relation extraction model determines and outputs the first text vector corresponding to each entity pair text information, including: the first language processing module in the initial relation extraction model segments each entity pair text information to obtain multiple first text segmentations; obtains a first word embedding vector corresponding to each first text segmentation, and obtains a position embedding vector of each first text segmentation; obtains the first text vector of each entity pair text information based on the first word embedding vector and the position embedding vector.
[0011] In one embodiment, the first text vector of each entity pair of text information is obtained based on the first word embedding vector and the position embedding vector, including: splicing the word embedding vector and the position embedding vector to obtain a splicing vector of each of the first text segmentations; and obtaining the first text vector of each entity pair of text information based on the splicing vector.
[0012] In one of the embodiments, the target model is trained according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model to obtain the target relationship extraction model corresponding to the initial relationship extraction model, including: obtaining the first relationship category prediction result corresponding to each entity pair of text information according to the initial relationship category prediction result of the source model for each entity pair of text information and the relationship category label of each entity pair of text information; obtaining the second relationship category prediction result of the target model; and the target model is trained according to the difference between the first relationship category prediction result and the second relationship category prediction result to obtain the target relationship extraction model corresponding to the initial relationship extraction model.
[0013] In one embodiment, the relationship extraction model to be distilled includes a second language processing module, a second feature extraction module and a second classification module; the obtaining of the second relationship category prediction result of the target model includes: inputting a plurality of entity pair text information into the relationship extraction model to be distilled to be trained, and determining and outputting the second text vector corresponding to each entity pair text information by the second language processing module of the relationship extraction model to be distilled; determining and outputting the second power feature corresponding to each entity pair text information by the second feature extraction module in the relationship extraction model to be distilled according to the second text vector output by the second language processing module; determining and outputting the second relationship category prediction result of each entity pair text information by the second classification module in the relationship extraction model to be distilled according to the second power feature output by the second feature extraction module.
[0014] In one embodiment, the second language processing module of the relationship extraction model to be distilled determines and outputs the second text vector corresponding to each entity pair text information, including: the second language processing module in the relationship extraction model to be distilled performs word segmentation on each entity pair text information to obtain multiple second text word segments; obtains a second word embedding vector corresponding to each second text word segmentation; and obtains the second text vector of each entity pair text information based on the second word embedding vector.
[0015] In a second aspect, the present application provides a device for constructing a relationship extraction model. The device comprises:
[0016] An acquisition module, used to acquire a plurality of entity pair text information associated with a target power distribution network system; the entity pair text information includes a pair of entity pairs and a relationship category label between the entity pairs;
[0017] A first entity pair text information training module, used for training an initial relation extraction model to be trained according to a plurality of entity pair text information and the relation category label of each entity pair text information, to obtain the initial relation extraction model;
[0018] The second training module is used to use the initial relation extraction model as the source model and the to-be-trained distilled relation extraction model as the target model, and train the target model according to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0019] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0020] Acquire multiple entity pair text information associated with the target distribution network system; the entity pair text information includes a pair of entity pairs and relationship category labels between the entity pairs;
[0021] The entity pair text information trains the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category label of each entity pair text information to obtain the initial relation extraction model;
[0022] The initial relation extraction model is used as the source model, and the to-be-trained distilled relation extraction model is used as the target model. According to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model is trained to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0023] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0024] Acquire multiple entity pair text information associated with the target distribution network system; the entity pair text information includes a pair of entity pairs and relationship category labels between the entity pairs;
[0025] The entity pair text information trains the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category label of each entity pair text information to obtain the initial relation extraction model;
[0026] The initial relation extraction model is used as the source model, and the to-be-trained distilled relation extraction model is used as the target model. According to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model is trained to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0027] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0028] Acquire multiple entity pair text information associated with the target distribution network system; the entity pair text information includes a pair of entity pairs and relationship category labels between the entity pairs;
[0029] The entity pair text information trains the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category label of each entity pair text information to obtain the initial relation extraction model;
[0030] The initial relation extraction model is used as the source model, and the to-be-trained distilled relation extraction model is used as the target model. According to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model is trained to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0031] In the above-mentioned relationship extraction model construction method, device, computer equipment, storage medium and computer program product, first, multiple entity pair text information associated with the target distribution network system can be obtained; the entity pair text information includes a pair of entity pairs, and the relationship category label between the entity pairs; the entity pair text information can then be trained according to the multiple entity pair text information and the relationship category label of each entity pair text information to obtain the initial relationship extraction model; then, the initial relationship extraction model can be used as the source model, and the relationship extraction model to be distilled can be used as the target model, and the target model can be trained according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model, so as to obtain the target relationship extraction model corresponding to the initial relationship extraction model. In the method provided in the embodiment of the present application, the relationship extraction model of the target distribution network system can be constructed by combining knowledge distillation and artificial intelligence, and the knowledge graph of the target distribution network system can be constructed based on the relationship extraction model, which is used for distribution network operation and maintenance, thereby improving the accuracy of relationship extraction and the efficiency of distribution network system operation and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions 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 related drawings can be obtained based on these drawings without paying creative work.
[0033] FIG1 is a schematic diagram of a flow chart of a method for constructing a relationship extraction model provided in an embodiment of the present application;
[0034] FIG2 is a schematic diagram of a process of training an initial relationship extraction model provided in an embodiment of the present application;
[0035] FIG3 is a schematic diagram of a process of obtaining a first text vector provided in an embodiment of the present application;
[0036] FIG4 is a flow chart of a training target relationship extraction model provided in an embodiment of the present application;
[0037] FIG5 is a structural block diagram of a relationship extraction model building device provided in an embodiment of the present application;
[0038] FIG6 is a diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] In an exemplary embodiment, as shown in FIG1 , a method for constructing a relationship extraction model is provided. This embodiment uses the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0041] Step 102: Acquire text information of multiple entity pairs associated with the target distribution network system.
[0042] Among them, the associated power text information can be obtained from multiple power databases associated with the target distribution network system. The target distribution network system can be the section of the system from the step-down distribution substation (high-voltage distribution substation) outlet to the user end in the power system. The distribution system is a power network system composed of a variety of distribution equipment (or components) and distribution facilities that transforms voltage and directly distributes electric energy to end users. The relationship extraction model construction method of the embodiment of the present application can also be used for other power systems. The power text information may include the distribution operation text information of the target distribution network system. The distribution operation text information may include multiple power entities, and a data preprocessing tool, such as a regular expression, can be used to perform data processing on the distribution operation text information, and the multiple power entities in the distribution operation text information and the relationship between the entities are marked to obtain multiple entity pair text information associated with the target distribution network system. Each entity pair text information in the multiple entity pair text information contains a pair of entity pairs and a relationship category label between the entity pairs. The relationship category label can be pre-set and can be used to represent the relationship between each entity pair, such as property attributes, inclusion, policy orientation, action and quantity.
[0043] Step 104 , training the initial relation extraction model to be trained according to the plurality of entity-pair text information and the relationship category labels of the entity-pair text information to obtain an initial relation extraction model.
[0044] Among them, in this step, the initial relationship extraction model to be trained may include a first language processing module, a first feature extraction module and a first classification module. The first language processing module may be a language representation model (Bidirectional Encoder Representations from Transformers, BERT), and the first feature extraction module and the first classification module may be a pulse coupled neural network (PCNN-Pulse Coupled Neural Network, PCNN). BERT is a pre-trained language representation model based on the Transformer model. It obtains rich text representation through large-scale unsupervised learning. BERT can capture syntactic and semantic information in the text. Specifically, each entity pair text information can be input into the initial relation extraction model to be trained. In the first part, each entity pair text information in the multiple entity pair text information can be segmented by the BERT model in the initial relation extraction model to obtain multiple first text segmentations corresponding to each entity pair text information, as shown in formula (1) and formula (2); next, each first text segmentation can be converted into a vector form to obtain a word embedding vector of each first text segmentation; further, the position embedding vector of each first text segmentation can be obtained. This process may include determining the entity pair text information corresponding to each first text segmentation. The first position of the first entity and the second position of the second entity in the information can be determined, and then the distance between each first text segmentation and the first position of the first entity can be determined as the first position embedding vector, and the distance between each first text segmentation and the second position of the second entity can be determined as the second position embedding vector, that is, the two position embedding vectors of each first text segmentation can be obtained; then, the word embedding vector of each first text segmentation and the two position embedding vectors can be spliced to obtain the splicing vector of each first text segmentation, as shown in formula (3); finally, the splicing vector can be used as the first text vector of the entity pair text information corresponding to the multiple first text segmentations.
[0045]
[0046] in, It can represent multiple first text segmentations; [CLS] and [SEP] are special markers used to indicate the beginning of entity pair text information and to segment sentences respectively; It is the word embedding vector of the entity pair text information.
[0047]
[0048] in, A first text vector of entity pair text information corresponding to the plurality of first text segmentations; is the word embedding vector; is the position embedding vector; It can represent the number of the multiple first text segmentations.
[0049] Part 2. In the first part, the BERT model can determine and output the first text vector of each entity pair text information. The feature extraction module in the PCNN model can include multiple convolution layers and multiple pooling layers. The feature extraction module can perform sliding and convolution calculations on the first text vector of each entity pair text information output by the BERT model through multiple different convolution layers to obtain multiple first power features corresponding to the entity pair text information. The multiple first power features can be in the form of a vector matrix, where the convolution calculation formula can refer to the following formula (4):
[0050]
[0051] in, It may be a feature vector matrix corresponding to the plurality of first power features; is the weight matrix of the i-th convolution kernel; is the convolution kernel length; is the concatenation of the j-w+1th and jth word vectors; n is the number of convolution kernels.
[0052] Next, the feature extraction module can filter the multiple first power features output by the multiple convolutional layers through multiple pooling layers to obtain multiple key first power features, and obtain the key feature vector matrix of the multiple key first power features corresponding to the text information of each entity, wherein each feature vector in the feature vector matrix of the first power feature can be segmented. In a possible implementation, each feature vector can be divided into three segments, the first segment is from the beginning of the vector to the first position of the first entity; the second segment is from the first position of the first entity to the second position of the second entity; and the third segment is from the second position of the second entity to the end of the vector. See the following formulas (5) and (6):
[0053]
[0054] in, is the maximum value of the jth segment in the i-th data; is the segmented maximum pooling result of the i-th data; It is the segmented maximum pooling result obtained by concatenating all convolution kernels; tanh is the activation function.
[0055] Furthermore, the classification module in the PCNN model may include a fully connected layer, which may obtain the initial relationship category prediction result between the first entity and the second entity in the entity pair text information according to the key feature vector matrix corresponding to the entity pair text information output by the feature extraction module. The calculation process may be shown in the following formulas (7) and (8):
[0056]
[0057] in, is the learnable weight; is a vector of Bernoulli random variables; is the dot product operation; b is the learnable bias; is the output value of the i-th node; t is the number of relationship types.
[0058] Step 108, taking the initial relation extraction model as the source model, and taking the to-be-trained distilled relation extraction model as the target model, and training the target model according to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, to obtain the target relation extraction model corresponding to the initial relation extraction model.
[0059] The to-be-trained distilled relation extraction model can be trained according to the initial relation category prediction result of the first entity and the second entity in the text information of the entity pair output by the initial relation extraction model and the relation category label of the first entity and the second entity. In a possible implementation, a first weight of the initial relation category prediction result and a second weight of the relation category label can be determined. According to the first weight and the second weight, the initial relation category prediction result and the relation category label are weighted summed to obtain the first relation category prediction result of the entity pair in the text information for the first entity and the second entity. In a possible implementation, a temperature parameter can also be introduced to soften the initial relation category prediction result output by the initial relation extraction model to obtain a softened relation category label. Then, according to the softened relation category label and the relation category label, the first relation category prediction result of the entity pair in the text information for the first entity and the second entity is obtained. The softening calculation can refer to the following formula (9). Furthermore, according to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model can be trained to obtain the target relation extraction model corresponding to the initial relation extraction model. Specifically, in the first part, the relation extraction model to be distilled may include a second language processing module, a second feature extraction module and a second classification module. The second language processing module may be a language representation model BERT, the second feature extraction module and the second classification module may be a pulse coupled neural network PCNN, BERT is a pre-trained language representation model based on the Transformer model, and a rich text representation is obtained through large-scale unsupervised learning. BERT can capture the syntactic and semantic information in the text. Specifically, multiple entity pair text information of each entity pair text information can be input into the relation extraction model to be distilled to be trained, and each entity pair text information in the multiple entity pair text information can be segmented by the BERT model in the relation extraction model to be distilled to obtain multiple second text segmentations corresponding to each entity pair text information; next, each second text segmentation can be converted into a vector form to obtain a word embedding vector of each second text segmentation; finally, the multiple word embedding vectors of the multiple second text segmentations can be used as the text vector of the entity pair text information corresponding to the multiple second text segmentations. The second part, in the first part, the BERT model can determine and output the second text vector of each entity pair text information, the feature extraction module in the PCNN model can include multiple convolution layers and multiple pooling layers, and the feature extraction module can perform sliding and convolution calculations on the second text vector of each entity pair text information output by the BERT model through multiple different convolution layers to obtain multiple second power features corresponding to the entity pair text information, and the multiple second power features can be in the form of a vector matrix.
[0060] Next, the feature extraction module can filter the multiple second power features output by the multiple convolutional layers through multiple pooling layers to obtain multiple key second power features, and obtain a key feature vector matrix of the multiple key second power features corresponding to the text information of each entity.
[0061] Furthermore, the classification module in the PCNN model may include a fully connected layer, which can obtain the second relationship category prediction result of the first entity and the second entity in the entity pair text information based on the key feature vector matrix of the key second power feature corresponding to the entity pair text information output by the feature extraction module.
[0062] Furthermore, the target model can be trained according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model to obtain the target relationship extraction model corresponding to the initial relationship extraction model, wherein the calculation of softening can refer to formula (9), and the calculation of the loss function can refer to the following formula (10).
[0063]
[0064] in, The softened probability of the initial relationship category prediction result. is the cross entropy loss after distillation of the source model and the target model; The loss between the target model prediction value and the true value; is the true label; and They are the probability distributions of the source model and target model outputs when the temperature parameter is T.
[0065] In addition, the Adaptive Moment Estimation (Adam) algorithm and the cross entropy loss function can be used to optimize the parameters of the initial relationship extraction model and the target relationship extraction model. After the model training is completed, the model parameters are saved in the data file, and the model parameters can be directly exported for use during testing.
[0066] In the method of this embodiment, first, multiple entity pair text information associated with the target distribution network system can be obtained; the entity pair text information includes a pair of entity pairs, and relationship category labels between the entity pairs; next, the initial relationship extraction model to be trained can be trained according to the multiple entity pair text information and the relationship category labels of each entity pair text information to obtain the initial relationship extraction model; then, the initial relationship extraction model can be used as the source model, and the relationship extraction model to be distilled to be trained can be used as the target model, and according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model, the target model can be trained to obtain the target relationship extraction model corresponding to the initial relationship extraction model. In the method provided in the embodiment of the present application, knowledge distillation and artificial intelligence can be combined to construct a relationship extraction model of the target distribution network system, and a knowledge graph of the target distribution network system can be constructed based on the relationship extraction model for distribution network operation and maintenance, thereby improving the accuracy of relationship extraction and the efficiency of distribution network system operation and maintenance.
[0067] In an exemplary embodiment, as shown in FIG2 , step 106 may include steps 202 to 208. Among them:
[0068] Step 202: input multiple entity pair text information into the initial relation extraction model to be trained, and the first language processing module in the initial relation extraction model determines and outputs the first text vector corresponding to each entity pair text information.
[0069] Among them, the initial relationship extraction model to be trained may include a first language processing module, a first feature extraction module and a first classification module. The first language processing module may be a language representation model BERT, and the first feature extraction module and the first classification module may be a pulse coupled neural network PCNN. Specifically, multiple entity pair text information of each entity pair text information can be input into the initial relation extraction model to be trained. In the first part, each entity pair text information in the multiple entity pair text information can be segmented by the BERT model in the initial relation extraction model to obtain multiple first text segmentations corresponding to each entity pair text information; next, each first text segmentation can be converted into a vector form to obtain a word embedding vector of each first text segmentation; further, a position embedding vector of each first text segmentation can be obtained, and the process can include determining a first position of a first entity and a second position of a second entity in the entity pair text information corresponding to each first text segmentation, and then, the distance between each first text segmentation and the first position of the first entity can be determined as a first position embedding vector, and the distance between each first text segmentation and the second position of the second entity can be determined as a second position embedding vector, that is, two position embedding vectors of each first text segmentation can be obtained; then, the word embedding vector of each first text segmentation and the two position embedding vectors can be spliced to obtain a splicing vector of each first text segmentation; finally, the splicing vector can be used as the first text vector of the entity pair text information corresponding to the multiple first text segmentations.
[0070] Step 204 , the first feature extraction module in the initial relationship extraction model determines and outputs the first power feature corresponding to the text information of each entity according to the first text vector output by the first language processing module.
[0071] In the first part, the BERT model can determine and output the first text vector of each entity pair text information. The feature extraction module in the PCNN model may include multiple convolutional layers and multiple pooling layers. The feature extraction module can perform sliding and convolution calculations on the first text vector of each entity pair text information output by the BERT model through multiple different convolutional layers to obtain multiple first power features corresponding to the entity pair text information. The multiple first power features can be in the form of a vector matrix.
[0072] Step 206 , the first classification module in the initial relationship extraction model determines and outputs the initial relationship category prediction result of the entity to text information according to the first power feature output by the first feature extraction module.
[0073] Among them, the feature extraction module can screen the multiple first power features output by the multiple convolution layers through multiple pooling layers to obtain multiple key first power features, and obtain the key feature vector matrix of the multiple key first power features corresponding to the text information of each entity. Among them, the segmented pooling layer of PCNN obtains a vector from each convolution kernel, divides the vector into three parts according to the positions of the two entities, and then uses the maximum pooling method to take out the maximum value of each part. Each feature vector in the feature vector matrix of the first power feature can be segmented. In a possible implementation method, each feature vector can be divided into three sections, the first section is from the beginning of the vector to the first position of the first entity; the second section is from the first position of the first entity to the second position of the second entity; the third section is from the second position of the second entity to the end of the vector. Step 208, according to the difference between the initial relationship category prediction result and the relationship category label, the initial relationship extraction model to be trained is trained to obtain the initial relationship extraction model.
[0074] Among them, the classification module in the PCNN model may include a fully connected layer, which can obtain the initial relationship category prediction result between the first entity and the second entity in the entity pair text information based on the key feature vector matrix corresponding to the entity pair text information output by the feature extraction module.
[0075] In the method of this embodiment, the semantic representation model and the artificial intelligence model can be combined to train the initial relationship extraction model, thereby improving the accuracy of teacher model training and teacher model action.
[0076] In an exemplary embodiment, as shown in FIG3 , step 202 may include steps 302 to 306. Among them:
[0077] Step 302: The first language processing module in the initial relation extraction model segments each entity pair of text information to obtain a plurality of first text segmentations.
[0078] Step 304, obtaining a first word embedding vector corresponding to each first text word segment, and obtaining a position embedding vector of each first text word segment.
[0079] Among them, the first position of the first entity and the second position of the second entity in the text information corresponding to each first text segmentation can be determined first, and then the distance between each first text segmentation and the first position of the first entity can be determined as a first position embedding vector, and the distance between each first text segmentation and the second position of the second entity can be determined as a second position embedding vector, that is, two position embedding vectors of each first text segmentation are obtained.
[0080] Step 306: Obtain a first text vector for each entity pair of text information based on the first word embedding vector and the position embedding vector.
[0081] Among them, the word embedding vector of each first text segmentation and the two position embedding vectors can be concatenated to obtain the concatenated vector of each first text segmentation, as shown in formula (3); finally, the concatenated vector can be used as the first text vector of the entity pair text information corresponding to the multiple first text segmentations.
[0082]
[0083] in, A first text vector of entity pair text information corresponding to the plurality of first text segmentations; is the word embedding vector; is the position embedding vector; It can represent the number of the multiple first text segmentations.
[0084] In an exemplary embodiment, step 306 may include:
[0085] The word embedding vector and the position embedding vector are concatenated to obtain the concatenated vector of each first text segmentation; and the first text vector of each entity pair text information is obtained according to the concatenated vector.
[0086] In the embodiment of the present application, a language representation model can be used to extract semantic information from multiple entity pair text information of the entity pair text information, which can improve the accuracy of subsequent relationship extraction.
[0087] In an exemplary embodiment, as shown in FIG4 , step 108 may include steps 402 to 406. Among them:
[0088] Step 402 : acquiring a first relationship category prediction result corresponding to each entity pair of text information according to the initial relationship category prediction result of the source model for each entity pair of text information and the relationship category label of each entity pair of text information.
[0089] The to-be-trained distilled relation extraction model can be trained based on the initial relation category prediction results of the first entity and the second entity in the text information of the entity pair output by the initial relation extraction model and the relation category labels of the first entity and the second entity. In a possible implementation, the first weight of the initial relation category prediction result and the second weight of the relation category label can be determined. According to the first weight and the second weight, the initial relation category prediction result and the relation category label are weighted and summed to obtain the first relation category prediction results of the first entity and the second entity in the text information of the entity pair. In a possible implementation, a temperature parameter can also be introduced to soften the initial relation category prediction results output by the initial relation extraction model to obtain a softened relation category label, and then according to the softened relation category label and the relation category label, the first relation category prediction results of the first entity and the second entity in the text information of the entity pair are obtained.
[0090] Step 404: Obtain the second relationship category prediction result of the target model.
[0091] Step 406: Train the target model according to the difference between the first relationship category prediction result and the second relationship category prediction result to obtain a target relationship extraction model corresponding to the initial relationship extraction model.
[0092] In one possible implementation, isomorphic distillation may also be performed on the intermediate layer of the to-be-distilled relation extraction model according to the intermediate layer of the initial relation extraction model.
[0093] In an exemplary embodiment, step 404 may include:
[0094] Input multiple entity pair text information into the to-be-trained to-be-distilled relation extraction model, and determine and output the second text vector corresponding to each entity pair text information by the second language processing module of the to-be-distilled relation extraction model; determine and output the second power feature corresponding to each entity pair text information by the second feature extraction module in the to-be-distilled relation extraction model according to the second text vector output by the second language processing module; determine and output the second relationship category prediction result of the entity pair text information by the second classification module in the to-be-distilled relation extraction model according to the second power feature output by the second feature extraction module. In a possible implementation, obtaining the second text vector may include: the second language processing module in the to-be-distilled relation extraction model performs word segmentation on each entity pair text information to obtain multiple second text word segments; obtain the second word embedding vector corresponding to each second text word segmentation; obtain the second text vector of each entity pair text information according to the second word embedding vector.
[0095] Among them, in the first part, the relation extraction model to be distilled may include a second language processing module, a second feature extraction module and a second classification module. The second language processing module may be a language representation model BERT, the second feature extraction module and the second classification module may be a pulse coupled neural network PCNN, BERT is two pre-trained language representation models based on the Transformer model, and a rich text representation is obtained through large-scale unsupervised learning. BERT can capture the syntactic and semantic information in the text. Specifically, each entity pair text information can be input into the relation extraction model to be trained to be distilled, and each entity pair text information in the multiple entity pair text information can be segmented by the BERT model in the relation extraction model to be distilled to obtain multiple second text segmentations corresponding to each entity pair text information; next, each second text segmentation can be converted into a vector form to obtain a word embedding vector of each second text segmentation; finally, the multiple word embedding vectors of the multiple second text segmentations can be used as the text vector of the entity pair text information corresponding to the multiple second text segmentations. The second part, in the first part, the BERT model can determine and output the second text vector of each entity pair text information, the feature extraction module in the PCNN model can include multiple convolution layers and multiple pooling layers, and the feature extraction module can perform sliding and convolution calculations on the second text vector of each entity pair text information output by the BERT model through multiple different convolution layers to obtain multiple second power features corresponding to the entity pair text information, and the multiple second power features can be in the form of a vector matrix.
[0096] Next, the feature extraction module can filter the multiple second power features output by the multiple convolutional layers through multiple pooling layers to obtain multiple key second power features, and obtain a key feature vector matrix of the multiple key second power features corresponding to the text information of each entity.
[0097] Furthermore, the classification module in the PCNN model may include a fully connected layer, which can obtain the second relationship category prediction result of the first entity and the second entity in the entity pair text information based on the key feature vector matrix of the key second power feature corresponding to the entity pair text information output by the feature extraction module.
[0098] In the method of this embodiment, knowledge distillation and artificial intelligence can be combined to train the initial relationship extraction model, and then the target relationship extraction model is trained based on the initial relationship model, thereby reducing the number of model parameters and improving the accuracy of the relationship extraction model.
[0099] In an exemplary embodiment, the embodiment of the present application may further include the following steps to introduce the test of the prediction accuracy of the target relationship extraction model, and the steps may specifically include:
[0100] The test entity pair text information associated with the target power distribution network system can be obtained; the multiple test entity pair text information is input into the target relationship extraction model to obtain the relationship category prediction result between the first entity and the second entity in the test entity pair text information; according to the difference between the relationship category prediction result and the actual relationship category label of the first entity and the second entity in the test entity pair text information, the prediction accuracy of the target relationship extraction model is determined. The calculation process can be referred to the following formula (11):
[0101]
[0102] Among them, TP is the true positive example, that is, the number of prediction accuracy that meets the requirements; FP is the false positive example, that is, the number of prediction accuracy that does not meet the requirements.
[0103] In the method of this embodiment, the trained target relationship extraction model can be tested to optimize the parameters of the target relationship extraction model and improve the prediction accuracy of the target relationship extraction model.
[0104] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0105] Based on the same inventive concept, the embodiment of the present application also provides a relationship extraction model construction device for implementing the relationship extraction model construction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more relationship extraction model construction device embodiments provided below can refer to the limitations of the relationship extraction model construction method above, and will not be repeated here.
[0106] In one embodiment, as shown in FIG5 , a relationship extraction model construction device is provided, including: an acquisition module 502, a first training module 504504, and a second training module 506506, wherein:
[0107] An acquisition module 502 is used to acquire a plurality of entity pair text information associated with a target power distribution network system; the entity pair text information includes a pair of entity pairs and a relationship category label between the entity pairs;
[0108] A first training module 504 is used to train the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category label of each entity pair text information to obtain the initial relation extraction model;
[0109] The second training module 506 is used to use the initial relationship extraction model as the source model and the to-be-trained distilled relationship extraction model as the target model, and train the target model according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model to obtain the target relationship extraction model corresponding to the initial relationship extraction model.
[0110] In one embodiment, the initial relationship extraction model includes a first language processing module, a first feature extraction module and a first classification module; the first training module 504 is also used to: input multiple entity pair text information into the initial relationship extraction model to be trained, and the first language processing module in the initial relationship extraction model determines and outputs the first text vector corresponding to each entity pair text information; the first feature extraction module in the initial relationship extraction model determines and outputs the first power feature corresponding to each entity pair text information according to the first text vector output by the first language processing module; the first classification module in the initial relationship extraction model determines and outputs the initial relationship category prediction result of each entity pair text information according to the first power feature output by the first feature extraction module; according to the difference between the initial relationship category prediction result and the relationship category label, the initial relationship extraction model to be trained is trained to obtain the initial relationship extraction model.
[0111] In one embodiment, the first training module 504 is also used to: use the first language processing module in the initial relation extraction model to segment the text information of each entity pair to obtain multiple first text segmentations; obtain the first word embedding vector corresponding to each first text segmentation, and obtain the position embedding vector of each first text segmentation; obtain the first text vector of each entity pair text information based on the first word embedding vector and the position embedding vector.
[0112] In one embodiment, the first training module 504 is further used to: concatenate the word embedding vector and the position embedding vector to obtain a concatenated vector of each of the first text segmentations; and obtain the first text vector of each of the entity pair text information based on the concatenated vector.
[0113] In one embodiment, the second training module 506 is further used to: obtain the first relationship category prediction result corresponding to each entity pair of text information based on the initial relationship category prediction result of the source model for each entity pair of text information and the relationship category label of each entity pair of text information; obtain the second relationship category prediction result of the target model; and train the target model based on the difference between the first relationship category prediction result and the second relationship category prediction result to obtain the target relationship extraction model corresponding to the initial relationship extraction model.
[0114] In one embodiment, the relationship extraction model to be distilled includes a second language processing module, a second feature extraction module and a second classification module; the second training module 506 is also used to: input multiple entity pair text information into the relationship extraction model to be distilled to be trained, and the second language processing module of the relationship extraction model to be distilled determines and outputs the second text vector corresponding to each entity pair text information; the second feature extraction module in the relationship extraction model to be distilled determines and outputs the second power feature corresponding to each entity pair text information according to the second text vector output by the second language processing module; the second classification module in the relationship extraction model to be distilled determines and outputs the second relationship category prediction result of each entity pair text information according to the second power feature output by the second feature extraction module.
[0115] In one embodiment, the second training module 506 is further used to: segment the text information of each entity pair by the second language processing module in the relationship extraction model to be distilled to obtain multiple second text segmentations; obtain the second word embedding vector corresponding to each second text segmentation; and obtain the second text vector of each entity pair text information based on the second word embedding vector.
[0116] Each module in the above-mentioned relationship extraction model construction device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0117] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in FIG6 . The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the construction of a relational extraction model. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for constructing a relational extraction model is implemented.
[0118] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0120] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0121] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0123] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0124] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0125] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a relationship extraction model, characterized in that: The method comprises: Acquire multiple entity pair text information associated with the target distribution network system; the entity pair text information includes a pair of entity pairs and relationship category labels between the entity pairs; Training the initial relation extraction model to be trained according to the plurality of entity pair text information and the relation category labels of the entity pair text information to obtain the initial relation extraction model; The initial relation extraction model is used as the source model, and the to-be-trained distilled relation extraction model is used as the target model. According to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model, the target model is trained to obtain the target relation extraction model corresponding to the initial relation extraction model.
2. The method according to claim 1, characterized in that The initial relationship extraction model includes a first language processing module, a first feature extraction module and a first classification module; The training of the initial relation extraction model to be trained to obtain the initial relation extraction model includes: Inputting a plurality of entity pair text information into the initial relation extraction model to be trained, and determining and outputting a first text vector corresponding to each entity pair text information by the first language processing module in the initial relation extraction model; The first feature extraction module in the initial relationship extraction model determines and outputs the first power feature corresponding to each entity pair text information according to the first text vector output by the first language processing module; The first classification module in the initial relationship extraction model determines and outputs the initial relationship category prediction result of each entity to the text information according to the first power feature output by the first feature extraction module; According to the difference between the initial relationship category prediction result and the relationship category label, the initial relationship extraction model to be trained is trained to obtain the initial relationship extraction model.
3. The method according to claim 2, characterized in that The first language processing module in the initial relationship extraction model determines and outputs a first text vector corresponding to each entity pair text information, including: The first language processing module in the initial relation extraction model performs word segmentation on each of the entity text information to obtain a plurality of first text word segments; Obtaining a first word embedding vector corresponding to each of the first text segmentations, and obtaining a position embedding vector of each of the first text segmentations; The first text vector of the text information of each entity pair is obtained according to the first word embedding vector and the position embedding vector.
4. The method according to claim 3, characterized in that The obtaining, according to the first word embedding vector and the position embedding vector, the first text vector of each entity pair text information includes: Concatenate the word embedding vector and the position embedding vector to obtain a concatenated vector of each first text word segment; The first text vector of each entity pair text information is obtained according to the splicing vector.
5. The method according to claim 1, characterized in that The step of training the target model according to the difference between the first relationship category prediction result corresponding to the source model and the second relationship category prediction result of the target model to obtain the target relationship extraction model corresponding to the initial relationship extraction model includes: Acquire the first relationship category prediction result corresponding to each entity pair of text information according to the initial relationship category prediction result of the source model for each entity pair of text information and the relationship category label of each entity pair of text information; Obtaining a prediction result of the second relationship category of the target model; According to the difference between the first relationship category prediction result and the second relationship category prediction result, the target model is trained to obtain the target relationship extraction model corresponding to the initial relationship extraction model.
6. The method according to claim 5, characterized in that The to-be-distilled relation extraction model comprises a second language processing module, a second feature extraction module and a second classification module; The obtaining the second relationship category prediction result of the target model includes: Inputting a plurality of entity pair text information into the to-be-distilled relation extraction model to be trained, and determining and outputting a second text vector corresponding to each entity pair text information by the second language processing module of the to-be-distilled relation extraction model; The second feature extraction module in the to-be-distilled relationship extraction model determines and outputs the second power feature corresponding to each of the entity pairs of text information according to the second text vector output by the second language processing module; The second classification module in the to-be-distilled relation extraction model determines and outputs the second relation category prediction result of each entity to the text information according to the second power feature output by the second feature extraction module.
7. The method according to claim 6, characterized in that The second language processing module of the to-be-distilled relation extraction model determines and outputs a second text vector corresponding to each of the entity pairs of text information, including: The second language processing module in the to-be-distilled relation extraction model performs word segmentation on each of the entity pairs of text information to obtain a plurality of second text word segments; Obtain a second word embedding vector corresponding to each of the second text word segments; The second text vector of each entity pair text information is obtained according to the second word embedding vector.
8. A relationship extraction model construction device, characterized in that: The device comprises: An acquisition module, used to acquire a plurality of entity pair text information associated with a target power distribution network system; the entity pair text information includes a pair of entity pairs and a relationship category label between the entity pairs; A first entity pair text information training module, used for training an initial relation extraction model to be trained according to a plurality of entity pair text information and the relation category label of each entity pair text information, to obtain the initial relation extraction model; The second training module is used to use the initial relation extraction model as the source model and the to-be-trained distilled relation extraction model as the target model, and train the target model according to the difference between the first relation category prediction result corresponding to the source model and the second relation category prediction result of the target model to obtain the target relation extraction model corresponding to the initial relation extraction model.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, 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 7 are implemented.
Citation Information
Patent Citations
Text relationship extraction method and device, computer equipment and storage medium
CN111324743A
Text statement processing method and device, computer equipment and storage medium
CN111950269A
Relationship extraction method, system and equipment and storage medium
CN114969372A
Entity relationship extraction method
CN115081452A
Document-level relation extraction method based on forward guidance knowledge distillation
CN115640809A
