--- name: finetuning 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. metadata: version: "1.0.0" --- # 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 - ❌ NEVER offer to move on to a downstream skill while training is in progress (logically impossible) - ❌ NEVER set ACCEPT_EULA to True without explicit user confirmation in the conversation - ✅ Always mention both the number AND title of sections you reference - ✅ If user asks how to run (notebook): If `run_cell` is available, offer to run it. Otherwise, tell them to run cells one by one (mention ipykernel requirement). - ✅ If user asks how to run (script): Tell them to run with `python3