Jeffrey Erickson | Senior Writer | February 25, 2025
As AI becomes more useful to businesses and AI agents in particular take on more complex workflows, AI fine-tuning will be an important part of the story. Those agents can answer questions about data and take actions on our behalf—writing code, managing calendars, presenting analytic insights, and so much more. Along the way, AI models will have to work together to investigate data and document stores, collect information, double-check their accuracy, trigger the right actions, and communicate them. The sophisticated AI models involved will be well-versed in general patterns of language, but they’ll also need to be optimized for specific domains with their own parlance, knowledge base, and more. How can the fine-tuning process help an AI model, and future AI agents, get the nuances and details right? We’ll explore aspects of AI model fine-tuning below.
AI model fine-tuning is the process that data scientists and machine learning (ML) engineers use to adapt a trained ML model to perform better at a specific task. Fine-tuning, for example, might be used to take a general-purpose large language model (LLM), such as Cohere’s Command or Meta’s Llama 2, and make it more conversant in a healthcare setting or a customer service role.
Those general-purpose models, sometimes called “foundation models,” are trained on large, general data sets—such as data from nearly the entire open internet. This helps them learn and understand a broad range of features and patterns. Some have a good handle on language; others can recognize and manipulate multimodal data, such as images, video, and audio as well as text.
Fine-tuning takes this sophisticated model and continues its training on a smaller data set drawn from a specific task or business domain. This gives the model an understanding of the taxonomy, context, and even specialized knowledge in that field.
The idea is to keep the vast knowledge from the model’s original training regimen while giving it a better understanding of the nuances and details of the domain where the AI model will be working. For example, a general-purpose AI model can be fine-tuned to read and discuss medical imaging, or an LLM-driven chatbot that’s become more fluent in local dialects can be fine-tuned to improve its role in customer service. The race to construct highly capable AI agents in a wide range of domains will often depend on fine-tuned models. Here’s a deeper discussion of the methods and mechanics of fine-tuning.
Key Takeaways
A primary challenge teams face when undertaking AI fine-tuning is the availability of high-quality, labeled data relevant to their use cases—acquiring or creating such data can be expensive and time-consuming. For example, labeling data can mean hours of noting areas in images that an AI should learn to recognize, or labeling sections of text to highlight key information. Still, fine-tuning offers compelling advantages that make it a crucial technique in modern AI development. Let’s look at some pros and cons.
AI fine-tuning works by using existing models as starting points. These foundation models, such as Meta’s Llama 2 or Cohere’s Command, are commonly available from cloud providers. Many organizations will bring other models to their data science platforms from centralized repositories, such as Hugging Face, TensorFlow Hub, and PyTorch Hub, that host pretrained machine learning models.
Start with a Pretrained Model
Choose a model that’s well suited to your task, whether that’s classifying text, analyzing sentiment, answering questions, writing articles, generating code, detecting objects, or any other job that requires AI or ML.
Fine-tuning an AI model requires three basic ingredients: a collection of properly formatted data, the right foundation model, and an infrastructure that provides the neural networks for deep learning and the GPUs to power the training regimen. These resources are often assembled in a data science platform or, more recently, a generative AI cloud service.
As often happens with technology, the AI fine-tuning process has gotten easier over time, thanks to new tools and infrastructure services from open source projects and cloud-provider development teams. These tools and services are helping automate fine-tuning—including complex tasks we’ll discuss, such as hyperparameter optimization, model selection, and data preprocessing. That’s making the process more accessible to nonexperts.
In fact, industry observers have noted that tools have gotten so good at abstracting away the data science minutia of fine-tuning that the hardest part is now collecting and formatting the best possible data set. Here, too, there are libraries of data ready-made for various domains, such as healthcare and finance, and capabilities, such as computer vision, sentiment analysis, or anomaly detection. In fact, a growing trend is to use a model for your use case that’s already been fine-tuned for that task using these libraries. From there, the organization might further fine-tune using a smaller data set and, perhaps, use a retrieval-augmented generation, or RAG, architecture to further improve AI outputs.
Companies have found ways to supplement traditional fine-tuning methods with a technique called reinforcement learning. This allows AI models to learn through trial and error and self-improvement rather than using a separate process of data set labeling and supervised fine-tuning.
How to Fine-Tune an AI Model in Four Steps
1. Use a pretrained model: The first step is to select a foundation model that’s appropriate to the task. There are popular models for natural language processing, computer vision, text generation, and other areas.
2. Add new data: Next, gather and prepare a task-specific data set. These might consist of labeled customer reviews or sample questions and answers in the domain your model is meant to address.
3. Adjust: Step three is to adjust the model as needed. Adjustments might include freezing layers to preserve the model’s previous learning; adjusting the learning rate, which can also help preserve the model’s existing knowledge; and adding layers where completely new tasks are learned, such as a classification layer for a text classification or a regression layer for predictions.
4. Train the model: This process involves feeding the new data through the model and updating the model’s parameters. The goal is to refine the model’s performance of your task while keeping the general knowledge from its initial training.
When fine-tuning a model, there are a range of techniques available to choose from. The first decision is whether you need full or selective fine-tuning.
Full fine-tuning is a process where all the layers and parameters of a foundational model are updated during the training process. This is a good choice when you have a large and diverse data set that can adequately update the model’s parameters without danger of overfitting.
Selective fine-tuning involves updating only a subset of the model’s layers or parameters using a smaller data set. This method is good for preserving the general knowledge of the foundation model and lowering the time and compute cost of the training regime. Here are examples of techniques for selective fine-tuning.
In some use cases, it makes sense to design and train your AI model from scratch. In most cases, however, an organization can get the desired result by fine-tuning a foundation model.
Training an AI model from scratch can be the better choice in a few instances. One example is when the domain you’re working in is very exacting, such as a niche medical application with perhaps very specific image data. Training from scratch requires you to assemble a large data set and run long rounds of training on AI-specific infrastructure. This can be expensive, requiring up to thousands of GPUs and millions of dollars. It’s also a task where the expertise of data scientists and ML engineers will be needed.
Fine-tuning an AI model, on the other hand, involves taking a foundation model and adapting it to a specific task using a smaller, task-specific data set. This process is often faster and more efficient because the model starts with a strong foundation in language and general knowledge and only needs to adjust to the nuances of the new task. This can improve the AI model’s performance for your needs with less work assembling and preparing data and many fewer rounds of training versus training from scratch. See more on the benefits of fine-tuning below.
A wide range of companies across industries, from startups to multinational corporations, are fine-tuning pretrained models. In fact, it’s becoming a standard practice for any organization looking to use AI because it lets them deploy systems tailored to their specific needs without the massive investment required for full-scale model training. Here are some use case examples.
Organizations working in finance, logistics, healthcare, and many other domains are bringing fine-tuned generative AI to their daily operations. These real-world stories will help you explore a wide range of live use cases. Here are three specific examples:
AI fine-tuning is evolving rapidly, especially as more AI agents depend on fine-tuned models. The future promises more automation, new techniques, and a wider array of model choices that can help organizations adapt AI models to their needs.
These innovations include improved ML services that automate fine-tuning, including hyperparameter optimization, model selection, and data preprocessing. We expect that context-aware data augmentation techniques will help the model learn more relevant features more quickly, and dynamic learning will allow a model to adjust its learning rate on the fly. And look for ML and foundation model builders to continue to release more versatile and powerful models that can transfer knowledge across different modalities and can be fine-tuned to perform tasks that require understanding multiple types of data. The trick will be to build a data infrastructure that’s versatile enough to take advantage of these new innovations when they arrive.
Did you know that Oracle Cloud Infrastructure (OCI) gives you access to what you need to fine-tune machine learning and foundation models? Oracle provides the physical infrastructure, data processing infrastructure, data science platform, and generative AI services in fully managed services. OCI’s generative AI service, for example, offers a simple and seamless integration with versatile LLMs in an easy-to-use service. Use it to fine-tune models for a wide range of use cases, including writing assistance, summarization, analysis, and chat.
Meanwhile, your data scientists and ML engineers can leverage Oracle’s data science platform to collaborate on building, training, and deploying ML models using Python and open source tools. A JupyterLab-based environment provides all the resources needed to experiment, develop models, and scale up model training with NVIDIA GPUs and distributed training. Take models into production and keep them healthy with ML operations capabilities, such as automated pipelines, model deployments, and model monitoring.
Fine-tuning an AI model is just one way you can leverage this technology to get a jump on the competition. Check out more ways businesses can benefit.
How is fine-tuning different from other types of model training?
Fine-tuning AI models is different from training AI models from scratch. It’s the process of adding rounds of training to a sophisticated foundation model, leading to more context-relevant outputs in a specific task. Fine-tuning often requires less data and is less time-consuming and costly than building and training a model from scratch.
Can fine-tuning be used with any type of model?
AI fine-tuning can be used with foundation models in a wide range of use cases, whether that’s image recognition, text classification, language generation, audio outputs, or other outputs.