finetuning — Claude Code skill: train models on Microsoft Foundry
A skill that walks through model fine-tuning on Microsoft Foundry: dataset prep, job submission, deployment, evaluation. Useful when the base model's behaviour does not fit.
npx skills add microsoft/skills --skill finetuning -a claude-codeWhat finetuning does
The skill covers the whole training path: SFT, DPO and RFT with graders. It ships Python scripts. submit_training.py sends a job, monitor_training.py polls it to completion, check_training.py reads training curves and lists checkpoints, deploy_model.py deploys through the ARM REST API, and evaluate_model.py scores the result with an LLM judge. A converter moves datasets between SFT, DPO and RFT formats, a generator produces synthetic data for distillation, and validators live in scripts/validate/.
Before submitting anything, the skill wants a baseline measurement on the base model. For RFT it advises tuning the grader so the base model fails 25-50% of examples, and it warns against deploying the last checkpoint without looking at the others. Token cost should be tracked next to accuracy.
Several failures are spelled out. An older openai SDK against the /v1/ endpoint returns “API version not supported”, so openai>=1.0 is needed. Open models reject Standard TrainingType and want globalStandard; the script takes a --use-rest flag or falls back on its own. A job can hang in post-training eval when the tool endpoint is under-provisioned, and a successful ARM call can still leave you with “DeploymentNotReady” — delete the deployment and recreate it. Training data dense with PII gets blocked by content safety at deployment time.
What it helps with
- prepare and validate a dataset before submitting a job
- pick between SFT, DPO and RFT for a given task
- calibrate the pass threshold for an RFT grader
- read training curves and choose a checkpoint over the final one
- generate synthetic data for distillation
Example prompts for the agent
- Prepare an SFT dataset and run
scripts/validate/validate_sft.pyon it - Submit an SFT job on
gpt-4.1-miniand monitor it to completion - Calibrate the grader for RFT and find the pass_threshold
How to install finetuning
1Skills CLI (Vercel)
npx skills add microsoft/skills --skill finetuning -a claude-code2Manually: put the files in place
~/.claude/skills/finetuning/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/finetuning/
Manually: put the files in place
.agents/skills/finetuning/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/finetuning/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install microsoft/skills finetuning2Manually: put the files in place
.github/skills/finetuning/SKILL.mdPlatform CLI
gemini skills install https://github.com/microsoft/skills --path .github/plugins/azure-skills/skills/microsoft-foundry/finetuningManually: put the files in place
.devin/skills/finetuning/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about finetuning
How do I install finetuning in Claude Code?
Run npx skills add microsoft/skills --skill finetuning -a claude-code. The skill lands in ~/.claude/skills/finetuning/SKILL.md.
What does the finetuning skill do?
It runs model fine-tuning on Microsoft Foundry: preparing data, submitting and monitoring the job, deploying and evaluating the result. SFT, DPO and RFT with graders are all covered.
How is SFT different from DPO and RFT?
SFT trains on labelled examples, DPO on preferences, RFT on reinforcement with graders. The skill includes references/training-types.md for choosing between them.
Source text
SKILL.md · MIT
--- 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" --- # 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](workflows/quickstart.md) | | **Full pipeline** | [workflows/full-pipeline.md](workflows/full-pipeline.md) | | **Create data** | [workflows/dataset-creation.md](workflows/dataset-creation.md) | | **Iterate** | [workflows/iterative-training.md](workflows/iterative-training.md) | | **Diagnose** | [workflows/diagnose-poor-results.md](workflows/diagnose-poor-results.md) | ## References | Topic | File | |-------|------| | SFT vs DPO vs RFT | [references/training-types.md](references/training-types.md) | | Hyperparameters | [references/hyperparameters.md](references/hyperparameters.md) | | Data formats | [references/dataset-formats.md](references/dataset-formats.md) | | Grader design (RFT) | [references/grader-design.md](references/grader-design.md) | | Reward hacking | [references/reward-hacking.md](references/reward-hacking.md) | | Agentic RFT (tools) | [references/agentic-rft.md](references/agentic-rft.md) | | Deployment | [references/deployment.md](references/deployment.md) | | Training curves | [references/training-curves.md](references/training-curves.md) | | Evaluation | [references/evaluation.md](references/evaluation.md) | | Vision fine-tuning | [references/vision-fine-tuning.md](references/vision-fine-tuning.md) | | Large file uploads | [references/large-file-uploads.md](references/large-file-uploads.md) | | Platform gotchas | [references/platform-gotchas.md](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 |
© Microsoft · MIT · microsoft/skills