A method for entity relationship extraction from Chinese short texts

Optimizing the BERT model through horizontal federated learning and adversarial training solves the problems of large BERT model size and insufficient Chinese data, and achieves efficient, safe and accurate Chinese short text relationship extraction, which is suitable for practical applications.

CN114492412BInactive Publication Date: 2024-10-01HUNAN UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202210124098.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-10
Publication Date
2024-10-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing Chinese short text relationship extraction method based on the BERT model has the problems of large model size, difficult deployment, high cost and low efficiency. In addition, the insufficient amount of Chinese data and privacy issues lead to insufficient comprehensive and accurate results.

Method used

Using a method that combines horizontal federated learning and adversarial training, the BERT model is optimized through adversarial perturbation to label head entities and tail entities, and uses horizontal federated learning collaborative training to obtain the final entity relationship extraction model to ensure data privacy and improve model robustness. sex.

Benefits of technology

It is possible to reduce the size of the model, improve the accuracy and ease of deployment of the model, and reduce computing and equipment requirements while ensuring data privacy, making it suitable for practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114492412B_ABST
    Figure CN114492412B_ABST
Patent Text Reader

Abstract

The present invention discloses an entity relationship extraction method for Chinese short texts, including obtaining Chinese data, and performing preprocessing, expanding and marking texts that are less than a preset sentence length to obtain processed texts; performing feature extraction on the processed texts; constructing a head entity annotation model, and performing head entity prediction; constructing a tail entity annotation model for a specific relationship, performing tail entity prediction, and obtaining the final triples of each participant; using horizontal federated learning for collaborative training, obtaining the final loss, obtaining the final entity relationship extraction model, and performing entity relationship extraction on the current Chinese short text. The present invention can effectively ensure the confidentiality of data and improve data security. At the same time, it is different from traditional federated learning. After integrating the idea of ​​knowledge distillation, it avoids the large parameters of the relationship extraction model, reduces a large part of the network overhead and time overhead, and can safely and efficiently extract the entity relationship of the Chinese short text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of natural language data processing, and in particular relates to an entity relationship extraction method for Chinese short texts. Background Art

[0002] In today's Internet era, Chinese short texts are important information carriers in our daily lives. A Chinese sentence can be a description of a person, a description of a tourist attraction, or the correspondence between medical disease symptoms, etc. Relation extraction of Chinese short texts, that is, the textual abstraction of the real world of life, identifies entities in unstructured Chinese natural language short texts (non-documents) and extracts the semantic relationships between entities. Relation extraction of Chinese short texts is an important cornerstone for building knowledge graphs and intelligent question-answering systems. The above semantic relationships are usually called triples SPO (Subject, Predicate, Object) in natural language processing.

[0003] In addition, with the development of pre-trained models and their remarkable achievements in classification and sequence labeling tasks in natural language processing, their application in relation extraction tasks is becoming more and more common, especially the BERT (Bidirectional Encoder Representation from Transformers) pre-trained model. Usually in the BERT-based relation extraction joint model, BERT's powerful encoding ability is used as a feature extractor for relation extraction tasks, while extracting the information of entities in sentences and the semantic and grammatical information of the sentences themselves. However, it should be noted that the BERT pre-trained model learns the feature representation of words by training massive samples. In the BERT model, the Chinese-BERT-wwm pre-trained model for Chinese tasks contains 110M parameters for training and learning word models. The research shows that the larger the parameter, the higher the accuracy of training. However, the corresponding weight model generated in the relation extraction method based on the BERT model is larger in size, which will lead to deployment difficulties in practical applications, high cost and low efficiency.

[0004] In addition, most of the current deep learning-based models model relations as discrete labels on entity pairs. First, all entities in the sentence are identified through named entity recognition, and then a relation classifier is learned to classify relations on entity pairs. This makes relation classification an unbalanced classification problem, resulting in incomplete and inaccurate results.

[0005] Furthermore, when applying relational models in Chinese short texts, we face the problem that different users in professional fields hold their own data, and data is private to companies or users. Most people or companies are sensitive about data, so data islands exist in real life. However, a small amount of data from each user is far from enough for machine learning. The insufficient amount of Chinese data and privacy issues are also one of the bottlenecks in the development of Chinese relationship extraction. Summary of the invention

