---
name: finetuning
description: "Fine-tune models on Microsoft Foundry using SFT (supervised), DPO (preference), or RFT (reinforcement with graders). Covers dataset preparation, training job submission, deployment, and evaluation. USE FOR: fine-tune, SFT, DPO, RFT, training data, grader, distillation, fine-tuned model, training job, large file upload, calibrate grader, deploy fine-tuned model, evaluate fine-tuned model. DO NOT USE FOR: general model deployment without fine-tuning (use deploy-model), agent creation (use agents), prompt optimization without training (use prompt-optimizer)."
license: MIT
metadata:
  author: Microsoft
  version: "0.0.0-placeholder"
title: finetuning
canonical_url: https://skilld.dev/gh/microsoft/github-copilot-for-azure/finetuning
last_updated: 2026-09-29T12:26:00.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> 33 supporting files sit beside this SKILL.md. When the Skill refers to one, fetch https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/PATH with PATH replaced.
>
> If the user asked to install this Skill, run `npx skilld install microsoft/github-copilot-for-azure/finetuning`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/finetuning`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/microsoft/github-copilot-for-azure/finetuning) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/finetuning`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/finetuning --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/finetuning --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Fine-Tuning on Microsoft Foundry

Fine-tune models using SFT (supervised), DPO (preference), or RFT (reinforcement with graders). Covers dataset prep, training, deployment, and evaluation.

## When to Use

Use this sub-skill when the user asks about:
- Fine-tuning a model (SFT, DPO, or RFT)
- Preparing, validating, or formatting training data
- Submitting, monitoring, or diagnosing training jobs
- Calibrating graders or pass thresholds for RFT
- Deploying or evaluating a fine-tuned model
- Choosing between training types (SFT vs DPO vs RFT)
- Distillation, synthetic data generation, or dataset quality scoring
- Large file uploads for training data
- Cleaning up fine-tuning resources (files, deployments)

**Do NOT use for:** General model deployment without fine-tuning (use deploy-model), agent creation (use agents), prompt optimization without training (use prompt-optimizer).

## Workflows

| Stage | Guide |
|-------|-------|
| **Quick start** | [workflows/quickstart.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/workflows/quickstart.md) |
| **Full pipeline** | [workflows/full-pipeline.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/workflows/full-pipeline.md) |
| **Create data** | [workflows/dataset-creation.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/workflows/dataset-creation.md) |
| **Iterate** | [workflows/iterative-training.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/workflows/iterative-training.md) |
| **Diagnose** | [workflows/diagnose-poor-results.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/workflows/diagnose-poor-results.md) |

## References

| Topic | File |
|-------|------|
| SFT vs DPO vs RFT | [references/training-types.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/training-types.md) |
| Hyperparameters | [references/hyperparameters.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/hyperparameters.md) |
| Data formats | [references/dataset-formats.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/dataset-formats.md) |
| Grader design (RFT) | [references/grader-design.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/grader-design.md) |
| Reward hacking | [references/reward-hacking.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/reward-hacking.md) |
| Agentic RFT (tools) | [references/agentic-rft.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/agentic-rft.md) |
| Deployment | [references/deployment.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/deployment.md) |
| Training curves | [references/training-curves.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/training-curves.md) |
| Evaluation | [references/evaluation.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/evaluation.md) |
| Vision fine-tuning | [references/vision-fine-tuning.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/vision-fine-tuning.md) |
| Large file uploads | [references/large-file-uploads.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/large-file-uploads.md) |
| Platform gotchas | [references/platform-gotchas.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/finetuning/references/platform-gotchas.md) |

## Scripts

| Script | Purpose |
|--------|---------|
| `scripts/submit_training.py` | Submit SFT/DPO/RFT jobs |
| `scripts/monitor_training.py` | Poll job until completion |
| `scripts/calibrate_grader.py` | Find optimal RFT pass_threshold |
| `scripts/check_training.py` | Analyze curves, list checkpoints |
| `scripts/deploy_model.py` | Deploy via ARM REST API |
| `scripts/evaluate_model.py` | LLM judge evaluation |
| `scripts/convert_dataset.py` | Convert between SFT/DPO/RFT formats |
| `scripts/generate_distillation_data.py` | Generate synthetic training data |
| `scripts/score_dataset.py` | Quality scoring on training data |
| `scripts/cleanup.py` | Delete old files and deployments |
| `scripts/validate/` | Data validators (SFT, DPO, RFT) + stats |

## Rules

1. **Always baseline first** — evaluate the base model before fine-tuning
2. **Validate data** before submitting — run `scripts/validate/validate_sft.py`
3. **Calibrate RFT graders** — target 25-50% failure rate on the base model
4. **Evaluate checkpoints** — don't blindly deploy the final one
5. **Measure token cost** alongside accuracy when comparing models

## Quick Reference

| Task | Command |
|------|---------|
| Validate SFT data | `python scripts/validate/validate_sft.py data.jsonl` |
| Submit SFT job | `python scripts/submit_training.py --model gpt-4.1-mini --training-file train.jsonl --validation-file val.jsonl --type sft` |
| Monitor job | `python scripts/monitor_training.py --job-id ftjob-xxx` |
| Analyze curves | `python scripts/check_training.py --job-id ftjob-xxx` |
| Deploy model | `python scripts/deploy_model.py --model-id ft:gpt-4.1-mini:... --name my-eval` |
| Evaluate model | `python scripts/evaluate_model.py --deployment-name my-eval --test-file test.jsonl` |

## Error Handling

| Error | Cause | Fix |
|-------|-------|-----|
| "API version not supported" | Older `openai` SDK on `/v1/` endpoint | Upgrade to `openai>=1.0` |
| "does not support fine-tuning with Standard TrainingType" | OSS model needs `globalStandard` | Use `--use-rest` flag or script auto-falls back |
| Job stuck in post-training eval | Under-provisioned tool endpoint (RFT) | Scale to S2+, enable Always On |
| "DeploymentNotReady" after ARM succeeds | ARM/data-plane race condition | Delete and recreate deployment, wait 5 min |
| Content safety block at deployment | PII-dense training data | Remove problematic document types |
