> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-css-tab-borders.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Fine-tune Azure OpenAI models with W&B experiment tracking to log metrics, hyperparameters, and training progress.

# Azure OpenAI fine-tuning

This guide shows you how to use W\&B with Azure OpenAI to track and evaluate fine-tuning jobs for GPT-3.5 or GPT-4 models. When you integrate W\&B, experiment tracking captures metrics, hyperparameters, and training artifacts so you can analyze and improve model performance. You can also use W\&B's evaluation tools to make data-driven decisions about model selection.

This guide is for machine learning practitioners who fine-tune Azure OpenAI models and want a systematic way to track and compare runs.

<Frame>
  <img src="https://mintcdn.com/wb-21fd5541-css-tab-borders/Zp1Au-vBGBD27x6o/images/integrations/aoai_ft_plot.png?fit=max&auto=format&n=Zp1Au-vBGBD27x6o&q=85&s=f4ada1f1a0ab73e475ddef180c303285" alt="Azure OpenAI fine-tuning metrics" width="1418" height="1198" data-path="images/integrations/aoai_ft_plot.png" />
</Frame>

## Prerequisites

Before you begin, complete the following:

* Set up Azure OpenAI service according to [official Azure documentation](https://wandb.me/aoai-wb-int).
* Configure a W\&B account with an API key.

## Workflow overview

The following stages summarize how a typical Azure OpenAI fine-tuning job flows through W\&B, from preparing the job through evaluating the resulting model.

### Fine-tuning setup

Fine-tuning setup involves the following steps:

* Prepare training data according to Azure OpenAI requirements.
* Configure the fine-tuning job in Azure OpenAI.
* Track the fine-tuning process and log metrics and hyperparameters with W\&B.

### Experiment tracking

During fine-tuning, W\&B captures:

* Training and validation metrics.
* Model hyperparameters.
* Resource usage.
* Training artifacts.

### Model evaluation

After fine-tuning, use [W\&B Weave](https://weave-docs.wandb.ai) to:

* Evaluate model outputs against reference datasets.
* Compare performance across different fine-tuning runs.
* Analyze model behavior on specific test cases.
* Make data-driven decisions for model selection.

## Real-world example

To see the integration applied end-to-end, explore the following resources:

* Explore the [medical note generation demo](https://wandb.me/aoai-ft-colab) to see how this integration facilitates:
  * Systematic tracking of fine-tuning experiments.
  * Model evaluation using domain-specific metrics.
* Work through an [interactive fine-tuning notebook](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/azure/azure_gpt_medical_notes.ipynb).

## Additional resources

* [Azure OpenAI W\&B Integration Guide](https://wandb.me/aoai-wb-int)
* [Azure OpenAI Fine-tuning Documentation](https://learn.microsoft.com/azure/ai-services/openai/how-to/fine-tuning?tabs=turbo%2Cpython\&pivots=programming-language-python)