[0006] The purpose of the present invention is to provide a method for extracting entity relationships of Chinese short texts, which can safely and efficiently extract entity relationships of Chinese short texts.

[0007] The entity relationship extraction method for Chinese short text provided by the present invention comprises the following steps:

[0008] S1. Obtain Chinese data and perform preprocessing, which includes segmenting long texts exceeding a preset sentence length, expanding texts less than a preset sentence length, and marking them to obtain processed texts;

[0009] S2. Load the BERT pre-trained model and perform feature extraction on the processed text;

[0010] S3. Build a head entity annotation model and perform head entity prediction;

[0011] S4. Build a tail entity annotation model for a specific relationship, perform tail entity prediction, and obtain the final triplet of each participant;

[0012] S5. Use horizontal federated learning for collaborative training to obtain the final loss, and input the final loss into the final triplet of each participant to obtain the final entity relationship extraction model, and perform entity relationship extraction on the current Chinese short text.

[0013] The step S1 includes setting the training set and verification data set data format json, including text label line and triple_list label line; segmenting long sentences whose length exceeds a preset value, so that the sentence length of each training data Chinese text is the preset value, expanding the sentences that are less than the preset value, adding special symbols, obtaining standard sentences, and marking the beginning and end; loading the tokenizer and word dictionary of the BERT pre-training model, marking and segmenting the original text to adapt to the input format of the BERT pre-training model.

[0014] The step S2 comprises:

[0015] A1. Input the processed original text into the embedding layer of the BERT pre-trained model, including word embedding coding to vectorize the text; segment embedding coding to separate the sentences and distinguish different sentences; position embedding coding to encode the word positions, using dynamic training to train the position coding dictionary, and find the word position coding through the position coding dictionary in the subsequent coding layer; add the three outputs of word embedding coding, segment embedding coding, and position embedding coding as the final input;

[0016] A2. Send the final input to the encoding layer, including inputting the output of the embedding layer into an encoding network consisting of 12 layers of the same structure. Each layer normalizes the result through a normalization function and outputs the last layer to obtain the output containing the semantic features of the sentence.

[0017] The step A1 comprises:

[0018] B1. Define the model after introducing adversarial training as:

[0019]

[0020] Among them, θ is the model parameter; E (x,y)~D represents external risk; x represents the output of word embedding in the embedding layer; y represents the global label; L(x+Δx,y; θ) represents the loss of a single sample; D represents the distribution of input samples; Δx represents the adversarial perturbation parameter; Ω represents the perturbation space; adversarial training is to inject the adversarial perturbation parameter Δx into the output x of the word embedding in the embedding layer, and use (x+Δx,y) as the data minimization loss to update the parameter, and calculate the adversarial perturbation parameter Δx.

[0021] Where x represents the output of word embedding in the embedding layer; y represents the global label; θ is the model parameter; ∈ is a constant;

[0022] B2. Standardize the anti-disturbance parameter Δx:

[0023]

[0024] Where Δx' represents the normalized adversarial perturbation parameter Δx; x represents the output of the word embedding in the embedding layer; sign(·) is a sign function used for normalization; y represents the global label; θ is a model parameter; ∈ is a constant;

[0025] B3. Add the standardized adversarial perturbation parameter Δx' to the input layer, delete the standardized adversarial perturbation parameter Δx', and restore the input layer;

[0026] B4. Repeat steps B1-B3 and iterate the adversarial disturbance parameter Δx. The entire optimization process is to alternately maximize the loss and minimize the external risk, and customize a disturbance parameter that maximizes the loss for each step.

[0027] The step S3 includes classifying the last hidden state of the BERT output to obtain the start and end positions of the head entity subject. The head and tail prediction of the subject uses a sigmoid activation function to perform a binary classification task to predict the probability distribution of the token as the head or the tail; sigmoid activation function: To map a real number to the interval (0,1) for binary classification, x represents the output of word embedding in the embedding layer; the output x of word embedding in the embedding layer is the value of the head of the entity in the probability interval [0,1], as the probability of token as the first word; the output x of word embedding in the embedding layer is the value of the tail of the entity in the probability interval [0,1], as the probability of token as the last word.

