A fine-tuning guide for both OpenAI and Open-Source Large Lauguage Models on Azure.
🔥 New (2024-11-20): Phi-3.5 Vision Fine-Tuning using LoRA [Jump to the notebook]
🔥 New (2024-10-25): Phi-3 Fine-Tuning using Q-LoRA [Jump to the notebook]
🔥 New (2024-10-05): Phi-3 Fine-Tuning using LoRA [Jump to the notebook]
🔥 New (2024-07-28): GPT-4 Fine-Tuning using Azure Machine Learning (Low-Code) Python SDK [Jump to the notebook]
🔥 New (2024-07-11): GPT-4 Fine-Tuning using Azure OpenAI UI Dashboard [Jump to the Guide]
🔥 New (2024-07-04): Phi-3 Fine-Tuning using Azure Machine Learning (Low-Code) Python SDK [Jump to the notebook]
Fine-Tuning, or Supervised Fine-Tuning, retrains an existing pre-trained LLM using example data, resulting in a new "custom" fine-tuned LLM that has been optimized for the provided task-specific examples.
Typically, we use Fine-Tuning to:
- improve LLM performance on specific tasks.
- introduce information that wasn't well represented by the base LLM model.
Good use cases include:
- steering the LLM outputs in a specific style or tone.
- too long or complex prompts to fit into the LLM prompt window.
You may consider Fine-Tuning when:
- you have tried Prompt Engineering and RAG approaches.
- latency is critically important to the use case.
- high accuracy is required to meet the customer requirement.
- you have thousands of high-quality samples with ground-truth data.
- you have clear evaluation metrics to benchmark fine-tuned models.
Lab 1: LLM Fine-Tuning via Azure Dashboards
- Lab 1.1: Fine-Tuning GPT-3.5 Model (1h duration)
- Lab 1.2: Fine-Tuning GPT-4 Model (1h duration)
- Lab 1.3: Fine-Tuning Llama2 Model (1h duration)
Lab 2: LLM Fine-Tuning via Azure Python SDK
- Lab 2.1: Fine-Tuning GPT-3.5 Model (2h duration)
- Lab 2.2: Fine-Tuning GPT-4 Model (2h duration)
- Lab 2.3: Fine-Tuning Llama2 Model (2h duration)
- Lab 2.4: Fine-Tuning Phi-3 Model (2h duration)
Lab 3: LLM Fine-Tuning via Open Source Tools
- Lab 3.1: Fine-Tuning Phi-3 Model using LoRA (3h duration)
- Lab 3.2: Fine-Tuning Phi-3 Model using Q-LoRA (3h duration)
- Lab 3.3: Fine-Tuning Phi-3.5 Vision Model using LoRA (3h duration)
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license.