# Finetuning ## Prerequisites Before starting this workflow, verify: 1. A `use_case_spec.md` file exists - If missing: Load the `use-case-specification` reference first, then resume - DON'T EVER offer to create a use case spec without loading the use-case-specification reference. 2. A fine-tuning technique (SFT, DPO, RLVR, RLAIF, or CPT/RFT (for Nova)) and base model have already been selected - If missing: Load the `model-selection` and/or `finetuning-technique` references to collect what's missing, then resume - Don't make recommendations on the spot. You MUST load the appropriate reference. 3. A base model name available on SageMakerHub has been identified - If missing: Load the `model-selection` reference 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: Load the `sdk-getting-started` reference 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 --- ### Out of Scope The following are supported by SageMaker and AWS but do not have a validated workflow in this reference. If the user's request matches one of these, let them know and proceed with best-effort guidance using general AWS knowledge: - Pre-training or creating a model from scratch - Bring-your-own container/algorithm training - Server-ful (non-serverless) SageMaker training jobs - HyperPod training - Traditional ML training (XGBoost, scikit-learn, custom algorithms) --- ## 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 reference 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