Fine-tuning
Fine-tune a large language model for solving a specific problem and optimizing cost.
Introduction
Fine-tuning is a powerful way to adapt large language models to specific tasks or domains. You can train the model to perform better on your specific use case by providing a dataset of examples. In this documentation, we’ll guide you through fine-tuning a model on Tune Studio.
When to Use Fine-Tuning
Fine-tuning is a powerful technique that allows you to tailor pre-trained language models to better suit your needs. Here are some scenarios where fine-tuning can be particularly beneficial:
- Enhance Model Performance: Improve the accuracy and relevance of a model for a specific task or domain, such as customer support, content generation, or specialized knowledge areas.
- Customize for Specific Use Cases: Adapt a general-purpose pre-trained model to address unique requirements in your application, ensuring it understands and responds appropriately to your context.
- Optimize Costs and Latency: By fine-tuning, you can reduce the need for lengthy prompts, leading to cost savings and faster response times during inference.
However, fine-tuning requires careful planning and effort. Before starting the process, ensure that you have:
- Optimized Your Prompts: Refine your prompts as much as possible using prompt engineering techniques.
- Identified Persistent Issues: Clearly understand the limitations or errors in the current model’s performance that you aim to resolve through fine-tuning.
Here is a simple flowchart to help you decide on the correct solution for your problem
Fine-tuning on Tune Studio
Tune Studio offers an intuitive platform designed to simplify the fine-tuning process. Our user-friendly interface and robust features allow you to easily create customized models using your datasets. Additionally, our pricing model will enables you to pay per token for inference, making it cost-effective.
Overview of Steps:
-
Create a Dataset:
- Gather examples relevant to your use case.
- Format them according to Tune Studio’s requirements (e.g., JSONL).
-
Upload the Dataset:
- Upload directly via Tune Studio’s UI or use HuggingFace repositories for seamless integration.
-
Create a Training Job:
- Configure training parameters such as epochs, learning rate, and batch size.
- Start the training job through Tune Studio’s UI or API.
-
Access Your Model:
- Once complete training, utilize your fine-tuned model through Tune Studio Playground OR
/chat/completion
APIs.
- Once complete training, utilize your fine-tuned model through Tune Studio Playground OR
By following these steps on Tune Studio’s platform, you can efficiently create high-performing models tailored specifically to your needs!
Creating a Dataset
To fine-tune a model effectively, you must create a dataset that provides clear examples of the desired behavior. Here’s how to prepare your dataset for Tune Studio:
Key Components of Your Dataset:
-
Diverse Demonstration Conversations:
- Include a wide range of example interactions similar to what you expect the model to handle during inference.
- Ensure these examples cover scenarios and contexts relevant to your use case.
-
Targeted Training Examples:
- Identify specific cases where the pre-trained model does not perform as expected.
- Create examples addressing these shortcomings, guiding the model towards improved responses.
-
Ideal Assistant Responses:
- For each example, interaction, provide an ideal response from the assistant.
- These responses should demonstrate how you want the model to behave in similar situations.
Tune Studio supports various dataset formats for fine-tuning. We recommend using JSONL (JSON Lines) for its flexibility and ease of use. HuggingFace datasets with designated columns are also supported.
Dataset example:
Guidelines:
- The role can only be one of
system
,human
,gpt
. - There should be only one
system
message at the start of each conversation. human
andgpt
messages should alternate starting withhuman
.
Check out an example dataset here called IAmGroot
Our platform provides built-in functionality to convert chat history threads into the chat format dataset directly from messaging platforms or forums without manual conversion. Check Threads
Upload the dataset to Tune Studio or HuggingFace
Once you have created a dataset, you need to upload it to a place that is easily accessible.
You can achieve this by uploading it through Tune Studio UI or HuggingFace and providing the repo URL.
When using a huggingface account, make sure that it is integrated! Check out Integrations for more info.
- Log in to Tune Studio.
- Go to the Finetune tab.
- Click on + Finetune Model.
- Select Choose a dataset.
- Scroll down and click on + Upload dataset.
Creating a Fine-tune job
Once you’ve prepared and uploaded your dataset correctly, you can start a new fine-tuning job via UI or API:
Currently, we support only 2 models for finetuning, with more support coming soon. Here is a list of supported models:
Model Name | Base Model ID |
---|---|
meta/llama-3-8b-instruct-8k | tune:5fmycsn2 |
meta/llama-3-8b-base-8k | tune:zil8q5hl |
- Navigate to the Finetune tab.
- Click on + Finetune Model.
- Enter a name for your model. This name will also be used in inference.
- Choose the base model.
- Choose a dataset by either Uploading it or using huggingface.
- Select the GPU resource and count. Recommend using nvidia-l4 if the dataset is small.
- Adjuest number of epochs and learning rate as needed.
- Optionally, integrate with W&B and Huggingface.
- Click on Deploy.
Using Hyperparameters for Better Results
Fine-tuning a Language Model (LM) requires careful adjustment of key parameters to optimize its performance for your specific task. Here’s a breakdown of crucial hyperparameters to consider:
Integration with Third-Party Systems:
Tune Studio provides integration capabilities for third-party systems, allowing you to track job state, metrics, and more. Currently, we support integration with Weights & Biases (W&B) and Huggingface.
To use integrations, ensure that you have connected your accounts first! For more information, check out Integrations.
Monitoring Fine-tuning Job Status
After starting a fine-tuning job, it may take some time to complete, depending on the complexity of the base model and dataset size. Regularly tracking the job status helps ensure smooth execution and successful completion. Here’s a breakdown of different statuses:
To track status efficiently, use Tune Studio’s user interface or leverage the GetFinetuneJob API.
Accessing Your Model
Once your fine-tuning job is completed, it will automatically appear in the Models Tab under the same name as your job. You can open it and access the model directly in the playground.
Congratulations! 🎉 Your fine-tuning job is complete, and your newly refined model is ready to shine. You have multiple exciting ways to leverage your fine-tuned model:
-
Explore in Tune Studio Playground: Dive right in and interact with your model directly within the Tune Studio Playground. Experience its capabilities firsthand and see how it performs on various tasks!
-
Integrate Seamlessly with Chat Completions API: Use our Chat Completions API to bring the power of your fine-tuned model into your existing workflows and applications. Enhance user experiences significantly by effortlessly integrating cutting-edge AI.
Currently the following operations are not allowed for deployed models,
- Changing the model name
- Updating model hardware
Please do not modify these from the UI as it might break your model.
Your journey doesn’t end here! Keep experimenting, refining, and pushing the boundaries of what’s possible with Tune Studio. We’re excited to see what you’ll create next!
Was this page helpful?