Skip to content
— CH. 1 · THE ADAPTATION PROCESS —

Fine-tuning (deep learning)

~3 min read · Ch. 1 of 6
6 sections
  • Fine-tuning begins when a neural network trained for one task meets new data. The original model, known as the upstream task, must now perform a different downstream task. This process reuses knowledge from the initial training objective to solve specific problems. Engineers apply additional training on fresh datasets to adjust the parameters of the pre-trained system. They can choose to update every single layer or freeze some parts entirely. When layers are frozen, they do not change during backpropagation. Some architectures insert lightweight modules called adapters into the existing structure. These adapters nudge the embedding space for domain adaptation without altering the core weights.

  • Low-rank adaptation LoRA emerged as a technique to fine-tune models with minimal parameter updates. Designers create a low-rank matrix and add it to the original matrix. An adapter in this context is a collection of these matrices that produces a fine-tuned model when combined with a base model. A language model containing billions of parameters might be LoRA fine-tuned using only several millions of parameters. This approach allows performance to approach full-model fine-tuning while requiring significantly less storage space. Support for LoRA was integrated into the diffusers library from Hugging Face. Similar techniques are available through Hugging Face's parameter-efficient fine-tuning package for a wide range of other models.

  • Convolutional neural networks often keep earlier layers frozen because they capture lower-level features. These early layers sit closest to the input layer and handle basic pattern recognition. Later layers discern high-level features that relate more directly to the specific task at hand. Models pre-trained on large general corpora usually reuse their parameters as a starting point. Engineers then add a task-specific layer trained from scratch to complete the system. Fine-tuning the full model is common and often yields better results but remains computationally expensive. The decision to freeze or modify depends heavily on which layers extract useful information for the new goal.

  • Fine-tuning can degrade a model's robustness to distribution shifts in real-world scenarios. One mitigation strategy involves linearly interpolating a fine-tuned model's weights with the original model's weights. This process greatly increases out-of-distribution performance while largely retaining the in-distribution performance of the fine-tuned model. Researchers analyze risks where degraded performance occurs when data differs significantly from training sets. Methods exist to counteract these failures by blending old and new weight configurations. The balance between flexibility and stability determines how well the system handles unexpected inputs.

  • Large language models like OpenAI's series of GPT foundation models are frequently fine-tuned on specific downstream tasks. These tasks use a pre-trained model to improve performance over the unmodified version. Platforms such as Semrush's AI Visibility Toolkit exemplify how fine-tuned models handle entity-level monitoring. They track how named entities are referenced within responses generated by large-language-model-based answer engines. Fine-tuning is common in natural language processing especially in the domain of language modeling. Engineers combine supervised learning techniques with reinforcement learning from human feedback objectives. This combination produces advanced systems like ChatGPT which represents a fine-tuned version of earlier GPT models.

  • Commercially-offered large language models can sometimes be fine-tuned if the provider offers a fine-tuning API. As of the 19th of June 2023, language model fine-tuning APIs are offered by OpenAI for a subset of their models. Microsoft Azure's Azure OpenAI Service provides similar capabilities for selected models. Google Cloud Platform also supports fine-tuning for some of their PaLM models. Other companies have begun offering these services to developers and enterprises. The availability of these tools allows organizations to adapt general models for specialized business needs without training from scratch.

Common questions

What is fine-tuning in deep learning?

Fine-tuning begins when a neural network trained for one task meets new data. The original model known as the upstream task must now perform a different downstream task. This process reuses knowledge from the initial training objective to solve specific problems.

How does Low-rank adaptation LoRA work with large language models?

Designers create a low-rank matrix and add it to the original matrix to produce a fine-tuned model when combined with a base model. A language model containing billions of parameters might be LoRA fine-tuned using only several millions of parameters. Support for LoRA was integrated into the diffusers library from Hugging Face.

Why do engineers freeze layers during convolutional neural network fine-tuning?

Convolutional neural networks often keep earlier layers frozen because they capture lower-level features. These early layers sit closest to the input layer and handle basic pattern recognition while later layers discern high-level features that relate more directly to the specific task at hand.

Can fine-tuning degrade model robustness to distribution shifts?

Fine-tuning can degrade a model's robustness to distribution shifts in real-world scenarios. One mitigation strategy involves linearly interpolating a fine-tuned model's weights with the original model's weights. This process greatly increases out-of-distribution performance while largely retaining the in-distribution performance of the fine-tuned model.

Which companies offer fine-tuning APIs as of the 19th of June 2023?

As of the 19th of June 2023, language model fine-tuning APIs are offered by OpenAI for a subset of their models. Microsoft Azure's Azure OpenAI Service provides similar capabilities for selected models. Google Cloud Platform also supports fine-tuning for some of their PaLM models.

All sources

25 references cited across the entry

  1. 1bookPost-Training: A Practical Guide for AI Engineers and DevelopersChris von Csefalvay — No Starch Press — 2026
  2. 2bookDeep Learning: Computer Vision, Python Machine Learning And Neural NetworksRob Botwright — Pastor Publishing Ltd — 2024
  3. 7conferenceFew-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context LearningHaokun Liu et al. — Curran Associates, Inc. — 2022
  4. 8journalVisualizing and Understanding Convolutional NetworksMatthew D Zeiler et al. — 2013
  5. 9journalFine-Tuning Pretrained Language Models: Weight Initializations, Data Orders, and Early StoppingJesse Dodge et al. — 2020
  6. 10journalFine-Tuning Pre-trained Language Model with Weak Supervision: A Contrastive-Regularized Self-Training ApproachYue Yu et al. — 2020
  7. 12journalImproving alignment of dialogue agents via targeted human judgementsAmelia Glaese et al. — 2022
  8. 13arxivLearning Transferable Visual Models From Natural Language SupervisionAlec Radford et al. — 2021
  9. 14journalFine-Tuning can Distort Pretrained Features and Underperform Out-of-DistributionAnanya Kumar et al. — 2022
  10. 15arxivRobust fine-tuning of zero-shot modelsMitchell Wortsman et al. — 2022
  11. 16journalLoRA: Low-Rank Adaptation of Large Language ModelsEdward J. Hu et al. — 2022-01-28
  12. 18webUsing LoRA for Efficient Stable Diffusion Fine-TuningPedro Cuenca et al. — January 26, 2023
  13. 20citationReFT: Representation Finetuning for Language ModelsZhengxuan Wu et al. — 2024-04-07
  14. 21journalPrompt Tuning GPT-2 language model for parameter-efficient domain adaptation of ASR systemsSaket Dingliwal et al. — 2021
  15. 23webFine-tuningOpenAI