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.
npx skills add https://github.com/awslabs/agent-plugins --skill finetuning
Before starting this workflow, verify:
use_case_spec.md file existsuse-case-specification skill first, then resumemodel-selection and/or finetuning-technique skills to collect what's missing, then resumemodel-selection skill to get itmodel-selection retrieves, as it may differ from other commonly used names for the same modelsdk-getting-started skill first, then resumerun_cell is available, offer to run it. Otherwise, tell them to run cells one by one (mention ipykernel requirement).python3 <script>.py⏸ Wait for user.
Read references/code_output_guide.md for output format rules, then read the code template matching the finetuning strategy:
code_templates/sft.pycode_templates/dpo.pycode_templates/rlvr.pycode_templates/rlaif_builtin.pycode_templates/rlaif_custom_prompt.pyThe template is a Python file where each # Cell N: Label comment marks the start of a new section. Split on these markers — everything between one marker and the next becomes one unit of output.
code_output_guide.mdmeta-):ACCEPT_EULA = False line from the config cellaccept_eula=ACCEPT_EULA, line from the trainer callmax_epochs or lr_warmup_steps_ratio from the Configure Trainer section and the Hyperparameter Overrides sectionIn the 'Setup & Credentials' cell, populate:
use_case_spec.md if needed)a-zA-Z0-9{0,62}customer-support-chatbot-v1references/rlvr_reward_function.md section "Helping Users Create Custom Reward Functions"CUSTOM_REWARD_FUNCTION in the Notebook with the ARN of the reward function (either given directly by the user, or from the function generation code as evaluator.arn).Read references/rlaif_guide.md and follow its instructions.
meta-)ACCEPT_EULA = True and uncomment accept_eula=ACCEPT_EULA in the generated notebook. If the user declines, leave ACCEPT_EULA = False and warn that training will fail without acceptance.ACCEPT_EULA variable and accept_eula parameter should already be omitted from the notebook (see Step 1.3).After generating the code, offer to run it. Training can take hours depending on your dataset and model.
Notebook mode: If run_cell is available, offer to run the cells. Otherwise tell the user to run cells themselves.
Script mode: Present the user with options:
> "Would you like me to:
>
> 1. Leave it to you — run with python scripts/[script_name]
> 2. Run it and wait until it's done
> 3. Start it but don't wait — we can check status later"
trainer.train(wait=True) blocks until complete. Report final status.wait=True to wait=False in the script, execute, report the training job name.Checking status:
describe-training-job --training-job-name NAME → TrainingJobStatus, FailureReason, SecondaryStatusTransitionslist-model-packages --model-package-group-name GROUP_NAME --sort-by CreationTime --sort-order Descending --max-results 1Showing results after completion:
scripts/mlflow_reference.py as the pattern to query MLflow metricsCRITICAL:
If the user wants to finetune a model they had already customized, follow the instructions in references/continuous_customization.md
rlvr_reward_function.md - Lambda reward function creation guide (RLVR only)templates/rlvr_reward_function_source_template.py - Lambda reward function source template for open-weights models (RLVR only)templates/nova_rlvr_reward_function_source_template.py - Lambda reward function source template for Nova 2.0 Lite (RLVR only)code_templates/sft.py - Complete notebook template for Supervised Fine-Tuning (OSS path)code_templates/dpo.py - Complete notebook template for Direct Preference Optimization (OSS path)code_templates/rlvr.py - Complete notebook template for Reinforcement Learning from Verifiable Rewards (OSS path)references/continuous_customization.md - Instructions on fine-tuning an already fine-tuned model.rlaif_guide.md - instructions on RLAIF finetuning optionsrlaif_builtin.py - Code template for RLAIF with built-in judge promptrlaif_custom_prompt.py - Code template for RLAIF with custom judge promptCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
Access NCBI GEO for gene expression/genomics data. Search/download microarray and RNA-seq datasets (GSE, GSM, GPL), retrieve SOFT/Matrix files, for transcriptomics and expression analysis.
Bayesian modeling with PyMC. Build hierarchical models, MCMC (NUTS), variational inference, LOO/WAIC comparison, posterior checks, for probabilistic programming and inference.
Multi-objective optimization framework. NSGA-II, NSGA-III, MOEA/D, Pareto fronts, constraint handling, benchmarks (ZDT, DTLZ), for engineering design and optimization problems.
Statistical modeling toolkit. OLS, GLM, logistic, ARIMA, time series, hypothesis tests, diagnostics, AIC/BIC, for rigorous statistical inference and econometric analysis.
Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.
Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.
Write docstrings for PyTorch functions and methods following PyTorch conventions. Use when writing or updating docstrings in PyTorch code.
Take awslabs/finetuning from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.