[0028] The step S4 includes adding the head and tail vectors of each subject and averaging them as entity features, adding the entity features to the token features, and predicting the tail entity on the specific relationship set schema; specifically, using the sigmoid activation function for classification, obtaining the probability distribution corresponding to each token under multiple classifications, and obtaining the final triplet.

[0029] The step S5 comprises the following steps:

[0030] C1. During the data processing phase, the data is reshuffled; 30% of the training set is used as the validation set; the remaining set is divided into two parts;

[0031] C2. Each participant's local model is trained using the model after the adversarial training. After the training is completed, a local prediction result is made for the verification data set, and the prediction result is uploaded to the server model for learning;

[0032] C3. The prediction results of the participants are uploaded to the server for summing and averaging. The trusted third-party server uses the fusion result features to train the local models of each participating method.

[0033] The step C3 comprises the following steps:

[0034] D1. Fusion of the local models of each participant, including summing and averaging the predicted probabilities of the tail entity of each participant's local model in a specific relationship, and normalizing them into probability distribution using softmax, to obtain the probability value of the predicted result s and the predicted probability distribution of the participant;

[0035] D2. Use a third-party server to learn the local models of each participant, including obtaining the probability value of the prediction result s, and obtaining the loss of the local tail entity prediction of a specific relationship in a small sample; use horizontal federated learning for collaborative training to obtain the final loss, and input the final loss into the final triplet of each participant to obtain the final entity relationship extraction model, and perform entity relationship extraction on the current Chinese short text.

[0036] The step D1 comprises summing and averaging the probabilities predicted by each participant's local model at the tail entity of a specific relationship,

[0037]

[0038] Among them, z(y i |s) represents the average of the sum of the final probability values; p(y i |s,Θ (j) ) represents the input text s and the input j-th participant model parameter Θ in the j-th participant (j) , whose output category is the i-th category y i The predicted probability of is the total number of participants;

[0039] Use softmax to normalize to probability distribution,

[0040]

[0041] Among them, q(y i |s) means that the predicted probability of each participant for each category is averaged and normalized to a probability distribution; s means text; exp(·) means the normalized exponential function; in normalization, τ means the temperature of the distillation process; r is distinguished from I in the numerator in the formula, and the denominator means the sum of the numerators, ∑ r exp(z(y r |s) / τ) represents the sum of probability distributions of all categories.

[0042] The step D2 includes training the server model on a local data set to obtain the training loss I of the local server model in a small sample: Among them, y i is the correct result of the i-th target; is the i-th prediction result; p(·) represents the probability function, is the probability of the prediction result being correct; log(·) is the logarithm, which is used to indicate the amount of information;

[0043] Add the loss of the distillation step: use the fusion of the participant prediction results and the KL divergence predicted by the third-party server model: KL divergence represents the difference between two probability distributions, where represents the predicted probability distribution of the participants; is the i-th prediction result; The probability distribution of the prediction for the third-party server is as follows: The smaller the difference, the smaller the overall loss of the third-party server model. The overall loss L is: Among them, D v For validation dataset.

[0044] The entity relationship extraction method for Chinese short texts provided by the present invention can effectively ensure the confidentiality of data and improve data security by introducing federated learning. At the same time, it is different from traditional centralized federated learning. After integrating the idea of ​​knowledge distillation, it avoids the relationship extraction model parameters being too large, and there will be a network performance bottleneck when uploading to the central server. In decentralized federated learning, only the probability distribution of the prediction results of the participants needs to be uploaded. Compared with uploading the entire model parameters, a large part of the network overhead and time overhead are reduced. A smaller model is learned while ensuring a small performance gap. Compared with a larger model, it is more applicable in production and life, and is easier to embed into practical applications, reducing the model's requirements for calculation and equipment, and meeting a wider range of usage needs. The introduction of adversarial training, by perturbing the embedding layer, generates adversarial samples, finds the model parameters with the smallest loss while improving the error rate, updates the model, improves the robustness of the model, and improves the accuracy of the overall model, so that the entity relationship of Chinese short texts can be extracted safely and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a schematic diagram of the process of the present invention.

