Classification model training method and device, classification method and device, equipment, medium and product
By using domain discriminator and adversarial loss in classification model training, adversarial domain adaptation is achieved, and the problem of poor performance of classification model under low resource labeling data is solved, and the classification performance and generalization ability of the model in specific fields is improved. .
Patent Information
- Application Number
- CN202411508185.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-14
AI Technical Summary
In the case of insufficient low resource labeling data in a specific field, the classification model performance caused by the transfer learning method is poor.
By using the domain discriminator to judge the domain of the sample during the classification model training process, and updating the model based on adversarial losses and classification losses, using data from the first and second fields to perform adversarial domain adaptation, reducing the Distribution differences improve classification performance.
In the case of low resource annotation data, the classification performance of the classification model is improved, and the generalization ability and robustness of the model are enhanced, especially in multi-field customer service scenarios.
Smart Images

Figure CN119312167A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to classification model training methods, classification methods, devices, equipment, media and products. Background Art
[0002] In the intelligent customer service scenario, the questions raised by users usually involve multiple different categories, such as "technical support", "order inquiry", "payment problem", etc. In order to efficiently classify these problems, transfer learning based on pre-trained language models (such as BERT, RoBERTa, etc.) is a more common traditional implementation method. It usually includes the following steps: first, collect and label customer problem data to build a dataset containing multi-category labels; second, use the pre-trained model for fine-tuning and apply it to the customer problem classification task. During the fine-tuning process, the model is usually trained with data from a specific field, so that it has a higher classification accuracy in that field. Finally, for different types of customer questions, the model maps the questions to the corresponding category labels through a classifier. However, this transfer learning method often requires a large amount of labeled data in a specific field for training to achieve better results. In the case of low resources in a specific field (insufficient labeled data in a specific field), the classification performance of the model obtained by the transfer learning method is poor. Summary of the invention
[0003] The present invention provides a classification model training method, a classification method, an apparatus, a device, a medium and a product, so as to solve the defect of poor classification performance of the classification model when there is insufficient labeled data in a specific field in the prior art, and to improve the classification performance of the classification model when there is insufficient labeled data in the specific field.
[0004] The present invention provides a classification model training method, comprising: Acquire sample data to be classified, input the sample data to a feature extraction module in a classification model, and acquire sample features output by the feature extraction module, wherein the field to which the sample data to be classified belongs is the first field or the second field; Inputting the sample features into a domain discriminator, obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, wherein the domain judgment result is used to judge the domain to which the sample data to be classified belongs; Inputting the sample features into a classification prediction module in the classification model to obtain a sample classification result output by the classification prediction module; An adversarial loss is generated based on the domain judgment result and the domain label corresponding to the sample data to be classified, a classification loss is determined based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and the classification model is updated based on the adversarial loss and the classification loss.
[0005] According to a classification model training method provided by the present invention, before inputting the sample data to be classified into a feature extraction module in the classification model, the method comprises: When the field corresponding to the sample data to be classified is the first field, the classification result label corresponding to the sample data to be classified is obtained from a labeled data set in the first field.
[0006] According to a classification model training method provided by the present invention, before inputting the sample data to be classified into a feature extraction module in the classification model, the method comprises: When the field corresponding to the sample data to be classified is the second field, if the classification result label corresponding to the sample data to be classified does not exist in the labeled data set corresponding to the second field, the sample data to be classified is input into the trained teacher model, and the result obtained by the teacher model for classifying the sample data to be classified is obtained as the classification result label, and the teacher model is used to classify the data in the second field.
[0007] According to a classification model training method provided by the present invention, the teacher model is a large language model.
[0008] According to a classification model training method provided by the present invention, before inputting the sample features into a domain discriminator and obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, the method comprises: A mask is randomly added to the sample features.
[0009] The present invention also provides a classification method, comprising: Obtaining data to be classified, and inputting the data to be classified into a trained classification model; Obtaining a classification result output by the classification model; Wherein, the classification model is trained based on any of the classification model training methods described above.
[0010] The present invention also provides a classification model training device, comprising: A sample feature acquisition module, used to acquire sample data to be classified, input the sample data to be classified into a feature extraction module in a classification model, and acquire sample features output by the feature extraction module, wherein the field to which the sample data to be classified belongs is the first field or the second field; A domain judgment result acquisition module, used to input the sample features into a domain discriminator, and obtain a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, wherein the domain judgment result is used to judge the domain to which the sample data to be classified belongs; A classification result acquisition module, used to input the sample features into the classification prediction module in the classification model, and obtain the sample classification result output by the classification prediction module; A model updating module is used to generate an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determine the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and update the classification model based on the adversarial loss and the classification loss.
[0011] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the classification model training method described above is implemented.
[0012] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the classification model training methods described above.
[0013] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the classification model training methods described above.
[0014] The classification model training method, classification method, device, equipment, medium and product provided by the present invention respectively input sample data to be classified from a first field and a second field into the classification model during the training process of the classification model, and provide a domain discriminator, and perform domain judgment on features extracted by a feature extraction module of the classification model through the domain discriminator, thereby realizing adversarial domain adaptation, so that the model can reduce the distribution differences between different fields while optimizing the classification accuracy. Even if there are few labeled data in a single field, the corresponding knowledge can be learned using labeled data from other fields, thereby improving the classification performance of the classification model in low-resource scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 It is a flow chart of the classification model training method provided by the present invention.
[0017] Figure 2It is a schematic diagram of the training architecture of the classification model in the classification model training method provided by the present invention.
[0018] Figure 3 It is a schematic diagram of the training process of the classification model in the classification model training method provided by the present invention.
[0019] Figure 4 It is a structural schematic diagram of a feature extraction module of a classification model in the classification model training method provided by the present invention.
[0020] Figure 5 It is a schematic diagram of the adversarial domain adaptation process in the classification model training method provided by the present invention.
[0021] Figure 6 It is a flow chart of the classification method provided by the present invention.
[0022] Figure 7 It is a structural schematic diagram of the classification model training device provided by the present invention.
[0023] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] Combine the following Figure 1-Figure 5 The classification model training method provided by the present invention is described. Figure 1 As shown, the classification model training method includes the steps of: S110, obtaining sample data to be classified, inputting the sample data to be classified into a feature extraction module in the classification model, obtaining sample features output by the feature extraction module, and the field to which the sample data to be classified belongs is the first field or the second field; S120, inputting the sample features into a domain discriminator, obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, the domain judgment result being used to judge the domain to which the sample data to be classified belongs; S130, inputting the sample features into a classification prediction module in the classification model, and obtaining the sample classification result output by the classification prediction module; S140, generating an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determining the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and updating the classification model based on the adversarial loss and the classification loss.
[0026] In the method provided by the present invention, the classification model includes a feature extraction module and a classification prediction module, the feature extraction module is used to extract features based on input data, and the classification prediction module is used to output classification results based on the extracted features. During the training process, the classification model and the domain discriminator are trained together, and the training is based on multiple groups of training data. Each group of training data includes sample data to be classified and sample labels corresponding to the sample data to be classified. The sample labels include domain labels and classification result labels. The domain labels reflect the real domain of the sample data to be classified, and the classification result labels reflect the real classification results of the sample data to be classified. The domain to which the sample data to be classified belongs is the first domain or the second domain. The first domain and the second domain are different domains, and there is no excessive limitation on what the specific domains are. The first domain is the target domain of the classification model, that is, after the classification model training is completed, the classification model is mainly used in the first domain.
[0027] There may be relatively few labeled data in the first domain. This situation can be called a low-resource scenario in the first domain. In view of the problem of poor classification performance obtained by training a classification model in a low-resource scenario, the method provided by the present invention is that during training, the sample data to be classified is first input into the feature extraction module in the classification model to obtain sample features, and the sample features are respectively input into the domain discriminator and the classification prediction module in the classification model. The domain discriminator determines which domain the sample data to be classified belongs to based on the sample features, and the classification prediction module classifies the sample data to be classified based on the sample features. An adversarial loss is generated based on the domain judgment result output by the domain discriminator and the domain label of the sample data to be classified, and a classification loss is generated based on the sample classification result output by the classification prediction module and the classification result label of the sample data to be classified. The classification model is updated based on the adversarial loss and the classification loss. In this way, for input data from different fields, the feature extraction module can extract features that make it impossible for the domain discriminator to distinguish the source of the features. In other words, the distribution differences between different fields can be narrowed, and features suitable for different fields can be learned. Even if there is insufficient labeled data in a specific field, classification knowledge can be learned through labeled data from other fields. At the same time, the classification loss can also ensure the accuracy of the classification results, so that the classification performance of the classification model finally trained is better.
[0028] like Figure 2As shown in the figure, the feature extraction module in the classification model can include the Tokenization module, the Embedding module, and the Encoding module. The Tokenization module is used to convert the input text into a Token sequence and add special tags (such as [CLS], [SEP]) for subsequent processing. This module converts the natural word into discrete tags that can be processed by the model. The Embedding module is used to map the Token sequence into a dense vector representation (including word embedding and position embedding) to provide the semantic and position information required by the model for the subsequent Encoding module. , after the Embedding module, the output embedding is The encoding module uses the Transformer structure for encoding, which can include a multi-layer Transformer encoding structure, such as Figure 3 As shown in the figure, the Transformer encoding structure contains multiple layers of self-attention and feedforward networks. Through the encoding module, the context feature representation can be extracted to obtain the feature h output by the feature extraction module. The lightweight Transformer structure reduces the computational complexity and memory usage of the classification model. This can reduce the number of model parameters while ensuring classification performance, so that it can be flexibly embedded and calculated in real time in scenarios with high computational timeliness requirements, such as intelligent customer service systems.
[0029] In one possible implementation, the sample features output by the feature extraction module can be directly input into the domain discriminator for discrimination to implement adversarial training, so that the feature extraction module can generate features that are not related to the domain, reduce the feature differences between different domains, learn classification knowledge from different domains, and help the model generalize better. In another possible implementation, a domain adaptation module can be set to add a mask to the sample features before inputting the sample features into the domain discriminator for discrimination. In other words, the sample features are dynamically masked. By combining dynamic masking and adversarial training, better adversarial training results can be obtained, so that the features extracted by the feature extraction module from data in different domains are closer, further reducing the differences between domains, and further enhancing the generalization of the model, so that the performance of the model in different domains is more robust, especially when facing complex multi-domain customer service problems, with stronger classification capabilities.
[0030] The domain discriminator is responsible for distinguishing whether the input data comes from the source domain or the target domain. The task of the domain discriminator is to determine whether the feature representation comes from the first domain or the second domain. This is the core part of domain adaptation, which narrows the gap between the source domain and the target domain through adversarial training. The processing of the domain discriminator can be expressed as: ,in, Indicates the domain judgment result. Representation domain discriminator based on sample features The process of making judgments.
[0031] The classification prediction module in the classification model uses the features output by the feature extraction module, maps the features to the classification space through the fully connected layer, outputs the classification results, and realizes the classification of user requests. For example, in the intelligent customer service scenario, the output is the category label of the user's question, such as "technical support", "order inquiry", "payment problem", "account settings", etc. The processing process of the classification prediction module can be expressed as: , where W represents the parameters of the classification prediction module.
[0032] When training the classification model, the domain label and classification result label corresponding to the sample data to be classified are first determined. The domain label is obtained by annotating the actual domain of the sample data to be classified. The classification result label corresponding to the sample field to be classified can be determined in different ways based on the different fields it belongs to. Specifically, before the sample data to be classified is input into the feature extraction module in the classification model, it includes: When the field corresponding to the sample data to be classified is the first field, a classification result label corresponding to the sample data to be classified is obtained from a labeled data set in the first field.
[0033] The first domain may correspond to a labeled data set, which includes data belonging to the first domain and its corresponding classification result labeling information. That is, the classification result label of the first domain is obtained based on the labeling. The training data set belonging to the first domain can be expressed as ,in, is the sample data to be classified belonging to the first field, is the corresponding classification result label, is the number of sample data to be classified belonging to the first field.
[0034] When the field corresponding to the sample data to be classified is the second field, if the classification result label corresponding to the sample data to be classified does not exist in the labeled data set corresponding to the second field, the sample data to be classified is input into the trained teacher model, and the result obtained by the teacher model for classifying the sample data to be classified is obtained as the classification result label, and the teacher model is used to classify the data in the second field.
[0035] For the second domain, it can also correspond to a labeled data set, which includes data belonging to the second domain and its corresponding classification result labeling information. The training data set belonging to the second domain can be expressed as ,in, Indicates the sample data to be classified belonging to the second field, is the corresponding classification result label, is the number of sample data to be classified belonging to the second field. It is understandable that when the classification result annotation information corresponding to the sample data to be classified belonging to the second field exists in the annotated data set of the second field, the classification result label corresponding to the sample data to be classified can be directly obtained from the annotated data set. In practical applications, data annotation mainly relies on manual work, which is a large workload. In one implementation of the method provided by the present invention, other models can be used to automatically classify the sample data to be classified belonging to the second field, and the output of the model can be used as the corresponding classification result label, which can reduce the workload.
[0036] In one possible implementation, the teacher model can be a large language model (LLM) to reduce the resource usage of a model specifically used to classify the sample data to be classified in the second field. Specifically, the generation of classification result labels based on the large language model can be to first design prompt words to guide the large language model to complete the classification action, for example: Input text: "I'm having trouble resetting my password, can you help me?"
[0037] Prompt design: "Categorize this request into the following categories: [Technical Support, Order Inquiry, Payment Issue, Account Setup, Other] based on the following customer request: 'I'm having trouble resetting my password, can you help me?'"
[0038] The large language model generates classification result labels (probability distribution): "Technical Support": 0.82,
[0039] "Order Query": 0.05,
[0040] "Payment Issue": 0.02,
[0041] "Account Settings": 0.08
[0042] "Other": 0.03.
[0043] It is worth noting that the classification result output by the large language model is not an exact result like labeling, but a distribution vector of the probability that the sample data to be classified belongs to each preset category, which can be called a soft label. , the generated soft label can be expressed as , is a probability distribution representing the probability of each class predicted by the teacher model.
[0044] like Figure 4 As shown in the figure, when the sample data to be classified belongs to the second domain, the large language model is used as the teacher model, the classification model is used as the student model, and the soft label is used as the supervisory signal to guide the student model to train. The student model gradually adjusts the model parameters based on the soft label so that its output is close to the output of the teacher model. At the same time, in the domain adaptation training, a small amount of sample data to be classified in the first domain is used, and adversarial training is used to reduce the difference in feature distribution between the first domain and the second domain, thereby improving the classification performance of the student model in the first domain.
[0045] The loss function of model training is described in detail below. In the method provided by the present invention, the training loss of the classification model includes two types: one is the adversarial loss of the domain discriminator, and the other is the classification loss of the classification prediction result output by the classification prediction module.
[0046] like Figure 5 As shown, the domain discriminator D attempts to distinguish the feature representations of the first domain and the second domain, and the training loss can be expressed as: ; in, represents adversarial loss, is the student model, that is, the sample features extracted by the classification model, is the weight, is the domain label, and denote the training datasets of the first domain and the second domain respectively.
[0047] The feature extraction module adjusts parameters through back propagation so that the domain discriminator cannot distinguish the source of the features: ,in, represents the parameters of the feature extraction module, Represents the parameters of the domain discriminator.
[0048] Therefore, the goals of adversarial training are: .
[0049] As for classification loss, there are two cases: the classification result label obtained by annotation and the classification result label generated by the model. The classification loss is obtained as follows: ,in, Adjust the balance of the two-class classification loss; is the classification loss of the student model on the labeled data, Measures the difference between the probability distribution of the student model and the teacher model output. For the labeled classification result labels, the cross entropy loss is used, and the formula is: ,in, represents the cross entropy loss, is the number of categories, is the classification result label, It is the sample data to be classified with the classification result label obtained by the classification model in the presence of annotations The sample classification results output above are Indicates the number of samples to be classified that have the labeled classification result labels. For the classification result labels generated by the model, KL divergence loss is used, and the formula is: ,in, represents the KL divergence loss, It is the sample data to be classified by the model in the second field The classification result labels generated on It is the sample classification result output by the classification model on the same data.
[0050] Based on the classification loss and adversarial loss, the classification model parameters are updated through the gradient descent algorithm. In order to calculate the gradient, the classification loss and adversarial loss need to be derived separately.
[0051] Classification Loss Parameters of the student model The gradient of is: ; in, is the gradient of the cross entropy loss, is the gradient of the KL divergence loss.
[0052] Adversarial Loss Parameters of the student model The gradient of is: .
[0053] Finally, the total gradient of the student model parameters is: .
[0054] The gradient is used to update the parameters of the student model, i.e., the classification model, so that it can learn knowledge from the teacher model and adapt to the data distribution of the target domain. By jointly optimizing these two loss functions, the classification model can have good classification performance in both the first domain and the second domain.
[0055] Based on the above classification model training method, the present invention also provides a classification method, such as Figure 6 include: S210, obtaining data to be classified, and inputting the data to be classified into a trained classification model; S220, obtaining the classification result output by the classification model; The classification model is obtained by training based on the classification model training method provided by the present invention.
[0056] The classification model training device provided by the present invention is described below. The classification model training device described below and the classification model training method described above can be referred to in correspondence with each other. Figure 7 As shown, the classification model training device provided by the present invention includes: The sample feature acquisition module 710 is used to acquire sample data to be classified, input the sample data to be classified into a feature extraction module in the classification model, and acquire the sample features output by the feature extraction module. The field to which the sample data to be classified belongs is the first field or the second field. The domain judgment result acquisition module 720 is used to input the sample features into the domain discriminator, and obtain the domain judgment result corresponding to the sample data to be classified output by the domain discriminator, and the domain judgment result is used to determine the domain to which the sample data to be classified belongs; The classification result acquisition module 730 is used to input the sample features into the classification prediction module in the classification model and obtain the sample classification result output by the classification prediction module; The model updating module 740 is used to generate an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determine the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and update the classification model based on the adversarial loss and the classification loss.
[0057] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the classification model training method and / or the classification method, which includes: obtaining sample data to be classified, inputting the sample data to be classified into the feature extraction module in the classification model, obtaining the sample features output by the feature extraction module, and the field to which the sample data to be classified belongs is the first field or the second field; inputting the sample features into the field discriminator, obtaining the domain judgment result corresponding to the sample data to be classified output by the field discriminator, and the domain judgment result is used to judge the field to which the sample data to be classified belongs; inputting the sample features into the classification prediction module in the classification model, and obtaining the sample classification result output by the classification prediction module; generating adversarial loss based on the domain judgment result and the field label corresponding to the sample data to be classified, determining the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and updating the classification model based on the adversarial loss and the classification loss. The classification method includes: obtaining data to be classified, inputting the data to be classified into the trained classification model; obtaining the classification result output by the classification model; wherein the classification model is trained based on the classification model training method as described above.
[0058] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0059] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the classification model training method and / or classification method provided by the above methods. The classification model training method includes: obtaining sample data to be classified, inputting the sample data to be classified into a feature extraction module in the classification model, obtaining sample features output by the feature extraction module, and the domain to which the sample data to be classified belongs is the first domain or the second domain; inputting the sample features into a domain discriminator, obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, and the domain judgment result is used to judge the domain to which the sample data to be classified belongs; inputting the sample features into a classification prediction module in the classification model, and obtaining a sample classification result output by the classification prediction module; generating an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determining the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and updating the classification model based on the adversarial loss and the classification loss. The classification method includes: obtaining data to be classified, inputting the data to be classified into a trained classification model; obtaining a classification result output by the classification model; wherein the classification model is trained based on the aforementioned classification model training method.
[0060] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the classification model training method and / or classification method provided by the above-mentioned methods, the classification model training method comprising: obtaining sample data to be classified, inputting the sample data to be classified into a feature extraction module in the classification model, obtaining sample features output by the feature extraction module, and the domain to which the sample data to be classified belongs is the first domain or the second domain; inputting the sample features into a domain discriminator, obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, and the domain judgment result is used to judge the domain to which the sample data to be classified belongs; inputting the sample features into a classification prediction module in the classification model, and obtaining a sample classification result output by the classification prediction module; generating an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determining the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and updating the classification model based on the adversarial loss and the classification loss. The classification method includes: obtaining data to be classified, inputting the data to be classified into a trained classification model; obtaining a classification result output by the classification model; wherein the classification model is trained based on the aforementioned classification model training method.
[0061] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0062] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A classification model training method, characterized in that: include: Acquire sample data to be classified, input the sample data to a feature extraction module in a classification model, and acquire sample features output by the feature extraction module, wherein the field to which the sample data to be classified belongs is the first field or the second field; Inputting the sample features into a domain discriminator, obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, wherein the domain judgment result is used to judge the domain to which the sample data to be classified belongs; Inputting the sample features into a classification prediction module in the classification model to obtain a sample classification result output by the classification prediction module; An adversarial loss is generated based on the domain judgment result and the domain label corresponding to the sample data to be classified, a classification loss is determined based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and the classification model is updated based on the adversarial loss and the classification loss.
2. The classification model training method according to claim 1, characterized in that: Before inputting the sample data to be classified into the feature extraction module in the classification model, it includes: When the field corresponding to the sample data to be classified is the first field, the classification result label corresponding to the sample data to be classified is obtained from a labeled data set in the first field.
3. The classification model training method according to claim 1, characterized in that: Before inputting the sample data to be classified into the feature extraction module in the classification model, it includes: When the field corresponding to the sample data to be classified is the second field, if the classification result label corresponding to the sample data to be classified does not exist in the labeled data set corresponding to the second field, the sample data to be classified is input into the trained teacher model, and the result obtained by the teacher model for classifying the sample data to be classified is obtained as the classification result label, and the teacher model is used to classify the data in the second field.
4. The classification model training method according to claim 3, characterized in that: The teacher model is a large language model.
5. The classification model training method according to claim 1, characterized in that: Before inputting the sample features into a domain discriminator and obtaining a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, the method includes: A mask is randomly added to the sample features.
6. A classification method, characterized in that: include: Obtaining data to be classified, and inputting the data to be classified into a trained classification model; Obtaining a classification result output by the classification model; Wherein, the classification model is trained based on the classification model training method according to any one of claims 1-5.
7. A classification model training device, characterized in that: include: A sample feature acquisition module, used to acquire sample data to be classified, input the sample data to be classified into a feature extraction module in a classification model, and acquire sample features output by the feature extraction module, wherein the field to which the sample data to be classified belongs is the first field or the second field; A domain judgment result acquisition module, used to input the sample features into a domain discriminator, and obtain a domain judgment result corresponding to the sample data to be classified output by the domain discriminator, wherein the domain judgment result is used to judge the domain to which the sample data to be classified belongs; A classification result acquisition module, used to input the sample features into the classification prediction module in the classification model, and obtain the sample classification result output by the classification prediction module; A model updating module is used to generate an adversarial loss based on the domain judgment result and the domain label corresponding to the sample data to be classified, determine the classification loss based on the difference between the sample classification result and the classification result label corresponding to the sample data to be classified, and update the classification model based on the adversarial loss and the classification loss.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it implements the classification model training method according to any one of claims 1 to 5 and / or the classification method according to claim 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the classification model training method as described in any one of claims 1 to 5 and / or the classification method as described in claim 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the classification model training method as described in any one of claims 1 to 5 and / or the classification method as described in claim 6.