WO2021189974A1 - 模型训练方法、文本分类方法、装置、计算机设备和介质 - Google Patents

模型训练方法、文本分类方法、装置、计算机设备和介质 Download PDF

Info

Publication number
WO2021189974A1
WO2021189974A1 PCT/CN2020/136314 CN2020136314W WO2021189974A1 WO 2021189974 A1 WO2021189974 A1 WO 2021189974A1 CN 2020136314 W CN2020136314 W CN 2020136314W WO 2021189974 A1 WO2021189974 A1 WO 2021189974A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
model
training
similar
trained
Prior art date
Application number
PCT/CN2020/136314
Other languages
English (en)
French (fr)
Inventor
李志韬
王健宗
吴天博
程宁
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021189974A1 publication Critical patent/WO2021189974A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • G06N20/20Ensemble learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the field of artificial intelligence, and in particular to a text classification model training method, text classification method, device, computer equipment and medium.
  • text mining techniques such as text classification are applied in more and more fields.
  • the inventor realizes that the existing text classification technology generally implements the classification of a large amount of semi-structured and unstructured text data through a trained text classification model. In the process of training the text classification model, a large amount of text data in different clients needs to be used. In actual business scenarios, many text data involve user privacy, but the existing text classification model cannot achieve data isolation and avoid data leakage, and cannot guarantee the security of text data.
  • This application provides a text classification model training method, the method includes:
  • the model parameters of the trained local classification model and the local classification results are encrypted and uploaded to a federated learning server for joint learning to obtain learning parameters, wherein the federated learning server is used to encrypt the uploaded data according to different clients Data for joint learning;
  • This application also provides a text classification method based on a text classification model, the text classification model being trained according to the above text classification model training method, and the method includes:
  • the text to be classified is input into the text classification model for classification prediction, and the text category corresponding to the text to be classified is obtained.
  • This application also provides a text classification model training device, which includes:
  • the model training module is used to obtain a text training set, perform text classification training on a local classification model according to the text training set, and obtain a trained local classification model and a local classification result;
  • the data upload module is used to encrypt the model parameters of the trained local classification model and the local classification results and upload them to a federated learning server for joint learning to obtain learning parameters, where the federated learning server is used to Joint learning of encrypted data uploaded by different clients;
  • the model update module is configured to receive the learning parameters sent by the federated learning server, update the trained local classification model according to the learning parameters, and use the updated local classification model as the trained text classification model.
  • the application also provides a computer device, which includes a memory and a processor;
  • the memory is used to store a computer program
  • the processor is configured to execute the computer program and implement the following steps when the computer program is executed:
  • the model parameters of the trained local classification model and the local classification results are encrypted and uploaded to a federated learning server for joint learning to obtain learning parameters, wherein the federated learning server is used to encrypt the uploaded data according to different clients Data for joint learning;
  • the text to be classified is input into the text classification model for classification prediction, and the text category corresponding to the text to be classified is obtained.
  • the present application also 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 processor implements the following steps:
  • the model parameters of the trained local classification model and the local classification results are encrypted and uploaded to a federated learning server for joint learning to obtain learning parameters, wherein the federated learning server is used to encrypt the uploaded data according to different clients Data for joint learning;
  • the text to be classified is input into the text classification model for classification prediction, and the text category corresponding to the text to be classified is obtained.
  • FIG. 1 is a schematic flowchart of a text classification model training method provided by an embodiment of the present application
  • Fig. 2 is a schematic diagram of a training process of a local classification model provided by an embodiment of the present application
  • FIG. 3 is a schematic flowchart of a sub-step of text classification training for a local classification model provided by an embodiment of the present application
  • FIG. 4 is a schematic flowchart of a sub-step of similar text prediction training for similar text models provided by an embodiment of the present application
  • Figure 5 is a schematic diagram of uploading encrypted data to a federated learning server provided by an embodiment of the present application
  • FIG. 6 is a schematic diagram of receiving learning parameters of a federated learning server according to an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a text classification method provided by an embodiment of the present application.
  • FIG. 8 is a schematic block diagram of a text classification model training device provided by an embodiment of the present application.
  • FIG. 9 is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application.
  • the embodiments of the present application provide a text classification model training method, text classification method, device, computer equipment, and medium.
  • the text classification model training method can be applied to multiple clients, multiple clients can perform text classification training on the local classification model according to the local text training set, and then upload the trained local classification model and the local classification results Perform joint learning in the federated learning server to isolate the text data of different clients and avoid data leakage, thereby improving the security of the text data; it can also enrich the training text data and improve the classification of the trained text classification model accuracy.
  • the client can be an electronic device such as a smart phone, a tablet computer, a notebook computer, and a desktop computer.
  • the text classification model training method includes steps S10 to S30.
  • Step S10 Obtain a text training set, perform text classification training on a local classification model according to the text training set, and obtain a trained local classification model and a local classification result.
  • the client may use local text data as a text training set; wherein, the text training set includes multiple training texts, which may be used as training data of a local classification model.
  • the local text data of the client may be user data collected by the client.
  • the local classification model can be trained in the client according to the local text data, and then the model parameters and local classification results of the trained local classification model are encrypted and uploaded to the federated learning server for joint learning.
  • the above-mentioned text training set can also be stored in a node of a blockchain.
  • the local classification model includes three parts: a word vector model, a clustering model, and a similar text model. Therefore, when training the local classification model, the word vector model, clustering model and similar text model need to be trained separately.
  • FIG. 2 is a schematic diagram of a training process of a local classification model provided in an embodiment of the present application.
  • the text training set is input into the word vector model, and the output word vector prediction results are used as the input of the clustering model.
  • the clustering model outputs the cluster prediction results after training; the cluster prediction results and the text training set Input the similar text model for training, and the similar text model outputs the text category prediction results.
  • FIG. 3 is a schematic flowchart of the sub-steps of performing text classification training on the local classification model according to the text training set in step S10 to obtain the trained local classification model and the local classification result, which may specifically include the following step S101 Go to step S104.
  • Step S101 Perform vectorization training on the word vector model according to the text training set to obtain a trained word vector model and a word vector prediction result.
  • the word vector model may include a BERT (Bidirectional Encoder Representations from Transformer) model.
  • BERT Bidirectional Encoder Representations from Transformer
  • the BERT model can use the Attention mechanism to take the semantic vector representation of the target word and each word in the context as input.
  • the vector representation of the target word and the vector representation of each context word are obtained through linear transformation.
  • the original value representation of the target word and each word of the context and then calculate the similarity between the vector of the target word and the vector of each word of the context as the weight, and the vector of the target word and the vector of each word of the context are weighted and merged as the output of Attention, that is, the target Enhanced semantic vector representation of words.
  • the training text in the training text set can be input into the BERT model, and each word in the training text can be converted into a one-dimensional vector by the BERT model by querying the word vector table, which is used as the BERT model After training, the output of the BERT model is the vector fused with full-text semantic information corresponding to each input word.
  • the model parameters of the word vector model after training include the attention weight; the word vector prediction result includes the word vector of the phrase corresponding to each training text.
  • Word vector prediction result By vectorizing the word vector model according to the training text set, taking into account the semantic information of the text, the accuracy of the word vector prediction of the trained word vector model can be improved, and the trained word vector model and semantic representation can also be obtained. Word vector prediction result.
  • Step S102 Perform text clustering training on the clustering model based on the word vector prediction result to obtain the trained clustering model and the clustering prediction result.
  • the word vector prediction result includes the predicted word vector corresponding to the training text.
  • the clustering model calculates the minimum square error between the predicted word vector and the preset clustering center according to the predicted word vector corresponding to each training text, so as to reduce the training text
  • Each training text in the set is divided into at least one cluster.
  • the clustering model may include, but is not limited to, hierarchical clustering algorithm, prototype clustering algorithm, density clustering algorithm, and so on.
  • the prototype clustering algorithm may include k-means algorithm, learning vector quantization, and Gaussian mixture clustering.
  • the clustering model is the k-means algorithm as an example for description.
  • the k-means algorithm is a simple iterative clustering algorithm that uses distance as a similarity index to obtain k clusters in a given data set, and the cluster center of each cluster is based on the clustering The mean of all values in the cluster is obtained.
  • the calculation formula is as follows:
  • m represents the number of samples
  • k represents the number of clusters
  • the training process of the k-means algorithm includes: (1) selecting k objects in the data space as the initial center, and each object represents a cluster center; (2) for the data objects in the sample, according to their relationship with these According to the Euclidean distance of the cluster centers, they are divided into the clusters corresponding to the closest cluster centers (most similar) according to the criterion of the closest distance; (3) All objects in each cluster are assigned to the corresponding clusters.
  • the mean value is used as the cluster center of the cluster, and the value of the objective function is calculated; (4) Determine whether the value of the cluster center and the objective function has changed, if it does not change, output the result, if it changes, return to step (2).
  • text clustering training is performed on the clustering model based on the predicted word vector corresponding to the training text, and the trained clustering model and the clustering prediction result are obtained.
  • the model parameters of the trained clustering model include at least one cluster center.
  • the cluster prediction result includes a cluster cluster corresponding to each training text, and each cluster cluster includes a plurality of semantically similar training texts.
  • the cluster cluster corresponding to training text A may include training text B, training text C, and training text D that are semantically similar to training text A.
  • the trained clustering model and clustering center can be obtained, and the clustering accuracy of the clustering model can be improved; follow-up can be based on the clustering corresponding to each training text Cluster, to determine multiple similar texts with similar semantics for each training text.
  • Step S103 Perform similar text prediction training on the similar text model based on the cluster prediction result and the text training set to obtain a similar text model and text category prediction results after training.
  • the similar text model is established based on the word frequency-inverse document frequency algorithm. It should be noted that the similar text model is used to determine multiple similar texts of each training text in the corresponding cluster according to the keywords of each training text.
  • the semantic information of the text and the keywords can be combined to predict the text category, thereby effectively improving the text category Forecast accuracy.
  • Figure 4 is a schematic flow chart of the sub-steps of performing similar text prediction training on similar text models based on cluster prediction results and text training sets in step S103 to obtain the trained similar text models and text category prediction results It may specifically include the following steps S1031 to S1035.
  • Step S1031 based on the similar text model, determine the similar text of each training text in the corresponding cluster according to the word frequency-inverse document frequency algorithm.
  • TF frequency-inverse document frequency
  • IDF inverse document frequency
  • n represents the number of occurrences of a word in the article
  • m represents the total number of words in the article.
  • w represents the total number of documents in the corpus; W represents the number of documents containing the word.
  • the process of extracting keywords can be understood as calculating the TF-IDF value corresponding to each word of the document, and then sorting each word in descending order according to the TF-IDF value, and using the first few words as keywords.
  • determining the similar text of each training text in the corresponding cluster according to the word frequency-inverse document frequency algorithm may include: determining the first keyword corresponding to each training text according to the word frequency-inverse document frequency algorithm , And determine the second keyword corresponding to other texts in the cluster cluster corresponding to each training text; if the second keyword matches the first keyword, determine the other text corresponding to the second keyword as each training text Similar text to text.
  • the TF-IDF value corresponding to each word in each training text is calculated according to the TF-IDF algorithm, and the word with the corresponding TF-IDF value greater than the preset TF-IDF threshold is determined as each training text corresponding The first keyword.
  • the TF-IDF algorithm calculate the TF-IDF value corresponding to each word in the other text in the cluster corresponding to each training text, and determine the word with the corresponding TF-IDF value greater than the preset TF-IDF threshold as The second keyword corresponding to other texts.
  • the preset TF-IDF threshold can be set according to actual conditions, and the specific value is not limited here.
  • training text A other texts may include training text B, training text C, training text D, and so on.
  • the second keyword matches the first keyword. For example, if the first keyword is the same as the second keyword, it is determined that the first keyword matches the second keyword.
  • training text B is similar text corresponding to training text A.
  • the training text C is a similar text corresponding to the training text A.
  • the training text D is not regarded as the similar text corresponding to the training text A.
  • each can be accurately and quickly determined Similar text to training text.
  • Step S1032 Determine the number of similar texts corresponding to each training text.
  • the number of similar texts corresponding to each training text is determined respectively.
  • similar texts corresponding to training text A include training text B and training text C.
  • Step S1033 When the number of similar texts corresponding to the training text is less than the preset number, adjust the parameters of the word frequency-inverse document frequency algorithm until it is determined based on the adjusted word frequency-inverse document frequency algorithm The number of similar texts in each training text is greater than or equal to the preset number, the training is ended, and the similar text model after training is obtained.
  • the preset number can be set according to actual conditions, and the specific value is not limited here.
  • the weight ratio of the inverse document frequency can be adjusted, and the total number of documents in the corpus can also be adjusted.
  • the training when the number of similar texts corresponding to each training text is less than the preset number, adjust the parameters of the word frequency-inverse document frequency algorithm; and then determine each training text based on the adjusted word frequency-inverse document frequency algorithm For similar texts in the corresponding clusters, until it is determined that the number of similar texts in each training text is greater than or equal to the preset number, the training is ended, and the similar text model after training is obtained.
  • the number of similar texts in each training text is greater than or equal to the preset number, which can ensure that there are enough similar texts in each training text, thereby improving the follow-up based on similar texts.
  • Step S1034 Calculate the similarity between each training text and the similar text of each training text according to a preset similarity algorithm.
  • the preset similarity algorithm may include, but is not limited to, Euclidean distance, cosine similarity, Manhattan distance, Chebyshev distance and other algorithms for calculation.
  • the similarity between the similar text of each training text and each training text can be calculated according to the cosine similarity algorithm. It is understandable that the cosine similarity algorithm uses the cosine value of the angle between two vectors in the vector space as a measure of the degree of similarity between the two vectors.
  • represents the angle between the vector V 1 and the vector V 2
  • n represents the dimension of the vector V 1 and the vector V 2
  • the value range of the cosine of the angle cos ⁇ is [0, 1].
  • the word vector matrix V 1 of all words corresponding to each training text is obtained, and the word vector matrix V 2 of all words of similar texts corresponding to each training text is obtained; and the words are calculated according to the angle cosine value
  • the similarity between the vector matrix V 1 and the word vector matrix V 2 is obtained by calculating the similarity between each training text and the similar text of each training text.
  • the word vector matrix V 1 of the first keyword corresponding to each training text is obtained, and the word vector matrix V 2 of the second keyword of the similar text corresponding to each training text is obtained; according to the angle
  • the cosine value is calculated by calculating the similarity between the word vector matrix V 1 and the word vector matrix V 2 , that is, the similarity between each training text and the similar text of each training text is calculated.
  • Step S1035 Determine the text category of the similar text corresponding to the maximum similarity as the text category prediction result corresponding to each training text.
  • a text category label may be added to each training text in the training text set in advance.
  • the text category corresponding to the training text can be determined through the text category label carried by the training text.
  • the text category may include, but is not limited to, insurance, medical, finance, tourism, sports, and automobile categories.
  • the text category of the similar text corresponding to the maximum similarity may be used as the text category prediction result corresponding to each training text. For example, if the text category label carried by the similar text corresponding to the maximum similarity is "medical", it can be determined that the text category prediction result corresponding to the training text is "medical".
  • Step S104 Combine the trained word vector model, the trained clustering model, and the trained similar text model to obtain the trained local classification model, and according to the word vector prediction result, The cluster prediction result and the text category prediction result generate the local classification result.
  • the local classification model includes three parts: a word vector model, a clustering model, and a similar text model
  • each client can combine the trained word vector model and the trained clustering model.
  • the model and the similar text model after training are merged to obtain a local classification model after training.
  • the local classification result is generated according to the word vector prediction result, the cluster prediction result and the text category prediction result.
  • generating the local classification result according to the word vector prediction result, the cluster prediction result, and the text category prediction result may include: predicting the word vector prediction result, the cluster prediction result, and the text category prediction based on a preset weight calculation formula The results are weighted and summed, and the local classification result is obtained.
  • the local classification model includes three parts: a word vector model, a clustering model, and a similar text model
  • the local classification model can separate the word vector prediction results, cluster prediction results, and The text category prediction result is calculated according to the weight coefficient, so as to obtain the final local classification result.
  • weight calculation formula is as follows:
  • J represents a local classification result
  • P a represents a word vector prediction result in the most probable result
  • ⁇ 1 represents the maximum probability of a result P a weighting coefficient
  • P b represents the maximum result of the clustering prediction result probability
  • ⁇ 2 represents the probability The weight coefficient of the maximum result P b
  • P c represents the result with the largest similarity in the text category prediction results
  • ⁇ 3 represents the weight coefficient of the maximum similarity result P c.
  • the prediction results of each model are merged according to different weights, which can improve the accuracy of subsequent joint learning sex.
  • Step S20 The model parameters of the trained local classification model and the local classification results are encrypted and uploaded to a federated learning server for joint learning to obtain learning parameters.
  • the federated learning server is used to obtain learning parameters according to different clients.
  • the uploaded encrypted data is used for joint learning.
  • FIG. 5 is a schematic diagram of uploading encrypted data to a federated learning server according to an embodiment of the present application.
  • each client obtains the trained local classification model locally, it needs to encrypt the model parameters and local classification results of the local classification model; then upload the encrypted data to the federated learning server, and the federated learning server will The received encrypted data undergoes joint learning to obtain learning parameters.
  • the federated learning server includes a federated learning model.
  • federated learning is divided into horizontal federated learning, vertical federated learning, and federated transfer learning.
  • federated learning refers to the method of machine learning modeling by uniting different clients or participants.
  • the client does not need to expose its own data to other clients and coordinators (also known as servers), so federated learning can protect user privacy and ensure data security, and can solve the problem of data islands .
  • Federated learning has the following advantages: data isolation, data will not be leaked to the outside, to meet the needs of user privacy protection and data security; it can ensure that the quality of the federated learning model is non-destructive, and there will be no negative transfer, ensuring that the federated learning model is better than the separated independent model The effect is good; it can ensure that each client can perform encrypted exchange of information and model parameters while maintaining independence, and grow at the same time.
  • model parameters of the local classification model include the attention weight in the word vector model, the cluster center in the cluster model, and the inverse document frequency in the similar text model.
  • the model parameters and local classification results of the trained local classification model need to be encrypted to obtain encrypted data; then the encrypted data is uploaded to Joint learning is carried out in the federated learning server.
  • privacy calculation methods such as homomorphic encryption, differential privacy, or multi-party secure calculation may be used.
  • homomorphic encryption the federated learning server may not decrypt the encrypted data, but directly conduct joint learning based on the encrypted data.
  • the training can be carried out indirectly based on the user data in different clients, and the training model can be expanded.
  • the number of samples not only can avoid data leakage, ensure the safety of user data to the greatest extent, but also improve the classification accuracy of the text classification model after training.
  • the federated learning server decrypts the encrypted data to obtain the decrypted data information; then, based on the federated learning model, performs joint learning based on the decrypted data information to obtain Learning parameters.
  • the federated learning server may use the global average method to perform joint learning to obtain learning parameters. For example, the average value of the model parameters in the local classification model is calculated separately, and then the parameter weights of some model parameters that are too different from the average value are lowered to obtain the learning parameters. Among them, the local classification result can be used to determine the loss function value of the federated learning model, so as to adjust the parameters of the federated learning according to the loss function value.
  • Step S30 Receive the learning parameters sent by the federated learning server, and update the trained local classification model according to the learning parameters, and use the updated local classification model as the trained text classification model.
  • FIG. 6 is a schematic diagram of receiving learning parameters of a federated learning server according to an embodiment of the present application.
  • each client receives the learning parameters sent by the federated learning server, and updates the local classification model according to the learning parameters, and uses the updated local classification model as the trained text classification model.
  • the trained word vector model, the trained clustering model, and the trained similar text model are respectively updated according to the learning parameters.
  • the model parameters of each model are updated to obtain the updated word vector model and the updated The clustering model and the updated similar text model.
  • the above-mentioned updated local classification model may also be stored in a node of a blockchain.
  • the accuracy of the text classification model in text classification can be further improved.
  • the word vector model is vectorized training according to the training text set, and the semantic information of the text is taken into account, which can improve the accuracy of the word vector prediction of the trained word vector model.
  • Similar text model training can realize the combination of the semantic information of the text and the keywords to predict the text category, thereby effectively improving the prediction accuracy of the text category; by determining the corresponding training text based on the word frequency-inverse document frequency algorithm
  • the first keyword and the second keyword corresponding to other texts in the cluster cluster corresponding to each training text can be determined accurately and quickly to determine the similar text of
  • FIG. 7 is a text classification method provided by an embodiment of the present application. As shown in FIG. 7, the text classification method specifically includes: step S401 and step S402.
  • Step S401 Obtain the text to be classified.
  • a text category query interface for external query text categories can be set in the client.
  • the user can query the text category of the related text in the text category query interface.
  • the client when the client receives the text input operation of the user in the text category query interface, it obtains the text data input by the user according to the text input operation, and uses the obtained text data as the text to be classified.
  • Step S402 Input the text to be classified into the text classification model for classification prediction, and obtain a text category corresponding to the text to be classified.
  • the text classification model is obtained by training according to the above-mentioned text classification model training method.
  • the trained text classification model can be invoked to perform classification prediction on the text to be classified.
  • the text classification model includes an updated word vector model, an updated clustering model, and an updated similar text model.
  • the classification prediction of the text to be classified may include: inputting the text to be classified into the updated word vector model for vectorization processing to obtain the word vector corresponding to the text to be classified; Enter the updated clustering model to perform cluster analysis to obtain the cluster clusters corresponding to the text to be classified; enter the text to be classified into the updated similar text model for similar text prediction, and obtain the corresponding cluster clusters of the text to be classified Calculate the similarity between the text to be classified and each similar text, and determine the text category of the similar text corresponding to the maximum similarity as the text category corresponding to the text to be classified.
  • the text classification method provided in the above embodiment can combine the semantic information and key of the text to be classified by inputting the text to be classified into the updated word vector model, the updated clustering model, and the updated similar text model for hierarchical prediction.
  • the word information is predicted, thereby improving the accuracy of predicting the text category corresponding to the text to be classified.
  • FIG. 8 is a schematic block diagram of a text classification model training device 100 provided in an embodiment of the present application.
  • the text classification model training device is used to execute the aforementioned text classification model training method.
  • the text classification model training device can be configured in a server or a terminal.
  • the text classification model training device 100 includes: a model training module 101, a data uploading module 102 and a model updating module 103.
  • the model training module 101 is configured to obtain a text training set, perform text classification training on a local classification model according to the text training set, and obtain a trained local classification model and a local classification result.
  • the data upload module 102 is configured to encrypt the model parameters of the trained local classification model and the local classification results and upload them to a federated learning server for joint learning to obtain learning parameters, wherein the federated learning server is used for Joint learning based on encrypted data uploaded by different clients.
  • the model update module 103 is configured to receive the learning parameters sent by the federated learning server, update the trained local classification model according to the learning parameters, and use the updated local classification model as the trained text classification model .
  • the above-mentioned apparatus may be implemented in the form of a computer program, and the computer program may run on the computer device as shown in FIG. 9.
  • FIG. 9 is a schematic block diagram of the structure of a computer device according to an embodiment of the present application.
  • the computer equipment can be a server or a terminal.
  • the computer device includes a processor and a memory connected through a system bus, where the memory may include a non-volatile storage medium and an internal memory.
  • the processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
  • the internal memory provides an environment for the operation of the computer program in the non-volatile storage medium.
  • the processor can execute any text classification model training method or text classification method.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), and application specific integrated circuits (Application Specific Integrated Circuits). Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
  • the processor is used to run a computer program stored in a memory to implement the following steps:
  • Obtain a text training set perform text classification training on a local classification model according to the text training set, and obtain a trained local classification model and a local classification result; combine the model parameters of the trained local classification model and the local classification result
  • the encrypted data is uploaded to a federated learning server for joint learning to obtain learning parameters, wherein the federated learning server is used for joint learning according to the encrypted data uploaded by different clients; receiving the learning parameters sent by the federated learning server, And update the trained local classification model according to the learning parameters, and use the updated local classification model as the trained text classification model.
  • the local classification model includes a word vector model, a clustering model, and a similar text model; the processor implements text classification training on the local classification model according to the text training set to obtain the trained local When the classification model and local classification results are used, it is used to achieve:
  • the text training set includes a plurality of training texts
  • the cluster prediction result includes a cluster cluster corresponding to each training text
  • the similar text model is established according to a word frequency-inverse document frequency algorithm
  • the similar text model Based on the similar text model, determine the similar text of each training text in the corresponding cluster according to the word frequency-inverse document frequency algorithm; determine the number of similar texts corresponding to each training text; When the number of similar texts corresponding to the training text is less than the preset number, the parameters of the word frequency-inverse document frequency algorithm are adjusted until each of the parameters is determined based on the adjusted word frequency-inverse document frequency algorithm.
  • the number of similar texts in the training text is greater than or equal to the preset number, the training is ended, and the similar text model after training is obtained; according to the preset similarity algorithm, each training text and each training text are calculated.
  • the similarity between similar texts of the training text determining the text category of the similar text corresponding to the maximum similarity as the text category prediction result corresponding to each training text.
  • the processor when the processor implements the determination of the similar texts of each training text in the corresponding cluster according to the word frequency-inverse document frequency algorithm, it is used to implement:
  • the processor when the processor realizes the generation of the local classification result according to the word vector prediction result, the cluster prediction result, and the text category prediction result, it is used to realize:
  • a weighted summation is performed on the word vector prediction result, the cluster prediction result, and the text category prediction result to obtain the local classification result.
  • the processor is further configured to implement:
  • the embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium stores a computer program.
  • the computer program includes program instructions, and the processor executes the program instructions to implement any text classification model training method provided in the embodiments of the present application.
  • the computer-readable storage medium may be the internal storage unit of the computer device described in the foregoing embodiment, for example, the hard disk or memory of the computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), or a secure digital card equipped on the computer device. , SD Card, Flash Card, etc.
  • the computer-readable storage medium may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function, etc.; the storage data area may store Data created by the use of nodes, etc.
  • the blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文本分类模型训练方法、文本分类方法、装置、计算机设备和介质,涉及人工智能和模型构建领域,通过将本地分类模型的模型参数和本地分类结果上传至联邦学习服务器进行联合学习,可以提高文本数据在模型训练过程中的安全性。该训练方法包括:获取文本训练集合,根据文本训练集合对本地分类模型进行文本分类训练;将训练后的本地分类模型的模型参数和本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数;接收联邦学习服务器发送的学习参数,并根据学习参数更新训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。还涉及区块链技术,文本训练集合可存储于区块链中。