[0046] Figure 2 Schematic diagram of a flow chart of an embodiment of the present invention.

[0047] Figure 3 Schematic diagram of the BERT pre-training model structure of an embodiment of the present invention.

[0048] Figure 4 Schematic diagram of the adversarial training process of the method of the present invention.

[0049] Figure 5 Schematic diagram of the horizontal federated learning framework structure of the method of the present invention. DETAILED DESCRIPTION

[0050] In order to improve the accuracy, comprehensiveness and ease of deployment of entity relationship extraction results, the present invention proposes a novel entity relationship extraction method for Chinese short texts.

[0051] On the one hand, adversarial training can be used to integrate user models to make up for the imbalance in relational classification, which results in incompleteness and inaccuracy. Adversarial training is essentially a data defense behavior that adds perturbations to construct adversarial samples, thereby improving the robustness of the model, and as a normalization method, it reduces overfitting and improves the performance and generalization of the model to a certain extent. At the beginning, the concept of adversarial training was applied to the image field, that is, adding tiny perturbations to continuous RGB values. In NLP tasks, it is usually used to adversarially target the encoding matrix parameters of the text. In fact, adversarial training can be abstracted as a model. Among them, D represents the training set; x represents the input layer; y represents the label; θ is the model parameter; L(x+Δx,y; θ) represents the loss of a single sample; Δx represents adversarial perturbation; Ω represents the perturbation space.

[0052] On the other hand, in order to solve the problems of insufficient data volume, security and privacy issues, and large-scale models that are difficult to deploy, we use horizontal federated learning to ensure data privacy while using distributed training to supplement the insufficient amount of Chinese data. The essence of horizontal federated learning is the union of samples. When two or more data sets have less data individually, we expand the samples to achieve the purpose of machine learning training. In supervised learning, the quantity and quality of data sets play a vital role in the performance of the model. Through horizontal federated learning, we can make up for the lack of data while ensuring the privacy and security of data. In addition, we use the idea of ​​knowledge distillation in decentralized federated learning to reduce the network consumption of uploading large-volume parameters. We use the larger sample data sets of the participants to learn a model with a small sample data set, which is conducive to the deployment and application of the model in actual production and life.

[0053] like Figure 1 Schematic diagram of the process of the present invention. Figure 2 The present invention provides a method for extracting entity relationships from Chinese short texts, comprising the following steps:

[0054] S1. Obtain Chinese data and perform preprocessing, which includes segmenting long texts exceeding a preset sentence length, expanding texts less than a preset sentence length, and marking them to obtain processed texts;

[0055] S2. Load the BERT pre-trained model and perform feature extraction on the processed text; in this embodiment, the BERT pre-trained model selects the Chinese-BERT-wwm model for the Chinese task, which has the same structure and is a BERT pre-trained model specifically for Chinese tasks;

[0056] S3. Build a head entity annotation model and perform head entity prediction;

[0057] S4. Build a tail entity annotation model for a specific relationship, perform tail entity prediction, and obtain the final triplet of each participant;

[0058] S5. Use horizontal federated learning for collaborative training to obtain the final loss, and input the final loss into the final triplet of each participant to obtain the final entity relationship extraction model, and perform entity relationship extraction on the current Chinese short text.

[0059] The step S1 includes setting the training set and the validation data set data format json, including a text label line and a triple_list label line; segmenting long sentences with a length of more than 100 characters, that is, the sentence length of each training data Chinese text is 100, expanding sentences with less than 100 characters, adding special symbols, obtaining standard sentences, and marking them at the beginning and end, that is, [CLS][SEP], which is used to mark a sentence with a length of 100; loading the tokenizer and word dictionary of the BERT pre-training model, marking and segmenting the original text (that is, the text label content) to adapt to the input format of the BERT pre-training model.

[0060] like Figure 3 Schematic diagram of the BERT pre-training model structure of an embodiment of the present invention. Step S2 includes:

[0061] A1. Input the processed original text into the embedding layer of the BERT pre-trained model, including token embedding, which vectorizes the text into words; segment embedding, which separates the sentences and distinguishes them from each other; position embedding, which encodes the word positions. The dynamic training method is used to train the position encoding dictionary (embedding_lookup). In the subsequent encoder layer, the position encoding of the word will be found through the position encoding dictionary; the three outputs of token embedding, segment embedding and position embedding are added together as the final input.

[0062] The step A1 comprises:

[0063] like Figure 4 The adversarial training process diagram of the method of the present invention. B1. The model after introducing adversarial training is defined as:

[0064]

[0065] Among them, θ is the model parameter; E (x,y)~DRepresents external experience; x represents the output of word embedding in the embedding layer, that is, the matrix parameter of the word embedding layer, that is, token embedding; y represents the global label; L(x+Δx,y;θ) represents the loss of a single sample; D represents the distribution of input samples; Δx represents the adversarial perturbation parameter, that is, the added perturbation represented; Ω represents the perturbation space; adversarial training can be described as injecting adversarial perturbation parameter Δx into the output x of the word embedding in the embedding layer. The goal of adversarial perturbation parameter Δx is to make the loss L(x+Δx,y;θ) of a single sample as large as possible, that is, to make the prediction of the existing BERT pre-training model as wrong as possible. After constructing the adversarial sample x+Δx for each sample, use (x+Δx,y) as the data pair to minimize the external experience to update the parameters (gradient descent);

[0066] Since the gradient descent will increase the loss function, on the contrary, the gradient rise will maximize the loss function, thereby calculating the adversarial perturbation parameter Δx.

[0067] Where x represents the output of word embedding in the embedding layer; y represents the global label; θ is the model parameter; ∈ is a constant, which is 0.25 in this embodiment, and the effect is stable and effective;

[0068] B2. In order to prevent the disturbance from being too large and losing its meaning during the calculation process, the anti-disturbance parameter Δx is standardized:

[0069]

[0070] Where Δx' represents the normalized adversarial perturbation parameter Δx; x represents the output of the word embedding in the embedding layer; sign(·) is a sign function used for normalization; y represents the global label; θ is a model parameter; ∈ is a constant;

[0071] B3. Add the standardized adversarial perturbation parameter Δx' to the input layer. At this time, the gradient decreases, the loss decreases, and the standardized adversarial perturbation parameter Δx' is deleted to restore the input layer.

[0072] B4. Repeat steps B1-B3 to iterate the adversarial perturbation parameter Δx. The entire optimization process is to alternately maximize the loss and minimize the external experience, and customize a perturbation parameter that maximizes the loss for each step until the effect of the adversarial sample is achieved, so as to improve the final accuracy of the BERT pre-trained model.

[0073] A2. Send the final input to the encoder layer, including inputting the output of the embedding layer into an encoder network with 12 layers of the same structure, normalizing the result of each layer through a normalization function, and outputting the last layer to obtain the output containing the semantic features of the sentence. In this embodiment, Figure 3 As shown, by encoding Lu Xun, that is, Zhou Shuren, the word embedding code, segment embedding code, and position embedding code of each character are obtained respectively, and the word features of Lu Xun, that is, Zhou Shuren, are finally obtained through the encoding layer.

[0074] The step S3 includes classifying the last hidden state of the BERT output to obtain the start and end positions of the head entity subject. The head and tail prediction of the subject uses a sigmoid activation function to perform a binary classification task to predict the probability distribution of the token as the head or the tail. Sigmoid activation function: In fact, a real number is mapped to the interval (0,1) for binary classification, where x represents the output of the word embedding in the embedding layer, that is, the value of the tail as the head or tail of the entity in the probability interval [0,1]. Therefore, the result can be used as the probability of the token being the first word or the last word, respectively.

[0075] The step S4 includes adding the head and tail vectors of each subject and averaging them as entity features, entity features plus token features, and predicting the tail entity of each relationship on the relationship schema; specifically, the sigmoid activation function is also used for classification. Unlike the binary classification problem of the head entity, the prediction of the tail entity is a multi-classification problem, because in the sigmoid function, different relationship topics correspond to an independent output, so the same result is the probability distribution corresponding to each token under multiple classifications, thereby predicting the possibility of being a tail entity and obtaining the final triplet.

