Data classification model training method, data classification method and apparatus
By alternating the training of the encoding and mapping layers of the data classification model, the catastrophic forgetting problem of machine learning models in data classification tasks is solved, and high-accuracy data classification is achieved in multi-task scenarios.
Patent Information
- Application Number
- CN202110003555.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-04
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2041-01-04
AI Technical Summary
Machine learning models can suffer from catastrophic forgetting when faced with a series of data classification tasks, leading to a decline in performance and accuracy on previous data classification tasks.
By acquiring a training sample set, the encoding and mapping layers of the data classification model are trained step by step. The encoding layer learns knowledge of each data classification task, and the mapping layer learns general knowledge between tasks. This alternating training is used to maintain and improve the accuracy of data classification.
To ensure the accuracy of the data classification model on forward data classification tasks, while maintaining high accuracy on new data classification tasks, a general target data classification model is obtained.
Smart Images

Figure CN114764865B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data classification model training method, a data classification method, an apparatus, a computer device, and a storage medium. Background Technology
[0002] With the development of computer technology, machine learning models have emerged. Training a machine learning model based on a specific data classification task allows the model to learn relevant knowledge about that task and thus perform specific data classification.
[0003] However, when a machine learning model faces a series of data classification tasks, catastrophic forgetting can occur. That is, the knowledge learned by the machine learning model in previous data classification tasks is overwritten by the new knowledge in subsequent data classification tasks, which ultimately leads to a decline in the performance of the machine learning model on the previous data classification tasks, that is, a decrease in the accuracy of the machine learning model in classifying data on the previous data classification tasks. Summary of the Invention
[0004] Therefore, it is necessary to provide a data classification model training method, data classification method, apparatus, computer equipment, and storage medium that can improve the accuracy of data classification in response to the above-mentioned technical problems.
[0005] A data classification model training method, the method comprising:
[0006] Obtain the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks;
[0007] Obtain the current training sample corresponding to the current data classification task, and train the encoding layer of the initial data classification model based on the current training sample to obtain the intermediate data classification model;
[0008] Obtain the updated training samples corresponding to the next data classification task, and train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model.
[0009] The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first feature and second feature;
[0010] The mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model.
[0011] Return to the step of obtaining the updated training samples corresponding to the next data classification task, until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0012] In one embodiment, obtaining the training sample set includes:
[0013] Multiple candidate samples are obtained; each candidate sample carries a candidate label; the candidate samples corresponding to the same candidate label are clustered to obtain the initial clusters corresponding to each candidate label; the processing priority of each candidate sample is determined based on the candidate label; the initial clusters are used as data classification sub-tasks, and the data classification sub-tasks corresponding to the same processing priority are clustered to obtain the target data classification task set corresponding to each processing priority; the target data classification task set includes each training sample corresponding to the same data classification task; a training sample set is obtained based on each target data classification task set.
[0014] In one embodiment, the target data classification model is used to determine the target label corresponding to the data to be classified from the candidate labels corresponding to the trained samples.
[0015] In one embodiment, the mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain an updated intermediate data classification model, including:
[0016] The second feature corresponding to the forward-trained sample is input into the mapping layer of the updated data classification model to obtain the corresponding predicted feature; the target training loss value is calculated based on the first feature and the predicted feature corresponding to the same training sample; the mapping layer parameters of the updated data classification model are adjusted based on the target training loss value until the convergence condition is met, and the updated intermediate data classification model is obtained.
[0017] A data classification model training device, the device comprising:
[0018] The training sample set acquisition module is used to acquire the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks;
[0019] The encoding layer training module is used to obtain the current training samples corresponding to the current data classification task, train the encoding layer of the initial data classification model based on the current training samples to obtain the intermediate data classification model; and obtain the updated training samples corresponding to the next data classification task, train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model.
[0020] The mapping layer training module is used to input the preceding trained samples of the updated training samples into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first feature and second feature; and to train the mapping layer of the updated data classification model based on the first feature and second feature corresponding to the same training sample to obtain the updated intermediate data classification model.
[0021] The target data classification model determination module is used to return the steps for obtaining the updated training samples corresponding to the next data classification task until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0022] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0023] Obtain the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks;
[0024] Obtain the current training sample corresponding to the current data classification task, and train the encoding layer of the initial data classification model based on the current training sample to obtain the intermediate data classification model;
[0025] Obtain the updated training samples corresponding to the next data classification task, and train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model.
[0026] The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first feature and second feature;
[0027] The mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model.
[0028] Return to the step of obtaining the updated training samples corresponding to the next data classification task, until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0029] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0030] Obtain the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks;
[0031] Obtain the current training sample corresponding to the current data classification task, and train the encoding layer of the initial data classification model based on the current training sample to obtain the intermediate data classification model;
[0032] Obtain the updated training samples corresponding to the next data classification task, and train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model.
[0033] The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first feature and second feature;
[0034] The mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model.
[0035] Return to the step of obtaining the updated training samples corresponding to the next data classification task, until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0036] The aforementioned data classification model training method, apparatus, computer equipment, and storage medium, through obtaining a training sample set including training samples corresponding to at least two data classification tasks, obtaining the current training sample corresponding to the current data classification task, training the encoding layer of the initial data classification model based on the current training sample to obtain an intermediate data classification model, obtaining the updated training sample corresponding to the next data classification task, training the encoding layer of the intermediate data classification model based on the updated training sample to obtain an updated data classification model, inputting the preceding trained samples of the updated training sample into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first and second features, training the mapping layer of the updated data classification model based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model, returning to the step of obtaining the updated training sample corresponding to the next data classification task, until training is completed, and obtaining the target data classification model based on the intermediate data classification model corresponding to the completed training. In this way, training the encoding layer of the data classification model allows the model to learn the knowledge specific to each data classification task from the training samples corresponding to each task. Training the mapping layer allows the model to learn the knowledge common to each data classification task. By alternating between training the encoding and mapping layers, the model can maintain its accuracy in the forward data classification task and also ensure its accuracy in the new data classification task, thus obtaining a general target data classification model.
[0037] A data classification method, the method comprising:
[0038] Obtain the data to be classified;
[0039] Input the data to be classified into the target data classification model to obtain the target classification result corresponding to the data to be classified;
[0040] The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is then repeated until training is complete. The target data classification model is obtained based on the intermediate data classification model at the time of training completion.
[0041] A data classification device, the device comprising:
[0042] The data acquisition module is used to acquire the data to be classified.
[0043] The classification result determination module is used to input the data to be classified into the target data classification model and obtain the target classification result corresponding to the data to be classified.
[0044] The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is then repeated until training is complete. The target data classification model is obtained based on the intermediate data classification model at the time of training completion.
[0045] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0046] Obtain the data to be classified;
[0047] Input the data to be classified into the target data classification model to obtain the target classification result corresponding to the data to be classified;
[0048] The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is then repeated until training is complete. The target data classification model is obtained based on the intermediate data classification model at the time of training completion.
[0049] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0050] Obtain the data to be classified;
[0051] Input the data to be classified into the target data classification model to obtain the target classification result corresponding to the data to be classified;
[0052] The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is then repeated until training is complete. The target data classification model is obtained based on the intermediate data classification model at the time of training completion.
[0053] The aforementioned data classification method, apparatus, computer equipment, and storage medium acquire the data to be classified, input the data to be classified into a target data classification model, and obtain the target classification result corresponding to the data to be classified. The target data classification model is based on the current training samples corresponding to the current data classification task in the training sample set. The encoding layer of the initial data classification model is trained to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is trained based on the updated training samples corresponding to the next data classification task in the training sample set to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first and second features. The mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain an updated intermediate data classification model. The process returns to the step of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task, until training is completed. The result is obtained based on the intermediate data classification model corresponding to the completed training. In this way, training the encoding layer of the data classification model allows the model to learn the knowledge specific to each data classification task from the training samples corresponding to each task. Training the mapping layer allows the model to learn the knowledge common to each data classification task. By alternating between training the encoding and mapping layers, the model can maintain its accuracy in the forward data classification task and also ensure its accuracy in the new data classification task, thus obtaining a general target data classification model. Attached Figure Description
[0054] Figure 1 This is a diagram illustrating the application environment of a data classification model training method in one embodiment.
[0055] Figure 2 This is a flowchart illustrating a data classification model training method in one embodiment;
[0056] Figure 3 This is a flowchart illustrating the data classification model training method in another embodiment;
[0057] Figure 4 This is a schematic diagram of the process for obtaining a training sample set in one embodiment;
[0058] Figure 5 This is a schematic diagram illustrating the process of encoding input data by the encoding layer in one embodiment;
[0059] Figure 6 This is a schematic diagram of text entity extraction in one embodiment;
[0060] Figure 7This is a schematic diagram of the process of assigning attention to entity features in one embodiment;
[0061] Figure 8 This is a schematic diagram of the process of training the mapping layer of the data classification model based on the first feature and the second feature corresponding to the same training sample in one embodiment.
[0062] Figure 9 This is a flowchart illustrating a data classification method in one embodiment;
[0063] Figure 10A This is a flowchart illustrating the data classification model training method in yet another embodiment;
[0064] Figure 10B This is a comparison chart of experimental results between the data classification model training method of this application and the traditional method in one embodiment;
[0065] Figure 10C This is a comparison chart of experimental results for the data classification model training method of this application in one embodiment;
[0066] Figure 11 This is a structural block diagram of a data classification model training device in one embodiment;
[0067] Figure 12 This is a structural block diagram of a data classification model training device in one embodiment;
[0068] Figure 13 This is a structural block diagram of a data classification device in one embodiment;
[0069] Figure 14 This is an internal structural diagram of a computer device in one embodiment;
[0070] Figure 15 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0071] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0072] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0073] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0074] Computer vision (CV) is the science that studies how to enable machines to "see." More specifically, it refers to machine vision, which uses cameras and computers to replace human eyes in tasks such as target recognition, tracking, and measurement, and further performs image processing to create images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, 3D object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), and common biometric recognition technologies such as facial recognition and fingerprint recognition.
[0075] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0076] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0077] The solutions provided in this application involve technologies such as computer vision, natural language processing, and machine learning in artificial intelligence, and are specifically illustrated through the following embodiments:
[0078] The data classification model training method and data classification method provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices, and server 104 can be implemented as a standalone server or a server cluster consisting of multiple servers.
[0079] Both terminal 102 and server 104 can be used independently to execute the data classification model training method provided in this embodiment. For example, server 104 obtains a training sample set, which includes training samples corresponding to at least two data classification tasks. Server 104 obtains the current training sample corresponding to the current data classification task, and trains the encoding layer of the initial data classification model based on the current training sample to obtain an intermediate data classification model. Server 104 obtains the updated training sample corresponding to the next data classification task, and trains the encoding layer of the intermediate data classification model based on the updated training sample to obtain an updated data classification model. Server 104 inputs the forward-trained samples of the updated training sample into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first feature and second feature. Based on the first feature and second feature corresponding to the same training sample, server 104 trains the mapping layer of the updated data classification model to obtain an updated intermediate data classification model. If further training is needed, server 104 can continue to obtain the updated training sample corresponding to the next data classification task and continue training, that is, return to the step of obtaining the updated training sample corresponding to the next data classification task until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completed training.
[0080] Terminal 102 and server 104 can also work together to execute the data classification model training method provided in this embodiment. For example, terminal 102 sends a training sample set to server 104, the training sample set including training samples corresponding to at least two data classification tasks. After receiving the training sample set, server 104 can obtain the current training sample corresponding to the current data classification task, train the encoding layer of the initial data classification model based on the current training sample to obtain an intermediate data classification model, obtain the updated training sample corresponding to the next data classification task, train the encoding layer of the intermediate data classification model based on the updated training sample to obtain an updated data classification model, input the preceding trained samples of the updated training sample into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first feature and second feature, train the mapping layer of the updated data classification model based on the first feature and second feature corresponding to the same training sample to obtain the updated intermediate data classification model, return to the step of obtaining the updated training sample corresponding to the next data classification task, until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completed training.
[0081] Of course, both terminal 102 and server 104 can be used independently to execute the data classification method provided in the embodiments of this application. Terminal 102 and server 104 can also be used collaboratively to execute the data classification method provided in the embodiments of this application.
[0082] In one embodiment, such as Figure 2 As shown, a data classification model training method is provided, which can be applied to... Figure 1 Taking the computer equipment mentioned above as an example, the computer equipment can be... Figure 1 Terminal 102 or server 104 in the reference. Figure 2 The data classification model training method includes the following steps:
[0083] Step S202: Obtain the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks.
[0084] The training sample set includes training samples corresponding to at least two data classification tasks. A single data classification task may have multiple training samples. A data classification task is used to classify data, determining the target data category from at least one data category. The data to be classified may specifically be an image, text, etc. A data classification task includes at least one sub-task, with each sub-task corresponding to a data category, and different sub-tasks corresponding to different data categories.
[0085] For example, the training sample set includes training texts corresponding to text classification tasks one, two, and three, respectively. Text classification task one includes text category 1 and text category 2, and is used to determine the target text category of the text to be classified from text category 1 and text category 2. Text classification task two includes text category 3 and text category 4, and is used to determine the target text category of the text to be classified from text category 3 and text category 4. Text classification task three includes text category 5 and text category 6, and is used to determine the target text category of the text to be classified from text category 5 and text category 6.
[0086] The training sample set includes training images corresponding to Image Classification Task 1, Image Classification Task 2, and Image Classification Task 3, respectively. Image Classification Task 1 includes multiple sporting dog breeds, such as English Springer Spaniels, Irish Setters, and Labrador Retrievers. Image Classification Task 1 is used to identify the target breed of the dog in the image to be classified from among these sporting dog breeds. Image Classification Task 2 includes multiple working dog breeds, such as Akitas and Siberian Huskies. Image Classification Task 3 includes toy dog breeds, such as Chihuahuas, Pomeranians, and Poodles. Image Classification Task 3 is used to identify the target breed of the dog in the image to be classified from among these toy dog breeds.
[0087] It is understood that different data classification tasks include at least one different data classification sub-task. For example, data classification task one includes data classification sub-tasks a and b, and data classification task two includes data classification sub-tasks a and c. Data classification task one includes data classification sub-tasks a and b, and data classification task two includes data classification sub-tasks c and d. The division of data classification tasks can be set according to actual needs; for example, different division methods can be set according to different application scenarios.
[0088] Specifically, a computer device can train a machine learning model applicable only to a specific data classification task based on training samples corresponding to that task. For example, machine learning model one can be trained based on training text corresponding to text classification task one, and model one can determine the target category of the text to be classified from the various text categories corresponding to text classification task one. Similarly, machine learning model two can be trained based on training text corresponding to text classification task two, and model two can determine the target category of the text to be classified from the various text categories corresponding to text classification task two. However, to reduce the number of models and improve training efficiency, the computer device can acquire a training sample set and train a general data classification model based on this set. The training sample set includes training samples corresponding to at least two data classification tasks. The computer device can first train the machine learning model based on training samples corresponding to a subset of data classification tasks, and then continue training the model based on training samples corresponding to new data classification tasks. This allows the machine learning model to continuously learn new data category recognition capabilities from training samples corresponding to new data classification tasks while maintaining its learned data category recognition capabilities, thus expanding the model's data category recognition capabilities. For example, a machine learning model is first trained based on the training text corresponding to text classification task one, and then the machine learning model is trained again based on the training text corresponding to text classification task two, so that the machine learning model can determine the target category of the text to be classified from the various text categories corresponding to text classification tasks one and two.
[0089] Step S204: Obtain the current training sample corresponding to the current data classification task, and train the encoding layer of the initial data classification model based on the current training sample to obtain the intermediate data classification model.
[0090] Here, the current data classification task can be any data classification task in the training sample set. The current training sample refers to the training sample corresponding to the current data classification task. The initial data classification model refers to a data classification model with initialized model parameters. There are various methods for initializing model parameters, such as random assignment, zeroing, or Gaussian distribution initialization. A data classification model is a machine learning model used to classify input data and determine the corresponding data category. An intermediate data classification model refers to a machine learning model obtained by training the initial data classification model based on the current training samples and adjusting the encoding layer parameters.
[0091] A data classification model consists of an encoding layer and a mapping layer. The encoding layer encodes the input data, while the mapping layer maps the output of the encoding layer. Finally, based on the output of the mapping layer, a classification result corresponding to the input data is generated. Training the encoding layer of the data classification model using training samples corresponding to the data classification task allows the model to learn the relevant knowledge of that task. The trained model can then be used to process the data classification task, determining the target data category from the various data categories corresponding to that task.
[0092] Specifically, the computer device can determine the current data classification task from the training sample set, obtain the current training sample corresponding to the current data classification task, train the encoding layer of the initial data classification model based on the current training sample, adjust the parameters of the encoding layer of the initial data classification model, and thus obtain the intermediate data classification model.
[0093] For example, the training sample set includes training samples corresponding to at least two data classification tasks. These tasks can be randomly sorted to obtain a data classification task sequence. The computer can then use the first-ranked data classification task as the current data classification task and train the encoding layer of the initial data classification model based on the training samples corresponding to the current task, thus obtaining an intermediate data classification model. In this way, the intermediate data classification model can learn the relevant knowledge of the first-ranked data classification task.
[0094] Step S206: Obtain the updated training samples corresponding to the next data classification task, and train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model.
[0095] The next data classification task can be any data classification task other than the current data classification task; that is, a data classification task in the training sample set that was not used in model training. Updating the training samples refers to the training samples corresponding to the next data classification task. Updating the data classification model is the machine learning model obtained by training the intermediate data classification model based on the updated training samples and adjusting the parameters of the encoding layer. It can be understood that when training the encoding layer of the model, only the parameters of the encoding layer are adjusted; similarly, when training the mapping layer of the model, only the parameters of the mapping layer are adjusted.
[0096] Specifically, the computer device can determine the next data classification task from the training sample set, obtain the updated training samples corresponding to the next data classification task, and train the encoding layer of the intermediate data classification model based on the updated training samples to obtain the updated data classification model. That is, after training the encoding layer of the initial data classification model based on the current training samples and completing the training, the encoding layer of the initial data classification model is trained again based on the updated training samples corresponding to the next data classification task.
[0097] For example, from a sequence of data classification tasks, a computer device can use the second-ranked data classification task as the next task. Based on the training samples corresponding to the next task, it can train the encoding layer of the intermediate data classification model, adjusting its parameters to obtain an updated model. In this way, the updated model can learn the relevant knowledge of the second-ranked task.
[0098] In one embodiment, training the encoding layer of a data classification model based on training samples can specifically involve inputting training samples into the data classification model, the data classification model outputting predicted labels corresponding to the training samples, calculating a training loss value based on the training labels and predicted labels carried by the training samples, and adjusting the encoding layer parameters of the data classification model based on the training loss value until the updated training loss value satisfies the convergence condition, thus obtaining a data classification model with a trained encoding layer. Here, the label is used to identify the data category of the training sample; the training label refers to the true data category corresponding to the training sample, and the predicted label refers to the predicted data category corresponding to the training sample.
[0099] Step S208: Input the forward-fed trained samples of the updated training samples into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first feature and second feature.
[0100] In this context, the preceding trained samples for updating the training samples refer to all the training samples that have already been used for model training before the training samples are updated. For example, in a sequence of data classification tasks, a computer trains the encoding layer of an initial data classification model based on the training samples corresponding to the first-ranked data classification task to obtain an intermediate data classification model. Then, it trains the encoding layer of the intermediate data classification model based on the training samples corresponding to the second-ranked data classification task. In this case, the preceding trained samples for the second-ranked data classification task are the same as the training samples for the first-ranked data classification task. Therefore, the preceding trained samples for updating the training samples include training samples corresponding to at least one data classification task.
[0101] The first feature refers to the data output by the encoding layer of the intermediate data classification model after the preceding trained samples of the updated training samples are input into the intermediate data classification model. The second feature refers to the data output by the encoding layer of the updated data classification model after the preceding trained samples of the updated training samples are input into the updated data classification model.
[0102] Specifically, the computer device can obtain the preceding trained samples of the updated training sample from the training sample set. These preceding trained samples are then input into the encoding layers of both the intermediate data classification model and the updated data classification model. The output of the encoding layer of the intermediate data classification model is used as the first feature, and the output of the encoding layer of the updated data classification model is used as the second feature. In other words, when there are multiple preceding trained samples of the updated training sample, each preceding trained sample is input into the encoding layers of both the intermediate data classification model and the updated data classification model to obtain the first and second features corresponding to each preceding trained sample.
[0103] Step S210: Train the mapping layer of the updated data classification model based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model.
[0104] Specifically, the computer device can train the mapping layer of the updated data classification model based on the first and second features corresponding to the same training sample, adjusting the parameters of the mapping layer to obtain a new data classification model. It can be understood that the output of the intermediate data classification model through the preceding trained samples of the updated training sample is relatively accurate because the intermediate data classification model is trained based on the preceding trained samples of the updated training sample. The output of the updated data classification model through the preceding trained samples of the updated training sample is less accurate because the updated data classification model is obtained by further adjusting the model parameters based on the updated training samples and the intermediate data classification model. At this point, after the updated data classification model has learned the knowledge of the updated training samples through training at the encoding layer and thus performs well on the data classification task corresponding to the updated training samples, the mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample. The aim is to ensure that the updated data classification model can maintain its performance on the data classification task corresponding to the preceding trained samples, so that the new data classification model obtained through training at the mapping layer can be applied to the data classification task corresponding to all currently trained samples. Furthermore, the new data classification model replaces the previous intermediate data classification model; that is, the new data classification model is used as the updated intermediate data classification model.
[0105] In one embodiment, training the mapping layer of the updated data classification model based on the first and second features corresponding to the training samples can specifically involve using the second feature corresponding to the training samples as input to the encoding layer of the updated data classification model, and using the first feature corresponding to the training samples as the expected output of the encoding layer of the updated data classification model. Supervised training is then performed on the encoding layer of the updated data classification model to obtain the data classification model trained on the mapping layer. The first feature corresponding to the training samples is the output of the encoding layer of the intermediate data classification model, and the second feature corresponding to the training samples is the output of the encoding layer of the updated data classification model. Thus, by using the second feature as input to the mapping layer of the updated data classification model and the first feature as the target output of the mapping layer, the results of the previously trained samples output by the intermediate data classification model and the results output by the updated data classification model can converge into a common space. This allows the data classification model trained on the mapping layer to learn the common knowledge of the currently trained data classification task, resulting in a data classification model applicable to the currently trained data classification task.
[0106] In one embodiment, since the data classification model already has good model parameters after training through the encoding layer, when training the mapping layer of the data classification model, a portion of the forward-trained samples can be obtained from all the forward-trained samples of the updated training samples. Based on a small number of forward-trained samples, the mapping layer of the updated data classification model can be trained, the mapping layer parameters can be fine-tuned, and a new data classification model can be obtained.
[0107] Step S212: Return to the step of obtaining the updated training samples corresponding to the next data classification task, until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0108] The target data classification model refers to the data classification model that has been finally trained.
[0109] Specifically, after training the mapping layer of the updated data classification model based on the first and second features corresponding to the same training sample to obtain a new data classification model, the previous intermediate data classification model can be replaced with the new data classification model. The new data classification model is then used as the updated intermediate data classification model. The process returns to the step of obtaining the updated training samples corresponding to the next data classification task, and a new round of encoding layer training and mapping layer training is performed. Based on the training samples corresponding to the next data classification task, the encoding layer of the current latest intermediate data classification model is trained to obtain a new updated data classification model. The training samples corresponding to the previous data classification task of the latest trained data classification task are input into the encoding layers of both the current latest intermediate data classification model and the updated data classification model to obtain the corresponding first and second features. Based on the first and second features corresponding to the same training sample, the mapping layer of the current latest updated data classification model is trained to obtain a new data classification model. The new data classification model replaces the previous intermediate data classification model, and the new data classification model is used as the updated intermediate data classification model. The process returns to the step of obtaining the updated training samples corresponding to the next data classification task, and a new round of encoding layer training and mapping layer training is performed. Similarly, training is complete when all training samples corresponding to the data classification tasks in the training sample set have participated in model training. The target data classification model is then obtained based on the final data classification model obtained after training. Alternatively, training is complete when the mapping layer has been trained a preset number of times. The target data classification model is then obtained based on the final data classification model obtained after training. Specifically, obtaining the target data classification model based on the intermediate data classification model corresponding to the training completion can involve using the final data classification model as the target data classification model.
[0110] For example, see reference. Figure 3 The training sample set includes training sample one for data classification task one, training sample two for data classification task two, training sample three for data classification task three, and training sample four for data classification task four. The encoding layer of the initial data classification model is trained based on training sample one to obtain the first data classification model. The encoding layer of the first data classification model is trained based on training sample two to obtain the second data classification model. Training sample one is input into the encoding layer of the first data classification model to obtain the first feature of training sample one output by the encoding layer. Training sample two is input into the encoding layer of the second data classification model to obtain the second feature of training sample one output by the encoding layer. The mapping layer of the second data classification model is trained based on the first and second features of training sample one to obtain the updated second data classification model.
[0111] The updated encoding layer of the second data classification model is trained using training sample three to obtain the third data classification model. Training sample one is then input into the encoding layers of both the updated second and third data classification models to obtain the first and second features of training sample one. Similarly, training sample two is input into the encoding layers of both models to obtain the first and second features of training sample two. The mapping layer of the third data classification model is then trained using the first and second features of training sample one and training sample two to obtain the updated third data classification model.
[0112] The updated encoding layer of the third data classification model is trained based on training sample four to obtain the fourth data classification model. Training sample one is then input into the encoding layers of both the updated third and fourth data classification models to obtain the first and second features of training sample one. Training sample two is also input into the encoding layers of both models to obtain the first and second features of training sample two. Similarly, training sample three is input into the encoding layers of both models to obtain the first and second features of training sample three. The mapping layer of the fourth data classification model is then trained based on the first and second features of training sample one, training sample two, and training sample three to obtain the updated fourth data classification model. This updated fourth data classification model is then used as the target data classification model.
[0113] In this way, by alternating between the encoding and mapping layers during training, the data classification model can maintain its performance on the previous data classification tasks as it learns new data classification tasks. Then, when the data to be classified is input into the target data classification model, the model can determine the target data category from all the data categories corresponding to the trained data classification tasks.
[0114] In the above data classification model training method, the following steps are taken: First, a training sample set is obtained, which includes training samples corresponding to at least two data classification tasks. Then, the current training sample corresponding to the current data classification task is obtained. Based on the current training sample, the encoding layer of the initial data classification model is trained to obtain an intermediate data classification model. Next, updated training samples corresponding to the next data classification task are obtained. Based on the updated training samples, the encoding layer of the intermediate data classification model is trained to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of both the intermediate and updated data classification models to obtain corresponding first and second features. Based on the first and second features corresponding to the same training sample, the mapping layer of the updated data classification model is trained to obtain an updated intermediate data classification model. The process then returns to the step of obtaining updated training samples corresponding to the next data classification task, continuing until training is complete. Finally, the target data classification model is obtained based on the intermediate data classification model corresponding to the completed training. In this way, training the encoding layer of the data classification model allows the model to learn the knowledge specific to each data classification task from the training samples corresponding to each task. Training the mapping layer allows the model to learn the knowledge common to each data classification task. By alternating between training the encoding and mapping layers, the model can maintain its accuracy in the forward data classification task and also ensure its accuracy in the new data classification task, thus obtaining a general target data classification model.
[0115] In one embodiment, such as Figure 4 As shown, the training sample set is obtained, including:
[0116] Step S402: Obtain multiple candidate samples; each candidate sample carries a candidate label.
[0117] Step S404: Cluster the candidate samples corresponding to the same candidate label to obtain the initial clusters corresponding to each candidate label.
[0118] Candidate samples can be either images or text. Candidate labels are data categories used to identify candidate samples.
[0119] Specifically, the computer device can acquire multiple candidate samples carrying candidate labels, and cluster the candidate samples corresponding to the same candidate label to obtain initial clusters corresponding to each candidate label. In other words, the computer device can first classify the candidate samples according to their data categories, and form an initial cluster for each candidate sample of the same data category, thus obtaining the initial clusters corresponding to each data category.
[0120] Step S406: Determine the processing priority of each candidate sample based on the candidate label.
[0121] Step S408: The initial cluster is used as a data classification subtask. Each data classification subtask corresponding to the same processing priority is clustered to obtain the target data classification task set corresponding to each processing priority. The target data classification task set includes each training sample corresponding to the same data classification task.
[0122] The processing priority is determined based on the parent category corresponding to the specific data category of the candidate sample. The candidate label of a candidate sample can be considered a subcategory; one subcategory corresponds to one parent category, and one parent category can correspond to at least one subcategory. The correspondence between parent and subcategories can be pre-stored in a category lookup table, allowing the parent category corresponding to a subcategory to be determined based on the category lookup table.
[0123] For example, candidate samples might be electronic medical records (EMRs). The parent category of an EMR can be categorized based on the severity of the disease; for instance, it could include mild, moderate, and severe illnesses. Subcategories can be categorized based on specific diseases, such as colds, coughs, fevers, and cancer. Diseases of lower severity are grouped into mild illnesses, those of moderate severity into moderate illnesses, and those of higher severity into severe illnesses. An EMR is a digital medical record stored, managed, transmitted, and reproduced using electronic devices (computers, health cards, etc.) to replace handwritten paper medical records. Its content includes all the information found in paper medical records.
[0124] The candidate samples are dog images. The parent category of dog images can be categorized based on the dog's purpose; for example, the parent categories include sporting dogs, working dogs, herding dogs, hunting dogs, terriers, family dogs, and companion dogs. Subcategories of dog images can be categorized based on specific dog breeds, such as Chihuahuas, Pomeranians, and Akitas. Dogs used for hunting birds are classified as sporting dogs; dogs used for chasing prey are classified as hunting dogs; dogs used for companionship and display are classified as companion dogs; dogs used for performing tasks and labor are classified as working dogs; dogs used for herding sheep and cattle are classified as herding dogs; dogs used for eliminating venomous snakes and pests are classified as terriers; and dogs used as companions, guard dogs, and watchdogs are classified as family dogs.
[0125] Specifically, the computer device can determine the processing priority of each candidate sample based on its candidate labels, with a parent category serving as a processing priority. Further, the computer device can treat an initial cluster as a data classification sub-task, and cluster the data classification sub-tasks belonging to the same parent category to obtain target data classification task sets corresponding to each processing priority. A target data classification task set includes candidate samples corresponding to each sub-category under the same parent category; that is, a target data classification task set includes all training samples corresponding to the same data classification task. A parent category can serve as a data classification task.
[0126] Step S410: Obtain a training sample set based on each target data classification task set.
[0127] Specifically, after obtaining each target data classification task set through clustering, the computer device can obtain a training sample set based on each target data classification task set, which can be composed of each target data classification task set.
[0128] For example, first, electronic medical records belonging to the same disease are grouped into an initial cluster, resulting in initial clusters corresponding to each disease. Each initial cluster serves as a sub-task of data classification. Sub-tasks for mild diseases, moderate diseases, and severe diseases are grouped into a target data classification task set, and these three sets form the training sample set. Specifically, the training sample set includes training samples corresponding to data classification task one, data classification task two, and data classification task three, respectively. The training samples for data classification task one include electronic medical records corresponding to at least one specific mild disease; the training samples for data classification task two include electronic medical records corresponding to at least one specific moderate disease; and the training samples for data classification task three include electronic medical records corresponding to at least one specific severe disease.
[0129] In one embodiment, the target data classification model is used to determine the target label corresponding to the data to be classified from the candidate labels corresponding to the trained samples.
[0130] Specifically, after the target data classification model is trained, the computer device can acquire the data to be classified, input the data to be classified into the target data classification model, and the target data classification model can output the target label corresponding to the data to be classified. This target label is a candidate label determined from all candidate labels corresponding to all trained samples, and the data to be classified has the highest probability of belonging to this candidate label. It can be understood that existing machine learning models are usually trained based on training samples corresponding to a single data classification task. Therefore, this machine learning model can only determine the target data category corresponding to the data to be classified from the various data categories corresponding to that data classification task. For example, an image recognition model trained based on training samples corresponding to sporting dogs can only identify the dog in the image to be classified with the highest probability of belonging to a particular sporting dog. However, the target data classification model of this application is trained based on training samples corresponding to multiple data classification tasks respectively. The target data classification model can determine the target data category corresponding to the data to be classified from the various data categories corresponding to each trained data classification task. For example, an image recognition model can be trained based on training samples corresponding to sporting dogs, working dogs, herding dogs, hunting dogs, terriers, family dogs, and companion dogs. This image recognition model can identify the breed of dog in the image to be classified with the highest probability.
[0131] In this embodiment, the candidate samples are clustered for the first time based on the candidate labels to obtain the data classification sub-task. The data classification sub-task is then clustered for the second time based on the processing priority to obtain the data classification task. Thus, a training sample set for training a general data classification model can be obtained based on the training samples corresponding to each data classification task.
[0132] In one embodiment, the training samples in the training sample set carry training labels, and the data classification model to be trained is an initial data classification model or an intermediate data classification model. Training the encoding layer of the data classification model to be trained includes the following steps: processing the input training samples through the data classification model to be trained to obtain the predicted labels corresponding to the input training samples; adjusting the encoding layer parameters of the data classification model to be trained based on the label difference between the training labels and the predicted labels corresponding to the input training samples until the convergence condition is met.
[0133] In this system, training labels are used to identify the true data categories of training samples. Predicted labels are used to identify the predicted categories of training samples; these are the classification results output by the data classification model after the training samples are input. Encoding layer parameters refer to the model parameters of the encoding layer of the data classification model.
[0134] Specifically, the classification model to be trained is either an initial data classification model or an intermediate data classification model. Training the encoding layer of the classification model to be trained can be achieved by processing the input training samples using the classification model to obtain the predicted labels corresponding to the input training samples. The label difference is then calculated based on the training labels and predicted labels of the input training samples. Backpropagation is then performed based on the label difference to update the encoding layer parameters of the classification model to be trained. In other words, the training loss value is calculated based on the training labels and predicted labels of the input training samples, and the encoding layer parameters of the classification model to be trained are updated based on the training loss value, until the convergence condition is met, resulting in a data classification model with a trained encoding layer. The convergence condition can specifically include the training loss value being minimized, the rate of change of the training loss value being less than a preset threshold, and the number of iterations reaching a preset number. The label difference or training loss value can be calculated using loss functions such as cross-entropy loss, exponential loss, and hinge loss.
[0135] When the data classification model to be trained is the initial data classification model, the current training sample is input into the initial data classification model to obtain the predicted label corresponding to the current training sample. The coding layer parameters of the initial data classification model are adjusted based on the label difference between the training label and the predicted label corresponding to the current training sample until the convergence condition is met, and the intermediate data classification model is obtained.
[0136] When the classification model for the data to be trained is an intermediate data classification model, the updated training samples are input into the intermediate data classification model to obtain the predicted labels corresponding to the updated training samples. The coding layer parameters of the intermediate data classification model are adjusted based on the label difference between the training labels and the predicted labels corresponding to the updated training samples until the convergence condition is met, and the updated data classification model is obtained.
[0137] In this embodiment, the input training samples are processed by the data classification model to be trained to obtain the predicted labels corresponding to the input training samples. The encoding layer parameters of the data classification model to be trained are adjusted based on the label differences between the training labels and the predicted labels of the input training samples until the updated label differences satisfy the convergence condition, resulting in a data classification model with a trained encoding layer. Supervised training allows for rapid adjustment of the encoding layer model parameters, enabling rapid training of the encoding layer of the data classification model.
[0138] In one embodiment, the current data classification model is any one of the initial data classification model, intermediate data classification model, updated data classification model, and target data classification model. The encoding layer of the current data classification model is used to encode the input training samples to obtain initial features, and the mapping layer of the current data classification model is used to map the initial features to obtain intermediate features.
[0139] Specifically, the current data classification model's encoding layer encodes the input training samples to obtain initial features, the mapping layer maps these initial features to obtain intermediate features, and finally, the predicted label corresponding to the input training sample is obtained based on the intermediate features output by the mapping layer. The current data classification model can be any one of the following: an initial data classification model, an intermediate data classification model, an updated data classification model, and a target data classification model. It can be understood that the current data classification model refers to the data classification model currently in use. That is, all data classification models in this application encode the input training samples through an encoding layer to obtain initial features, and then map these initial features through a mapping layer to obtain intermediate features.
[0140] In one embodiment, the data classification model includes an encoding layer, a mapping layer, and a classification layer. After training samples are input into the data classification model, the encoding layer encodes the input training samples, extracts their feature information, and obtains the initial features corresponding to the input training samples. Further, the mapping layer receives the initial features from the encoding layer, maps them to a feature space, and obtains the intermediate features corresponding to the input training samples. Finally, the classification layer receives the intermediate features from the mapping layer, classifies them, and converts them into a preset data format for output, thereby obtaining the predicted labels corresponding to the training samples.
[0141] In one embodiment, the encoding layer of the data classification model includes at least one encoding subnetwork, and the mapping layer includes at least one mapping subnetwork, with one encoding subnetwork corresponding to one mapping subnetwork. When the encoding layer of the data classification model includes at least two encoding subnetworks, each encoding subnetwork is used to extract different feature information from the input training samples. For example, an image classification model includes three encoding subnetworks: one for extracting the overall features of the input image, one for extracting the background features, and one for extracting the foreground features. An image classification model may also include four encoding subnetworks: one for extracting the color features, one for extracting the texture features, one for extracting the shape features, and one for extracting the spatial relationship features. The specific purpose of each encoding subnetwork in the data classification model can be set according to the specific data classification task.
[0142] When the encoding layer of a data classification model includes at least two encoding subnetworks, each encoding subnetwork can receive different data as input data. For example, training samples include at least two types of training data, with each type of training data corresponding to one encoding subnetwork. After the training samples are input into the data classification model, each type of training data is input into its corresponding encoding subnetwork. Each encoding subnetwork encodes its own input data and outputs its corresponding initial sub-features. Initial features are obtained based on these initial sub-features. Furthermore, the data classification model can also include a data extraction layer. After the training samples are input into the data classification model, they are first input into the data extraction layer to extract the corresponding target data. The target data is then input into its corresponding encoding subnetwork to obtain the initial sub-features corresponding to the target data. The training samples are then input into their corresponding encoding subnetworks to obtain the initial sub-features corresponding to the training samples. For example, when the training samples are training images, after the training images are input into the data classification model, entity extraction layers can first extract entities from the text in the training images to obtain the entity data corresponding to the training images. Then, the entity data and training images are input into the corresponding encoding sub-networks. The entity data is encoded by the encoding sub-network corresponding to the entity extraction layer to obtain entity features. The training images are encoded by the encoding sub-network corresponding to the training images to obtain image features. Finally, the entity features and image features are combined to form the initial features.
[0143] The encoding sub-networks and mapping sub-networks are in a one-to-one correspondence. The initial sub-features output by each encoding sub-network are input into their respective mapping sub-networks. Each mapping sub-network performs mapping processing on its own initial sub-features, outputting intermediate sub-features corresponding to each initial sub-feature. Intermediate features are then obtained based on these intermediate sub-features. Further, after receiving these intermediate sub-features, the classification layer performs unified classification processing on them, fuses them, and converts them into a preset data format for output, thereby obtaining the predicted labels corresponding to the training samples.
[0144] In one embodiment, the encoding layer's encoding process for the input training samples specifically includes forward encoding and backward encoding. Forward encoding of the input training samples yields the corresponding forward features, while backward encoding yields the corresponding backward features. Based on these forward and backward features, the initial features corresponding to the input training samples are obtained. It can be understood that each encoding sub-network can perform both forward and backward encoding processes on its respective input data, obtaining the corresponding initial sub-features based on the processing results of these two processes.
[0145] In one embodiment, when the encoding layer of the data classification model includes at least two encoding sub-networks, these different encoding sub-networks can influence each other. For example, the initial sub-feature 'a' output by the first encoding sub-network can influence the initial sub-feature 'b' output by the second encoding sub-network. The initial sub-feature 'b' output by the second encoding sub-network is then updated based on the initial sub-feature 'a' output by the first encoding sub-network. This update can specifically involve attention allocation, fusion, or other processing.
[0146] In one embodiment, when the data classification model is a text classification model, the encoding layer structure of the text classification model can specifically be an LSTM network. An LSTM network is a special type of RNN that can learn long-term dependencies and effectively extract contextual features. When the data classification model is an image classification model, the encoding layer structure of the image classification model can specifically be a CNN network.
[0147] In this embodiment, the encoding layer of the data classification model encodes the input training samples to obtain initial features, and the mapping layer maps the initial features transmitted from the encoding layer to obtain intermediate features. Through the collaboration of the encoding and mapping layers, the data classification model can ultimately output the classification result corresponding to the input data.
[0148] In one embodiment, such as Figure 5 As shown, the input training samples include text data and entity data. The encoding layer includes encoding sub-networks corresponding to the text data and encoding sub-networks corresponding to the entity data. The determination of the initial features includes the following steps:
[0149] Step S502: Encode the text data using the encoding sub-network corresponding to the text data to obtain text features.
[0150] Step S504: Encode the entity data through the coding sub-network corresponding to the entity data to obtain entity features.
[0151] Step S506: Obtain initial features based on entity features and text features.
[0152] Among them, training samples can be training text, text data refers to the entire training text, and entity data refers to each entity in the training text.
[0153] Specifically, the input training samples include text data and entity data, and the encoding layer includes an encoding sub-network corresponding to the text data and an encoding sub-network corresponding to the entity data. After the computer device inputs the input training samples into the data classification model, it can encode the text data in the input training samples through the encoding sub-network corresponding to the text data to obtain the text features corresponding to the text data, and encode the entity data in the input training samples through the encoding sub-network corresponding to the entity data to obtain the entity features corresponding to the entity data. Finally, the initial features are composed of the entity features and the text features.
[0154] In one embodiment, the training text can be input into the entity extraction model, that is, the text data is input into the entity extraction model to obtain the entity data. The entity extraction model can specifically be an entity recognition model based on BERT-LSTM-CRF. Further, an entity extraction model for fine-grained entity extraction can be trained based on the entity training samples with fine-grained annotations. Fine-grained annotation means refining entities, dividing ordinary entities into more refined entity categories, and maximizing the use of the detailed knowledge of entity words. For example, traditional medical entity extraction models can only recognize coarse entities such as diseases, symptoms, and drugs in medical texts, while a medical entity extraction model trained based on entity training samples with fine-grained annotations can not only recognize coarse-grained entities such as diseases, symptoms, and drugs in medical texts, but also recognize fine-grained entities such as degree words, time words, location words, negation words, and conjunction words in medical texts. Refer to Figure 6 , after inputting the medical text into the medical entity extraction model for fine-grained entity extraction, it can output each fine-grained entity and coarse-grained entity in the medical text. As Figure 6 shown, the original medical text (Raw Note) input into the medical entity extraction model is the Chinese text "Red rash on the left scalp, accompanied by pain, which is pulsatile pain, persistent, complaining of mild fever, without dizziness" and the corresponding English text "Get tickles on the left scalp with feeling of continually pulsatile ache. Mild fever and no dizziness". The output of the medical entity extraction model can be to mark each fine-grained entity, coarse-grained entity and their corresponding entity categories in the medical text. As Figure 6As shown, the entity extraction results specifically include location words (left), body part words (scalp), symptoms (tickles, ache), modifiers (pulsatile, continuous, mild), symptoms (fever), and negative words (no dizziness). The sub-entities are arranged in the order of their appearance in the Chinese text. When training the medical entity extraction model, a large amount of medical corpus can be collected. For example, collecting 50,000 medical texts and labeling them with 14 entity categories including diseases, symptoms, drugs, and treatment methods, among which 11 categories are fine-grained entity categories, including but not limited to conjunctions, negative words, location words, and degree words. Of course, it is understandable that entity extraction models for fine-grained entity extraction can also be trained in other fields besides medicine.
[0155] In one embodiment, encoding text data using the encoding subnetwork corresponding to the text data to obtain text features can specifically involve forward encoding the text data using the encoding subnetwork corresponding to the text data to obtain positive features, reverse encoding the text data using the encoding subnetwork corresponding to the text data to obtain reverse features, and concatenating the positive and reverse features to obtain the text features. Similarly, encoding entity data using the encoding subnetwork corresponding to entity data to obtain entity features can specifically involve forward encoding the entity data using the encoding subnetwork corresponding to the entity data to obtain positive features, reverse encoding the entity data using the encoding subnetwork corresponding to the entity data to obtain reverse features, and concatenating the positive and reverse features to obtain the entity features.
[0156] In this embodiment, when the data classification model is a text classification model, the input training samples can include not only text data but also entity data. Thus, the encoding layer of the data classification model can encode the text data using the encoding sub-network corresponding to the text data to obtain text features, and encode the entity data using the encoding sub-network corresponding to the entity data to obtain entity features. These text features and entity features are then transmitted to the mapping layer. By comprehensively considering the influence of both text and entities on text classification, the accuracy of text classification in the text classification model can be improved.
[0157] In one embodiment, the current data classification model includes an entity extraction layer, and the encoding layer includes an encoding sub-network corresponding to the entity extraction layer and an encoding sub-network corresponding to the input training samples. The determination of initial features includes the following steps: extracting entities from the input training samples through the entity extraction layer to obtain entity data corresponding to the input training samples; encoding the entity data through the encoding sub-network corresponding to the entity extraction layer to obtain entity features; encoding the input training samples through the encoding sub-network corresponding to the input training samples to obtain text features; and obtaining initial features based on entity features and text features.
[0158] Specifically, in addition to encoding and mapping layers, data classification models can also include entity extraction layers. After training samples are input into the data classification model, the entity extraction layer first extracts entities from the input training samples to obtain the entity data corresponding to the input training samples. Then, the entity data and the input training samples are respectively input into the corresponding encoding subnetworks. The entity data is encoded by the encoding subnetwork corresponding to the entity extraction layer to obtain entity features, and the input training samples are encoded by the encoding subnetwork corresponding to the input training samples to obtain text features. Finally, the entity features and text features constitute the initial features.
[0159] In one embodiment, when the training sample is training text, after the training text is input into the data classification model, the entity extraction layer can first extract entities from the training text to obtain the entity data corresponding to the training text. Then, the entity data and the training text are respectively input into the corresponding encoding subnetwork. The entity data is encoded by the encoding subnetwork corresponding to the entity extraction layer to obtain entity features, and the training text is encoded by the encoding subnetwork corresponding to the training text to obtain text features. Finally, the entity features and text features constitute the initial features.
[0160] In one embodiment, encoding entity data through the encoding subnetwork corresponding to the entity extraction layer to obtain entity features can specifically involve forward encoding the entity data using the encoding subnetwork corresponding to the entity extraction layer to obtain positive features, and reverse encoding the entity data using the encoding subnetwork corresponding to the entity extraction layer to obtain reverse features. The positive and reverse features are then concatenated to obtain the entity features. Similarly, encoding input training samples through the encoding subnetwork corresponding to the input training samples to obtain text features can specifically involve forward encoding the input training samples using the encoding subnetwork corresponding to the input training samples to obtain positive features, and reverse encoding the input training samples using the encoding subnetwork corresponding to the input training samples to obtain reverse features. The positive and reverse features are then concatenated to obtain the text features.
[0161] In this embodiment, to improve data processing efficiency, the data classification model may include an entity extraction layer in addition to the encoding and mapping layers. This eliminates the need for a separate entity extraction model to first extract entities from the training text, and then inputting the training text and the extracted entities into the data classification model. Entity extraction from the training text can be performed directly within the data classification model's internal entity extraction layer. Simply input the training text into the data classification model, and it can perform entity extraction, encoding, mapping, and other operations, thereby improving data processing efficiency.
[0162] In one embodiment, such as Figure 7 As shown, the entity data includes at least one entity, and the entity features include the entity sub-features corresponding to each entity. Initial features are obtained based on the entity features and text features, including:
[0163] Step S702: Based on the text features, attention is assigned to the entity sub-features corresponding to each entity to obtain the attention information corresponding to each entity.
[0164] Among them, attention allocation is used to assign different attention information to each entity, and the attention information of an entity can reflect the importance of the entity in the text.
[0165] Specifically, entity features and text features can influence each other. For example, in the medical field, knowledge of certain entity words (such as symptoms, examinations, and medications) plays a crucial role in the final classification of medical record texts. The same entity words should have different importance in different contexts. For instance, electronic medical record A records fever accompanied by a rash on the head, while electronic medical record B only records fever alone; electronic medical record A and electronic medical record B clearly correspond to different text categories. It is understandable that this applies to text classification in other fields besides medicine; entity data will influence the text classification results to some extent. Therefore, to give greater emphasis to important entities in the current context, an attention mechanism between entities and their context can be introduced. The attention mechanism enables neural networks to focus on a subset of their input (or features): selecting specific inputs. In situations with limited computing power, the attention mechanism is a resource allocation scheme that is a primary means of solving the problem of information overload, allocating computing resources to more important tasks. Computer devices can allocate attention to the entity sub-features corresponding to each entity based on text features, obtaining attention information for each entity.
[0166] In one embodiment, the computer device may allocate attention according to the following formula:
[0167]
[0168] Among them, u m This represents the attention information of the m-th entity in the training text. This represents the entity vector of the m-th entity in the training text, i.e., the entity sub-feature of the m-th entity. Indicates to Perform matrix transpose. c This represents the text vector of the training text, i.e., the text feature. Indicates calculation The modulus length, ||h c ||2 indicates the calculation of h c The magnitude of the vector. The importance relationship between two entities can be obtained through operations between the entity vector of an entity and the text vector containing that entity.
[0169] Step S704: Normalize the attention information corresponding to each entity to obtain the attention factor corresponding to each entity.
[0170] Specifically, the computer device can normalize the attention information corresponding to each entity to obtain the attention factor corresponding to each entity. That is, the computer device can normalize the attention information corresponding to each entity to obtain the weight corresponding to each entity.
[0171] In one embodiment, the computer device may be normalized according to the following formula:
[0172]
[0173] Among them, a m This represents the weight corresponding to the m-th entity in the training text, i.e., the attention factor corresponding to the m-th entity in the training text. exp represents the exponential operation of e. m This represents the attention information for the m-th entity in the training text. M represents the number of entities in the training text. j This represents the attention information for the j-th entity in the training text. The weight of an entity in the text can be obtained by comparing it with all other entities.
[0174] Step S706: Obtain updated entity features based on the entity sub-features and attention factors corresponding to each entity.
[0175] Specifically, the computer device can obtain the updated entity features by weighted summation of the entity sub-features and corresponding attention factors for each entity.
[0176] In one embodiment, the computer device may calculate the updated entity features according to the following formula:
[0177]
[0178] Among them, h s Represents the updated entity features, a m This represents the weight corresponding to the m-th entity in the training text, i.e., the attention factor corresponding to the m-th entity in the training text. Let represent the entity vector of the m-th entity in the training text, i.e., the entity sub-feature of the m-th entity. M represents the number of entities in the training text. The final entity vector is obtained by multiplying the original entity vector by the weights.
[0179] Step S708: Obtain initial features based on text features and updated entity features.
[0180] Specifically, once the updated entity features are calculated, the computer device can combine the text features and the updated entity features to form initial features. Further, the initial features are transmitted to a mapping layer, where the text features are mapped using a mapping sub-network corresponding to the text data to obtain intermediate sub-features. Similarly, the updated entity features are mapped using a mapping sub-network corresponding to the entity data to obtain intermediate sub-features. The intermediate features are then composed of these intermediate sub-features.
[0181] In one embodiment, the computer device can map text features according to the following formula:
[0182]
[0183] Among them, Z c This represents the mapping result of text features. This represents the model parameters of the mapping subnetwork corresponding to the text data. Indicates to Perform matrix transpose. c This represents the text features corresponding to the training text, that is, the output data of the encoding subnetwork corresponding to the text data. c This indicates that the input data for the encoding subnetwork is text data. Indicates x c Encoding processing involves encoding the text data using the corresponding encoding subnetwork.
[0184] In one embodiment, the computer device may map the updated entity features according to the following formula:
[0185]
[0186] Among them, Z s This represents the mapping result of the updated entity features. This represents the model parameters of the mapping subnetwork corresponding to the entity data. Indicates to Perform matrix transpose. s This represents the updated entity features. s This indicates that the input data for the encoded subnetwork is entity data. (x s ) represents x s Encoding and attention allocation are performed, namely, encoding entity data through the encoding sub-network corresponding to the entity data, and assigning attention to entity features based on text features.
[0187] In this embodiment, attention allocation processing is performed on entity features based on text features, which can distinguish between important and unimportant entities in the text. Important entities represent more key semantic information, and more attention is allocated to important entities, thereby accurately improving the accuracy of text classification.
[0188] In one embodiment, encoding the current input data through the current encoding subnetwork to obtain the features corresponding to the current input data includes: performing forward encoding on the current input data through the current encoding subnetwork to obtain forward features; performing reverse encoding on the current input data through the current encoding subnetwork to obtain reverse features; and obtaining the features corresponding to the current input data based on the forward and reverse features.
[0189] Specifically, the computer device encodes the current input data through the current encoding sub-network. This can be done by forward encoding the current input data using the current encoding sub-network to obtain positive features, and then backward encoding the current input data using the current encoding sub-network to obtain backward features. The features corresponding to the current input data are then derived based on the forward and backward features. Specifically, this can be achieved by concatenating the forward and backward features, performing weighted summation, or other similar processing.
[0190] In one embodiment, if the current input data is training text, the computer device can perform forward encoding and reverse encoding using the following formulas:
[0191]
[0192] in, This represents the result of forward encoding the first t words of the training text, specifically the text vector at time t (the input time of the forward input of the t-th character). LSTM (Long Short-Term Memory) indicates forward encoding processing via an LSTM network. This represents the t-th word in the training text. This represents the result of forward encoding the first t-1 words of the training text, i.e., the text vector at time t-1 (the input time of the forward input of the t-1th character).
[0193] This represents the result of inverse encoding the first t words of the training text, specifically the text vector at time t (the input time of the inverse input of the t-th character). LSTM indicates inverse encoding processing via an LSTM network. This represents the t-th word in the training text. This represents the result of the reverse encoding of the first t-1 words of the training text, i.e., the text vector at time t-1 (the input time of the reverse input of the t-1th character).
[0194] Finally, you can and Cascade That is, to and spliced together to obtain
[0195] The above formula indicates that the text vector at time t (i.e., the time when the t-th character is input) is calculated based on the vectors from the previous t-1 times and the t-th word. This can be understood as follows: each word of the training text can be input forward into the LSTM network for forward encoding, and each word of the training text can be input backward into the LSTM network for backward encoding. Similarly, each entity of the training text can be input forward into the LSTM network in the order of its appearance in the training text for forward encoding, and each entity of the training text can be input backward into the LSTM network in the order of its appearance in the training text for backward encoding.
[0196] In this embodiment, by performing forward and reverse encoding on the input data through an encoding subnetwork, the data classification model can learn the relationships between words in the text and enhance the generalization ability of the data classification model.
[0197] In one embodiment, the encoding layer includes at least two encoding sub-networks, the mapping layer includes at least two mapping sub-networks, the encoding sub-networks and the mapping sub-networks correspond one-to-one, the initial features include the initial sub-features output by each encoding sub-network, and the determination of intermediate features includes the following steps: inputting the initial sub-features output by each encoding sub-network into the corresponding mapping sub-network to obtain the intermediate sub-features output by each mapping sub-network; and obtaining intermediate features based on each intermediate sub-feature.
[0198] Specifically, the encoding layer of the data classification model can include at least two encoding sub-networks, and the mapping layer can include at least two mapping sub-networks. One encoding sub-network corresponds to one mapping sub-network; that is, there is a one-to-one correspondence between the encoding and mapping sub-networks. After training samples are input into the data classification model, each encoding sub-network can output its corresponding initial sub-features through data processing. Since one encoding sub-network corresponds to one mapping sub-network, the initial sub-features output by each encoding sub-network are input into the corresponding mapping sub-network. Through data processing, each mapping sub-network can output its corresponding intermediate sub-features, and intermediate features are obtained from these intermediate sub-features.
[0199] In this embodiment, the encoding subnetwork and the mapping subnetwork are in one-to-one correspondence. The output data of an encoding subnetwork is input into the corresponding mapping subnetwork, which can effectively ensure the orderliness of data processing within the data classification model.
[0200] In one embodiment, training the mapping layer of the updated data classification model based on the first and second features corresponding to the same training sample to obtain an updated intermediate data classification model includes: inputting the second feature corresponding to the forward-trained sample into the mapping layer of the updated data classification model to obtain the corresponding predicted feature; calculating the target training loss value based on the first feature and the predicted feature corresponding to the same training sample; and adjusting the mapping layer parameters of the updated data classification model based on the target training loss value until the convergence condition is met to obtain the updated intermediate data classification model.
[0201] Specifically, to ensure that the updated data classification model maintains its performance on the preceding trained samples after training with updated training samples, the mapping layer of the updated data classification model needs to be trained. Specifically, the second feature can be used as the input to the mapping layer of the updated data classification model, and the first feature can be used as the expected output of the mapping layer. Training the mapping layer of the updated data classification model allows it to maintain its performance on the preceding trained samples.
[0202] The computer device can input the second feature corresponding to the previously trained sample into the mapping layer of the updated data classification model to obtain the predicted feature output by the mapping layer. Based on the first feature and the predicted feature corresponding to the same training sample, a target training loss value is calculated. Backpropagation is then performed based on the target training loss value to adjust the parameters of the mapping layer of the updated data classification model and continue training until a convergence condition is met, resulting in a data classification model with a trained mapping layer. This trained data classification model with a trained mapping layer is then used as a new intermediate data classification model to replace the previous intermediate model. The convergence condition can specifically include the target training loss value being minimized, the rate of change of the target training loss value being less than a preset threshold, and the number of iterations reaching a preset number. The target training loss value can be calculated using loss functions such as cross-entropy loss, exponential loss, and hinge loss.
[0203] In one embodiment, such as Figure 8 As shown, the encoding layer includes at least two encoding sub-networks, and the mapping layer includes at least two mapping sub-networks. The encoding sub-networks and mapping sub-networks correspond one-to-one. The first feature includes the first sub-feature output by each encoding sub-network of the intermediate data classification model, and the second feature includes the second sub-feature output by each encoding sub-network of the updated data classification model. The mapping layer of the updated data classification model is trained based on the first and second features corresponding to the same training sample to obtain the updated intermediate data classification model, including:
[0204] Step S802: Input each second sub-feature corresponding to the forward-trained sample into the corresponding mapping sub-network in the update data classification model to obtain the corresponding predicted sub-features.
[0205] Specifically, the encoding layer of the updated data classification model includes at least two encoding sub-networks, and the mapping layer includes at least two mapping sub-networks, with one encoding sub-network corresponding to one mapping sub-network. The computer device inputs training samples into the encoding layers of both the intermediate data classification model and the updated data classification model. Each encoding sub-network of the intermediate data classification model outputs a first sub-feature corresponding to the training sample; these first sub-features are combined to obtain a first feature. Similarly, each encoding sub-network of the updated data classification model outputs a second sub-feature corresponding to the training sample; these second sub-features are combined to obtain a second feature. Furthermore, the computer device can input the second sub-features corresponding to the previously trained samples into the corresponding mapping sub-networks in the updated data classification model, and each mapping sub-network outputs its corresponding predicted sub-feature.
[0206] Step S804: Obtain the corresponding encoding subnetwork and mapping subnetwork as the target encoding subnetwork and target mapping subnetwork.
[0207] Step S806: Calculate the training loss value based on the first sub-feature output by the target encoding sub-network and the predicted sub-feature output by the target mapping sub-network corresponding to the same training sample, and obtain the training loss value corresponding to each mapping sub-network.
[0208] Specifically, since one encoding subnetwork corresponds to one mapping subnetwork, one first sub-feature corresponds to one predicted sub-feature. Therefore, the computer device can calculate the training loss value based on the first sub-feature output by the target encoding subnetwork and the predicted sub-feature output by the target mapping subnetwork corresponding to the same training sample, thus obtaining the training loss value for each mapping subnetwork. Here, the target encoding subnetwork and the target mapping subnetwork refer to encoding subnetworks and mapping subnetworks that have a corresponding relationship.
[0209] Step S808: Adjust the parameters of the corresponding mapping subnetwork in the updated data classification model based on each training loss value until the convergence condition is met, and obtain the updated intermediate data classification model.
[0210] Specifically, the computer can backpropagate each training loss value to adjust the parameters of the corresponding mapping sub-network in the updated data classification model and continue training until the convergence condition is met, resulting in a trained data classification model with the mapping layer. This trained model is then used as a new intermediate data classification model to replace the previous one. The convergence condition can include each training loss value being at its minimum, the sum of all training losses being at its minimum, the average rate of change of all training losses being less than a preset threshold, and the number of iterations reaching a preset number. The target training loss value can be calculated using loss functions such as cross-entropy loss, exponential loss, and hinge loss.
[0211] For example, the updated data classification model includes a first encoding sub-network and a first mapping sub-network with a corresponding relationship, and a second encoding sub-network and a second mapping sub-network with a corresponding relationship. The computer device can input training samples into the encoding layers of the intermediate data classification model and the updated data classification model, respectively. The first encoding sub-network of the intermediate data classification model outputs a first sub-feature a1, the second encoding sub-network of the intermediate data classification model outputs a first sub-feature a2, the first encoding sub-network of the updated data classification model outputs a second sub-feature b1, and the second encoding sub-network of the updated data classification model outputs a second sub-feature b2. Then, the computer device can input the second sub-feature b1 into the first mapping sub-network of the updated data classification model to obtain the first predicted sub-feature c1 output by the first mapping sub-network. Based on the first sub-feature a1 and the first predicted sub-feature c1, a training loss value d1 is calculated, and the model parameters of the first mapping sub-network of the updated data classification model are adjusted based on the training loss value d1. The computer device inputs the second sub-feature b2 into the second mapping sub-network of the updated data classification model to obtain the first predicted sub-feature c2. Based on the first sub-feature a2 and the first predicted sub-feature c2, the training loss value d2 is calculated. Based on the training loss value d2, the model parameters of the second mapping sub-network of the updated data classification model are adjusted. After the model parameters of the mapping sub-network are adjusted, the above steps are repeated to calculate new training loss values d1 and d2. When the updated training loss values d1 and d2 satisfy the convergence condition, the trained data classification model of the mapping layer is obtained.
[0212] In this embodiment, different mapping sub-networks are adjusted by different training loss values, which can effectively ensure the accuracy of the parameters of each mapping sub-network, thereby improving the data classification accuracy of the data classification model.
[0213] In one embodiment, such as Figure 9 As shown, a data classification method is provided, which can be applied to... Figure 1 Taking the computer equipment mentioned above as an example, the computer equipment can be... Figure 1 Terminal 102 or server 104 in the reference. Figure 9 The data classification method includes the following steps:
[0214] Step S902: Obtain the data to be classified.
[0215] Step S904: Input the data to be classified into the target data classification model to obtain the target classification result corresponding to the data to be classified. The target data classification model is based on the current training samples corresponding to the current data classification task in the training sample set. The encoding layer of the initial data classification model is trained to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is trained based on the updated training samples corresponding to the next data classification task in the training sample set to obtain an updated data classification model. The forward trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first feature and second feature. The mapping layer of the updated data classification model is trained based on the first feature and second feature corresponding to the same training sample to obtain an updated intermediate data classification model. The step of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is returned until the training is completed. The result is obtained based on the intermediate data classification model corresponding to the completed training.
[0216] Specifically, when the training sample set is a training text set, the target data classification model finally trained based on the training sample set is a target text classification model. In this case, the data to be classified can be the text to be classified. After the computer device obtains the text to be classified, it can input the text to be classified into the target text classification model to obtain the target classification result output by the target text classification model.
[0217] When the training sample set is a training image set, the target data classification model finally trained based on the training image set is a target image classification model. In this case, the data to be classified can be an image. After the computer device acquires the image to be classified, it can input the image to be classified into the target image classification model to obtain the target classification result output by the target image classification model.
[0218] Computer devices can acquire data to be classified input or viewed by users on a terminal, input this data into a trained target data classification model, and obtain the target classification result corresponding to the data. The computer device can then display the target classification result to the user; for example, it can display the target classification result of a medical record to be classified, allowing the user to proceed with further processing. The computer device can also recommend information to the user based on the target classification result. For instance, if the output of the target data classification model determines that the news a user is currently browsing is entertainment news, the computer device can proactively recommend other entertainment news to the user, thereby improving information recommendation efficiency.
[0219] It is understood that the specific process of training the initial data classification model based on the training sample set to obtain the target data classification model can refer to the methods described in the various relevant embodiments of the aforementioned data classification model training method, and will not be repeated here.
[0220] The above data classification method involves acquiring the data to be classified, inputting it into a target data classification model, and obtaining the target classification result corresponding to the data to be classified. The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process returns to the step of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task, until training is complete. The final data classification result is obtained based on the intermediate data classification model at the time of training completion. In this way, training the encoding layer of the data classification model allows the model to learn the knowledge specific to each data classification task from the training samples corresponding to each task. Training the mapping layer allows the model to learn the knowledge common to each data classification task. By alternating between training the encoding and mapping layers, the model can maintain its accuracy in the forward data classification task and also ensure its accuracy in the new data classification task, thus obtaining a general target data classification model.
[0221] This application also provides an application scenario in which the above-described data classification model training method is applied. Specifically, the data classification model training method is applied in this scenario as follows:
[0222] 1. Establish a training text set
[0223] In the medical field, text classification tasks can be categorized based on the severity of the disease, thus establishing a training text set that includes training texts corresponding to at least two text classification tasks. Since primary care hospitals mainly handle common diseases (ordinary diseases), secondary hospitals mainly handle moderate diseases, and tertiary hospitals mainly handle severe and complex diseases, a training text set can be established that includes training texts corresponding to three text classification tasks: medical records for various common diseases, medical records for various moderate diseases, and medical records for various severe and complex diseases. It is understandable that text classification tasks can also be categorized in other ways.
[0224] 2. Train the target text classification model based on the training text set.
[0225] like Figure 10A As shown, the text classification model employs a dual-channel setup for the original medical record text and entities, using a bidirectional LSTM as the encoder to encode both entities and text separately. Text is encoded through its corresponding encoding sub-network, with the final output serving as a high-dimensional vector representation of the text, i.e., text features. Entities are encoded through their corresponding encoding sub-networks, with each step's output serving as a high-dimensional vector representation of each entity, i.e., entity features. Furthermore, an attention mechanism combines the encoding results of the two encoding sub-networks, assigning weights to each entity based on the text features to strengthen the entity's role in the final vector representation, thus obtaining updated entity features. Following this, a continuous learning method maps the encoding results of the two encoding sub-networks to two high-dimensional representation spaces suitable for all tasks: a general text representation space and a general entity representation space. Finally, a classification layer classifies the input text using both the general text and entity representation spaces, outputting the classification result corresponding to the input text.
[0226] The training phase of the text classification model is divided into two steps: the first step is to train the encoding layer, and the second step is to train the mapping layer. Dividing the training into two steps is primarily to ensure the model's performance on both the current task and all previous tasks. Specifically, the first step, training the encoding layer, mainly allows the model to learn the contextual linguistic features from the data of the current task, while the second step, training the mapping layer, mainly uses the vector representation from the previous time step as the target to obtain a vector representation applicable to all tasks.
[0227] When training for each text classification task, the first step is to extract a portion of the training texts for each task from the complete training text set. Alternatively, a very small number of training texts for each task can be randomly selected from the complete training text set for the second step of training.
[0228] 2-1. Encoding Layer Training
[0229] The encoding layer of the initial text classification model is trained using the training text corresponding to text classification task one to obtain an intermediate text classification model. The encoding layer of the intermediate text classification model is then trained using the training text corresponding to text classification task two to obtain an updated text classification model.
[0230] Training the encoding layer of a text classification model based on training text can be achieved by inputting the training text into the text classification model, which then outputs the predicted category corresponding to the training text. The parameters of the encoding layer of the text classification model are adjusted based on the training category and the predicted category corresponding to the training text until the convergence condition is met, thus obtaining a text classification model with a trained encoding layer.
[0231] 2-2. Mapping Layer Training
[0232] The training texts corresponding to text classification task one are input into the intermediate text classification model and the updated text classification model, respectively, to obtain the first feature output by the encoding layer of the intermediate text classification model and the second feature output by the encoding layer of the updated text classification model. The second feature corresponding to the same training text is input into the mapping layer of the updated text training model to obtain the corresponding predicted feature. The parameters of the mapping layer of the updated text training model are adjusted based on the first feature and the predicted feature corresponding to the same training text until the convergence condition is met, resulting in a text classification model with a trained mapping layer.
[0233] Taking the text channel as an example to illustrate the training of the mapping layer, the subset of training text used for the k-th task can be defined as Rk. The high-dimensional vector representation of Rk after the training of the k-th task (i.e., at time k) is defined as Ek'. Similarly, the original text and corresponding high-dimensional vector representations of the first k-1 tasks at the current time k are {R1, R2, R3, ..., Rk-1} and {E1', E2', E3', ..., Ek-1'}, respectively. After training the (k+1)-th task, {R1, R2, R3, ..., Rk} is input into the encoding layer of the current text classification model to obtain the corresponding high-dimensional vectors {E1, E2, E3, ..., Ek}. These sets of high-dimensional vectors constitute the training data (X, Y) of the mapping layer for the current text classification task, i.e., {(E1, E1'), (E2, E2'), (E3, E3'), ..., (Ek, Ek')}. In the training data (X, Y), X serves as the input to the mapping layer of the current text classification model, and Y serves as the expected output of the mapping layer of the current text classification model. The mapping layer of the current text classification model is then trained.
[0234] It's understandable that the mapping layer can also be called the alignment layer. The purpose of the alignment layer is to convert the text vectors and entity vector codes obtained after training for each text classification task into a vector code that is applicable to all tasks, thereby achieving continuous learning and ensuring that the model does not forget previous tasks when learning subsequent tasks.
[0235] 2-3. Alternate training of the encoding layer and the mapping layer.
[0236] The text classification model with the already trained mapping layer is used as a new intermediate data classification model. The encoding layer of the latest intermediate data classification model is trained based on the training text corresponding to text classification task three to obtain a new updated data classification model.
[0237] The training texts for text classification task one are input into the latest intermediate text classification model and the latest updated text classification model, respectively, to obtain the first feature output by the encoding layer of the latest intermediate text classification model and the second feature output by the encoding layer of the latest updated text classification model. The training texts for text classification task two are then input into the latest intermediate text classification model and the latest updated text classification model, respectively, to obtain the first feature output by the encoding layer of the latest intermediate text classification model and the second feature output by the encoding layer of the latest updated text classification model. The second feature corresponding to the same training text is then input into the mapping layer of the latest updated text classification model to obtain the corresponding predicted feature. The parameters of the mapping layer of the latest updated text classification model are adjusted based on the first feature and the predicted feature corresponding to the same training text until the convergence condition is met, resulting in a text classification model with a trained mapping layer.
[0238] After all text classification tasks in the training text set have been trained, the text classification model obtained after the last mapping layer training is used as the target text classification model. Thus, after obtaining the medical record text to be classified, the text can be input into the target text classification model to obtain the specific category corresponding to the medical record text.
[0239] In this embodiment, the medical record text classification model can be reused and iterated across multiple hospitals at minimal cost using original medical record data. First, the concept of continuous learning is introduced. When integrating a new hospital or iterating the model, training only needs to be performed on the new text classification task, eliminating the need to retain hospital medical record data for extended periods. Model training can even be completed without the data leaving the hospital. Second, a preprocessing step is performed on the medical record text to extract a series of medical entities as input for another channel. This dual-channel approach not only improves model performance but also further enhances the utilization rate of medical record text. Third, an attention mechanism is used during the encoding process to facilitate interaction between medical entities and the medical record text. This redistributes the importance of different entities within the text, improving encoding efficiency, feature extraction accuracy, and ultimately, the accuracy of medical record text classification.
[0240] It is understood that the data classification model training method of this application can be applied not only to medical text classification and training of medical text classification models, but also to text classification in other fields such as news and information classification, and to training various text classification models. Furthermore, in addition to being applied to text classification and training text classification models, it can also be applied to image classification and training image classification models.
[0241] Furthermore, the data classification model in this embodiment can be called Embedding Episodic Memory and Consolidation, E 2 MC. E 2 The test was conducted using MC and target data classification models obtained through other continuous learning methods, and the test results are as follows: Figure 10B As shown. Figure 10B EWC (Elastic Weight Consolidation), a regularization-based long-term learning method, avoids catastrophic forgetting by imposing constraints on the loss function. Specifically, during training for each task, EWC adds a regularization term to the loss function to restrict the model's parameters from optimizing in a direction compatible with all tasks. Figure 10B GEM (Gradient Episodic Memory) performs quadratic programming on the gradient of each parameter, simultaneously incorporating the loss of the current model from previous tasks into the updated gradient. Building upon GEM, researchers have proposed AAGEM (Average Gradient Episodic Memory), which uses an averaging approach to improve the overall efficiency of GEM. Additionally... Figure 10B MBPA++ is a scheme that introduces a recall mechanism during the prediction phase in order to avoid forgetting. Figure 10B The remaining two comparison objects can serve as the upper and lower bounds for the field of continuous learning. Figure 10B The horizontal axis represents the number of data classification tasks involved in model training, and the vertical axis represents the model's data classification accuracy. Data classification accuracy can refer to the average accuracy of the data classification model across all trained tasks, which can be specifically measured through... The calculation yields , where K represents the number of data classification tasks participating in model training, and acc f,k This represents the accuracy of the data classification model f on the k-th task. From... Figure 10B As can be seen from E 2 MC significantly outperforms other existing solutions and is not far from the upper limit of the continuous learning field.
[0242] Furthermore, the dual-channel and single-channel approaches to data classification models are compared to demonstrate the beneficial effects of introducing entity knowledge and attention mechanisms. Figure 10C As shown, E 2 MC (no-attention) indicates that no attention mechanism is introduced in the model, E 2 MC (no-entity) indicates that no entity channels are introduced in the model. For example... Figure 10CAs shown, the dual-channel approach significantly improves the model's performance. This is because the introduction of entity knowledge enhances the model's mapping ability between the existing task space and the general space, further optimizing the model's forgetting behavior.
[0243] It should be understood that, although Figure 2-5 The steps in flowchart 7-10A are shown sequentially as indicated by the arrows; however, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are performed, and they can be executed in other orders. Figure 2-5 At least some of the steps in 7-10A may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0244] In one embodiment, such as Figure 11 As shown, a data classification model training device is provided. This device can be a software module, a hardware module, or a combination of both integrated into a computer device. Specifically, the device includes: a training sample set acquisition module 1102, an encoding layer training module 1104, a mapping layer training module 1106, and a target data classification model determination module 1108, wherein:
[0245] The training sample set acquisition module 1102 is used to acquire the training sample set; the training sample set includes training samples corresponding to at least two data classification tasks.
[0246] The encoding layer training module 1104 is used to obtain the current training sample corresponding to the current data classification task, train the encoding layer of the initial data classification model based on the current training sample to obtain the intermediate data classification model; and obtain the updated training sample corresponding to the next data classification task, train the encoding layer of the intermediate data classification model based on the updated training sample to obtain the updated data classification model.
[0247] The mapping layer training module 1106 is used to input the preceding trained samples of the updated training samples into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain the corresponding first feature and second feature; and to train the mapping layer of the updated data classification model based on the first feature and second feature corresponding to the same training sample to obtain the updated intermediate data classification model.
[0248] The target data classification model determination module 1108 is used to return the steps of obtaining the updated training samples corresponding to the next data classification task until training is completed, and obtain the target data classification model based on the intermediate data classification model corresponding to the completion of training.
[0249] In one embodiment, the training sample set acquisition module is further configured to acquire multiple candidate samples; each candidate sample carries a candidate label; cluster each candidate sample corresponding to the same candidate label to obtain an initial cluster corresponding to each candidate label; determine the processing priority corresponding to each candidate sample based on the candidate label; use the initial cluster as a data classification sub-task, and cluster each data classification sub-task corresponding to the same processing priority to obtain a target data classification task set corresponding to each processing priority; the target data classification task set includes each training sample corresponding to the same data classification task; and obtain a training sample set based on each target data classification task set.
[0250] In one embodiment, the target data classification model is used to determine the target label corresponding to the data to be classified from the candidate labels corresponding to the trained samples.
[0251] In one embodiment, the training samples in the training sample set carry training labels, the data classification model to be trained is an initial data classification model or an intermediate data classification model, and the encoding layer training module is also used to process the input training samples through the data classification model to be trained to obtain the predicted labels corresponding to the input training samples; and to adjust the encoding layer parameters of the data classification model to be trained based on the label difference between the training labels and the predicted labels corresponding to the input training samples until the convergence condition is met.
[0252] In one embodiment, the current data classification model is any one of the initial data classification model, intermediate data classification model, updated data classification model, and target data classification model. The encoding layer of the current data classification model is used to encode the input training samples to obtain initial features, and the mapping layer of the current data classification model is used to map the initial features to obtain intermediate features.
[0253] In one embodiment, the input training samples include text data and entity data, and the encoding layer includes an encoding subnetwork corresponding to the text data and an encoding subnetwork corresponding to the entity data, such as... Figure 12 As shown, the device further includes:
[0254] The input training sample processing module 1110 is used to encode the text data through the encoding sub-network corresponding to the text data to obtain text features; to encode the entity data through the encoding sub-network corresponding to the entity data to obtain entity features; and to obtain initial features based on the entity features and text features.
[0255] In one embodiment, the current data classification model includes an entity extraction layer, and the encoding layer includes an encoding subnetwork corresponding to the entity extraction layer and an encoding subnetwork corresponding to the input training samples. The input training sample processing module is further configured to extract entities from the input training samples through the entity extraction layer to obtain entity data corresponding to the input training samples; encode the entity data through the encoding subnetwork corresponding to the entity extraction layer to obtain entity features; encode the input training samples through the encoding subnetwork corresponding to the input training samples to obtain text features; and obtain initial features based on the entity features and text features.
[0256] In one embodiment, the entity data includes at least one entity, and the entity features include entity sub-features corresponding to each entity. The input training sample processing module is further configured to perform attention allocation on the entity sub-features corresponding to each entity based on the text features to obtain attention information corresponding to each entity; normalize the attention information corresponding to each entity to obtain attention factors corresponding to each entity; obtain updated entity features based on the entity sub-features and attention factors corresponding to each entity; and obtain initial features based on the text features and the updated entity features.
[0257] In one embodiment, the input training sample processing module is further configured to perform forward encoding processing on the current input data through the current encoding sub-network to obtain forward features; perform reverse encoding processing on the current input data through the current encoding sub-network to obtain reverse features; and obtain the features corresponding to the current input data based on the forward and reverse features.
[0258] In one embodiment, the encoding layer includes at least two encoding sub-networks, the mapping layer includes at least two mapping sub-networks, the encoding sub-networks and the mapping sub-networks correspond one-to-one, the initial features include the initial sub-features output by each encoding sub-network, the input training sample processing module is further used to input the initial sub-features output by each encoding sub-network into the corresponding mapping sub-network to obtain the intermediate sub-features output by each mapping sub-network; and to obtain intermediate features based on each intermediate sub-feature.
[0259] In one embodiment, the mapping layer training module is further configured to input the second feature corresponding to the forward-trained sample into the mapping layer of the updated data classification model to obtain the corresponding predicted feature; calculate the target training loss value based on the first feature and the predicted feature corresponding to the same training sample; and adjust the mapping layer parameters of the updated data classification model based on the target training loss value until the convergence condition is met to obtain the updated intermediate data classification model.
[0260] In one embodiment, the encoding layer includes at least two encoding sub-networks, and the mapping layer includes at least two mapping sub-networks. The encoding sub-networks and mapping sub-networks correspond one-to-one. The first feature includes the first sub-features output by each encoding sub-network of the intermediate data classification model, and the second feature includes the second sub-features output by each encoding sub-network of the updated data classification model. The mapping layer training module is further configured to input each second sub-feature corresponding to the forward-trained sample into the corresponding mapping sub-network in the updated data classification model to obtain the corresponding predicted sub-features; obtain the encoding sub-networks and mapping sub-networks with corresponding relationships as the target encoding sub-network and the target mapping sub-network; calculate the training loss value based on the first sub-feature output by the target encoding sub-network and the predicted sub-feature output by the target mapping sub-network corresponding to the same training sample to obtain the training loss value corresponding to each mapping sub-network; and adjust the parameters of the corresponding mapping sub-network in the updated data classification model based on each training loss value until the convergence condition is met to obtain the updated intermediate data classification model.
[0261] In one embodiment, such as Figure 13 As shown, a data classification device is provided. This device can be a software module, a hardware module, or a combination of both as part of a computer device. Specifically, the device includes: a data acquisition module 1302 and a classification result determination module 1304, wherein:
[0262] Data acquisition module 1302 is used to acquire data to be classified;
[0263] The classification result determination module 1304 is used to input the data to be classified into the target data classification model and obtain the target classification result corresponding to the data to be classified.
[0264] The target data classification model is trained on the encoding layer of the initial data classification model based on the current training samples corresponding to the current data classification task in the training sample set, to obtain an intermediate data classification model. The encoding layer of the intermediate data classification model is then trained on the updated training samples corresponding to the next data classification task in the training sample set, to obtain an updated data classification model. The preceding trained samples of the updated training samples are input into the encoding layers of the intermediate data classification model and the updated data classification model, respectively, to obtain the corresponding first and second features. The mapping layer of the updated data classification model is then trained on the first and second features corresponding to the same training sample, to obtain an updated intermediate data classification model. The process of training the encoding layer of the intermediate data classification model based on the updated training samples corresponding to the next data classification task is then repeated until training is complete. The target data classification model is obtained based on the intermediate data classification model at the time of training completion.
[0265] Specific limitations regarding the data classification model training device and the data classification device can be found in the limitations regarding the data classification model training method and the data classification method above, and will not be repeated here. Each module in the aforementioned data classification model training device and data classification device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0266] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 14 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores training sample sets, target data classification models, and other data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a data classification model training method and a data classification method.
[0267] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 15 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data classification model training method and a data classification method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0268] Those skilled in the art will understand that Figure 14 , 15The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0269] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0270] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0271] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0272] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0273] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0274] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A data classification model training method, characterized in that, The method comprises: obtaining a training sample set; the training sample set comprises training samples corresponding to at least two data classification tasks; the training sample comprises text data and entity data, the text data is training text, and the entity data is each entity in the training text; obtaining a current training sample corresponding to a current data classification task, training an encoding layer of an initial data classification model based on the current training sample to obtain an intermediate data classification model; obtaining an updated training sample corresponding to a next data classification task, training the encoding layer of the intermediate data classification model based on the updated training sample to obtain an updated data classification model; inputting a forward trained sample of the updated training sample into the encoding layer of the intermediate data classification model and the updated data classification model respectively to obtain corresponding first features and second features; training a mapping layer of the updated data classification model based on the first features and the second features corresponding to the same training sample to obtain an updated intermediate data classification model; returning to the step of obtaining the updated training sample corresponding to the next data classification task until the training is completed, and obtaining a target data classification model based on the corresponding intermediate data classification model when the training is completed; the target data classification model is used for inputting to-be-classified data into the target data classification model to obtain a target classification result corresponding to the to-be-classified data.
2. The method of claim 1, wherein, The obtaining of the training sample set comprises: obtaining a plurality of candidate samples; the candidate samples carry candidate labels; clustering each candidate sample corresponding to the same candidate label to obtain an initial clustering cluster corresponding to each candidate label; determining a processing priority corresponding to each candidate sample based on the candidate label; clustering each data classification subtask corresponding to the same processing priority by taking the initial clustering cluster as a data classification subtask to obtain a target data classification task set corresponding to each processing priority; the target data classification task set comprises each training sample corresponding to the same data classification task; obtaining the training sample set based on each target data classification task set.
3. The method of claim 1, wherein, The training sample in the training sample set carries a training label, and a to-be-trained data classification model is an initial data classification model or an intermediate data classification model; the training of the encoding layer of the to-be-trained data classification model comprises the following steps: performing data processing on an input training sample by the to-be-trained data classification model to obtain a predicted label corresponding to the input training sample; adjusting the encoding layer parameters of the to-be-trained data classification model based on the label difference between the training label and the predicted label corresponding to the input training sample until a convergence condition is met.
4. The method of claim 1, wherein, The current data classification model is any one of an initial data classification model, an intermediate data classification model, an updated data classification model and a target data classification model; the encoding layer of the current data classification model is used for encoding processing on an input training sample to obtain an initial feature; and the mapping layer of the current data classification model is used for mapping processing on the initial feature to obtain an intermediate feature.
5. The method of claim 4, wherein, The encoding layer includes an encoding subnetwork corresponding to the text data and an encoding subnetwork corresponding to the entity data, and the determination of the initial feature includes the following steps: The text data is encoded by the encoding subnetwork corresponding to the text data to obtain a text feature; The entity data is encoded by the encoding subnetwork corresponding to the entity data to obtain an entity feature; The initial feature is obtained based on the entity feature and the text feature.
6. The method of claim 4, wherein, The current data classification model includes an entity extraction layer, the encoding layer includes an encoding subnetwork corresponding to the entity extraction layer and an encoding subnetwork corresponding to the input training sample, and the determination of the initial feature includes the following steps: The entity extraction layer extracts the entity data from the input training sample to obtain the entity data corresponding to the input training sample; The entity data is encoded by the encoding subnetwork corresponding to the entity extraction layer to obtain an entity feature; The input training sample is encoded by the encoding subnetwork corresponding to the input training sample to obtain a text feature; The initial feature is obtained based on the entity feature and the text feature.
7. The method according to claim 5 or 6, characterized in that, The entity data includes at least one entity, and the entity feature includes an entity subfeature corresponding to each entity. The initial feature is obtained based on the entity feature and the text feature, including: The attention information corresponding to each entity is obtained by performing attention allocation on the entity subfeature corresponding to each entity based on the text feature; The attention information corresponding to each entity is normalized to obtain an attention factor corresponding to each entity; The updated entity feature is obtained based on the entity subfeature corresponding to each entity and the attention factor; The initial feature is obtained based on the text feature and the updated entity feature.
8. The method according to claim 5 or 6, characterized in that, The current input data is encoded by a current encoding subnetwork to obtain a feature corresponding to the current input data, including: The current input data is forward encoded by the current encoding subnetwork to obtain a forward feature; The current input data is backward encoded by the current encoding subnetwork to obtain a backward feature; The feature corresponding to the current input data is obtained based on the forward feature and the backward feature.
9. The method of claim 4, wherein, The encoding layer includes at least two encoding subnetworks, the mapping layer includes at least two mapping subnetworks, the encoding subnetworks and the mapping subnetworks correspond one-to-one, the initial feature includes an initial subfeature output by each encoding subnetwork, and the determination of the intermediate feature includes the following steps: The initial subfeature output by each encoding subnetwork is input into the corresponding mapping subnetwork to obtain an intermediate subfeature output by each mapping subnetwork; The intermediate feature is obtained based on each intermediate subfeature.
10. The method of claim 1, wherein, The encoding layer includes at least two encoding sub-networks, the mapping layer includes at least two mapping sub-networks, the encoding sub-networks and the mapping sub-networks correspond one by one, the first feature includes first sub-features output by respective encoding sub-networks of an intermediate data classification model, the second feature includes second sub-features output by respective encoding sub-networks of an updated data classification model, the mapping layer of the updated data classification model is trained based on the first feature and the second feature corresponding to the same training sample, to obtain an updated intermediate data classification model, including: The respective second sub-features corresponding to the forward trained sample are input into the corresponding mapping sub-networks of the updated data classification model, to obtain respective prediction sub-features corresponding to the forward trained sample; An encoding sub-network and a mapping sub-network having a corresponding relationship are obtained as a target encoding sub-network and a target mapping sub-network; A training loss value is calculated based on the first sub-feature output by the target encoding sub-network and the prediction sub-feature output by the target mapping sub-network corresponding to the same training sample, to obtain a training loss value corresponding to each mapping sub-network; Parameters of the corresponding mapping sub-network in the updated data classification model are adjusted based on the respective training loss values, until a convergence condition is met, to obtain an updated intermediate data classification model.
11. A method of data classification, characterized by, The method includes: Obtaining to-be-classified data; The to-be-classified data is input into a target data classification model, to obtain a target classification result corresponding to the to-be-classified data; The target data classification model is obtained by training an encoding layer of an initial data classification model based on a current training sample corresponding to a current data classification task in a training sample set, obtaining an intermediate data classification model, training the encoding layer of the intermediate data classification model based on an updated training sample corresponding to a next data classification task in the training sample set, obtaining an updated data classification model, inputting forward trained samples of the updated training sample into the encoding layers of the intermediate data classification model and the updated data classification model respectively, obtaining corresponding first features and second features, training a mapping layer of the updated data classification model based on the first feature and the second feature corresponding to the same training sample, obtaining an updated intermediate data classification model, returning to the step of training the encoding layer of the intermediate data classification model based on the updated training sample corresponding to the next data classification task until training is completed, and obtaining the corresponding intermediate data classification model based on the training completion; the training sample includes text data and entity data, the text data refers to training text, and the entity data refers to respective entities in the training text.
12. A data classification model training apparatus, characterized by comprising: The device includes: A training sample set acquisition module is configured to acquire a training sample set; the training sample set includes training samples corresponding to at least two data classification tasks; the training sample includes text data and entity data, the text data refers to training text, and the entity data refers to respective entities in the training text. The encoding layer training module is configured to obtain a current training sample corresponding to a current data classification task, train an encoding layer of an initial data classification model based on the current training sample, and obtain an intermediate data classification model; obtain an updated training sample corresponding to a next data classification task, train the encoding layer of the intermediate data classification model based on the updated training sample, and obtain an updated data classification model. The mapping layer training module is configured to input a forward trained sample of the updated training sample into the encoding layer of the intermediate data classification model and the updated data classification model respectively, and obtain corresponding first features and second features; train a mapping layer of the updated data classification model based on the first features and the second features corresponding to the same training sample, and obtain an updated intermediate data classification model. The target data classification model determination module is configured to return the step of obtaining the updated training sample corresponding to the next data classification task until training is completed, obtain a target data classification model based on the intermediate data classification model corresponding to the time when the training is completed; and the target data classification model is configured to input data to be classified into the target data classification model, and obtain a target classification result corresponding to the data to be classified.
13. The data classification model training apparatus according to claim 12, characterized by, The training sample set obtaining module is further configured to obtain a plurality of candidate samples; the candidate samples carry candidate labels; and each candidate sample corresponding to a same candidate label is clustered to obtain an initial clustering cluster corresponding to each candidate label. The processing priority of each candidate sample is determined based on the candidate label. The initial clustering cluster is used as a data classification subtask, and each data classification subtask corresponding to a same processing priority is clustered to obtain a target data classification task set corresponding to each processing priority. The target data classification task set includes each training sample corresponding to a same data classification task. The training sample set is obtained based on each target data classification task set. 14.The data classification model training apparatus of claim 12, wherein, The training sample in the training sample set carries a training label, and the data classification model to be trained is an initial data classification model or an intermediate data classification model. The encoding layer training module is further configured to perform data processing on an input training sample through the data classification model to be trained, to obtain a predicted label corresponding to the input training sample; and adjust the encoding layer parameters of the data classification model to be trained based on the label difference between the training label and the predicted label corresponding to the input training sample until a convergence condition is met.
15. The data classification model training apparatus of claim 12, wherein, The current data classification model is any one of an initial data classification model, an intermediate data classification model, an updated data classification model, and a target data classification model. The encoding layer of the current data classification model is configured to perform encoding processing on an input training sample to obtain an initial feature. The mapping layer of the current data classification model is configured to perform mapping processing on the initial feature to obtain an intermediate feature.
16. The data classification model training apparatus of claim 15, wherein, The encoding layer includes an encoding subnetwork corresponding to text data and an encoding subnetwork corresponding to entity data, and the apparatus further includes an input training sample processing module, which is configured to perform encoding processing on the text data through the encoding subnetwork corresponding to the text data to obtain text features, perform encoding processing on the entity data through the encoding subnetwork corresponding to the entity data to obtain entity features, and obtain the initial features based on the entity features and the text features.
17. The data classification model training apparatus of claim 15, wherein The current data classification model includes an entity extraction layer, the encoding layer includes an encoding subnetwork corresponding to the entity extraction layer and an encoding subnetwork corresponding to an input training sample, and the input training sample processing module is further configured to perform entity extraction on the input training sample through the entity extraction layer to obtain entity data corresponding to the input training sample, perform encoding processing on the entity data through the encoding subnetwork corresponding to the entity extraction layer to obtain entity features, and perform encoding processing on the input training sample through the encoding subnetwork corresponding to the input training sample to obtain text features. The initial features are obtained based on the entity features and the text features.
18. The data classification model training apparatus according to claim 16 or 17, characterized by, The entity data includes at least one entity, and the entity features include entity subfeatures corresponding to the entities, and the input training sample processing module is further configured to perform attention allocation on the entity subfeatures corresponding to the entities based on the text features to obtain attention information corresponding to the entities. The attention information corresponding to the entities is normalized to obtain attention factors corresponding to the entities. Updated entity features are obtained based on the entity subfeatures corresponding to the entities and the attention factors, and the initial features are obtained based on the text features and the updated entity features.
19. The data classification model training apparatus according to claim 16 or 17, characterized in that, The input training sample processing module is further configured to perform forward encoding processing on a current input data through a current encoding subnetwork to obtain forward features, and perform reverse encoding processing on the current input data through the current encoding subnetwork to obtain reverse features. The features corresponding to the current input data are obtained based on the forward features and the reverse features.
20. The data classification model training apparatus of claim 15, wherein, The encoding layer includes at least two encoding subnetworks, the mapping layer includes at least two mapping subnetworks, the encoding subnetworks and the mapping subnetworks correspond to each other in a one-to-one manner, the initial features include initial subfeatures output by the encoding subnetworks, and the input training sample processing module is further configured to input the initial subfeatures output by the encoding subnetworks to corresponding mapping subnetworks to obtain intermediate subfeatures output by the mapping subnetworks, and obtain the intermediate features based on the intermediate subfeatures.
21. The data classification model training apparatus of claim 12, wherein, The encoding layer includes at least two encoding sub-networks, the mapping layer includes at least two mapping sub-networks, the encoding sub-networks and the mapping sub-networks correspond one by one, the first feature includes first sub-features output by respective encoding sub-networks of an intermediate data classification model, the second feature includes second sub-features output by respective encoding sub-networks of an updated data classification model, and the mapping layer training module is further configured to input respective second sub-features corresponding to the forward trained sample into corresponding mapping sub-networks of the updated data classification model to obtain corresponding respective predicted sub-features; obtaining an encoding sub-network and a mapping sub-network having a corresponding relationship as a target encoding sub-network and a target mapping sub-network; calculating a training loss value based on the first sub-feature output by the target encoding sub-network and the predicted sub-feature output by the target mapping sub-network corresponding to the same training sample to obtain a training loss value corresponding to each mapping sub-network; adjusting parameters of the corresponding mapping sub-network in the updated data classification model based on each training loss value until a convergence condition is met to obtain an updated intermediate data classification model.
22. A data classification apparatus characterized by comprising: The apparatus comprises: a data acquisition module configured to acquire data to be classified; a classification result determination module configured to input the data to be classified into a target data classification model to obtain a target classification result corresponding to the data to be classified; The target data classification model is obtained based on the following steps: training an encoding layer of an initial data classification model based on a current training sample corresponding to a current data classification task in a training sample set to obtain an intermediate data classification model, training the encoding layer of the intermediate data classification model based on an updated training sample corresponding to a next data classification task in the training sample set to obtain an updated data classification model, inputting forward trained samples of the updated training sample into the encoding layers of the intermediate data classification model and the updated data classification model respectively to obtain corresponding first features and second features, training a mapping layer of the updated data classification model based on the first features and the second features corresponding to the same training sample to obtain an updated intermediate data classification model, and returning to the step of training the encoding layer of the intermediate data classification model based on the updated training sample corresponding to the next data classification task until training is completed, and obtaining the target data classification model based on the intermediate data classification model corresponding to the training completion; the training sample includes text data and entity data, the text data refers to training text, and the entity data refers to each entity in the training text. 23.A computer device, comprising a memory and a processor, wherein the memory stores a computer program. The processor executes the computer program to implement the method of any one of claims 1-11.
24. A computer readable storage medium storing a computer program, wherein the computer program comprises instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1-23. The computer program is executed by the processor to implement the method of any one of claims 1-11.
25. A computer program product comprising computer instructions, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1-11. The computer program is executed by the processor to implement the method of any one of claims 1-11.
Citation Information
Patent Citations
Method for determining user tag and self-coding network training method and device
CN109753608A
Multi-task classification method and device and related equipment
CN111881968A