Model Optimization in Microsoft Foundry: Supervised Fine-Tuning

Microsoft Developer · Advanced ·📰 AI News & Updates ·3mo ago

Key Takeaways

This video demonstrates model optimization in Microsoft Foundry using supervised fine-tuning, covering the fundamentals of fine-tuning, its scenarios, and options available in Foundry, with a hands-on example of fine-tuning a language model for a retail company's chatbot.

Full Transcript

Imagine a retail company wants to build a chatbot and they come to you with a request of wanting the chatbot to behave in a very specific way as well as have it grounded on the product data. What do you do? The first step will be prompt engineering where you try adding in a system prompt and give it examples of how the model should behave. We'll prompt our model saying I want to paint my wooden deck. What will you suggest? And wait for a few seconds for it to respond. You will see it will come back with a very wordy response like giving us tips recommendation from Zava. using around 445 tokens of an input of 45 tokens. I'm using GPD41 as a model here. So the next step will be okay can I ground this on our own data using rag or can I find ways to have the model respond in a short-term manner right you can also use rag where you ground your own data to the LLM but then it doesn't solve the question of reducing token usage and also improving performance so what do you do finetuning fine-tuning is where you customize an already pre-trained LLM to work on a very specific task or on a new data set to just enhance its performance and improve accuracy. You can use fine-tuning when you want to one improve the quality two reduce the cost in terms of token usage and lastly you can use it to reduce the latency by training smaller models meaning faster responses or even in Microsoft Foundry you have various fine-tuning options including supervised finetuning vision finetuning and reinforcement fine tuning In this session, we'll focus on supervised fine tuning where the model learns from your examples. How do you do this? So, let's check out the code. We're using variables. So, first thing first is to ensure our model is loaded. And then we get our training and validation files. For training, we have about 40 examples. And for validation, we have a set of 10. For this, we've given the system message, your cora, polite, factual, and helpful. And if someone asks a question, politeness shows the emoji as well as an acknowledgement note. Factual means they give you the prize. And then helpful means it follows up with a question at the end. So with that, you're aiming at reducing the tokens used as well as being factual, polite, and helpful. The distribution of the tokens you can see is about a minimum or a maximum of 62 and 78 tokens. So in average it's about 68.15. That is for both the assistant tokens, the validation as well as the question tokens. We then upload our maintaining job to the cloud and we add it to Azure. You can see we've added our training and validation files. We now specify the fine tuning job. We give it the training files, validation files, the model as well as the seed. That's the only parameter that we using for this. We have the rest of it as defaults. And it will take some time for the fine tuning job to get started once it's submitted. So you can see this is a fine tuning job submitted and then we're tracking the fine tuning job waiting until it's done. So it takes um the time it will take and then once it's done it gives us now the output and from the output you can see it lists us what were the events that took place. We can see the training tokens build were about 8,000 and then it did an evaluation once the model was done training and the evaluation passed [snorts] and also we can see the different checkpoints. So what do we do next? we deploy our finetuning model. So once you see the different checkpoints, you can see it gives us the loss that we had at the end and then the accuracy loss was 1.2 accuracy was 0.6. Uh and then that was the first checkpoint but then at the end we had yeah same accuracy same loss and then we deploy our fine tuning job. So we want to deploy it directly to Azure so that we can use it for reference. We deploy it with a capacity of eight and we're using the developer tier so that we just experiment and not get charged for our deployment. The deployment takes about 12 minutes 45 seconds to complete. And once it's complete we want to also test it out. So we have two prompts. So the first prompt is what kind of paint should I buy for my outdoor deck? And you can see the responses are good. The other option of testing is going to the playground and actually testing out the fine tune model. So you can see this is our fine tuning job. This was the progress. It took about 1 hour 34 minutes. You can see these are all the metrics that we have. So you can see how the loss decreased and the accuracy increased over time. And then you can also check out the logs what happened at each stage what was the steps and then you can also see the model evaluation past. The other thing you can do is checkpoints. This is where you can deploy very specific parts of the model. So instead of deploying the end of it in case like it has overfeitted or anything you can deploy a specific checkpoint and then you have a model that's been deployed and then we tell it your cora an assistant that is polite factual and helpful and we ask the question again I want to paint my outdoor wooden deck so what are the suggestions that you have you'll see from the response it will be much faster. than what we had earlier and it will be much shorter. That's it. So, it's telling us the emoji. Perfect. The acknowledgement note giving us the facts of how much it cost and it's asking do you need any application tips the amount of tokens used very little 73 tokens from the range of about 500. So, we walked through how you can do a simple supervised fine tuning in Microsoft Foundry. You've seen how the model moves from basically having an output that is very unstructured to structuring the output and to being what exactly you want the customer to see. Next, we'll see how you can use faint tuning for aentic tool calls. So, see you in the next video.

Original Description