[0076] like Figure 5 Schematic diagram of the horizontal federated learning framework structure of the method of the present invention, where Figure 4 (1) indicates uploading encrypted gradients, Figure 4 (2) represents the aggregation gradient (safe), Figure 4 (3) indicates returning the model update parameters. Figure 4 (4) represents updating the model; the step S5 comprises the following steps:

[0077] C1. In the data processing stage, the data is reshuffled; 30% of the data in the training set is taken as the validation data set D v, which is also the training data set of the server model, is trained separately; the remaining data set is evenly divided into two parts, simulating the unshared data sets of the two participants in the federation, which also conforms to the scenario of horizontal federated learning. The data features are consistent, and only the sample content is different;

[0078] C2. Each participant's local model is trained using the model after the introduction of adversarial training. After the training is completed, the participants make their own prediction results for the verification data set. The prediction results are uploaded to the server model for learning. The horizontal federation adopts decentralization because the BERTbase model used in the model as an encoder has a parameter of 110M. There will be data transmission delay loss when uploading parameters. For the prediction of the verification set, the model's final soft-target in the relationship category is actually taken, and a probability will be assigned to each category.

[0079] C3. The prediction results of the participants are uploaded to the server for summing and averaging. The trusted third-party server uses the fusion result features to train the local models of each participant.

[0080] The step C3 comprises the following steps:

[0081] D1. Fusion of local models of each participant: Sum and average the probabilities predicted by each participant’s local model at the tail entity of a specific relationship.

[0082]

[0083] Among them, z(y i |s) represents the average of the sum of the final probability values; p(y i |s,Θ (j) ) represents the input text s and the input j-th participant model parameter Θ in the j-th participant (j) , whose output category is the i-th category y i The predicted probability of is the total number of participants;

[0084] Use softmax to normalize to probability distribution,

[0085]

[0086] Among them, q(y i |s) represents the average of the predicted probabilities of each participant for each category and then normalized to a probability distribution; exp(·) represents the normalized exponential function; in the normalization, τ represents the temperature of the distillation process, that is, the predicted probability z(y i|s) is transformed into an exponential function; r is distinguished from the numerator I in the formula, and the denominator means the sum of the numerators, that is, the sum of the probability distributions of all categories. The entire formula conforms to the basic definition of the softmax activation function.

[0087] exp(·) is the normalized exponential function, which is the probability of the model's prediction result Transform to exponential function to ensure the non-negativity of probability. r exp(z(y r ∣s) / τ) is the result after all the transformations, and the sum of the probabilities of the predicted results is guaranteed to be 1, that is, normalized, to obtain an approximate probability, and the result range is (0,1). In normalization, τ represents the temperature of the distillation process. In order to solve the problem that the probability distribution of the softmax output is small, the probability values ​​of the negative samples are very close to 0, and the value is taken as a number greater than 1. The probability distribution after normalization will tend to be smooth. The greater the entropy of the distribution, the more information in the negative samples will be relatively amplified.

[0088] D2. Use a third-party server to learn the local models of each participant, including using horizontal federated learning for collaborative training, obtaining the final loss, and inputting the final loss into the final triples of each participant to obtain the final entity relationship extraction model, and extract entity relationships from the current Chinese short text:

[0089] The server model is trained on the local data set, and the training loss I of the local server model in the small sample is obtained: That is, the classification cross entropy of the tail entity classification prediction, where y i is the correct result of the i-th target; is the i-th prediction result; p(·) represents the probability function, is the probability of the prediction result being correct; log(·) is the logarithm. When the probability range is (0,1), the result range of -log is (0,∞), which is used to represent the amount of information in the classification problem. The loss I of the tail entity prediction of a specific relationship in the local small sample is between (0,∞). The closer the loss is to 0, the greater the probability. Therefore, it is necessary to minimize the training loss I of the local server model in the small sample to make the result more reliable.

