What is transfer learning?
Transfer learning is a technique where a model trained on one task is reused as the starting point for a different but related task. Instead of starting from random weights, the new model starts from weights that already encode useful features, such as edges and shapes for images or grammar and word meaning for text. Only part of the network, or all of it with a small learning rate, is then trained on the new data.
Transfer learning is the default way to build vision and language models when labeled data is limited. A classifier for skin lesions, crop diseases, or factory defects usually starts from a network pretrained on ImageNet. Text classifiers, chatbots, and code assistants start from pretrained language models such as BERT or GPT. It cuts the data needed from millions of examples to thousands or fewer, and training time from days to hours.
Key ideas
- Transfer learning starts a new task from a model already trained on a large related dataset.
- Early CNN layers learn general features such as edges and textures, while later layers become task-specific.
- Freezing keeps a layer's weights fixed, and fine-tuning updates them with a small learning rate.
- Smaller datasets call for freezing more layers, and larger datasets allow fine-tuning more of the network.
- Fine-tuning reaches good accuracy with far less labeled data and compute than training from scratch.
- Pretrained language models such as BERT and GPT apply the same idea to text.
Short takes on this topic
Common questions
What is the difference between transfer learning and fine-tuning?
Transfer learning is the general idea of reusing a model trained on one task for another. Fine-tuning is one way to do it: continue training some or all of the pretrained weights on the new data. The other common way is feature extraction, where the pretrained network stays frozen and only a new classifier on top is trained.
Does transfer learning work for NLP?
Yes, and it is now the standard approach. ULMFiT (2018) showed that fine-tuning a pretrained language model beat task-specific models on text classification, and BERT and GPT made the pattern universal. Almost every modern NLP system starts from a pretrained Transformer.
What is negative transfer?
Negative transfer is when starting from pretrained weights gives worse results than training from scratch. It can happen when the source and target domains are very different, or when an aggressive learning rate destroys the pretrained features early in fine-tuning. Comparing against a scratch baseline on a validation set is the way to detect it.
What is domain adaptation?
Domain adaptation is a form of transfer learning where the task stays the same but the input distribution changes, for example a sentiment model trained on movie reviews applied to product reviews. Methods range from fine-tuning on a small labeled sample of the new domain to training on unlabeled target data so that features from both domains look alike.
Related explainers
- Convolutional Neural Networks — How CNNs see and understand images
- Feature Extraction — How networks find patterns in raw data
- LoRA & Parameter-Efficient Fine-Tuning — Adapt large models by training tiny low-rank matrices instead of all the weights
- BERT & Masked Language Modeling — Mask a word, predict it from both sides — how BERT learns deep bidirectional representations
- Data Augmentation — Artificially expand training data with transformed copies to reduce overfitting
- Overfitting & Underfitting — The bias-variance tradeoff and generalization
References
- Yosinski et al. (2014), "How transferable are features in deep neural networks?"
- Zeiler & Fergus (2013), "Visualizing and Understanding Convolutional Networks"
- Howard & Ruder (2018), "Universal Language Model Fine-tuning for Text Classification" (ULMFiT)
- Raghu et al. (2019), "Transfusion: Understanding Transfer Learning for Medical Imaging"
- Stanford CS231n, "Transfer Learning" course notes
Last updated