# Finetuning

Generates code that fine-tunes a base model using SageMaker serverless training jobs.

- Repository: https://github.com/awslabs/agent-plugins (933 stars)
- Category: AI and agents
- License: Apache-2.0
- Last updated: 2026-10-15
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add awslabs/agent-plugins --skill finetuning -g -a claude-code -y`
Codex: `npx skills add awslabs/agent-plugins --skill finetuning -g -a codex -y`
Cursor: `npx skills add awslabs/agent-plugins --skill finetuning -g -a cursor -y`
Gemini CLI: `npx skills add awslabs/agent-plugins --skill finetuning -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add awslabs/agent-plugins`

## Description

Generates code that fine-tunes a base model using SageMaker serverless training jobs. Use when the user says "start training", "fine-tune my model", "I'm ready to train", or when the plan reaches the finetuning step. Supports SFT, DPO, RLVR, and RLAIF trainers, including RLVR Lambda reward function and RLAIF custom prompt creation.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Prerequisites

Before starting this workflow, verify:

1. A `use_case_spec.md` file exists
   - If missing: Activate the `use-case-specification` skill first, then resume
   - DON'T EVER offer to create a use case spec without activating the use-case-specification skill.

2. A fine-tuning technique (SFT, DPO, RLVR, RLAIF, or CPT/RFT (for Nova)) and base model have already been selected
   - If missing: Activate the `model-selection` and/or `finetuning-technique` skills to collect what's missing, then resume
   - Don't make recommendations on the spot. You MUST activate the appropriate skill.

3. A base model name available on SageMakerHub has been identified
   - If missing: Activate the `model-selection` skill to get it
   - **Important:** Only use the model name that `model-selection` retrieves, as it may differ from other commonly used names for the same model

4. The SDK environment has been verified (SDK version, region, execution role)
   - If not done: Activate the `sdk-getting-started` skill first, then resume

5. A training dataset uploaded to a bucket in the environment's default region.
   - If not met: Help the user upload the dataset to the correct S3

---

# Critical Rules

## Code Generation Rules

- ✅ Use EXACTLY the imports shown in each code template
- ❌ Do NOT add additional imports even if they seem helpful
- ❌ Do NOT create variables before they're needed in that section
- 📋 Copy the code structure precisely - no improvisation
- 🎯 Follow the minimal code principle strictly
- ✅ When writing code, make sure the indentation and f strings are correct

## User Communication Rules

The rest: https://github.com/awslabs/agent-plugins/blob/HEAD/plugins/sagemaker-ai/skills/finetuning/SKILL.md