[0090] Add the loss of the distillation step: use the fusion of the participant prediction results and the KL divergence predicted by the third-party server model: KL divergence, also known as relative entropy, is the difference between two probability distributions, where represents the predicted probability distribution of the participants; is the i-th prediction result; The probability distribution of the prediction for the third-party server is as follows: The smaller the difference, the smaller the overall loss of the third-party server model. The overall loss L is: Among them, D v A validation dataset, which is a small sample of third-party servers.

[0091] Advantages of the present invention: The introduction of federated learning can effectively ensure the confidentiality of data and improve data security. At the same time, it is different from traditional centralized federated learning. After integrating the idea of ​​knowledge distillation, it avoids the relationship extraction model parameters being too large, and there will be network performance bottlenecks when uploading to the central server. In decentralized federated learning, only the probability distribution of the prediction results of the participants needs to be uploaded. Compared with uploading the entire model parameters, a large part of the network overhead and time overhead is reduced. A smaller model is learned while ensuring a small performance gap. Compared with a larger model, it is more applicable in production and life, and is easier to embed into practical applications. It reduces the model's requirements for computing and equipment and meets a wider range of usage needs. The introduction of adversarial training generates adversarial samples by perturbing the embedding input layer, while improving the error rate, finding the model parameters with the smallest loss, updating the model, and improving the robustness of the model while improving the accuracy of the overall model.

Claims

1. A method for extracting entity relations from Chinese short texts. Features The steps include: S1. Obtain Chinese data and perform preprocessing, which includes segmenting long texts exceeding a preset sentence length, expanding texts less than a preset sentence length, and marking them to obtain processed texts; S2. Load the BERT pre-trained model and perform feature extraction on the processed text; S3. Build a head entity annotation model and perform head entity prediction; S4. Build a tail entity annotation model for a specific relationship, perform tail entity prediction, and obtain the final triplet of each participant; S5. Use horizontal federated learning to perform collaborative training, obtain the final loss, and input the final loss into the final triple of each participant to obtain the final entity relationship extraction model, and perform entity relationship extraction on the current Chinese short text; The steps include: C1. During the data processing phase, the data is reshuffled; 30% of the training set is used as the validation set; the remaining set is divided into two parts; C2. Each participant's local model is trained using the model after the adversarial training. After the training is completed, a local prediction result is made for the verification data set, and the prediction result is uploaded to the server model for learning; C3. Upload the prediction results of the participants to the server for summing and averaging, and the trusted third-party server uses the fusion result features to train the local models of each participating method; including the following steps: D1. Fusion of the local models of each participant, including summing and averaging the predicted probabilities of the tail entity of each participant's local model in a specific relationship, and normalizing them into probability distribution using softmax, to obtain the probability value of the predicted result s and the predicted probability distribution of the participant; D2. Use a third-party server to learn the local models of each participant, including obtaining the probability value of the prediction result s, and obtaining the loss of the local tail entity prediction of a specific relationship in a small sample; use horizontal federated learning for collaborative training to obtain the final loss, and input the final loss into the final triplet of each participant to obtain the final entity relationship extraction model, and perform entity relationship extraction on the current Chinese short text.

2. According to the entity relationship extraction method for Chinese short texts according to claim 1, Features The step S1 includes setting the training set and verification data set data format json, including text label line and triple_list label line; segmenting long sentences whose length exceeds a preset value, so that the sentence length of each training data Chinese text is the preset value, expanding the sentences that are less than the preset value, adding special symbols, obtaining standard sentences, and marking the beginning and end; loading the tokenizer and word dictionary of the BERT pre-training model, marking and segmenting the original text to adapt to the input format of the BERT pre-training model.

3. According to the entity relationship extraction method for Chinese short texts according to claim 2, Features The step S2 comprises: A1. Input the processed original text into the embedding layer of the BERT pre-trained model, including word embedding coding to vectorize the text; segment embedding coding to separate the sentences and distinguish different sentences; position embedding coding to encode the word positions, using dynamic training to train the position coding dictionary, and find the word position coding through the position coding dictionary in the subsequent coding layer; add the three outputs of word embedding coding, segment embedding coding, and position embedding coding as the final input; A2. Send the final input to the encoding layer, including inputting the output of the embedding layer into an encoding network with 12 layers of the same structure. Each layer normalizes the result through a normalization function and outputs the last layer to obtain the output containing the semantic features of the sentence.

