{"owner":"aws","repo":"amazon-sagemaker-examples","hasSkills":true,"totalSkillsCount":2,"totalTokensCount":3228,"categories":["root-instruction"],"hasMcp":false,"mcpConfig":null,"found":["llms.txt","AGENTS.md"],"skills":{"llms.txt":"# Amazon SageMaker Examples\n\n> Example notebooks for building, training, and deploying models with the Amazon SageMaker\n> Python SDK **v3**. This repository targets **v3 only**; `pip install sagemaker` installs v3.\n> SDK v3 is modular (`sagemaker-core`, `sagemaker-train`, `sagemaker-serve`, `sagemaker-mlops`)\n> and is not backward compatible with v2. v2 examples are archived, not maintained.\n\nThis file follows the llms.txt convention (https://llmstxt.org): a curated index plus explicit\ninstructions so AI coding agents generate correct, current (v3) code.\n\n## Instructions for LLM agents (SageMaker Python SDK)\n\n- **SDK-first:** for any SageMaker task (train, deploy, process, pipelines), use the\n  **SageMaker Python SDK v3** as the primary interface. Do not drop to raw `boto3`\n  (`create_training_job`, `create_endpoint`), the AWS CLI, or hand-rolled framework scripts\n  unless the user explicitly asks. Intent → interface:\n  - \"train / fine-tune / training job / serverless training\" → `sagemaker.train.ModelTrainer` (`.train(...)`)\n  - \"deploy / host / real-time or serverless or async endpoint\" → `sagemaker.serve.ModelBuilder` (`.deploy(...)`)\n  - \"process data / feature engineering / preprocess\" → `sagemaker.core.resources.ProcessingJob`\n  - \"pipeline / orchestrate / MLOps\" → `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n  - \"container image URI\" → `sagemaker.core.image_uris.retrieve(...)`\n- Default to SageMaker Python SDK **v3**.\n- **Never** emit these v2 patterns unless the user explicitly asks for \"v2\":\n  - `from sagemaker.estimator import Estimator` → use `from sagemaker.train import ModelTrainer`\n  - framework estimator classes (`from sagemaker.pytorch import PyTorch`, TensorFlow, SKLearn,\n    XGBoost, HuggingFace) → `ModelTrainer` + `from sagemaker.core import image_uris` (`image_uris.retrieve(...)`)\n  - `estimator.fit(...)` → `model_trainer.train(...)`\n  - `from sagemaker.model import Model` / `model.deploy(...)` → `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)`\n  - `from sagemaker.predictor import Predictor` / `predictor.predict(...)` → `Predictor` replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)`\n  - `from sagemaker.processing import Processor/ScriptProcessor/SKLearnProcessor` → `sagemaker.core.resources.ProcessingJob`\n  - `from sagemaker.workflow...` → `from sagemaker.mlops...`\n- Removed in v3 (no replacement): MXNet, Chainer, RLEstimator, Training Compiler.\n- After generating SageMaker code, validate it contains none of the v2 patterns above. If unsure\n  of a mapping, consult the migration guide below or call the migration MCP tool.\n- No hardcoded account IDs, role ARNs, regions, or bucket names. Use `get_execution_role()` and\n  `Session().default_bucket()`.\n\n## Migration\n\n- [V2 → V3 migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md): authoritative mappings and before/after examples\n- [SageMaker Python SDK (source)](https://github.com/aws/sagemaker-python-sdk)\n- [SageMaker Python SDK docs](https://sagemaker.readthedocs.io/)\n\n## Core v3 interfaces\n\n- Training: `sagemaker.train.ModelTrainer` (+ `train.configs`: `Compute`, `SourceCode`, `InputData`)\n- Inference: `sagemaker.serve.ModelBuilder` (+ `serve.configs.InferenceSpec`), then `ModelBuilder.deploy(...)`\n- Processing: `sagemaker.core.resources.ProcessingJob`\n- MLOps / Pipelines: `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n- Images: `sagemaker.core.image_uris.retrieve(...)`\n\n## Example categories\n\nThe repository is organized by ML capability, in lifecycle order.\n\n- `training/`: training with `ModelTrainer` — script and framework training, distributed training, managed spot with checkpointing, heterogeneous clusters, bring-your-own-container, AWS Batch training queues, `@remote`\n- `model_customization/`: fine-tuning foundation models — SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning with a private model hub, distributed fine-tuning\n- `evaluation/`: the `*Evaluator` surface — benchmark evaluation, custom scorers, LLM-as-a-judge, Inspect AI\n- `inference/`: deployment with `ModelBuilder` and sagemaker-core — real-time/serverless/async endpoints, in-process and local-container modes, inference pipelines, multi-model and multi-container endpoints, A/B testing, shadow variants, deployment guardrails, autoscaling with inference components, `optimize()`, batch transform, Bedrock deployment, Marketplace model packages, Augmented AI\n- `mlops/`: Pipelines with Model Registry, lineage tracking, experiment tracking, Feature Store, processing jobs, EMR Serverless steps, Clarify, MLflow\n\nBrowse them at https://github.com/aws/amazon-sagemaker-examples/tree/default\n","AGENTS.md":"# AGENTS.md — Amazon SageMaker Examples\n\nGuidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer,\nKiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md\nconvention (https://agents.md).\n\n## Project context\n\nThis repository contains example notebooks for the **Amazon SageMaker Python SDK v3**.\n`pip install sagemaker` installs **v3**. SDK v3 is a modular redesign and is **not\nbackward compatible** with v2. It is split into:\n\n- `sagemaker-core` — foundation primitives and the low-level, resource-oriented API\n- `sagemaker-train` — training (`ModelTrainer`)\n- `sagemaker-serve` — model building & deployment (`ModelBuilder`)\n- `sagemaker-mlops` — pipelines and workflow orchestration\n\n## Golden rule: generate v3 by default\n\nGenerate **SageMaker Python SDK v3** code by default. Produce v2 code **only** when the\nuser explicitly asks for \"v2\" (e.g., \"give me the v2 version\"); if you do, label it as\ndeprecated and note `pip install 'sagemaker<3.0'`.\n\n## SDK-first: use the SageMaker Python SDK for SageMaker tasks\n\nFor any Amazon SageMaker task (training, deployment, processing, pipelines), **default to the\nSageMaker Python SDK v3** as the primary interface. Do **not** drop to raw `boto3`\n(`client(\"sagemaker\").create_training_job(...)`), the AWS CLI, or hand-rolled framework\nscripts unless the user explicitly asks for them, because the SDK handles image resolution,\npackaging, and job wiring that raw clients leave to the caller.\n\nMap the user's intent to the v3 interface:\n\n| User intent (natural language) | Use this v3 interface |\n|---|---|\n| \"train a model\", \"training job\", \"serverless / managed training\", \"fine-tune\" | `sagemaker.train.ModelTrainer` → `.train(...)` |\n| \"distributed training\", \"multi-GPU / multi-node\" | `ModelTrainer` with `Compute(instance_count=N, ...)` |\n| \"hyperparameter tuning\", \"HPO\", \"sweep\" | `sagemaker.train` tuner APIs on top of `ModelTrainer` |\n| \"deploy a model\", \"real-time / serverless / async endpoint\", \"host / serve\" | `sagemaker.serve.ModelBuilder` → `.deploy(...)` |\n| \"batch inference\", \"batch transform\", \"offline scoring\" | `sagemaker.core.resources` transform APIs |\n| \"process data\", \"feature engineering\", \"preprocess\", \"transform dataset\" | `sagemaker.core.resources.ProcessingJob` |\n| \"build an ML pipeline\", \"orchestrate a workflow\", \"MLOps\" | `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps` |\n| \"register a model\", \"model registry\" | `sagemaker.mlops` model-registry APIs |\n| \"get / retrieve a container image URI\" | `sagemaker.core.image_uris.retrieve(...)` |\n\nOnly step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM\nor S3 setup step), and say so explicitly when you do.\n\n**Honest scope note:** this guidance only steers agents that have this file (or the SDK repo,\nor an equivalent rules/MCP configuration) in context. It does not change a plain chat session\nthat never loads these files — winning those requires corpus/discoverability work outside this\nrepo (see the deprecation recommendations doc).\n\n## Banned v2 patterns → required v3 replacements\n\nDo not emit the left column unless v2 is explicitly requested. Mappings follow the official\n[migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md).\n\n| v2 (do NOT use) | v3 (use instead) |\n|---|---|\n| `from sagemaker.estimator import Estimator` | `from sagemaker.train import ModelTrainer` |\n| framework estimator classes — `from sagemaker.pytorch import PyTorch` (also TensorFlow, SKLearn, XGBoost, HuggingFace) | `ModelTrainer` + `from sagemaker.core import image_uris` → `image_uris.retrieve(...)` |\n| `estimator.fit(...)` | `model_trainer.train(...)` |\n| `from sagemaker.model import Model` / `model.deploy(...)` | `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)` |\n| `from sagemaker.predictor import Predictor` / `predictor.predict(...)` | `Predictor` is replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)` |\n| `from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessor` | `sagemaker.core.resources.ProcessingJob` |\n| `from sagemaker.workflow...` (old paths) | `from sagemaker.mlops...` (`sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`) |\n\nRemoved in v3 with **no** direct replacement (do not invent shims): MXNet, Chainer,\nRLEstimator, Training Compiler.\n\n## Required workflow when writing SageMaker code\n\n1. Write the code using v3 patterns from the table above.\n2. **Self-check** the output for any banned v2 pattern (if a migration MCP tool such as\n   `sagemaker-sdk-helper` is available, call its validate/transform tools).\n3. If a v2 pattern is found, fix it to v3 and re-check until clean.\n4. Only then present the code.\n\n## Repository layout (capability folders)\n\nThe repository is organized by ML capability, following the lifecycle order:\n\n- `training/` — training with `ModelTrainer`: script and framework training, distributed\n  training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues, `@remote`\n- `model_customization/` — fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT,\n  recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuning\n- `evaluation/` — the `*Evaluator` surface: benchmark, custom scorer, LLM-as-a-judge, Inspect AI\n- `inference/` — deployment with `ModelBuilder` and sagemaker-core: real-time / serverless /\n  async endpoints, local and in-process modes, inference pipelines, MME / multi-container,\n  A/B testing, shadow variants, guardrails, autoscaling, `optimize()`, batch transform, Bedrock\n- `mlops/` — Pipelines and Model Registry, lineage, experiments, Feature Store, processing,\n  EMR Serverless steps, Clarify, MLflow\n\n(Category folders carry leading-space ordering prefixes in this repo — `      training`,\n`     model_customization`, `    evaluation`, `   inference`, `  mlops` — so that they list in\nlifecycle order. Match the existing name exactly, including the prefix, when adding files.)\n\n## Code conventions\n\n- No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use\n  `get_execution_role()` and `Session().default_bucket()`.\n- Do not require interactive input to run.\n- Notebook file naming: `sm-<feature>_<description>.ipynb`.\n- Each notebook includes: a title cell, a setup cell (`%pip install sagemaker`), a cleanup\n  cell that deletes created resources, and a summary cell.\n- Clear cell outputs before committing. Target the latest v3.\n\n## Canonical v3 example (train + deploy)\n\nGrounded in the migration guide; verify exact signatures against the installed SDK.\n\n```python\nfrom sagemaker.core import image_uris\nfrom sagemaker.train import ModelTrainer\nfrom sagemaker.train.configs import SourceCode, Compute, InputData\nfrom sagemaker.serve import ModelBuilder\nfrom sagemaker.serve.configs import InferenceSpec\n\n# Training\ntraining_image = image_uris.retrieve(\n    framework=\"pytorch\", region=\"us-west-2\", version=\"2.0.0\",\n    py_version=\"py310\", instance_type=\"ml.p3.2xlarge\", image_scope=\"training\",\n)\nmodel_trainer = ModelTrainer(\n    training_image=training_image,\n    role=role,\n    source_code=SourceCode(source_dir=\"./src\", entry_script=\"train.py\"),\n    compute=Compute(instance_type=\"ml.p3.2xlarge\", instance_count=1),\n)\nmodel_trainer.train(input_data_config=[InputData(channel_name=\"train\", data_source=\"s3://<bucket>/train\")])\n\n# Inference\nmodel_builder = ModelBuilder(\n    inference_spec=InferenceSpec(\n        image_uri=\"<inference-image-uri>\",\n        model_data_url=\"s3://<bucket>/model.tar.gz\",\n    ),\n    role=role,\n)\npredictor = model_builder.deploy(instance_type=\"ml.m5.large\", initial_instance_count=1)\n```\n\n## References\n\n- V2 → V3 migration guide: https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md\n- SageMaker Python SDK (source): https://github.com/aws/sagemaker-python-sdk\n- SageMaker Python SDK docs: https://sagemaker.readthedocs.io/\n- Curated index for agents: ./llms.txt\n"},"files":{"llms.txt":"# Amazon SageMaker Examples\n\n> Example notebooks for building, training, and deploying models with the Amazon SageMaker\n> Python SDK **v3**. This repository targets **v3 only**; `pip install sagemaker` installs v3.\n> SDK v3 is modular (`sagemaker-core`, `sagemaker-train`, `sagemaker-serve`, `sagemaker-mlops`)\n> and is not backward compatible with v2. v2 examples are archived, not maintained.\n\nThis file follows the llms.txt convention (https://llmstxt.org): a curated index plus explicit\ninstructions so AI coding agents generate correct, current (v3) code.\n\n## Instructions for LLM agents (SageMaker Python SDK)\n\n- **SDK-first:** for any SageMaker task (train, deploy, process, pipelines), use the\n  **SageMaker Python SDK v3** as the primary interface. Do not drop to raw `boto3`\n  (`create_training_job`, `create_endpoint`), the AWS CLI, or hand-rolled framework scripts\n  unless the user explicitly asks. Intent → interface:\n  - \"train / fine-tune / training job / serverless training\" → `sagemaker.train.ModelTrainer` (`.train(...)`)\n  - \"deploy / host / real-time or serverless or async endpoint\" → `sagemaker.serve.ModelBuilder` (`.deploy(...)`)\n  - \"process data / feature engineering / preprocess\" → `sagemaker.core.resources.ProcessingJob`\n  - \"pipeline / orchestrate / MLOps\" → `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n  - \"container image URI\" → `sagemaker.core.image_uris.retrieve(...)`\n- Default to SageMaker Python SDK **v3**.\n- **Never** emit these v2 patterns unless the user explicitly asks for \"v2\":\n  - `from sagemaker.estimator import Estimator` → use `from sagemaker.train import ModelTrainer`\n  - framework estimator classes (`from sagemaker.pytorch import PyTorch`, TensorFlow, SKLearn,\n    XGBoost, HuggingFace) → `ModelTrainer` + `from sagemaker.core import image_uris` (`image_uris.retrieve(...)`)\n  - `estimator.fit(...)` → `model_trainer.train(...)`\n  - `from sagemaker.model import Model` / `model.deploy(...)` → `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)`\n  - `from sagemaker.predictor import Predictor` / `predictor.predict(...)` → `Predictor` replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)`\n  - `from sagemaker.processing import Processor/ScriptProcessor/SKLearnProcessor` → `sagemaker.core.resources.ProcessingJob`\n  - `from sagemaker.workflow...` → `from sagemaker.mlops...`\n- Removed in v3 (no replacement): MXNet, Chainer, RLEstimator, Training Compiler.\n- After generating SageMaker code, validate it contains none of the v2 patterns above. If unsure\n  of a mapping, consult the migration guide below or call the migration MCP tool.\n- No hardcoded account IDs, role ARNs, regions, or bucket names. Use `get_execution_role()` and\n  `Session().default_bucket()`.\n\n## Migration\n\n- [V2 → V3 migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md): authoritative mappings and before/after examples\n- [SageMaker Python SDK (source)](https://github.com/aws/sagemaker-python-sdk)\n- [SageMaker Python SDK docs](https://sagemaker.readthedocs.io/)\n\n## Core v3 interfaces\n\n- Training: `sagemaker.train.ModelTrainer` (+ `train.configs`: `Compute`, `SourceCode`, `InputData`)\n- Inference: `sagemaker.serve.ModelBuilder` (+ `serve.configs.InferenceSpec`), then `ModelBuilder.deploy(...)`\n- Processing: `sagemaker.core.resources.ProcessingJob`\n- MLOps / Pipelines: `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n- Images: `sagemaker.core.image_uris.retrieve(...)`\n\n## Example categories\n\nThe repository is organized by ML capability, in lifecycle order.\n\n- `training/`: training with `ModelTrainer` — script and framework training, distributed training, managed spot with checkpointing, heterogeneous clusters, bring-your-own-container, AWS Batch training queues, `@remote`\n- `model_customization/`: fine-tuning foundation models — SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning with a private model hub, distributed fine-tuning\n- `evaluation/`: the `*Evaluator` surface — benchmark evaluation, custom scorers, LLM-as-a-judge, Inspect AI\n- `inference/`: deployment with `ModelBuilder` and sagemaker-core — real-time/serverless/async endpoints, in-process and local-container modes, inference pipelines, multi-model and multi-container endpoints, A/B testing, shadow variants, deployment guardrails, autoscaling with inference components, `optimize()`, batch transform, Bedrock deployment, Marketplace model packages, Augmented AI\n- `mlops/`: Pipelines with Model Registry, lineage tracking, experiment tracking, Feature Store, processing jobs, EMR Serverless steps, Clarify, MLflow\n\nBrowse them at https://github.com/aws/amazon-sagemaker-examples/tree/default\n","AGENTS.md":"# AGENTS.md — Amazon SageMaker Examples\n\nGuidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer,\nKiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md\nconvention (https://agents.md).\n\n## Project context\n\nThis repository contains example notebooks for the **Amazon SageMaker Python SDK v3**.\n`pip install sagemaker` installs **v3**. SDK v3 is a modular redesign and is **not\nbackward compatible** with v2. It is split into:\n\n- `sagemaker-core` — foundation primitives and the low-level, resource-oriented API\n- `sagemaker-train` — training (`ModelTrainer`)\n- `sagemaker-serve` — model building & deployment (`ModelBuilder`)\n- `sagemaker-mlops` — pipelines and workflow orchestration\n\n## Golden rule: generate v3 by default\n\nGenerate **SageMaker Python SDK v3** code by default. Produce v2 code **only** when the\nuser explicitly asks for \"v2\" (e.g., \"give me the v2 version\"); if you do, label it as\ndeprecated and note `pip install 'sagemaker<3.0'`.\n\n## SDK-first: use the SageMaker Python SDK for SageMaker tasks\n\nFor any Amazon SageMaker task (training, deployment, processing, pipelines), **default to the\nSageMaker Python SDK v3** as the primary interface. Do **not** drop to raw `boto3`\n(`client(\"sagemaker\").create_training_job(...)`), the AWS CLI, or hand-rolled framework\nscripts unless the user explicitly asks for them, because the SDK handles image resolution,\npackaging, and job wiring that raw clients leave to the caller.\n\nMap the user's intent to the v3 interface:\n\n| User intent (natural language) | Use this v3 interface |\n|---|---|\n| \"train a model\", \"training job\", \"serverless / managed training\", \"fine-tune\" | `sagemaker.train.ModelTrainer` → `.train(...)` |\n| \"distributed training\", \"multi-GPU / multi-node\" | `ModelTrainer` with `Compute(instance_count=N, ...)` |\n| \"hyperparameter tuning\", \"HPO\", \"sweep\" | `sagemaker.train` tuner APIs on top of `ModelTrainer` |\n| \"deploy a model\", \"real-time / serverless / async endpoint\", \"host / serve\" | `sagemaker.serve.ModelBuilder` → `.deploy(...)` |\n| \"batch inference\", \"batch transform\", \"offline scoring\" | `sagemaker.core.resources` transform APIs |\n| \"process data\", \"feature engineering\", \"preprocess\", \"transform dataset\" | `sagemaker.core.resources.ProcessingJob` |\n| \"build an ML pipeline\", \"orchestrate a workflow\", \"MLOps\" | `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps` |\n| \"register a model\", \"model registry\" | `sagemaker.mlops` model-registry APIs |\n| \"get / retrieve a container image URI\" | `sagemaker.core.image_uris.retrieve(...)` |\n\nOnly step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM\nor S3 setup step), and say so explicitly when you do.\n\n**Honest scope note:** this guidance only steers agents that have this file (or the SDK repo,\nor an equivalent rules/MCP configuration) in context. It does not change a plain chat session\nthat never loads these files — winning those requires corpus/discoverability work outside this\nrepo (see the deprecation recommendations doc).\n\n## Banned v2 patterns → required v3 replacements\n\nDo not emit the left column unless v2 is explicitly requested. Mappings follow the official\n[migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md).\n\n| v2 (do NOT use) | v3 (use instead) |\n|---|---|\n| `from sagemaker.estimator import Estimator` | `from sagemaker.train import ModelTrainer` |\n| framework estimator classes — `from sagemaker.pytorch import PyTorch` (also TensorFlow, SKLearn, XGBoost, HuggingFace) | `ModelTrainer` + `from sagemaker.core import image_uris` → `image_uris.retrieve(...)` |\n| `estimator.fit(...)` | `model_trainer.train(...)` |\n| `from sagemaker.model import Model` / `model.deploy(...)` | `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)` |\n| `from sagemaker.predictor import Predictor` / `predictor.predict(...)` | `Predictor` is replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)` |\n| `from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessor` | `sagemaker.core.resources.ProcessingJob` |\n| `from sagemaker.workflow...` (old paths) | `from sagemaker.mlops...` (`sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`) |\n\nRemoved in v3 with **no** direct replacement (do not invent shims): MXNet, Chainer,\nRLEstimator, Training Compiler.\n\n## Required workflow when writing SageMaker code\n\n1. Write the code using v3 patterns from the table above.\n2. **Self-check** the output for any banned v2 pattern (if a migration MCP tool such as\n   `sagemaker-sdk-helper` is available, call its validate/transform tools).\n3. If a v2 pattern is found, fix it to v3 and re-check until clean.\n4. Only then present the code.\n\n## Repository layout (capability folders)\n\nThe repository is organized by ML capability, following the lifecycle order:\n\n- `training/` — training with `ModelTrainer`: script and framework training, distributed\n  training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues, `@remote`\n- `model_customization/` — fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT,\n  recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuning\n- `evaluation/` — the `*Evaluator` surface: benchmark, custom scorer, LLM-as-a-judge, Inspect AI\n- `inference/` — deployment with `ModelBuilder` and sagemaker-core: real-time / serverless /\n  async endpoints, local and in-process modes, inference pipelines, MME / multi-container,\n  A/B testing, shadow variants, guardrails, autoscaling, `optimize()`, batch transform, Bedrock\n- `mlops/` — Pipelines and Model Registry, lineage, experiments, Feature Store, processing,\n  EMR Serverless steps, Clarify, MLflow\n\n(Category folders carry leading-space ordering prefixes in this repo — `      training`,\n`     model_customization`, `    evaluation`, `   inference`, `  mlops` — so that they list in\nlifecycle order. Match the existing name exactly, including the prefix, when adding files.)\n\n## Code conventions\n\n- No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use\n  `get_execution_role()` and `Session().default_bucket()`.\n- Do not require interactive input to run.\n- Notebook file naming: `sm-<feature>_<description>.ipynb`.\n- Each notebook includes: a title cell, a setup cell (`%pip install sagemaker`), a cleanup\n  cell that deletes created resources, and a summary cell.\n- Clear cell outputs before committing. Target the latest v3.\n\n## Canonical v3 example (train + deploy)\n\nGrounded in the migration guide; verify exact signatures against the installed SDK.\n\n```python\nfrom sagemaker.core import image_uris\nfrom sagemaker.train import ModelTrainer\nfrom sagemaker.train.configs import SourceCode, Compute, InputData\nfrom sagemaker.serve import ModelBuilder\nfrom sagemaker.serve.configs import InferenceSpec\n\n# Training\ntraining_image = image_uris.retrieve(\n    framework=\"pytorch\", region=\"us-west-2\", version=\"2.0.0\",\n    py_version=\"py310\", instance_type=\"ml.p3.2xlarge\", image_scope=\"training\",\n)\nmodel_trainer = ModelTrainer(\n    training_image=training_image,\n    role=role,\n    source_code=SourceCode(source_dir=\"./src\", entry_script=\"train.py\"),\n    compute=Compute(instance_type=\"ml.p3.2xlarge\", instance_count=1),\n)\nmodel_trainer.train(input_data_config=[InputData(channel_name=\"train\", data_source=\"s3://<bucket>/train\")])\n\n# Inference\nmodel_builder = ModelBuilder(\n    inference_spec=InferenceSpec(\n        image_uri=\"<inference-image-uri>\",\n        model_data_url=\"s3://<bucket>/model.tar.gz\",\n    ),\n    role=role,\n)\npredictor = model_builder.deploy(instance_type=\"ml.m5.large\", initial_instance_count=1)\n```\n\n## References\n\n- V2 → V3 migration guide: https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md\n- SageMaker Python SDK (source): https://github.com/aws/sagemaker-python-sdk\n- SageMaker Python SDK docs: https://sagemaker.readthedocs.io/\n- Curated index for agents: ./llms.txt\n"},"items":[{"name":"AGENTS.md","path":"AGENTS.md","rawUrl":"https://raw.githubusercontent.com/aws/amazon-sagemaker-examples/HEAD/AGENTS.md","title":"AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# AGENTS.md — Amazon SageMaker Examples\n\nGuidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer,\nKiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md\nconvention (https://agents.md).\n\n## Project context\n\nThis repository contains example notebooks for the **Amazon SageMaker Python SDK v3**.\n`pip install sagemaker` installs **v3**. SDK v3 is a modular redesign and is **not\nbackward compatible** with v2. It is split into:\n\n- `sagemaker-core` — foundation primitives and the low-level, resource-oriented API\n- `sagemaker-train` — training (`ModelTrainer`)\n- `sagemaker-serve` — model building & deployment (`ModelBuilder`)\n- `sagemaker-mlops` — pipelines and workflow orchestration\n\n## Golden rule: generate v3 by default\n\nGenerate **SageMaker Python SDK v3** code by default. Produce v2 code **only** when the\nuser explicitly asks for \"v2\" (e.g., \"give me the v2 version\"); if you do, label it as\ndeprecated and note `pip install 'sagemaker<3.0'`.\n\n## SDK-first: use the SageMaker Python SDK for SageMaker tasks\n\nFor any Amazon SageMaker task (training, deployment, processing, pipelines), **default to the\nSageMaker Python SDK v3** as the primary interface. Do **not** drop to raw `boto3`\n(`client(\"sagemaker\").create_training_job(...)`), the AWS CLI, or hand-rolled framework\nscripts unless the user explicitly asks for them, because the SDK handles image resolution,\npackaging, and job wiring that raw clients leave to the caller.\n\nMap the user's intent to the v3 interface:\n\n| User intent (natural language) | Use this v3 interface |\n|---|---|\n| \"train a model\", \"training job\", \"serverless / managed training\", \"fine-tune\" | `sagemaker.train.ModelTrainer` → `.train(...)` |\n| \"distributed training\", \"multi-GPU / multi-node\" | `ModelTrainer` with `Compute(instance_count=N, ...)` |\n| \"hyperparameter tuning\", \"HPO\", \"sweep\" | `sagemaker.train` tuner APIs on top of `ModelTrainer` |\n| \"deploy a model\", \"real-time / serverless / async endpoint\", \"host / serve\" | `sagemaker.serve.ModelBuilder` → `.deploy(...)` |\n| \"batch inference\", \"batch transform\", \"offline scoring\" | `sagemaker.core.resources` transform APIs |\n| \"process data\", \"feature engineering\", \"preprocess\", \"transform dataset\" | `sagemaker.core.resources.ProcessingJob` |\n| \"build an ML pipeline\", \"orchestrate a workflow\", \"MLOps\" | `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps` |\n| \"register a model\", \"model registry\" | `sagemaker.mlops` model-registry APIs |\n| \"get / retrieve a container image URI\" | `sagemaker.core.image_uris.retrieve(...)` |\n\nOnly step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM\nor S3 setup step), and say so explicitly when you do.\n\n**Honest scope note:** this guidance only steers agents that have this file (or the SDK repo,\nor an equivalent rules/MCP configuration) in context. It does not change a plain chat session\nthat never loads these files — winning those requires corpus/discoverability work outside this\nrepo (see the deprecation recommendations doc).\n\n## Banned v2 patterns → required v3 replacements\n\nDo not emit the left column unless v2 is explicitly requested. Mappings follow the official\n[migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md).\n\n| v2 (do NOT use) | v3 (use instead) |\n|---|---|\n| `from sagemaker.estimator import Estimator` | `from sagemaker.train import ModelTrainer` |\n| framework estimator classes — `from sagemaker.pytorch import PyTorch` (also TensorFlow, SKLearn, XGBoost, HuggingFace) | `ModelTrainer` + `from sagemaker.core import image_uris` → `image_uris.retrieve(...)` |\n| `estimator.fit(...)` | `model_trainer.train(...)` |\n| `from sagemaker.model import Model` / `model.deploy(...)` | `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)` |\n| `from sagemaker.predictor import Predictor` / `predictor.predict(...)` | `Predictor` is replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)` |\n| `from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessor` | `sagemaker.core.resources.ProcessingJob` |\n| `from sagemaker.workflow...` (old paths) | `from sagemaker.mlops...` (`sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`) |\n\nRemoved in v3 with **no** direct replacement (do not invent shims): MXNet, Chainer,\nRLEstimator, Training Compiler.\n\n## Required workflow when writing SageMaker code\n\n1. Write the code using v3 patterns from the table above.\n2. **Self-check** the output for any banned v2 pattern (if a migration MCP tool such as\n   `sagemaker-sdk-helper` is available, call its validate/transform tools).\n3. If a v2 pattern is found, fix it to v3 and re-check until clean.\n4. Only then present the code.\n\n## Repository layout (capability folders)\n\nThe repository is organized by ML capability, following the lifecycle order:\n\n- `training/` — training with `ModelTrainer`: script and framework training, distributed\n  training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues, `@remote`\n- `model_customization/` — fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT,\n  recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuning\n- `evaluation/` — the `*Evaluator` surface: benchmark, custom scorer, LLM-as-a-judge, Inspect AI\n- `inference/` — deployment with `ModelBuilder` and sagemaker-core: real-time / serverless /\n  async endpoints, local and in-process modes, inference pipelines, MME / multi-container,\n  A/B testing, shadow variants, guardrails, autoscaling, `optimize()`, batch transform, Bedrock\n- `mlops/` — Pipelines and Model Registry, lineage, experiments, Feature Store, processing,\n  EMR Serverless steps, Clarify, MLflow\n\n(Category folders carry leading-space ordering prefixes in this repo — `      training`,\n`     model_customization`, `    evaluation`, `   inference`, `  mlops` — so that they list in\nlifecycle order. Match the existing name exactly, including the prefix, when adding files.)\n\n## Code conventions\n\n- No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use\n  `get_execution_role()` and `Session().default_bucket()`.\n- Do not require interactive input to run.\n- Notebook file naming: `sm-<feature>_<description>.ipynb`.\n- Each notebook includes: a title cell, a setup cell (`%pip install sagemaker`), a cleanup\n  cell that deletes created resources, and a summary cell.\n- Clear cell outputs before committing. Target the latest v3.\n\n## Canonical v3 example (train + deploy)\n\nGrounded in the migration guide; verify exact signatures against the installed SDK.\n\n```python\nfrom sagemaker.core import image_uris\nfrom sagemaker.train import ModelTrainer\nfrom sagemaker.train.configs import SourceCode, Compute, InputData\nfrom sagemaker.serve import ModelBuilder\nfrom sagemaker.serve.configs import InferenceSpec\n\n# Training\ntraining_image = image_uris.retrieve(\n    framework=\"pytorch\", region=\"us-west-2\", version=\"2.0.0\",\n    py_version=\"py310\", instance_type=\"ml.p3.2xlarge\", image_scope=\"training\",\n)\nmodel_trainer = ModelTrainer(\n    training_image=training_image,\n    role=role,\n    source_code=SourceCode(source_dir=\"./src\", entry_script=\"train.py\"),\n    compute=Compute(instance_type=\"ml.p3.2xlarge\", instance_count=1),\n)\nmodel_trainer.train(input_data_config=[InputData(channel_name=\"train\", data_source=\"s3://<bucket>/train\")])\n\n# Inference\nmodel_builder = ModelBuilder(\n    inference_spec=InferenceSpec(\n        image_uri=\"<inference-image-uri>\",\n        model_data_url=\"s3://<bucket>/model.tar.gz\",\n    ),\n    role=role,\n)\npredictor = model_builder.deploy(instance_type=\"ml.m5.large\", initial_instance_count=1)\n```\n\n## References\n\n- V2 → V3 migration guide: https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md\n- SageMaker Python SDK (source): https://github.com/aws/sagemaker-python-sdk\n- SageMaker Python SDK docs: https://sagemaker.readthedocs.io/\n- Curated index for agents: ./llms.txt\n","isInternal":false,"tokens":2030,"sizeBytes":8051},{"name":"llms.txt","path":"llms.txt","rawUrl":"https://raw.githubusercontent.com/aws/amazon-sagemaker-examples/HEAD/llms.txt","title":"LLM Index & Context Digest","category":"root-instruction","format":"text","content":"# Amazon SageMaker Examples\n\n> Example notebooks for building, training, and deploying models with the Amazon SageMaker\n> Python SDK **v3**. This repository targets **v3 only**; `pip install sagemaker` installs v3.\n> SDK v3 is modular (`sagemaker-core`, `sagemaker-train`, `sagemaker-serve`, `sagemaker-mlops`)\n> and is not backward compatible with v2. v2 examples are archived, not maintained.\n\nThis file follows the llms.txt convention (https://llmstxt.org): a curated index plus explicit\ninstructions so AI coding agents generate correct, current (v3) code.\n\n## Instructions for LLM agents (SageMaker Python SDK)\n\n- **SDK-first:** for any SageMaker task (train, deploy, process, pipelines), use the\n  **SageMaker Python SDK v3** as the primary interface. Do not drop to raw `boto3`\n  (`create_training_job`, `create_endpoint`), the AWS CLI, or hand-rolled framework scripts\n  unless the user explicitly asks. Intent → interface:\n  - \"train / fine-tune / training job / serverless training\" → `sagemaker.train.ModelTrainer` (`.train(...)`)\n  - \"deploy / host / real-time or serverless or async endpoint\" → `sagemaker.serve.ModelBuilder` (`.deploy(...)`)\n  - \"process data / feature engineering / preprocess\" → `sagemaker.core.resources.ProcessingJob`\n  - \"pipeline / orchestrate / MLOps\" → `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n  - \"container image URI\" → `sagemaker.core.image_uris.retrieve(...)`\n- Default to SageMaker Python SDK **v3**.\n- **Never** emit these v2 patterns unless the user explicitly asks for \"v2\":\n  - `from sagemaker.estimator import Estimator` → use `from sagemaker.train import ModelTrainer`\n  - framework estimator classes (`from sagemaker.pytorch import PyTorch`, TensorFlow, SKLearn,\n    XGBoost, HuggingFace) → `ModelTrainer` + `from sagemaker.core import image_uris` (`image_uris.retrieve(...)`)\n  - `estimator.fit(...)` → `model_trainer.train(...)`\n  - `from sagemaker.model import Model` / `model.deploy(...)` → `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)`\n  - `from sagemaker.predictor import Predictor` / `predictor.predict(...)` → `Predictor` replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)`\n  - `from sagemaker.processing import Processor/ScriptProcessor/SKLearnProcessor` → `sagemaker.core.resources.ProcessingJob`\n  - `from sagemaker.workflow...` → `from sagemaker.mlops...`\n- Removed in v3 (no replacement): MXNet, Chainer, RLEstimator, Training Compiler.\n- After generating SageMaker code, validate it contains none of the v2 patterns above. If unsure\n  of a mapping, consult the migration guide below or call the migration MCP tool.\n- No hardcoded account IDs, role ARNs, regions, or bucket names. Use `get_execution_role()` and\n  `Session().default_bucket()`.\n\n## Migration\n\n- [V2 → V3 migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md): authoritative mappings and before/after examples\n- [SageMaker Python SDK (source)](https://github.com/aws/sagemaker-python-sdk)\n- [SageMaker Python SDK docs](https://sagemaker.readthedocs.io/)\n\n## Core v3 interfaces\n\n- Training: `sagemaker.train.ModelTrainer` (+ `train.configs`: `Compute`, `SourceCode`, `InputData`)\n- Inference: `sagemaker.serve.ModelBuilder` (+ `serve.configs.InferenceSpec`), then `ModelBuilder.deploy(...)`\n- Processing: `sagemaker.core.resources.ProcessingJob`\n- MLOps / Pipelines: `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n- Images: `sagemaker.core.image_uris.retrieve(...)`\n\n## Example categories\n\nThe repository is organized by ML capability, in lifecycle order.\n\n- `training/`: training with `ModelTrainer` — script and framework training, distributed training, managed spot with checkpointing, heterogeneous clusters, bring-your-own-container, AWS Batch training queues, `@remote`\n- `model_customization/`: fine-tuning foundation models — SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning with a private model hub, distributed fine-tuning\n- `evaluation/`: the `*Evaluator` surface — benchmark evaluation, custom scorers, LLM-as-a-judge, Inspect AI\n- `inference/`: deployment with `ModelBuilder` and sagemaker-core — real-time/serverless/async endpoints, in-process and local-container modes, inference pipelines, multi-model and multi-container endpoints, A/B testing, shadow variants, deployment guardrails, autoscaling with inference components, `optimize()`, batch transform, Bedrock deployment, Marketplace model packages, Augmented AI\n- `mlops/`: Pipelines with Model Registry, lineage tracking, experiment tracking, Feature Store, processing jobs, EMR Serverless steps, Clarify, MLflow\n\nBrowse them at https://github.com/aws/amazon-sagemaker-examples/tree/default\n","isInternal":false,"tokens":1198,"sizeBytes":4808}],"systemPromptSnippet":"<yakaai_skills repo=\"aws/amazon-sagemaker-examples\">\n<!-- File: AGENTS.md (Tokens: ~2030 | Category: root-instruction) -->\n# AGENTS.md — Amazon SageMaker Examples\n\nGuidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer,\nKiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md\nconvention (https://agents.md).\n\n## Project context\n\nThis repository contains example notebooks for the **Amazon SageMaker Python SDK v3**.\n`pip install sagemaker` installs **v3**. SDK v3 is a modular redesign and is **not\nbackward compatible** with v2. It is split into:\n\n- `sagemaker-core` — foundation primitives and the low-level, resource-oriented API\n- `sagemaker-train` — training (`ModelTrainer`)\n- `sagemaker-serve` — model building & deployment (`ModelBuilder`)\n- `sagemaker-mlops` — pipelines and workflow orchestration\n\n## Golden rule: generate v3 by default\n\nGenerate **SageMaker Python SDK v3** code by default. Produce v2 code **only** when the\nuser explicitly asks for \"v2\" (e.g., \"give me the v2 version\"); if you do, label it as\ndeprecated and note `pip install 'sagemaker<3.0'`.\n\n## SDK-first: use the SageMaker Python SDK for SageMaker tasks\n\nFor any Amazon SageMaker task (training, deployment, processing, pipelines), **default to the\nSageMaker Python SDK v3** as the primary interface. Do **not** drop to raw `boto3`\n(`client(\"sagemaker\").create_training_job(...)`), the AWS CLI, or hand-rolled framework\nscripts unless the user explicitly asks for them, because the SDK handles image resolution,\npackaging, and job wiring that raw clients leave to the caller.\n\nMap the user's intent to the v3 interface:\n\n| User intent (natural language) | Use this v3 interface |\n|---|---|\n| \"train a model\", \"training job\", \"serverless / managed training\", \"fine-tune\" | `sagemaker.train.ModelTrainer` → `.train(...)` |\n| \"distributed training\", \"multi-GPU / multi-node\" | `ModelTrainer` with `Compute(instance_count=N, ...)` |\n| \"hyperparameter tuning\", \"HPO\", \"sweep\" | `sagemaker.train` tuner APIs on top of `ModelTrainer` |\n| \"deploy a model\", \"real-time / serverless / async endpoint\", \"host / serve\" | `sagemaker.serve.ModelBuilder` → `.deploy(...)` |\n| \"batch inference\", \"batch transform\", \"offline scoring\" | `sagemaker.core.resources` transform APIs |\n| \"process data\", \"feature engineering\", \"preprocess\", \"transform dataset\" | `sagemaker.core.resources.ProcessingJob` |\n| \"build an ML pipeline\", \"orchestrate a workflow\", \"MLOps\" | `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps` |\n| \"register a model\", \"model registry\" | `sagemaker.mlops` model-registry APIs |\n| \"get / retrieve a container image URI\" | `sagemaker.core.image_uris.retrieve(...)` |\n\nOnly step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM\nor S3 setup step), and say so explicitly when you do.\n\n**Honest scope note:** this guidance only steers agents that have this file (or the SDK repo,\nor an equivalent rules/MCP configuration) in context. It does not change a plain chat session\nthat never loads these files — winning those requires corpus/discoverability work outside this\nrepo (see the deprecation recommendations doc).\n\n## Banned v2 patterns → required v3 replacements\n\nDo not emit the left column unless v2 is explicitly requested. Mappings follow the official\n[migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md).\n\n| v2 (do NOT use) | v3 (use instead) |\n|---|---|\n| `from sagemaker.estimator import Estimator` | `from sagemaker.train import ModelTrainer` |\n| framework estimator classes — `from sagemaker.pytorch import PyTorch` (also TensorFlow, SKLearn, XGBoost, HuggingFace) | `ModelTrainer` + `from sagemaker.core import image_uris` → `image_uris.retrieve(...)` |\n| `estimator.fit(...)` | `model_trainer.train(...)` |\n| `from sagemaker.model import Model` / `model.deploy(...)` | `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)` |\n| `from sagemaker.predictor import Predictor` / `predictor.predict(...)` | `Predictor` is replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)` |\n| `from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessor` | `sagemaker.core.resources.ProcessingJob` |\n| `from sagemaker.workflow...` (old paths) | `from sagemaker.mlops...` (`sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`) |\n\nRemoved in v3 with **no** direct replacement (do not invent shims): MXNet, Chainer,\nRLEstimator, Training Compiler.\n\n## Required workflow when writing SageMaker code\n\n1. Write the code using v3 patterns from the table above.\n2. **Self-check** the output for any banned v2 pattern (if a migration MCP tool such as\n   `sagemaker-sdk-helper` is available, call its validate/transform tools).\n3. If a v2 pattern is found, fix it to v3 and re-check until clean.\n4. Only then present the code.\n\n## Repository layout (capability folders)\n\nThe repository is organized by ML capability, following the lifecycle order:\n\n- `training/` — training with `ModelTrainer`: script and framework training, distributed\n  training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues, `@remote`\n- `model_customization/` — fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT,\n  recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuning\n- `evaluation/` — the `*Evaluator` surface: benchmark, custom scorer, LLM-as-a-judge, Inspect AI\n- `inference/` — deployment with `ModelBuilder` and sagemaker-core: real-time / serverless /\n  async endpoints, local and in-process modes, inference pipelines, MME / multi-container,\n  A/B testing, shadow variants, guardrails, autoscaling, `optimize()`, batch transform, Bedrock\n- `mlops/` — Pipelines and Model Registry, lineage, experiments, Feature Store, processing,\n  EMR Serverless steps, Clarify, MLflow\n\n(Category folders carry leading-space ordering prefixes in this repo — `      training`,\n`     model_customization`, `    evaluation`, `   inference`, `  mlops` — so that they list in\nlifecycle order. Match the existing name exactly, including the prefix, when adding files.)\n\n## Code conventions\n\n- No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use\n  `get_execution_role()` and `Session().default_bucket()`.\n- Do not require interactive input to run.\n- Notebook file naming: `sm-<feature>_<description>.ipynb`.\n- Each notebook includes: a title cell, a setup cell (`%pip install sagemaker`), a cleanup\n  cell that deletes created resources, and a summary cell.\n- Clear cell outputs before committing. Target the latest v3.\n\n## Canonical v3 example (train + deploy)\n\nGrounded in the migration guide; verify exact signatures against the installed SDK.\n\n```python\nfrom sagemaker.core import image_uris\nfrom sagemaker.train import ModelTrainer\nfrom sagemaker.train.configs import SourceCode, Compute, InputData\nfrom sagemaker.serve import ModelBuilder\nfrom sagemaker.serve.configs import InferenceSpec\n\n# Training\ntraining_image = image_uris.retrieve(\n    framework=\"pytorch\", region=\"us-west-2\", version=\"2.0.0\",\n    py_version=\"py310\", instance_type=\"ml.p3.2xlarge\", image_scope=\"training\",\n)\nmodel_trainer = ModelTrainer(\n    training_image=training_image,\n    role=role,\n    source_code=SourceCode(source_dir=\"./src\", entry_script=\"train.py\"),\n    compute=Compute(instance_type=\"ml.p3.2xlarge\", instance_count=1),\n)\nmodel_trainer.train(input_data_config=[InputData(channel_name=\"train\", data_source=\"s3://<bucket>/train\")])\n\n# Inference\nmodel_builder = ModelBuilder(\n    inference_spec=InferenceSpec(\n        image_uri=\"<inference-image-uri>\",\n        model_data_url=\"s3://<bucket>/model.tar.gz\",\n    ),\n    role=role,\n)\npredictor = model_builder.deploy(instance_type=\"ml.m5.large\", initial_instance_count=1)\n```\n\n## References\n\n- V2 → V3 migration guide: https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md\n- SageMaker Python SDK (source): https://github.com/aws/sagemaker-python-sdk\n- SageMaker Python SDK docs: https://sagemaker.readthedocs.io/\n- Curated index for agents: ./llms.txt\n\n<!-- File: llms.txt (Tokens: ~1198 | Category: root-instruction) -->\n# Amazon SageMaker Examples\n\n> Example notebooks for building, training, and deploying models with the Amazon SageMaker\n> Python SDK **v3**. This repository targets **v3 only**; `pip install sagemaker` installs v3.\n> SDK v3 is modular (`sagemaker-core`, `sagemaker-train`, `sagemaker-serve`, `sagemaker-mlops`)\n> and is not backward compatible with v2. v2 examples are archived, not maintained.\n\nThis file follows the llms.txt convention (https://llmstxt.org): a curated index plus explicit\ninstructions so AI coding agents generate correct, current (v3) code.\n\n## Instructions for LLM agents (SageMaker Python SDK)\n\n- **SDK-first:** for any SageMaker task (train, deploy, process, pipelines), use the\n  **SageMaker Python SDK v3** as the primary interface. Do not drop to raw `boto3`\n  (`create_training_job`, `create_endpoint`), the AWS CLI, or hand-rolled framework scripts\n  unless the user explicitly asks. Intent → interface:\n  - \"train / fine-tune / training job / serverless training\" → `sagemaker.train.ModelTrainer` (`.train(...)`)\n  - \"deploy / host / real-time or serverless or async endpoint\" → `sagemaker.serve.ModelBuilder` (`.deploy(...)`)\n  - \"process data / feature engineering / preprocess\" → `sagemaker.core.resources.ProcessingJob`\n  - \"pipeline / orchestrate / MLOps\" → `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n  - \"container image URI\" → `sagemaker.core.image_uris.retrieve(...)`\n- Default to SageMaker Python SDK **v3**.\n- **Never** emit these v2 patterns unless the user explicitly asks for \"v2\":\n  - `from sagemaker.estimator import Estimator` → use `from sagemaker.train import ModelTrainer`\n  - framework estimator classes (`from sagemaker.pytorch import PyTorch`, TensorFlow, SKLearn,\n    XGBoost, HuggingFace) → `ModelTrainer` + `from sagemaker.core import image_uris` (`image_uris.retrieve(...)`)\n  - `estimator.fit(...)` → `model_trainer.train(...)`\n  - `from sagemaker.model import Model` / `model.deploy(...)` → `from sagemaker.serve import ModelBuilder`; `ModelBuilder(...).deploy(...)`\n  - `from sagemaker.predictor import Predictor` / `predictor.predict(...)` → `Predictor` replaced by `Endpoint` (sagemaker-core); use the predictor returned by `ModelBuilder.deploy(...)`\n  - `from sagemaker.processing import Processor/ScriptProcessor/SKLearnProcessor` → `sagemaker.core.resources.ProcessingJob`\n  - `from sagemaker.workflow...` → `from sagemaker.mlops...`\n- Removed in v3 (no replacement): MXNet, Chainer, RLEstimator, Training Compiler.\n- After generating SageMaker code, validate it contains none of the v2 patterns above. If unsure\n  of a mapping, consult the migration guide below or call the migration MCP tool.\n- No hardcoded account IDs, role ARNs, regions, or bucket names. Use `get_execution_role()` and\n  `Session().default_bucket()`.\n\n## Migration\n\n- [V2 → V3 migration guide](https://github.com/aws/sagemaker-python-sdk/blob/master/migration.md): authoritative mappings and before/after examples\n- [SageMaker Python SDK (source)](https://github.com/aws/sagemaker-python-sdk)\n- [SageMaker Python SDK docs](https://sagemaker.readthedocs.io/)\n\n## Core v3 interfaces\n\n- Training: `sagemaker.train.ModelTrainer` (+ `train.configs`: `Compute`, `SourceCode`, `InputData`)\n- Inference: `sagemaker.serve.ModelBuilder` (+ `serve.configs.InferenceSpec`), then `ModelBuilder.deploy(...)`\n- Processing: `sagemaker.core.resources.ProcessingJob`\n- MLOps / Pipelines: `sagemaker.mlops.pipeline.Pipeline`, `sagemaker.mlops.steps`\n- Images: `sagemaker.core.image_uris.retrieve(...)`\n\n## Example categories\n\nThe repository is organized by ML capability, in lifecycle order.\n\n- `training/`: training with `ModelTrainer` — script and framework training, distributed training, managed spot with checkpointing, heterogeneous clusters, bring-your-own-container, AWS Batch training queues, `@remote`\n- `model_customization/`: fine-tuning foundation models — SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning with a private model hub, distributed fine-tuning\n- `evaluation/`: the `*Evaluator` surface — benchmark evaluation, custom scorers, LLM-as-a-judge, Inspect AI\n- `inference/`: deployment with `ModelBuilder` and sagemaker-core — real-time/serverless/async endpoints, in-process and local-container modes, inference pipelines, multi-model and multi-container endpoints, A/B testing, shadow variants, deployment guardrails, autoscaling with inference components, `optimize()`, batch transform, Bedrock deployment, Marketplace model packages, Augmented AI\n- `mlops/`: Pipelines with Model Registry, lineage tracking, experiment tracking, Feature Store, processing jobs, EMR Serverless steps, Clarify, MLflow\n\nBrowse them at https://github.com/aws/amazon-sagemaker-examples/tree/default\n</yakaai_skills>"}