A method to reduce the cost of training sample annotation for transfer learning
By distinguishing between target task samples and source task samples in transfer learning, and using feature mapping functions to reduce the amount of labeling and avoid repeated labeling, the problems of high labeling cost and forgotten model debugging in migration learning are solved, and an efficient labeling process and stability are achieved. model performance.
Patent Information
- Application Number
- CN202010879066.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-08-27
AI Technical Summary
In transfer learning, the target task requires a large amount of labeled data to adapt the source task model, which results in high labeling costs and waste of repeated labeling and catastrophic forgetting problems in model debugging, which affects the learning effect of the target task.
By distinguishing processing among target task samples, only samples that are not located in the source task sample space are required to be labeled, and alternative samples are automatically found from the source task labeled sample set, and the source task samples are mapped to the common feature space using the feature mapping function. Reduce the amount of annotations and avoid duplicate annotations, and adjust annotation leverage parameters to balance cost and quality.
It effectively reduces the amount of training sample labeling, avoids repeated labeling of samples, maintains model performance, reduces labeling costs, and controls labeling costs by adjusting labeling lever parameters to ensure the quality of labeled samples.
Smart Images

Figure CN112016451B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of transfer learning of artificial intelligence, and in particular to a method for reducing the labeling cost of target task samples by utilizing source task knowledge and existing labeled data. Background Art
[0002] Currently, successful machine learning models attach great importance to data, and their high performance relies on a large amount of labeled data. Machine learning models have been successfully applied to tasks that have accumulated or can easily obtain a large amount of labeled data (such as computer vision, text translation, speech recognition, etc.). However, many application scenarios have not yet accumulated or are not easy to obtain a large amount of labeled data. In order to cope with the long tail of the distribution of application scenarios, the task knowledge that has been learned needs to be transferred to new tasks.
[0003] The goal of transfer learning is to transfer the knowledge learned from the source task to the target task. In the field of machine learning, the knowledge here is generally reflected in the structure and model parameters of the machine learning model (such as a deep neural network). At present, even if the target task is very similar to the source task, the structure and model parameters of the machine learning model trained on the source task need to be specifically adjusted before it can be effectively applied to the target task. Except for a few cases (such as zero-shot / one-shot / few-shot learning, etc.), model debugging still requires a large amount of target task labeled data. It takes a lot of time / money to add labels to these target task data.
[0004] In transfer learning, the knowledge / skills required by the target task and the source task should partially overlap (a basic condition for the success of transfer learning), that is, the sample distribution of the target task and the source task in a common feature space should partially overlap (such as Figure 1 ). In this case, the sampled samples of the target task (in the common feature space) will contain some samples that also belong to the source task, and the proportion of these samples increases as the similarity between the two tasks increases.
[0005] In practical applications, the source task sample annotation work is completed first. When annotating the target task samples, if the existing samples of the source task are not considered, some identical / similar samples in the source task sample set will be repeatedly annotated (located in Figure 1 This duplication of work causes cost waste, and the cost waste increases as the similarity of the two tasks increases.
[0006] A common practice is to use samples in the source task that are related to the target task directly as labeled samples for the target task. This can obtain a large number of labeled samples at one time, but there are the following problems: (1) The information of these source task samples is already contained in the partial model and parameters from the source task adopted by the target model, and using them again for training is a waste of computing resources. (2) The problem of repeated labeling waste when labeling new target task samples is not solved. (3) When the number of labeled samples from the source task is large, the targeted adaptation process for the target task almost becomes retraining a new model. (4) Since the source task and the target task are different, a large number of different samples ( Figure 1 Samples in region 1 in the middle) will affect the learning of the true target task.
[0007] The catastrophic forgetting of original knowledge that is common in the model debugging process also poses a challenge to sample labeling. Figure 1 For example, if only samples in region 3 are labeled to train the target model, even though part of the model and parameters from the source task were initially used, the model will still forget the knowledge in regions 1 and 2. For the target task, forgetting the knowledge in region 1 is not a big deal, but forgetting the knowledge in region 2 should not be a big deal.
[0008] The present invention provides a method for solving the above problems. Figure 1 The target task samples in the middle area 3 require annotation, and for the samples in the overlapping area 2, the best replacement is found from the labeled training sample set of the source task. In addition, this method can flexibly adjust the proportion of manually labeled samples according to the annotation budget, thereby balancing the annotation cost and generation quality of the labeled sample dataset.
[0009] Unlike general semi-supervised learning (semi-supervised learning usually automatically labels data based on the current model output, and the labels made by the model are often wrong, and the wrong samples will mislead the subsequent model learning), the samples retrieved from the source task sample set will not be mislabeled (unless the labels of the source task samples are originally wrong). Possible problems include (1) samples from region 1 are retrieved. In the ideal case of the best common mapping feature space, this problem will not occur on a large scale, and its worst impact is only to make the target task more generalized. (2) Samples from region 2 are retrieved as substitutes for the current target task samples, but the retrieved samples cannot truly represent the current target task samples. This is equivalent to not labeling the current target task samples, but labeling another target task sample.
[0010] The choice of common feature space will obviously affect the effect of the final model learning, but finding the best common feature space is a matter of transfer learning rather than the present invention. The present invention assumes that the mapping of source task and target task samples to the common feature space can be achieved by using part of the source task knowledge (i.e., the part of the model structure and model parameters learned in the source task and to be transferred to the target task). Summary of the invention
[0011] The purpose of the present invention is to overcome the defects and shortcomings of the prior art and provide a method for reducing the cost of training sample annotation for transfer learning.
[0012] The present invention is achieved in that:
[0013] This method is used to distinguish and process the samples to be labeled for the target task: target task samples that are not in the source task sample space are required to be labeled; for target task samples that are in the source task sample space, the best replacement is automatically found from the source task labeled sample set. Under the premise of keeping the number of labeled samples unchanged and not significantly reducing the model training effect, this method can flexibly adjust the proportion of manually labeled samples according to the labeling budget, thereby balancing the labeling cost and generation quality of the labeled sample data set.
[0014] The method comprises the following specific steps:
[0015] Step 1: Construct a replacement sample set: Take out samples with the target task category label from the source task labeled sample set as the replacement sample set S.
[0016] S={(X c ,Y c ),c=1,2,...,l s} is a replacement sample set, and there are l s There are different sample subsets, each of which contains a sample feature dataset X c ={x i ,i=1,2,...,n c} and a corresponding sample annotation dataset Y c ={y i ,i=1,2,...,n c}, where x i is the feature vector of the i-th sample, y i ∈{1,2,...,l s} is the label category of the i-th sample, n c is the number of samples in the cth sample subset;
[0017] Step 2: Map the replacement sample set to the common feature space: Use the function f() to map each sample feature vector in the replacement sample set S to the common feature space, and then construct a new data set S f . Wherein, f() is a feature mapping function, which maps a non-fixed dimensional feature vector of any sample into another fixed dimensional feature vector. The vector space where the mapped feature vector resides is called a common feature space. In the present invention, the feature mapping function f() is a partial model (including model structure and model parameters) trained on the labeled sample set of the source task; the new data set S f ={(X f,c ,Y c ),c=1,2,...,l s}, where X f,c ={f(x i ),i=1,2,...,n c This step pre-calculates f(z j ) is used to reduce repeated calculations in steps 4 and 5 and improve calculation efficiency.
[0018] Step 3, construct the target task sample set U to be labeled: select N samples from the unlabeled sample pool of the target task to form the set U. The selection method can be random selection, or an active learning method, such as selecting N samples with the largest information entropy for the current target model.
[0019] The value of N is determined by the following rule: N = ρ * T. T is the number of samples that require manual annotation, which is calculated by the annotation budget D of this round and the manual annotation cost C of a single sample: T = round (D / C); ρ ∈ [1,5] is the annotation leverage, that is, the number of annotated samples obtained in the end is ρ times the number of actual manual annotations T.
[0020] Step 4: Calculate the difference between the target task sample and the replacement sample set. i The difference with the replacement sample set S is where dist(·,·) calculates the Euclidean distance between two vectors, z j is the feature vector of the jth sample in the replacement sample set S.
[0021] Step 5: Labeling and replacement of target task samples. The 3T / 4 samples in the target task sample set U with the largest difference from the replacement sample set S are required to be manually labeled; for the remaining samples, the most similar samples in the replacement sample set are selected as replacements with probability 1-T / 4 / (N-3T / 4), and are required to be manually labeled with probability T / 4 / (N-3T / 4).
[0022] Among them, the target task sample xi The most similar sample in the replacement sample set The selection method is as follows: y * is the feature vector in the replacement sample set The corresponding annotation category.
[0023] Step 6, put into the labeled target task sample pool: put the N labeled samples obtained in step 5 into the labeled target task sample pool L.
[0024] Step 7: Train the target task model: Use the currently labeled target task sample pool L to train the target task model.
[0025] Step 8: Repeat steps 3 to 7 until the target task model meets the performance requirements or there is no need for additional annotation.
[0026] Compared with the prior art, the present invention has the following advantages and effects:
[0027] (1) Reducing the amount of training sample annotations. The present invention only selects samples that represent the difference between the source task and the target task for annotation, rather than requiring annotation of all target task samples.
[0028] (2) Avoid duplicate sample labeling. If the target task sample is the same or similar to the source task training sample, it will not be required to be labeled.
[0029] (3) Increase the number of labeled samples without increasing the labeling cost. If the target task sample is the same or similar to a source task training sample, the corresponding training sample in the source task is automatically retrieved to replace the current target task sample, and the labeling result of the training sample is also retrieved.
[0030] (4) The actual sample labeling cost can be controlled by adjusting parameters. In the present invention, a labeling lever parameter is used to control the proportion of manually labeled samples in the total number. When the total number of samples remains unchanged: when the lever parameter is reduced, more samples are required to be manually labeled and fewer samples are replaced by samples in the source task, and the labeling cost increases; when the lever parameter is increased, fewer samples are required to be manually labeled and more samples are replaced by samples in the source task, and the labeling cost decreases.
[0031] (5) The model performance can be kept stable while compressing the annotation cost. The annotation lever parameters of the present invention can be adjusted within a wide range, and the quality of the obtained annotation sample set remains good, that is, the accuracy of the model trained by this annotation sample set will not be significantly reduced.
[0032] (6) Can be used in conjunction with any sample selection method. For example, the present invention can process samples from any sample selection method (e.g., randomly selected samples or an active learning method), further reducing the annotation cost without significantly affecting the effect of the method.
[0033] (7) It is applicable to application scenarios where the model needs to be updated (the model at time t corresponds to the source task model, and the model at time t+1 corresponds to the target task model), and where a personalized model (corresponding to the target task model) is established based on the general model (corresponding to the source task model).
[0034] (8) Steps 3, 4, and 5 play a key role in achieving the goal of the method of the present invention, that is, reducing the target task sample labeling cost without losing the target model performance. This is reflected in: in step 3, the method of the present invention uses a labeling lever ρ∈[1,5] to make the labeling cost adjustable. When the total number of samples obtained remains unchanged: when the lever parameter is reduced, more samples are required to be manually labeled and fewer samples are replaced by samples in the source task, and the labeling cost increases; when the lever parameter is increased, fewer samples are required to be manually labeled and more samples are replaced by samples in the source task, and the labeling cost decreases; steps 4 and 5 are used to ensure that the obtained labeled sample set does not cause performance loss of the target task model as much as possible. It is mainly guaranteed from two aspects: a) the difference between the part of the replacement samples from the source task and the replaced target task samples is the smallest. b) the difference between the part of the target task samples that are manually labeled and the existing samples of the source task is the largest. Step 4 includes the difference measurement method necessary to achieve the previous two guarantees. Step 5 distinguishes the target task samples to be manually labeled and the target samples to be replaced by the source task samples based on this difference measurement. In order to avoid excessive aggregation of manually labeled samples in the target task sample space, step 5 randomly selects a small number (T / 4) target task samples (they are not necessarily the most different from the existing samples of the source task) for manual labeling. These samples will be scattered in the target task sample space, increasing the internal diversity of the entire manually labeled sample set. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of the sample distribution of source tasks and target tasks;
[0036] Figure 2 It is a flowchart of the method for reducing the cost of training sample annotation for transfer learning proposed by the present invention. DETAILED DESCRIPTION
[0037] The technical solution of the present invention will be clearly and completely described below in conjunction with embodiments.
[0038] Embodiment 1:
[0039] This embodiment applies the technical solution provided by the present invention to obtain labeled data for model training for a machine vision task of identifying cat and dog pet pictures.
[0040] Preparation and instructions before implementation:
[0041] Source task: CIFAR-10 classification.
[0042] Source task labeled sample set: open dataset CIFAR-10, with 10 different object categories (including cats and dogs), each category has 6000 32*32 size color images.
[0043] Source task model: A 10-class classification model trained on the CIFAR-10 dataset. This model is a deep neural network model with a VGG16 structure.
[0044] Target task: Accurately determine whether the animal in an input image from an Internet pet website is a cat, dog, or other (divided into 3 categories).
[0045] Unlabeled sample set for the target task: 50,000 pet color pictures of different sizes downloaded from pet websites. Most of them are cats and dogs, and a small number are other pets such as lizards, mice, pigs, etc. The pictures are not labeled with categories.
[0046] Target task model: The network structure is consistent with the source task model, only the number of outputs of the last classifier layer is changed from 10 to 3. The initial model parameters are all migrated from the source task model; when the model parameters are adapted using the target task samples, the feature extraction network module (the part before the fully connected layer in the VGG16 structure) is frozen.
[0047] Public feature mapping function: The feature extraction network module of the source task model (the part before the fully connected layer in the VGG16 structure) is used as the public feature mapping function f().
[0048] The unit price C for labeling and the total budget D: The unit price for labeling a certain category of pictures is C = 0.1 yuan / picture, and the current budget for labeling is D = 500 yuan.
[0049] Expected number of labeled samples for the target task: >= 10,000
[0050] If the performance of the target task model does not meet expectations, an additional annotation budget of 200 yuan can be added.
[0051] Start implementing the program (such as Figure 2 shown):
[0052] (1) Take out the cat and dog images from the labeled sample set of the source task to form the replacement sample set S. Another feasible approach is to remove the non-animal categories (airplanes, cars, ships, trucks) in the labeled sample set of the source task, and then change the non-cat and dog categories (birds, deer, frogs, horses) to "others" to form the replacement sample set S.
[0053] (2) Use a common feature mapping function to map all samples in the replacement sample set to a common feature space. That is, each sample in the replacement sample set is used as the input of the source task model, and then the corresponding output is taken out at the output end of the feature extraction network module of the source task model, and all the outputs form a new set.
[0054] (3) Select N = ρ*T samples from the target task unlabeled sample set to form the target task sample set U to be labeled. Using the budget funds, you can ask people to label T = D / C = 500 / 0.1 = 5000 pictures. In order to get > = 10000 labeled pictures in the end, the labeling leverage ρ ≥ 2 is required. Here, ρ = 2, then N = 10000 in the end.
[0055] Sample selection method 1: randomly select N samples from the unlabeled sample set of the target task.
[0056] Sample selection method 2 uses the maximum information amount strategy of active learning to select N samples. The specific operation is as follows: First, each sample x in the unlabeled sample set of the target task i As the input of the current target task model, the probability p(y i |x i ),y i =0,1,2, where 0, 1, 2 represent cats, dogs, and others respectively; then, calculate the information entropy of the sample Finally, all samples are sorted in descending order according to information entropy, and the first N samples of the sorted sample sequence are taken.
[0057] (4) Calculate the difference between the target task sample and the replacement sample set. i The difference with the alternative sample set S is calculated as where dist(·,·) calculates the Euclidean distance between two vectors, z j is the feature vector of the jth sample in the replacement sample set S. j ) has been calculated in step (2) and can be directly applied here without repeated calculation.
[0058] (5) Sort all samples in the target task sample set U in descending order according to their difference from the alternative sample set S. Manual labeling is required for the first 3T / 4 samples. For the remaining samples, the most similar sample in the alternative sample set is selected as a replacement with probability 1-T / 4 / (N-3T / 4) and manual labeling is required with probability T / 4 / (N-3T / 4). i The most similar sample in the replacement sample set The selection method is as follows: y * is the feature vector in the replacement sample set The corresponding annotation category.
[0059] (6) Put the N labeled samples obtained in step (5) into the labeled sample pool L of the target task.
[0060] (7) Use the samples in the labeled sample pool L of the current target task to debug the target task model.
[0061] (8) Test the performance of the target task model. If the performance does not meet expectations, add an additional annotation budget of RMB 200 and repeat steps 3 to 7.
[0062] It should be understood that the invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall be within the scope of protection of the claims attached to the invention if they do not depart from the spirit and scope of the invention.
Claims
1. A method for reducing the cost of training sample annotation for transfer learning, characterized in that: This method is used to distinguish and process the target task samples to be labeled: target task samples that are not in the source task sample space are required to be labeled; for target task samples that are in the source task sample space, the best replacement is automatically found from the source task labeled sample set; The method includes obtaining labeled data for model training for a machine vision task of identifying cat and dog pet pictures; wherein the source task includes CIFAR-10 classification, the labeled sample set of the source task includes the open data set CIFAR-10, which has 10 different object categories, and each category has 6000 32*32 color images; the source task model includes a 10-classification model trained on the basis of the CIFAR-10 data set; the model is a deep neural network model with a VGG16 structure; the target task includes accurately judging whether the animal in an input picture from an Internet pet website is a cat, a dog or other; the unlabeled sample set of the target task includes 50,000 pet color pictures of different sizes downloaded from the pet website, and the pictures have no labeled categories; the network structure is consistent with the source task model, and only the output number of the last classifier layer is changed from 10 to 3; the feature extraction network module of the source task model, that is, the part before the fully connected layer in the VGG16 structure, is used as a public feature mapping function f(); Step 1: Construct a replacement sample set: Take samples with the target task category label from the source task labeled sample set as the replacement sample set S; Step 2, mapping the replacement sample set to the common feature space; Step 3: construct a target task sample set U to be labeled; Step 4, calculate the difference between the target task sample and the alternative sample set; Step 5: label and replace target task samples; Step 6: Add the labeled target task sample pool; Step 7: training the target task model; Step 8: Repeat steps 3 to 7 until the target task model meets the performance requirements or there is no need for additional annotation. The alternative sample set constructed in step 1 includes: S = {(X c ,Y c ),c=1,2,...,l s } is a replacement sample set, and there are l s There are different sample subsets, each of which contains a sample feature dataset X c ={x i ,i=1,2,...,n c } and a corresponding sample annotation dataset Y c ={y i ,i=1,2,...,n c }, where x i is the feature vector of the i-th sample, y i ∈{1,2,...,l s } is the label category of the i-th sample, n c is the number of samples in the cth sample subset; In step 2, mapping the replacement sample set to the common feature space includes: using function f() to map each sample feature vector in the replacement sample set S to the common feature space, thereby constructing a new data set S f ; Where f() is the feature mapping function; In step 3, constructing the target task sample set U to be labeled includes: selecting N samples from the unlabeled sample pool of the target task to form the set U; wherein the value of N is determined by the following rule: N = ρ * T; T is the number of samples required to be manually labeled, which is calculated by the current round of labeling budget D and the manual labeling cost C of a single sample: T = round (D / C); ρ∈[1,5] is the labeling leverage, that is, the number of labeled samples finally obtained is ρ times the number of actual manual labels T; In step 4, the difference between the target task sample and the alternative sample set is calculated as follows: i The difference with the replacement sample set S is where dist(·,·) calculates the Euclidean distance between two vectors, z j is the feature vector of the jth sample in the replacement sample set S; The target task sample labeling and replacement in step 5 includes: requiring manual labeling of the 3T / 4 samples in the target task sample set U that have the largest difference from the replacement sample set S; for the remaining samples, taking the most similar sample in the replacement sample set as a replacement with probability 1-T / 4 / (N-3T / 4), requiring manual labeling with probability T / 4 / (N-3T / 4); In step 6, putting the labeled target task sample pool is to put the N labeled samples obtained in step 5 into the labeled target task sample pool L; The target task model is trained in step 7 by using the currently labeled target task sample pool L to train the target task model.
Citation Information
Patent Citations
Transfer learning method and device
CN104616031A
Domain adaptation method based on deep network and confrontation technology
CN108921281A
Classifier training method, apparatus, electronic apparatus, and computer readable medium
CN109460795A
Cross-domain text sentiment classification method based on domain confrontation self-adaption
CN109492099A
Target detection method based on full-automatic learning
CN111191732A