4. According to the entity relationship extraction method for Chinese short texts according to claim 3, Features The step A1 comprises: B1. Define the model after introducing adversarial training as: Among them, θ is the model parameter; E (x,y)~D Represents external risk; x represents the output of word embedding in the embedding layer; y represents the global label; L(x+Δx,y; θ) represents the loss of a single sample; D represents the distribution of input samples; Δx represents the adversarial perturbation parameter; Ω represents the perturbation space; adversarial training is to inject the adversarial perturbation parameter Δx into the output x of the word embedding in the embedding layer, and use (x+Δx,y) as the data minimization loss to update the parameter, and calculate the adversarial perturbation parameter Δx. Where x represents the output of word embedding in the embedding layer; y represents the global label; θ is the model parameter; ∈ is a constant; B2. Standardize the anti-disturbance parameter Δx: Where Δx' represents the normalized adversarial perturbation parameter Δx; x represents the output of the word embedding in the embedding layer; sign(·) is a sign function used for normalization; y represents the global label; θ is a model parameter; ∈ is a constant; B3. Add the standardized adversarial perturbation parameter Δx' to the input layer, delete the standardized adversarial perturbation parameter Δx', and restore the input layer; B4. Repeat steps B1-B3 to iterate the adversarial perturbation parameter Δx. The entire optimization process is to alternately maximize the loss and minimize the external experience, and customize an adversarial perturbation parameter that can maximize the loss for each step.

5. According to the entity relationship extraction method for Chinese short texts according to claim 4, Features The step S3 includes classifying the last hidden state of the BERT output to obtain the start and end positions of the head entity subject. The head and tail prediction of the subject uses a sigmoid activation function to perform a binary classification task to predict the probability distribution of the token as the head or the tail; sigmoid activation function: To map a real number to the interval (0,1) for binary classification, x represents the output of word embedding in the embedding layer; the output x of word embedding in the embedding layer is the value of the head of the entity in the probability interval [0,1], as the probability of token as the first word; the output x of word embedding in the embedding layer is the value of the tail of the entity in the probability interval [0,1], as the probability of token as the last word.

6. The entity relationship extraction method for Chinese short text according to claim 5, Features The step S4 includes adding the head and tail vectors of each subject and averaging them as entity features, adding the entity features to the token features, and predicting the tail entity on the specific relationship set schema; specifically, using the sigmoid activation function for classification, obtaining the probability distribution corresponding to each token under multiple classifications, and obtaining the final triplet.

7. The entity relationship extraction method for Chinese short text according to claim 1, Features The step D1 comprises summing and averaging the probabilities predicted by each participant's local model at the tail entity of a specific relationship, Among them, z(y i |s) represents the average of the sum of the final probability values; p(yi|s,Θ (j) ) represents the input text s and the input j-th participant model parameter Θ in the j-th participant (j) , whose output category is the i-th category y i The predicted probability of is the total number of participants; Use softmax to normalize to probability distribution, Among them, q(y i |s) means that the predicted probability of each participant for each category is averaged and normalized to a probability distribution; s means text; exp(·) means the normalized exponential function; in normalization, τ means the temperature of the distillation process; r is distinguished from I in the numerator in the formula, and the denominator means the sum of the numerators, Σ r exp(z(y r |s) / τ) represents the sum of probability distributions of all categories; The step D2 includes training the server model on a local data set to obtain the training loss I of the local server model in a small sample: Among them, y i is the correct result of the i-th target; is the i-th prediction result; p(·) represents the probability function, is the probability of the prediction result being correct; log(·) is the logarithm, which is used to indicate the amount of information; Add the loss of the distillation step: use the fusion of the participant prediction results and the KL divergence predicted by the third-party server model: KL divergence represents the difference between two probability distributions, where represents the predicted probability distribution of the participants; is the i-th prediction result; The probability distribution of the prediction for the third-party server is as follows: The smaller the difference, the smaller the overall loss of the third-party server model. The overall loss L is: Among them, D v For validation dataset.

Citation Information

Cited By

  • System and method for short text matching

    US12585873B1