Overview
This exercise walks you through fine-tuning a GPT-4o model using Azure AI Foundry to create a custom chat application. The goal is to refine the model’s responses to ensure a consistent conversational tone tailored for a travel assistant.
Steps & Configuration Details
1. Deploy a Base Model in Azure AI Foundry
- Open Azure AI Foundry portal (https://ai.azure.com) and sign in.
- Search for gpt-4o and select Use this model.
- Configuration Items:
- Azure AI Foundry Resource: A valid name.
- Subscription: Your Azure subscription.
- Resource Group: Select or create a resource group.
- Region: Choose from:
- East US 2
- North Central US
- Sweden Central (regions supporting fine-tuning).
- Deployment Name:
gpt-4o
(default).
2. Fine-Tune the Model
- Download Training Data:
https://raw.githubusercontent.com/MicrosoftLearning/mslearn-ai-studio/refs/heads/main/data/travel-finetune-hotel.jsonl
- Save the file as JSONL (ensure it’s not saved as
.txt
). - Navigate to Fine-tuning under Build and customize.
- Select Add fine-tune model → Choose gpt-4o → Click Next.
Fine-Tuning Configuration:
- Method of Customization:
Supervised
- Base Model:
gpt-4o
- Training Data: Upload the
.jsonl
file. - Model Suffix:
ft-travel
- Seed:
Random
Submit the fine-tuning job—it may take 30 minutes or longer.
3. Chat with the Base Model
- Open Chat Playground.
- Verify gpt-4o is selected.
- Test queries:
"What can you do?"
"Where in Rome should I stay?"
- Modify the System Message:
You are an AI travel assistant that helps people plan their trips. Your objective is to offer support for travel-related inquiries, such as visa requirements, weather forecasts, local attractions, and cultural norms. You should not provide any hotel, flight, rental car, or restaurant recommendations. Ask engaging questions to help someone plan their trip and think about what they want to do on their holiday.
- Apply changes and test again.
4. Review the Training File
- Open the JSONL file in a text editor.
- Example training data format:
{ "messages": [ { "role": "system", "content": "You are an AI travel assistant..." }, { "role": "user", "content": "What's a must-see in Paris?" }, { "role": "assistant", "content": "Oh la la! You simply must twirl around the Eiffel Tower..." } ] }
- The fine-tuned model learns response style from these examples.
5. Deploy the Fine-Tuned Model
- Navigate to Fine-tuning → Select the completed job.
- Deployment Configuration:
- Deployment Name: A valid name.
- Deployment Type:
Standard
- Tokens per Minute Rate Limit:
50K
(or max available). - Content Filter:
Default
- Wait for deployment to complete.
6. Test the Fine-Tuned Model
- Open Fine-Tuned Model → Select Open in Playground.
- Ensure the System Message includes the refined instructions.
- Test queries:
"Where in Rome should I stay?"
"What are some local delicacies I should try?"
"What's the best way to get around the city?"
- Compare responses with the base model.
7. Clean Up
- Delete Azure resources to avoid unnecessary costs:
- Open Azure Portal (https://portal.azure.com).
- Navigate to Resource Groups.
- Select the resource group and click Delete.