Description

模型训练方法、文本分类方法、装置、计算机设备和介质
本申请要求于2020年10月21日提交中国专利局、申请号为2020111339791,发明名称为“模型训练方法、文本分类方法、装置、计算机设备和介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种文本分类模型训练方法、文本分类方法、装置、计算机设备和介质。
背景技术
随着互联网的高速发展和大数据时代的到来,文本分类等文本挖掘技术应用于越来越多的领域。发明人意识到现有的文本分类技术一般是通过训练后的文本分类模型,实现对大量的半结构化、非结构化的文本数据进行分类处理。在对文本分类模型进行训练的过程中,需要用到不同客户端中大量的文本数据。由于在实际业务场景中,很多文本数据中都涉及到用户隐私,但是现有的文本分类模型不能做到数据隔离和避免数据泄露,无法保证文本数据的安全性。
因此如何提高文本数据在模型训练过程中的安全性成为亟需解决的问题。
发明内容
本申请提供了一种文本分类模型训练方法,所述方法包括:
获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
本申请还提供了一种基于文本分类模型的文本分类方法,所述文本分类模型为根据上述的文本分类模型训练方法训练得到,所述方法包括:
获取待分类文本;
将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
本申请还提供了一种文本分类模型训练装置,所述装置包括:
模型训练模块,用于获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
数据上传模块,用于将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
模型更新模块,用于接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
本申请还提供了一种计算机设备,所述计算机设备包括存储器和处理器;
所述存储器,用于存储计算机程序;
所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现如下步骤:
获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型;
或如下步骤:
获取待分类文本;
将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现如下步骤:
获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型;
或如下步骤:
获取待分类文本;
将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请的实施例提供的一种文本分类模型训练方法的示意流程图;
图2是本申请实施例提供的一种本地分类模型的训练过程的示意图;
图3是本申请实施例提供的一种对本地分类模型进行文本分类训练的子步骤的示意性流程图;
图4是本申请的实施例提供的一种对相似文本模型进行相似文本预测训练的子步骤的示意性流程图;
图5是本申请实施例提供的一种上传加密数据至联邦学习服务器的示意图;
图6是本申请实施例提供的一种接收联邦学习服务器的学习参数的示意图;
图7是本申请的实施例提供的一种文本分类方法的示意性流程图;
图8是本申请实施例提供的一种文本分类模型训练装置的示意性框图;
图9是本申请实施例提供的一种计算机设备的结构示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
本申请的实施例提供了一种文本分类模型训练方法、文本分类方法、装置、计算机设备和介质。其中,该文本分类模型训练方法可以应用于多个客户端中,多个客户端可以根据本地的文本训练集合对本地分类模型进行文本分类训练,然后将训练后的本地分类模型和本地分类结果上传至联邦学习服务器中进行联合学习,实现对不同客户端的文本数据进行隔离和避免数据泄露,从而提高了文本数据的安全性;还可以丰富训练的文本数据,提高了训练完成的文本分类模型的分类准确性。
其中,客户端可以是智能手机、平板电脑、笔记本电脑和台式电脑等电子设备。
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
如图1所示,文本分类模型训练方法包括步骤S10至步骤S30。
步骤S10、获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果。
示例性的,客户端可以将本地的文本数据作为文本训练集合;其中,文本训练集合包括多个训练文本,可以作为本地分类模型的训练数据。
需要说明的是,客户端本地的文本数据可以是客户端采集的用户数据。在对本地分类模型进行训练时,为了提高文本分类的准确性,需要将不同用户数据进行训练。但是在医疗、金融以及财险等场景中,用户数据涉及到用户的个人信息或隐私保护,因此,不能将不同用户数据一起作为训练数据进行训练。在本申请实施例中,可以在客户端中分别根据本地的文本数据进行本地分类模型的训练,然后将训练后的本地分类模型的模型参数和本地分类结果加密后上传至联邦学习服务器进行联合学习,实现对不同客户端的文本数据进行隔离和避免数据泄露,最大限度地保证了用户数据的安全,还可以提高训练完成的文本分类模型的分类准确性。
需要强调的是,为进一步保证上述文本训练集合的私密和安全性,上述文本 训练集合还可以存储于一区块链的节点中。
在本申请实施例中,本地分类模型包括词向量模型、聚类模型以及相似文本模型三个部分。因此,在本地分类模型训练时,需要分别对词向量模型、聚类模型和相似文本模型进行训练。
示例性的,如图2所示,图2是本申请实施例提供的一种本地分类模型的训练过程的示意图。在图2中,将文本训练集合输入词向量模型中,将输出的词向量预测结果作为聚类模型的输入,聚类模型在训练后输出聚类预测结果;将聚类预测结果和文本训练集合输入相似文本模型中训练,相似文本模型输出文本类别预测结果。
请参阅图3,图3是步骤S10中根据文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果的子步骤的示意性流程图,具体可以包括以下步骤S101至步骤S104。
步骤S101、根据所述文本训练集合对所述词向量模型进行向量化训练,得到训练后的词向量模型和词向量预测结果。
示例性的,词向量模型可以包括BERT(Bidirectional Encoder Representations from Transformer)模型。
需要说明的是,在训练时,BERT模型可以通过Attention(注意力)机制将目标字和上下文各个字的语义向量表示作为输入,首先通过线性变换获得目标字的向量表示、上下文各个字的向量表示以及目标字与上下文各个字的原始值表示,然后计算目标字的向量与上下文各个字的向量的相似度作为权重,加权融合目标字的向量和上下文各个字的向量,作为Attention的输出,即目标字的增强语义向量表示。
示例性的,在本申请实施例中,可以将训练文本集合中的训练文本输入BERT模型中,由BERT模型通过查询字向量表将训练文本中的每个字转换为一维向量,作为BERT模型的输入进行训练;在训练后,BERT模型输出的是输入的各字对应的融合全文语义信息后的向量。
示例性的,训练后的词向量模型的模型参数包括注意力权重;词向量预测结果包括每个训练文本对应的词组的词向量。
通过根据训练文本集合对词向量模型进行向量化训练,考虑了文本的语义信息,可以提高训练后的词向量模型的预测词向量的准确性,还可以得到训练后的词向量模型和表示语义的词向量预测结果。
步骤S102、基于所述词向量预测结果对所述聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果。
示例性的,词向量预测结果包括训练文本对应的预测词向量。
需要说明的是,在本申请实施例中,通过聚类模型根据每个训练文本对应的预测词向量,计算预测词向量与预设的聚类中心之间的最小化平方误差,以将训练文本集合中的各训练文本划分为至少一个聚类簇。
示例性的,聚类模型可以包括但不限于层次聚类算法、原型聚类算法以及密度聚类算法等等。其中,原型聚类算法可以包括k均值算法、学习向量量化以及高斯混合聚类。在本申请实施例中,以聚类模型为k均值算法为例进行说明。其中,k均值算法是一种简单的迭代型聚类算法,采用距离作为相似性指标,从而得到给定数据集中的k个聚类簇,且每个聚类簇的聚类中心是根据聚类簇中所有值的均值得到。
示例性的,给定样本集D={x 1,x 2,…,x m},k均值算法对聚类所得簇划分 C={C 1,C 2,…,C k}最小化平方误差的计算公式如下:
Figure PCTCN2020136314-appb-000001
式中,m表示样本的个数;k表示聚类簇的个数;
Figure PCTCN2020136314-appb-000002
表示聚类簇C i的均值向量。
示例性的,k均值算法的训练过程包括:(1)选取数据空间中的k个对象作为初始中心,每个对象代表一个聚类中心;(2)对于样本中的数据对象,根据它们与这些聚类中心的欧氏距离,按距离最近的准则将它们分到距离它们最近的聚类中心(最相似)所对应的聚类簇;(3)将每个聚类簇中所有对象所对应的均值作为该聚类簇的聚类中心,计算目标函数的值;(4)判断聚类中心和目标函数的值是否发生改变,若不变,则输出结果,若改变,返回步骤(2)。
示例性的,基于训练文本对应的预测词向量对聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果。其中,训练后的聚类模型的模型参数包括至少一个聚类中心。聚类预测结果包括每个训练文本对应的聚类簇,每个聚类簇包括多个语义相似的训练文本。例如,对于训练文本A,训练文本A对应的聚类簇可以包括与训练文本A语义相似的训练文本B、训练文本C以及训练文本D等等。
通过基于预测词向量对聚类模型进行文本聚类训练,可以得到训练后的聚类模型和聚类中心,提高了聚类模型的聚类准确性;后续可以根据每个训练文本对应的聚类簇,确定每个训练文本多个语义相似的相似文本。
步骤S103、基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果。
示例性的,相似文本模型为根据词频-逆文档频率算法建立的。需要说明的是,相似文本模型用于根据每个训练文本的关键词,确定每个训练文本在对应的聚类簇中的多个相似文本。
通过基于词频-逆文档频率算法,根据聚类预测结果和文本训练集合对相似文本模型进行训练,可以实现将文本的语义信息与关键词进行结合来预测文本的类别,进而有效提高了文本类别的预测准确性。
请参阅图4,图4是步骤S103中基于聚类预测结果和文本训练集合对相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果的子步骤的示意性流程图,具体可以包括以下步骤S1031至步骤S1035。
步骤S1031、基于所述相似文本模型,根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本。
需要说明的是,在词频-逆文档频率(TF-IDF)算法中,TF表示词频(Term Frequency),IDF表示逆文档频率(Inverse Document Frequency)。TF-IDF算法是一种用于信息检索与数据挖掘的常用加权技术,可以评估一个词在一个文件集或者一个语料库中对某个文件的重要程度。
示例性的,词频TF的计算公式,如下所示:
Figure PCTCN2020136314-appb-000003
式中,n表示某个词在文章中的出现次数;m表示文章的总词数。
在一个语料库中,逆文档频率的计算公式,如下所示:
Figure PCTCN2020136314-appb-000004
式中,w表示语料库的文档总数;W表示包含该词的文档数。
示例性的,TF-IDF值的计算公式,如下所示:
Figure PCTCN2020136314-appb-000005
需要说明的是,TF-IDF值与一个词在文档中的出现次数成正比,与该词在整个语言中的出现次数成反比。因此,提取关键词的过程可以理解为计算出文档的每个词对应的TF-IDF值,然后根据TF-IDF值对每个词降序排列,将排在最前面的几个词作为关键词。
在一些实施例中,根据词频-逆文档频率算法确定每个训练文本在对应的聚类簇中的相似文本,可以包括:根据词频-逆文档频率算法确定每个训练文本对应的第一关键词,以及确定每个训练文本对应的聚类簇中的其他文本对应的第二关键词;若第二关键词与第一关键词匹配,则将第二关键词对应的其他文本确定为每个训练文本的相似文本。
示例性的,根据TF-IDF算法计算每个训练文本中的各词对应的TF-IDF值,将对应的TF-IDF值大于预设的TF-IDF阈值的词,确定为每个训练文本对应的第一关键词。根据TF-IDF算法,计算每个训练文本对应的聚类簇中的其他文本的各词对应的TF-IDF值,将对应的TF-IDF值大于预设的TF-IDF阈值的词,确定为其他文本对应的第二关键词。
其中,预设的TF-IDF阈值可以根据实际情况设定,具体数值在此不作限定。
示例性的,对于训练文本A,其它文本可以包括训练文本B、训练文本C以及训练文本D等等。
示例性的,在确定第一关键词与第二关键词之后,需要判断第二关键词与第一关键词是否匹配。例如,若第一关键词与第二关键词相同,则判定第一关键词与第二关键词匹配。
在一些实施例中,若判定第二关键词与第一关键词匹配,则将第二关键词对应的其他文本确定为每个训练文本的相似文本。
例如,若训练文本A对应的第一关键词与训练文本B对应的第二关键词匹配,则可以确定训练文本B为训练文本A对应的相似文本。
例如,若训练文本A对应的第一关键词与训练文本C对应的第二关键词匹配,则还可以确定训练文本C为训练文本A对应的相似文本。
又例如,若训练文本A对应的第一关键词与训练文本D对应的第二关键词不匹配,则不将训练文本D作为训练文本A对应的相似文本。
通过根据词频-逆文档频率算法确定每个训练文本对应的第一关键词,以及确定每个训练文本对应的聚类簇中的其他文本对应的第二关键词,可以准确且快速地确定每个训练文本的相似文本。
步骤S1032、确定每个所述训练文本对应的相似文本的个数。
示例性的,在根据词频-逆文档频率算法确定每个训练文本在对应的聚类簇中的相似文本之后,分别确定每个训练文本对应的相似文本的个数。
例如,训练文本A对应的相似文本包括训练文本B和训练文本C两个。
步骤S1033、当存在所述训练文本对应的相似文本的个数小于预设个数时,调整所述词频-逆文档频率算法的参数,直至基于调整后的所述词频-逆文档频率算法,确定每个所述训练文本的相似文本的个数大于或等于所述预设个数,结束训练,得到所述训练后的相似文本模型。
示例性的,预设个数可以根据实际情况设定,具体数值在此不作限定。
示例性的,调整词频-逆文档频率算法的参数,可以调整逆文档频率的权重比,也可以调整语料库的文档总数。
示例性的,当每个训练文本对应的相似文本的个数小于预设个数时,调整词频-逆文档频率算法的参数;然后基于调整后的词频-逆文档频率算法,确定每个训练文本在对应的聚类簇中的相似文本,直至确定每个训练文本的相似文本的个数大于或等于预设个数,结束训练,得到训练后的相似文本模型。
通过调整词频-逆文档频率算法的参数,使得每个训练文本的相似文本的个数大于或等于预设个数,可以保证每个训练文本有足够多的相似文本,从而提高了后续根据相似文本确定每个训练文本对应的文本类别的准确性。
步骤S1034、根据预设的相似度算法,计算每个所述训练文本与每个所述训练文本的相似文本之间的相似度。
示例性的,预设的相似度算法可以包括但不限于欧式距离、余弦相似度、曼哈顿距离以及切比雪夫距离等算法进行计算。
需要说明的是,在本申请实施例中,可以根据余弦相似度算法计算每个训练文本的相似文本与每个训练文本之间的相似度。可以理解的是,余弦相似度算法用向量空间中两个向量的夹角余弦值作为衡量两个向量间相似程度的大小。
示例性的,夹角余弦值的计算公式为:
Figure PCTCN2020136314-appb-000006
式中,θ表示向量V 1和向量V 2之间的夹角,n表示向量V 1和向量V 2中的维数;夹角余弦值cosθ的值域为[0,1]。
在一些实施例中,获取每个训练文本对应的全部词的词向量矩阵V 1,以及获取每个训练文本对应的相似文本的全部词的词向量矩阵V 2;根据夹角余弦值,计算词向量矩阵V 1与词向量矩阵V 2之间的相似度,即得到计算每个训练文本与每个训练文本的相似文本之间的相似度。
在另一些实施例中,获取每个训练文本对应的第一关键词的词向量矩阵V 1,以及获取每个训练文本对应的相似文本的第二关键词的词向量矩阵V 2;根据夹角余弦值,计算词向量矩阵V 1与词向量矩阵V 2之间的相似度,即得到计算每个训练文本与每个训练文本的相似文本之间的相似度。通过根据每个训练文本对应的第一关键词的词向量矩阵和相似文本的第二关键词的词向量矩阵计算相似度,可以 大大减少计算量,提高了相似度的计算效率。
步骤S1035、将最大相似度对应的相似文本的文本类别,确定为每个所述训练文本对应的文本类别预测结果。
示例性的,可以预先对训练文本集合中的各训练文本添加文本类别标签。通过训练文本携带的文本类别标签可以确定训练文本对应的文本类别。
示例性的,文本类别可以包括但不限于保险、医疗、金融、旅游、体育以及汽车等等类别。
示例性的,在计算每个训练文本与每个训练文本的相似文本之间的相似度后,可以将最大相似度对应的相似文本的文本类别,作为每个训练文本对应的文本类别预测结果。例如,若最大相似度对应的相似文本携带的文本类别标签为“医疗”,则可以确定训练文本对应的文本类别预测结果为“医疗”。
步骤S104、将所述训练后的词向量模型、所述训练后的聚类模型以及所述训练后的相似文本模型合并得到所述训练后的本地分类模型,以及根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果。
需要说明的是,在本申请实施例,由于本地分类模型包括词向量模型、聚类模型和相似文本模型三个部分,因此,各个客户端可以将训练后的词向量模型、训练后的聚类模型和训练后的相似文本模型进行合并,得到训练后的本地分类模型。同样,根据词向量预测结果、聚类预测结果和文本类别预测结果生成本地分类结果。
在一些实施例,根据词向量预测结果、聚类预测结果和文本类别预测结果生成本地分类结果,可以包括:基于预设的权重计算公式,对词向量预测结果、聚类预测结果和文本类别预测结果进行加权求和,得到本地分类结果。
需要说明的是,由于本地分类模型包括词向量模型、聚类模型和相似文本模型三个部分,因此,本地分类模型可以按照预先设置的权重系数,分别将词向量预测结果、聚类预测结果和文本类别预测结果按照权重系数进行计算,从而得到最终的本地分类结果。
示例性的,权重计算公式如下所示:
J=λ 1P a2P b3P c
其中,J表示本地分类结果,P a表示词向量预测结果中概率最大的结果,λ 1表示概率最大结果P a的权重系数,P b表示聚类预测结果中概率最大的结果,λ 2表示概率最大结果P b的权重系数;P c表示文本类别预测结果中相似度最大的结果,λ 3表示相似度最大结果P c的权重系数。
通过基于预设的权重计算公式对词向量预测结果、聚类预测结果和文本类别预测结果进行加权求和,实现将各模型的预测结果按照不同的权重进行融合,可以提高后续的联合学习的准确性。
步骤S20、将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习。
请参阅图5,图5是本申请实施例提供的一种上传加密数据至联邦学习服务器的示意图。如图5所示,各个客户端在本地得到训练后的本地分类模型后,需要将本地分类模型的模型参数和本地分类结果进行加密;然后将加密数据上传至联邦学习服务器,由联邦学习服务器根据接收到的这些加密数据进行联合学习,得到学习参数。
其中,联邦学习服务器包括联邦学习模型。示例性的,联邦学习分为横向联邦学习、纵向联邦学习以及联邦迁移学习等类型。
需要说明的是,联邦学习是指通过联合不同的客户端或参与者进行机器学习建模的方法。在联邦学习中,客户端不需要向其它客户端和协调者(也称为服务器)暴露自己所拥有的数据,因而联邦学习可以很好的保护用户隐私和保障数据安全,并可以解决数据孤岛问题。联邦学习具有以下优势:数据隔离,数据不会泄露到外部,满足用户隐私保护和数据安全的需求;能够保证联邦学习模型的质量无损,不会出现负迁移,保证联邦学习模型比割裂的独立模型效果好;能够保证各客户端在保持独立性的情况下,进行信息与模型参数的加密交换,并同时获得成长。
示例性的,本地分类模型的模型参数包括词向量模型中的注意力权重、聚类模型中的聚类中心以及相似文本模型中的逆文档频率。
在一些实施例中,将训练后的本地分类模型的模型参数和本地分类结果上传至联邦学习服务器进行联合学习之前,需要对模型参数和本地分类结果进行加密得到加密数据;然后将加密数据上传至联邦学习服务器中进行联合学习。
示例性的,在进行数据加密时,可以采用同态加密、差分隐私或多方安全计算等隐私计算方法。需要说明的是,当采用同态加密时,联邦学习服务器可以不对加密数据进行解密,直接根据加密数据进行联合学习。
可以理解的是,通过将训练后的本地分类模型的模型参数和本地分类结果加密后上传至联邦学习服务器进行联合学习,实现间接地根据不同客户端中的用户数据进行训练,扩充训练模型时的样本数量;不仅可以避免数据泄露,最大限度地保证了用户数据的安全,而且可以提高训练完成的文本分类模型的分类准确性。
示例性的,联邦学习服务器在接收到各个客户端上传的加密数据后,对加密数据进行解密处理,得到解密后的数据信息;然后基于联邦学习模型,根据解密后的数据信息进行联合学习,得到学习参数。
在具体实施方式中,联邦学习服务器可以采用全局平均法进行联合学习,得到学习参数。例如,分别计算本地分类模型中模型参数的平均值,然后对于一些与平均值相差过大的模型参数调低其参数权重,以得到学习参数。其中,本地分类结果可以用于确定联邦学习模型的损失函数值,以根据损失函数值调整联邦学习的参数。
步骤S30、接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
请参阅图6,图6是本申请实施例提供的一种接收联邦学习服务器的学习参数的示意图。在图6中,各个客户端接收联邦学习服务器发送的学习参数,并且根据学习参数更新本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
示例性的,根据学习参数分别更新训练后的词向量模型、训练后的聚类模型 以及训练后的相似文本模型,例如,更新各个模型的模型参数,得到更新后的词向量模型、更新后的聚类模型以及更新后的相似文本模型。
需要强调的是,为进一步保证上述更新后的本地分类模型的私密和安全性,上述更新后的本地分类模型还可以存储于一区块链的节点中。
通过根据学习参数更新本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型,可以进一步提高文本分类模型在文本分类时的准确性。
上述实施例提供的文本分类模型训练方法,通过根据训练文本集合对词向量模型进行向量化训练,考虑了文本的语义信息,可以提高训练后的词向量模型的预测词向量的准确性,还可以得到训练后的词向量模型和表示语义的词向量预测结果;通过基于预测词向量对聚类模型进行文本聚类训练,可以得到训练后的聚类模型和聚类中心,提高了聚类模型的聚类准确性,后续可以根据每个训练文本对应的聚类簇,确定每个训练文本多个语义相似的相似文本;通过基于词频-逆文档频率算法,根据聚类预测结果和文本训练集合对相似文本模型进行训练,可以实现将文本的语义信息与关键词进行结合来预测文本的类别,进而有效提高了文本类别的预测准确性;通过根据词频-逆文档频率算法确定每个训练文本对应的第一关键词,以及确定每个训练文本对应的聚类簇中的其他文本对应的第二关键词,可以准确且快速地确定每个训练文本的相似文本;通过调整词频-逆文档频率算法的参数,使得每个训练文本的相似文本的个数大于或等于预设个数,可以保证每个训练文本有足够多的相似文本,从而提高了后续根据相似文本确定每个训练文本对应的文本类别的准确性;通过将训练后的本地分类模型的模型参数和本地分类结果加密后上传至联邦学习服务器进行联合学习,实现间接地根据不同客户端中的用户数据进行训练,扩充训练模型时的样本数量;不仅可以避免数据泄露,最大限度地保证了用户数据的安全,而且可以提高训练完成的文本分类模型的分类准确性;通过根据学习参数更新本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型,可以进一步提高文本分类模型在文本分类时的准确性。
请参阅图7,图7是本申请实施例提供的一种文本分类方法。如图7所示,该文本分类方法,具体包括:步骤S401和步骤S402。
步骤S401、获取待分类文本。
需要说明的是,可以在客户端中设置对外查询文本类别的文本类别查询界面。用户可以在文本类别查询界面查询相关文本的文本类别。
示例性的,当客户端接收到用户在文本类别查询界面中的文本输入操作时,根据文本输入操作获取用户输入的文本数据,将获取的文本数据作为待分类文本。
步骤S402、将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
其中,文本分类模型为根据上述的文本分类模型训练方法训练得到。
示例性的,可以调用训练完成的文本分类模型对待分类文本进行分类预测。其中,文本分类模型包括更新后的词向量模型、更新后的聚类模型以及更新后的相似文本模型。
在一些实施例中,对待分类文本进行分类预测,可以包括:将待分类文本输入更新后的词向量模型中进行向量化处理,得到待分类文本对应的词向量;将待分类文本对应的词向量输入更新后的聚类模型中进行聚类分析,得到待分类文本对应的聚类簇;将待分类文本输入更新后的相似文本模型中进行相似文本预测, 得到待分类文本在对应的聚类簇中的至少一个相似文本;计算待分类文本与每个相似文本之间的相似度,将最大相似度对应的相似文本的文本类别,确定为待分类文本对应的文本类别。
上述实施例提供的文本分类方法,通过将待分类文本输入更新后的词向量模型、更新后的聚类模型以及更新后的相似文本模型中进行分级预测,可以结合待分类文本的语义信息和关键词信息进行预测,从而提高了预测待分类文本对应的文本类别的准确性。
请参阅图8,图8是本申请的实施例还提供一种文本分类模型训练装置100的示意性框图,该文本分类模型训练装置用于执行前述的文本分类模型训练方法。其中,该文本分类模型训练装置可以配置于服务器或终端中。
如图8所示,该文本分类模型训练装置100,包括:模型训练模块101、数据上传模块102和模型更新模块103。
模型训练模块101,用于获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果。
数据上传模块102,用于将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习。
模型更新模块103,用于接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
上述的装置可以实现为一种计算机程序的形式,该计算机程序可以在如图9所示的计算机设备上运行。
请参阅图9,图9是本申请实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以是服务器或终端。
请参阅图9,该计算机设备包括通过系统总线连接的处理器和存储器,其中,存储器可以包括非易失性存储介质和内存储器。
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种文本分类模型训练方法或文本分类方法。
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:
获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以 得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
在一个实施例中,所述本地分类模型包括词向量模型、聚类模型以及相似文本模型;所述处理器在实现根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果时,用于实现:
根据所述文本训练集合对所述词向量模型进行向量化训练,得到训练后的词向量模型和词向量预测结果;基于所述词向量预测结果对所述聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果;基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果;将所述训练后的词向量模型、所述训练后的聚类模型以及所述训练后的相似文本模型合并得到所述训练后的本地分类模型,以及根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果。
在一个实施例中,所述文本训练集合包括多个训练文本,所述聚类预测结果包括每个训练文本对应的聚类簇,所述相似文本模型为根据词频-逆文档频率算法建立的;所述处理器在实现基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果时,用于实现:
基于所述相似文本模型,根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本;确定每个所述训练文本对应的相似文本的个数;当存在所述训练文本对应的相似文本的个数小于预设个数时,调整所述词频-逆文档频率算法的参数,直至基于调整后的所述词频-逆文档频率算法,确定每个所述训练文本的相似文本的个数大于或等于所述预设个数,结束训练,得到所述训练后的相似文本模型;根据预设的相似度算法,计算每个所述训练文本与每个所述训练文本的相似文本之间的相似度;将最大相似度对应的相似文本的文本类别,确定为每个所述训练文本对应的文本类别预测结果。
在一个实施例中,所述处理器在实现根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本时,用于实现:
根据所述词频-逆文档频率算法确定每个所述训练文本对应的第一关键词,以及确定每个所述训练文本对应的聚类簇中的其他文本对应的第二关键词;若所述第二关键词与所述第一关键词匹配,则将所述第二关键词对应的所述其他文本确定为每个所述训练文本的相似文本。
在一个实施例中,所述处理器在实现根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果时,用于实现:
基于预设的权重计算公式,对所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果进行加权求和,得到所述本地分类结果。
在一个实施例中,所述处理器还用于实现:
获取待分类文本;将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
本申请的实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质可以是非易失性,也可以是易失性,所述计算机可读存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申 请实施例提供的任一项文本分类模型训练方法。
其中,所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字卡(Secure Digital Card,SD Card),闪存卡(Flash Card)等。
进一步地,所述计算机可读存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。
本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种文本分类模型训练方法,其中,包括:
    获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
    将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
    接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
  2. 根据权利要求1所述的文本分类模型训练方法,其中,所述本地分类模型包括词向量模型、聚类模型以及相似文本模型;所述根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果,包括:
    根据所述文本训练集合对所述词向量模型进行向量化训练,得到训练后的词向量模型和词向量预测结果;
    基于所述词向量预测结果对所述聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果;
    基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果;
    将所述训练后的词向量模型、所述训练后的聚类模型以及所述训练后的相似文本模型合并得到所述训练后的本地分类模型,以及根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果。
  3. 根据权利要求2所述的文本分类模型训练方法,其中,所述文本训练集合包括多个训练文本,所述聚类预测结果包括每个训练文本对应的聚类簇,所述相似文本模型为根据词频-逆文档频率算法建立的;
    所述基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果,包括:
    基于所述相似文本模型,根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本;
    确定每个所述训练文本对应的相似文本的个数;
    当存在所述训练文本对应的相似文本的个数小于预设个数时,调整所述词频-逆文档频率算法的参数,直至基于调整后的所述词频-逆文档频率算法,确定每个所述训练文本的相似文本的个数大于或等于所述预设个数,结束训练,得到所述训练后的相似文本模型;
    根据预设的相似度算法,计算每个所述训练文本与每个所述训练文本的相似文本之间的相似度;
    将最大相似度对应的相似文本的文本类别,确定为每个所述训练文本对应的文本类别预测结果。
  4. 根据权利要求3所述的文本分类模型训练方法,其中,所述根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本,包括:
    根据所述词频-逆文档频率算法确定每个所述训练文本对应的第一关键词,以及确定每个所述训练文本对应的聚类簇中的其他文本对应的第二关键词;
    若所述第二关键词与所述第一关键词匹配,则将所述第二关键词对应的所述其他文本确定为每个所述训练文本的相似文本。
  5. 根据权利要求2所述的文本分类模型训练方法,其中,所述根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果,包括:
    基于预设的权重计算公式,对所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果进行加权求和,得到所述本地分类结果。
  6. 根据权利要求2所述的文本分类模型训练方法,其中,所述本地分类模型的模型参数包括所述词向量模型中的注意力权重、所述聚类模型中的聚类中心以及所述相似文本模型中的逆文档频率。
  7. 一种基于文本分类模型的文本分类方法,其中,所述文本分类模型为根据权利要求1至6任一项所述的文本分类模型训练方法训练得到,所述文本分类方法包括:
    获取待分类文本;
    将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
  8. 一种文本分类模型训练装置,其中,包括:
    模型训练模块,用于获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
    数据上传模块,用于将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
    模型更新模块,用于接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型。
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器;
    所述存储器,用于存储计算机程序;
    所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现:
    如下步骤:获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
    将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
    接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型;或
    如下步骤:
    获取待分类文本;
    将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
  10. 根据权利要求9所述的计算机设备,其中,所述本地分类模型包括词向量模型、聚类模型以及相似文本模型;所述根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果,包括:
    根据所述文本训练集合对所述词向量模型进行向量化训练,得到训练后的词 向量模型和词向量预测结果;
    基于所述词向量预测结果对所述聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果;
    基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果;
    将所述训练后的词向量模型、所述训练后的聚类模型以及所述训练后的相似文本模型合并得到所述训练后的本地分类模型,以及根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果。
  11. 根据权利要求10所述的计算机设备,其中,所述文本训练集合包括多个训练文本,所述聚类预测结果包括每个训练文本对应的聚类簇,所述相似文本模型为根据词频-逆文档频率算法建立的;
    所述基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果,包括:
    基于所述相似文本模型,根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本;
    确定每个所述训练文本对应的相似文本的个数;
    当存在所述训练文本对应的相似文本的个数小于预设个数时,调整所述词频-逆文档频率算法的参数,直至基于调整后的所述词频-逆文档频率算法,确定每个所述训练文本的相似文本的个数大于或等于所述预设个数,结束训练,得到所述训练后的相似文本模型;
    根据预设的相似度算法,计算每个所述训练文本与每个所述训练文本的相似文本之间的相似度;
    将最大相似度对应的相似文本的文本类别,确定为每个所述训练文本对应的文本类别预测结果。
  12. 根据权利要求11所述的计算机设备,其中,所述根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本,包括:
    根据所述词频-逆文档频率算法确定每个所述训练文本对应的第一关键词,以及确定每个所述训练文本对应的聚类簇中的其他文本对应的第二关键词;
    若所述第二关键词与所述第一关键词匹配,则将所述第二关键词对应的所述其他文本确定为每个所述训练文本的相似文本。
  13. 根据权利要求10所述的计算机设备,其中,所述根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果,包括:
    基于预设的权重计算公式,对所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果进行加权求和,得到所述本地分类结果。
  14. 根据权利要求10所述的计算机设备,其中,所述本地分类模型的模型参数包括所述词向量模型中的注意力权重、所述聚类模型中的聚类中心以及所述相似文本模型中的逆文档频率。
  15. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现:
    如下步骤:获取文本训练集合,根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果;
    将所述训练后的本地分类模型的模型参数和所述本地分类结果加密后上传至联邦学习服务器进行联合学习,以得到学习参数,其中,所述联邦学习服务器用于根据不同客户端上传的加密数据进行联合学习;
    接收所述联邦学习服务器发送的所述学习参数,并根据所述学习参数更新所述训练后的本地分类模型,将更新后的本地分类模型作为训练完成的文本分类模型;或
    如下步骤:
    获取待分类文本;
    将所述待分类文本输入所述文本分类模型中进行分类预测,得到所述待分类文本对应的文本类别。
  16. 根据权利要求15所述的计算机可读存储介质,其中,所述本地分类模型包括词向量模型、聚类模型以及相似文本模型;所述根据所述文本训练集合对本地分类模型进行文本分类训练,得到训练后的本地分类模型和本地分类结果,包括:
    根据所述文本训练集合对所述词向量模型进行向量化训练,得到训练后的词向量模型和词向量预测结果;
    基于所述词向量预测结果对所述聚类模型进行文本聚类训练,得到训练后的聚类模型和聚类预测结果;
    基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果;
    将所述训练后的词向量模型、所述训练后的聚类模型以及所述训练后的相似文本模型合并得到所述训练后的本地分类模型,以及根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结果。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述文本训练集合包括多个训练文本,所述聚类预测结果包括每个训练文本对应的聚类簇,所述相似文本模型为根据词频-逆文档频率算法建立的;
    所述基于所述聚类预测结果和所述文本训练集合对所述相似文本模型进行相似文本预测训练,得到训练后的相似文本模型和文本类别预测结果,包括:
    基于所述相似文本模型,根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本;
    确定每个所述训练文本对应的相似文本的个数;
    当存在所述训练文本对应的相似文本的个数小于预设个数时,调整所述词频-逆文档频率算法的参数,直至基于调整后的所述词频-逆文档频率算法,确定每个所述训练文本的相似文本的个数大于或等于所述预设个数,结束训练,得到所述训练后的相似文本模型;
    根据预设的相似度算法,计算每个所述训练文本与每个所述训练文本的相似文本之间的相似度;
    将最大相似度对应的相似文本的文本类别,确定为每个所述训练文本对应的文本类别预测结果。
  18. 根据权利要求17所述的计算机可读存储介质,其中,所述根据所述词频-逆文档频率算法确定每个所述训练文本在对应的聚类簇中的相似文本,包括:
    根据所述词频-逆文档频率算法确定每个所述训练文本对应的第一关键词,以及确定每个所述训练文本对应的聚类簇中的其他文本对应的第二关键词;
    若所述第二关键词与所述第一关键词匹配,则将所述第二关键词对应的所述其他文本确定为每个所述训练文本的相似文本。
  19. 根据权利要求16所述的计算机可读存储介质,其中,所述根据所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果生成所述本地分类结 果,包括:
    基于预设的权重计算公式,对所述词向量预测结果、所述聚类预测结果和所述文本类别预测结果进行加权求和,得到所述本地分类结果。
  20. 根据权利要求16所述的计算机可读存储介质,其中,所述本地分类模型的模型参数包括所述词向量模型中的注意力权重、所述聚类模型中的聚类中心以及所述相似文本模型中的逆文档频率。