Dive into the fundamentals of model optimization with Microsoft Foundry. In this session, we break down what finetuning is, explore the scenarios of why and when you should use it, and discuss the various fine-tuning options available in Foundry. We wrap up by walking through a simple tone fine-tuning demo directly in Foundry, alongside a comprehensive showcase of checkpoints, logs, and essential evaluation metrics to check you finetuning job performance. 00:03 Welcome and scenario 01:23 What is fine-tuning and when to use it 01:57 Fine-Tuning options in Microsoft Foundry 02:15 Demo: Supervised finetuning 05:23 Showcase: Checkpoints, logs, and metrics Microsoft Foundry - https://aka.ms/foundry-ft Foundry Finetuning Demos on GitHub - https://aka.ms/ft-demos Bethany Jepchumba, Twitter/X - https://twitter.com/bethanyjep Bethany Jepchumba, LinkedIn - https://www.linkedin.com/in/bethany-jep/ Bethany Jepchumba, GitHub - https://github.com/bethanyjep
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Microsoft Developer · Microsoft Developer · 0 of 60

← Previous Next →
1 Prepare for the DP-300 exam & the Azure Database Administrator Associate cert | Data Exposed
Prepare for the DP-300 exam & the Azure Database Administrator Associate cert | Data Exposed
Microsoft Developer
2 What I Wish I Knew ... about landing a job in tech
What I Wish I Knew ... about landing a job in tech
Microsoft Developer
3 Igniting Developer Innovation with Vector Search
Igniting Developer Innovation with Vector Search
Microsoft Developer
4 Combining the power of vector search with Azure OpenAI then revolutionize image search with vectors!
Combining the power of vector search with Azure OpenAI then revolutionize image search with vectors!
Microsoft Developer
5 What I Wish I Knew ... about finding your place in tech
What I Wish I Knew ... about finding your place in tech
Microsoft Developer
6 Fluent UI React Insights: Accessible by default
Fluent UI React Insights: Accessible by default
Microsoft Developer
7 Signing Container Images with Notary Project
Signing Container Images with Notary Project
Microsoft Developer
8 What I Wish I Knew ... about finding your place in tech
What I Wish I Knew ... about finding your place in tech
Microsoft Developer
9 What programming languages does GitHub Copilot support?
What programming languages does GitHub Copilot support?
Microsoft Developer
10 What I Wish I Knew ... about how much your job can change
What I Wish I Knew ... about how much your job can change
Microsoft Developer
11 What I Wish I Knew ... about how much your job can change
What I Wish I Knew ... about how much your job can change
Microsoft Developer
12 How do I become more confident about AI?
How do I become more confident about AI?
Microsoft Developer
13 How do I become more confident about AI?
How do I become more confident about AI?
Microsoft Developer
14 Performance Demos of SQL’s Intelligent Query Processing Feedback capabilities | Data Exposed
Performance Demos of SQL’s Intelligent Query Processing Feedback capabilities | Data Exposed
Microsoft Developer
15 What I Wish I Knew ... about coming to Microsoft
What I Wish I Knew ... about coming to Microsoft
Microsoft Developer
16 What I Wish I Knew ... about coming to Microsoft
What I Wish I Knew ... about coming to Microsoft
Microsoft Developer
17 Revolutionizing Image Search with Vectors
Revolutionizing Image Search with Vectors
Microsoft Developer
18 Igniting developer innovation with Vector search and Azure OpenAI
Igniting developer innovation with Vector search and Azure OpenAI
Microsoft Developer
19 Getting Started with Azure AI Studio's Prompt Flow - Part 2
Getting Started with Azure AI Studio's Prompt Flow - Part 2
Microsoft Developer
20 What I Wish I Knew ... about finding my career path
What I Wish I Knew ... about finding my career path
Microsoft Developer
21 What I Wish I Knew ... about finding my career path
What I Wish I Knew ... about finding my career path
Microsoft Developer
22 Windows Terminal's journey to Open Source
Windows Terminal's journey to Open Source
Microsoft Developer
23 Can I trust the code that GitHub Copilot generates?
Can I trust the code that GitHub Copilot generates?
Microsoft Developer
24 What I Wish I Knew ... about interviewing
What I Wish I Knew ... about interviewing
Microsoft Developer
25 What I Wish I Knew ... about interviewing
What I Wish I Knew ... about interviewing
Microsoft Developer
26 What is the Microsoft TechSpark Program?
What is the Microsoft TechSpark Program?
Microsoft Developer
27 SQL Server 2022: Accelerate query performance while reducing query compile time - w/ no code changes
SQL Server 2022: Accelerate query performance while reducing query compile time - w/ no code changes
Microsoft Developer
28 What I Wish I Knew ... about discovering computer science
What I Wish I Knew ... about discovering computer science
Microsoft Developer
29 What I Wish I Knew ... about discovering computer science
What I Wish I Knew ... about discovering computer science
Microsoft Developer
30 Call center transcription and analysis using Azure AI
Call center transcription and analysis using Azure AI
Microsoft Developer
31 How to use Text Analytics for health in Azure AI Language
How to use Text Analytics for health in Azure AI Language
Microsoft Developer
32 Azure OpenAI-powered summarization in Azure AI Language
Azure OpenAI-powered summarization in Azure AI Language
Microsoft Developer
33 Accelerate data labeling using Azure OpenAI and Azure AI Language
Accelerate data labeling using Azure OpenAI and Azure AI Language
Microsoft Developer
34 Building a Private ChatGPT with Azure OpenAI
Building a Private ChatGPT with Azure OpenAI
Microsoft Developer
35 What I Wish I Knew ... about how to interview
What I Wish I Knew ... about how to interview
Microsoft Developer
36 What I Wish I Knew ... about how to interview
What I Wish I Knew ... about how to interview
Microsoft Developer
37 Getting Started with Azure AI Studio's Prompt Flow - Part 3
Getting Started with Azure AI Studio's Prompt Flow - Part 3
Microsoft Developer
38 Intelligent Apps with Azure Kubernetes Service (AKS)
Intelligent Apps with Azure Kubernetes Service (AKS)
Microsoft Developer
39 Getting Started with Azure Blob Storage | Data Exposed: MVP Edition
Getting Started with Azure Blob Storage | Data Exposed: MVP Edition
Microsoft Developer
40 Chat + Your Data + Plugins
Chat + Your Data + Plugins
Microsoft Developer
41 What I Wish I Knew ... about different career paths
What I Wish I Knew ... about different career paths
Microsoft Developer
42 What I Wish I Knew ... about different career paths
What I Wish I Knew ... about different career paths
Microsoft Developer
43 Advanced Dev Tunnels Features | OD122
Advanced Dev Tunnels Features | OD122
Microsoft Developer
44 Learn Live - Manage performance and availability in Azure Cosmos DB for PostgreSQL
Learn Live - Manage performance and availability in Azure Cosmos DB for PostgreSQL
Microsoft Developer
45 Plan your SQL Migration to Azure with confidence | Data Exposed
Plan your SQL Migration to Azure with confidence | Data Exposed
Microsoft Developer
46 What I Wish I Knew ... about social skills in a tech career
What I Wish I Knew ... about social skills in a tech career
Microsoft Developer
47 What I Wish I Knew ... about social skills in a tech career
What I Wish I Knew ... about social skills in a tech career
Microsoft Developer
48 All About Vectors, Search, and Function Calling in Azure OpenAI - Labor Day Special
All About Vectors, Search, and Function Calling in Azure OpenAI - Labor Day Special
Microsoft Developer
49 Introduction to project ORAS
Introduction to project ORAS
Microsoft Developer
50 What I Wish I Knew ... about finding the right major
What I Wish I Knew ... about finding the right major
Microsoft Developer
51 What I Wish I Knew ... about finding the right major
What I Wish I Knew ... about finding the right major
Microsoft Developer
52 What I Wish I Knew ... about how to approach programming
What I Wish I Knew ... about how to approach programming
Microsoft Developer
53 What I Wish I Knew ... about how to approach programming
What I Wish I Knew ... about how to approach programming
Microsoft Developer
54 Learn Live - Scale from a single node to multiple nodes with Azure Cosmos DB for PostgreSQL
Learn Live - Scale from a single node to multiple nodes with Azure Cosmos DB for PostgreSQL
Microsoft Developer
55 What I Wish I Knew ... about diversity in tech #1
What I Wish I Knew ... about diversity in tech #1
Microsoft Developer
56 What I Wish I Knew ... about diversity in tech #1
What I Wish I Knew ... about diversity in tech #1
Microsoft Developer
57 Get started with SQL Server AGs across Windows, Linux and Container Replicas | Data Exposed
Get started with SQL Server AGs across Windows, Linux and Container Replicas | Data Exposed
Microsoft Developer
58 Writing LLM Apps with Azure AI and PromptFlow
Writing LLM Apps with Azure AI and PromptFlow
Microsoft Developer
59 What I Wish I Knew ... about how cool working in tech could be
What I Wish I Knew ... about how cool working in tech could be
Microsoft Developer
60 Open Source foundation models in Azure Machine Learning & optimization techniques behind the scenes
Open Source foundation models in Azure Machine Learning & optimization techniques behind the scenes
Microsoft Developer

This video teaches how to perform supervised fine-tuning in Microsoft Foundry to optimize a language model's performance for a specific task, such as building a chatbot for a retail company. The video covers the fundamentals of fine-tuning, its scenarios, and options available in Foundry, with a hands-on example.

Key Takeaways
  1. Load the model
  2. Prepare training and validation files
  3. Upload the fine-tuning job to the cloud
  4. Specify the fine-tuning job parameters
  5. Track the fine-tuning job
  6. Deploy the fine-tuned model
  7. Test the fine-tuned model
💡 Fine-tuning can be used to customize a pre-trained LLM for a specific task or dataset, improving its performance and accuracy, and reducing token usage and latency.

Related Reads

Chapters (5)

0:03 Welcome and scenario
1:23 What is fine-tuning and when to use it
1:57 Fine-Tuning options in Microsoft Foundry
2:15 Demo: Supervised finetuning
5:23 Showcase: Checkpoints, logs, and metrics
Up next
How to Build Custom AI Agents
AI Agents Podcast
Watch →