TechTarget.com/searchenterpriseai

https://www.techtarget.com/searchenterpriseai/definition/fine-tuning

What is fine-tuning in machine learning and AI?

By Lev Craig

Fine-tuning is the process of taking a pretrained machine learning model and further training it on a smaller, targeted data set. The aim of fine-tuning is to maintain the original capabilities of a pretrained model while adapting it to suit more specialized use cases.

Building on top of an existing sophisticated model through fine-tuning enables machine learning developers to create effective models for specific use cases more efficiently. This approach is especially beneficial when computational resources are limited or relevant data is scarce.

The performance of a fine-tuned model can surpass that of the original pretrained model on the specific tasks for which it was fine-tuned. For example, a business incorporating generative AI into customer support might train a large language model (LLM) on its product information, policies and past customer interactions. This enterprise-specific training helps the fine-tuned model produce more useful, relevant responses compared with its more general pretrained counterpart.

How does fine-tuning work?

Fine-tuning begins with an existing model that has already been trained on a large, diverse data set, learning a wide range of features and patterns. For instance, a pretrained image recognition model might be trained on millions of images, ranging from landscapes to household objects to people.

As part of this initial training, the pretrained model learns to generalize by identifying underlying patterns and features in its training data. Over time, the model becomes able to correctly interpret new input. A large image model like this would gradually learn to detect whether an image contains a bird after analyzing thousands of images of birds.

But despite their impressive generalization abilities, off-the-shelf pretrained models do not always work well for niche use cases. The aforementioned model trained on general images might recognize a bird, broadly speaking, but struggle to accurately distinguish among species -- a problem when developing an app to help bird-watchers identify their sightings, for example.

Building a comprehensive image processing model from scratch for such a niche task would be computationally intensive, expensive and likely beyond the means of a small app developer. Fine-tuning plays a crucial role in such scenarios, taking advantage of the extensive foundational learning of pretrained models and adapting that baseline knowledge for specific tasks. In this way, fine-tuning strikes a balance between general knowledge and task-specific expertise.

To start fine-tuning a machine learning model, the model developer builds or selects a smaller, specialized data set targeted to their use case, such as a collection of bird photos. Although these fine-tuning data sets might comprise hundreds or thousands of data points, they are still generally much smaller than the original model's training data set.

After acquiring and preprocessing this additional data, the developer further trains -- or fine-tunes -- the pretrained model. The early layers of the neural network, which capture basic features such as simple textures in images or vector embeddings in text, typically remain unchanged, or "frozen." Later layers, in contrast, are adjusted or added to capture the new data and better match the task at hand.

This process aims to balance retaining the model's valuable foundational knowledge with improving its performance on the fine-tuning use case. To this end, model developers often set a lower learning rate -- a hyperparameter that describes how much a model's weights are adjusted during training. Setting a lower learning rate during fine-tuning helps prevent drastic changes to the already learned weights, ensuring the model preserves its existing knowledge.

What are the risks and benefits of fine-tuning?

As with any machine learning technique, fine-tuning a model has certain benefits and disadvantages.

The key benefits of fine-tuning include the following:

However, fine-tuning also comes with a number of risks and challenges, including the following:

Real-world applications for fine-tuning

Fine-tuning has many possible use cases in real-world settings. The following are a few examples:

RAG vs. fine-tuning vs. transfer learning

Retrieval-augmented generation (RAG), fine-tuning and transfer learning are distinct concepts that share some overarching similarities. Briefly, fine-tuning and transfer learning are strategies for applying preexisting models to new tasks, whereas RAG is a type of model architecture that blends external information retrieval with generative AI capabilities.

Transfer learning, the broadest concept of the three, involves using knowledge that a model learned from one task as the starting point for a second, related task. Transfer learning is a common strategy in deep learning fields such as NLP and computer vision, particularly for tasks where collecting extensive data is challenging.

Fine-tuning is a specific technique within the broader category of transfer learning that involves making small adjustments to a pretrained model's parameters to improve its performance on a specific task. This often includes modifying or adding certain layers in the model, while keeping most of the original pretrained model's structure.

Unlike transfer learning and fine-tuning, RAG refers to a specific type of NLP model architecture. RAG combines a pretrained language model with a knowledge retrieval system. Unlike fine-tuning and transfer learning, which are machine learning training methods, RAG is a technique for enhancing model output by incorporating additional information from external data sources.

In RAG, the model retrieves contextual information from an external knowledge source -- for example, a database or collection of documents -- in response to a user's query. A generative AI model, such as a transformer-based LLM, then uses that data to inform its output. This is particularly useful for applications where generating accurate responses requires information not contained within the LLM itself.

29 Jul 2024

All Rights Reserved, Copyright 2018 - 2026, TechTarget | Read our Privacy Statement