PCT/CN2020/136314 2020-10-21 2020-12-15 模型训练方法、文本分类方法、装置、计算机设备和介质 WO2021189974A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011133979.1A CN112256874B (zh) 2020-10-21 2020-10-21 模型训练方法、文本分类方法、装置、计算机设备和介质
CN202011133979.1 2020-10-21

Publications (1)

Publication Number Publication Date
WO2021189974A1 true WO2021189974A1 (zh) 2021-09-30

Family

ID=74263447

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/136314 WO2021189974A1 (zh) 2020-10-21 2020-12-15 模型训练方法、文本分类方法、装置、计算机设备和介质

Country Status (2)

Country Link
CN (1) CN112256874B (zh)
WO (1) WO2021189974A1 (zh)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114040272A (zh) * 2021-10-09 2022-02-11 中国联合网络通信集团有限公司 一种路径确定方法、装置和存储介质
CN114386533A (zh) * 2022-01-28 2022-04-22 华控清交信息科技(北京)有限公司 一种gbdt模型的横向训练方法、装置、电子设备及系统
CN114610905A (zh) * 2022-03-23 2022-06-10 腾讯科技(深圳)有限公司 一种数据处理方法及相关装置
CN114944934A (zh) * 2022-04-24 2022-08-26 华控清交信息科技(北京)有限公司 一种联邦学习方法和系统、第一隐私计算平台和第二隐私计算平台
CN115168577A (zh) * 2022-06-30 2022-10-11 北京百度网讯科技有限公司 模型更新方法、装置、电子设备及存储介质
CN115811402A (zh) * 2022-11-14 2023-03-17 吉林大学 基于隐私保护联邦学习的医疗数据分析方法及存储介质
CN115994226A (zh) * 2023-03-21 2023-04-21 杭州金智塔科技有限公司 基于联邦学习的聚类模型训练系统及方法
CN115994527A (zh) * 2023-03-23 2023-04-21 广东聚智诚科技有限公司 一种基于机器学习的ppt自动生成系统
CN116108491A (zh) * 2023-04-04 2023-05-12 杭州海康威视数字技术股份有限公司 基于半监督联邦学习的数据泄露预警方法、装置及系统
CN116339799A (zh) * 2023-04-06 2023-06-27 山景智能(北京)科技有限公司 一种智能化数据接口管理的方法、系统、终端设备及存储介质
CN116541769A (zh) * 2023-07-05 2023-08-04 北京邮电大学 一种基于联邦学习的节点数据分类方法及系统
CN116756293A (zh) * 2023-08-11 2023-09-15 之江实验室 一种模型训练的方法、装置、存储介质及电子设备
CN117076387A (zh) * 2023-08-22 2023-11-17 北京天华星航科技有限公司 基于磁带的海量小文件的快速归档恢复系统

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112968872B (zh) * 2021-01-29 2023-04-18 成都信息工程大学 基于自然语言处理的恶意流量检测方法、系统、终端
CN112835798B (zh) * 2021-02-03 2024-02-20 广州虎牙科技有限公司 聚类学习方法、测试步骤聚类方法及相关装置
CN113011503B (zh) * 2021-03-17 2021-11-23 彭黎文 一种电子设备的数据取证方法、存储介质及终端
CN113807535B (zh) * 2021-04-01 2023-11-03 京东科技控股股份有限公司 联邦学习模型的训练方法、装置、电子设备和存储介质
CN112990484B (zh) * 2021-04-21 2021-07-20 腾讯科技(深圳)有限公司 基于非对称联邦学习的模型联合训练方法、装置及设备
CN113177595B (zh) * 2021-04-29 2022-07-12 北京明朝万达科技股份有限公司 文档分类模型构建、训练、测试方法及模型构建系统
CN113312667B (zh) * 2021-06-07 2022-09-02 支付宝(杭州)信息技术有限公司 一种风险防控方法、装置及设备
CN113344220B (zh) * 2021-06-18 2022-11-11 山东大学 一种联邦学习中基于局部模型梯度的用户筛选方法、系统、设备及存储介质
CN113516199B (zh) * 2021-07-30 2022-07-15 山西清众科技股份有限公司 一种基于差分隐私的图像数据生成方法
CN114095503A (zh) * 2021-10-19 2022-02-25 广西综合交通大数据研究院 一种基于区块链的联邦学习参与节点选择方法
CN113887741B (zh) * 2021-11-05 2022-09-30 深圳市电子商务安全证书管理有限公司 基于联邦学习的数据生成方法、装置、设备及存储介质
CN114860927B (zh) * 2022-04-18 2023-04-25 广东工业大学 面向多任务联邦学习的文本匹配方法
CN115081642B (zh) * 2022-07-19 2022-11-15 浙江大学 一种多方协同更新业务预测模型的方法及系统
CN116192363B (zh) * 2023-04-26 2023-07-11 中新宽维传媒科技有限公司 基于文字信息的可听化处理方法、装置、介质和计算设备
CN117251726A (zh) * 2023-08-28 2023-12-19 北京邮电大学 公共卫生事件检测模型训练方法、检测方法、装置及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109739978A (zh) * 2018-12-11 2019-05-10 中科恒运股份有限公司 一种文本聚类方法、文本聚类装置及终端设备
WO2019149200A1 (zh) * 2018-02-01 2019-08-08 腾讯科技(深圳)有限公司 文本分类方法、计算机设备及存储介质
CN111078876A (zh) * 2019-12-04 2020-04-28 国家计算机网络与信息安全管理中心 一种基于多模型集成的短文本分类方法和系统
CN111310938A (zh) * 2020-02-10 2020-06-19 深圳前海微众银行股份有限公司 基于半监督的横向联邦学习优化方法、设备及存储介质
CN111428881A (zh) * 2020-03-20 2020-07-17 深圳前海微众银行股份有限公司 识别模型的训练方法、装置、设备及可读存储介质
CN111768008A (zh) * 2020-06-30 2020-10-13 平安科技(深圳)有限公司 联邦学习方法、装置、设备和存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8583416B2 (en) * 2007-12-27 2013-11-12 Fluential, Llc Robust information extraction from utterances
CN108595706B (zh) * 2018-05-10 2022-05-24 中国科学院信息工程研究所 一种基于主题词类相似性的文档语义表示方法、文本分类方法和装置
CN110825877A (zh) * 2019-11-12 2020-02-21 中国石油大学(华东) 一种基于文本聚类的语义相似度分析方法
CN111581949B (zh) * 2020-05-12 2023-03-21 上海市研发公共服务平台管理中心 学者人名的消歧方法、装置、存储介质及终端

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019149200A1 (zh) * 2018-02-01 2019-08-08 腾讯科技(深圳)有限公司 文本分类方法、计算机设备及存储介质
CN109739978A (zh) * 2018-12-11 2019-05-10 中科恒运股份有限公司 一种文本聚类方法、文本聚类装置及终端设备
CN111078876A (zh) * 2019-12-04 2020-04-28 国家计算机网络与信息安全管理中心 一种基于多模型集成的短文本分类方法和系统
CN111310938A (zh) * 2020-02-10 2020-06-19 深圳前海微众银行股份有限公司 基于半监督的横向联邦学习优化方法、设备及存储介质
CN111428881A (zh) * 2020-03-20 2020-07-17 深圳前海微众银行股份有限公司 识别模型的训练方法、装置、设备及可读存储介质
CN111768008A (zh) * 2020-06-30 2020-10-13 平安科技(深圳)有限公司 联邦学习方法、装置、设备和存储介质

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114040272B (zh) * 2021-10-09 2023-05-02 中国联合网络通信集团有限公司 一种路径确定方法、装置和存储介质
CN114040272A (zh) * 2021-10-09 2022-02-11 中国联合网络通信集团有限公司 一种路径确定方法、装置和存储介质
CN114386533A (zh) * 2022-01-28 2022-04-22 华控清交信息科技(北京)有限公司 一种gbdt模型的横向训练方法、装置、电子设备及系统
CN114386533B (zh) * 2022-01-28 2022-09-16 华控清交信息科技(北京)有限公司 一种gbdt模型的横向训练方法、装置、电子设备及系统
CN114610905A (zh) * 2022-03-23 2022-06-10 腾讯科技(深圳)有限公司 一种数据处理方法及相关装置
CN114610905B (zh) * 2022-03-23 2024-04-26 腾讯科技(深圳)有限公司 一种数据处理方法及相关装置
CN114944934A (zh) * 2022-04-24 2022-08-26 华控清交信息科技(北京)有限公司 一种联邦学习方法和系统、第一隐私计算平台和第二隐私计算平台
CN114944934B (zh) * 2022-04-24 2023-12-29 华控清交信息科技(北京)有限公司 一种联邦学习方法和系统、第一隐私计算平台和第二隐私计算平台
CN115168577A (zh) * 2022-06-30 2022-10-11 北京百度网讯科技有限公司 模型更新方法、装置、电子设备及存储介质
CN115168577B (zh) * 2022-06-30 2023-03-21 北京百度网讯科技有限公司 模型更新方法、装置、电子设备及存储介质
CN115811402B (zh) * 2022-11-14 2023-05-30 吉林大学 基于隐私保护联邦学习的医疗数据分析方法及存储介质
CN115811402A (zh) * 2022-11-14 2023-03-17 吉林大学 基于隐私保护联邦学习的医疗数据分析方法及存储介质
CN115994226A (zh) * 2023-03-21 2023-04-21 杭州金智塔科技有限公司 基于联邦学习的聚类模型训练系统及方法
CN115994226B (zh) * 2023-03-21 2023-10-20 杭州金智塔科技有限公司 基于联邦学习的聚类模型训练系统及方法
CN115994527A (zh) * 2023-03-23 2023-04-21 广东聚智诚科技有限公司 一种基于机器学习的ppt自动生成系统
CN116108491A (zh) * 2023-04-04 2023-05-12 杭州海康威视数字技术股份有限公司 基于半监督联邦学习的数据泄露预警方法、装置及系统
CN116108491B (zh) * 2023-04-04 2024-03-22 杭州海康威视数字技术股份有限公司 基于半监督联邦学习的数据泄露预警方法、装置及系统
CN116339799B (zh) * 2023-04-06 2023-11-28 山景智能(北京)科技有限公司 一种智能化数据接口管理的方法、系统、终端设备及存储介质
CN116339799A (zh) * 2023-04-06 2023-06-27 山景智能(北京)科技有限公司 一种智能化数据接口管理的方法、系统、终端设备及存储介质
CN116541769A (zh) * 2023-07-05 2023-08-04 北京邮电大学 一种基于联邦学习的节点数据分类方法及系统
CN116756293A (zh) * 2023-08-11 2023-09-15 之江实验室 一种模型训练的方法、装置、存储介质及电子设备
CN117076387A (zh) * 2023-08-22 2023-11-17 北京天华星航科技有限公司 基于磁带的海量小文件的快速归档恢复系统
CN117076387B (zh) * 2023-08-22 2024-03-01 北京天华星航科技有限公司 基于磁带的海量小文件的快速归档恢复系统

Also Published As

Publication number Publication date
CN112256874B (zh) 2023-08-08
CN112256874A (zh) 2021-01-22

Similar Documents

Publication Publication Date Title
WO2021189974A1 (zh) 模型训练方法、文本分类方法、装置、计算机设备和介质
US11714602B2 (en) Methods and systems for identifying a level of similarity between a plurality of data representations
US20210049198A1 (en) Methods and Systems for Identifying a Level of Similarity Between a Filtering Criterion and a Data Item within a Set of Streamed Documents
US10394851B2 (en) Methods and systems for mapping data items to sparse distributed representations
Qi et al. Compatibility-aware web API recommendation for mashup creation via textual description mining
WO2020057022A1 (zh) 关联推荐方法、装置、计算机设备和存储介质
US10943068B2 (en) N-ary relation prediction over text spans
US20150044660A1 (en) Caching Natural Language Questions and Results in a Question and Answer System
WO2021189951A1 (zh) 文本搜索方法、装置、计算机设备和存储介质
CN108681557A (zh) 基于自扩充表示和相似双向约束的短文本主题发现方法及系统
US11734332B2 (en) Methods and systems for reuse of data item fingerprints in generation of semantic maps
US20190332619A1 (en) Methods and systems for mapping data items to sparse distributed representations
Zhao et al. Discerning influence patterns with beta-poisson factorization in microblogging environments
WO2023033942A1 (en) Efficient index lookup using language-agnostic vectors and context vectors
WO2022116444A1 (zh) 文本分类方法、装置、计算机设备和介质
Fan et al. Topic modeling methods for short texts: A survey
Liu et al. Unstructured Text Resource Access Control Attribute Mining Technology Based on Convolutional Neural Network
Zhu et al. Few-shot temporal knowledge graph completion based on meta-optimization
Karamollaoğlu et al. Content Based Sentiment Analysis for Turkish Twitter Feeds Through Vector Space Model
CN117851446A (zh) 数据查询的方法、装置、计算设备集群

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20926541

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20926541

Country of ref document: EP

Kind code of ref document: A1