amazon-sagemaker-examples README

The project's README from github.com/aws/amazon-sagemaker-examples. As one markdown file: README.md.

SageMaker

:exclamation::fire: Announcing SageMaker-Core: A New Python SDK for Amazon SageMaker :fire::exclamation:

Introduction

Today, Amazon SageMaker is excited to announce the release of SageMaker-Core, a new Python SDK that provides an object-oriented interface for interacting with SageMaker resources such as TrainingJob, Model, and Endpoint. This SDK introduces the resource chaining feature, allowing developers to pass resource objects as parameters, eliminating manual parameter specification and simplifying code management. SageMaker-Core abstracts low-level details like resource state transitions and polling logic, achieving full parity with SageMaker APIs. It also includes usability improvements such as auto code completion, comprehensive documentation, and type hints, enhancing the overall developer experience.

Use Case

SageMaker-Core is ideal for ML practitioners who seek full customization of AWS primitives for their ML workloads. SageMaker-Core is an improvement over Boto3, providing a more intuitive and efficient way to manage SageMaker resources. By providing an intuitive object-oriented interface and resource chaining, the SDK allows for seamless integration and management of SageMaker resources. This flexibility, combined with intelligent defaults enables developers to tailor their ML workloads according to their needs. Comprehensive documentation, and type hints help developers write code faster and with fewer errors without navigating complex API documentation.

Call to Action

To learn more about SageMaker-Core, visit the documentation and example notebooks. Get started today by integrating SageMaker-Core into your machine learning workflows and experience the benefits of a streamlined and efficient development process.

Amazon SageMaker Examples

Example Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using Amazon SageMaker.

:books: Read this before you proceed further

Amazon SageMaker examples are divided in two repositories:

Planning to submit a PR to this repository? Read this first:

:hammer_and_wrench: Setup

The quickest setup to run example notebooks includes:

:computer: Usage

These example notebooks are automatically loaded into SageMaker Notebook Instances. They can be accessed by clicking on the SageMaker Examples tab in Jupyter or the SageMaker logo in JupyterLab.

Although most examples utilize key Amazon SageMaker functionality like distributed, managed training or real-time hosted endpoints, these notebooks can be run outside of Amazon SageMaker Notebook Instances with minimal modification (updating IAM role definition and installing the necessary libraries).

:notebook: Example Notebook Categories

The notebooks are organized by ML capability, following the lifecycle order of a typical project: train a model, customize it, evaluate it, deploy it, then operationalize it. Every notebook is self-contained: it lives with the scripts, data and images it needs, and all of its references are relative to its own folder.

Training

Amazon SageMaker Training is a fully managed service that helps you train ML models at scale. It containerizes your workload and manages the AWS compute for you, so you can focus on the model rather than the infrastructure. These examples train with ModelTrainer from SageMaker Python SDK v3 and cover script and framework training, distributed training, managed spot training with checkpointing, heterogeneous clusters, bringing your own container, submitting work through AWS Batch training queues, and running local code as a training job with @remote.

Model Customization

Model customization adapts a pre-trained foundation model to your data and your task, which is usually far cheaper and faster than training from scratch. These examples cover the fine-tuning techniques SageMaker supports — supervised fine-tuning (SFT), direct preference optimization (DPO), reinforcement learning with verifiable rewards (RLVR), RL from AI feedback (RLAIF), multi-turn RL (MTRL) and continued pre-training (CPT) — along with recipe overrides, data mixing, JumpStart fine-tuning with a private model hub, and distributed fine-tuning across serverless, serverful and HyperPod compute.

Evaluation

Before you promote a customized model you need to know whether it actually got better. These examples use the SageMaker evaluator surface to score models: standard benchmark evaluation, your own scoring function, an LLM acting as a judge, and Inspect AI. They show how to evaluate a base model and a fine-tuned model on the same footing so the comparison is meaningful.

Inference

With Amazon SageMaker you can get predictions from your trained models through a broad set of deployment options, and scale them without taking on the operational burden yourself. These examples deploy with ModelBuilder and sagemaker-core, and cover real-time, serverless and asynchronous endpoints; in-process and local-container modes for fast iteration; inference pipelines; multi-model and multi-container endpoints; safe rollout through A/B testing, shadow variants and deployment guardrails; autoscaling with inference components; latency and cost optimization with optimize(); batch transform; deployment to Amazon Bedrock; AWS Marketplace model packages; and human review with Augmented AI.

MLOps

MLOps applies DevOps practices to machine learning: continuous integration and deployment, reproducibility, lineage and governance. It accounts for the parts of an AI/ML project that ordinary software delivery does not, which shortens delivery time, reduces defects and makes data science more productive. These examples cover SageMaker Pipelines with the Model Registry, lineage tracking, experiment tracking, Feature Store, processing jobs, EMR Serverless steps, bias and explainability analysis with Clarify, and MLflow.

:balance_scale: License

This library is licensed under the Apache 2.0 License. For more details, please take a look at the LICENSE file.

:handshake: Contributing

Although we're extremely excited to receive contributions from the community, we're still working on the best mechanism to take in examples from external sources. Please bear with us in the short-term if pull requests take longer than expected or are closed. Please read our contributing guidelines if you'd like to open an issue or submit a pull request.

amazon-sagemaker-examples (aws/amazon-sagemaker-examples)

Searching Database…

这是什么?这是 AWS 官方提供的一组 Jupyter 笔记本,演示如何使用 Amazon SageMaker 构建、训练和部署机器学习模型。
这是一个库,还是只是一组示例笔记本?它纯粹是一组笔记本,本身并不是 SDK 或库。每个笔记本都是独立的,自带脚本、数据和图片,并按机器学习生命周期阶段组织:训练、模型定制、评估、推理和 MLOps。
这些笔记本怎么运行?它们会自动加载到 SageMaker Notebook Instance 中,可以通过 Jupyter 或 JupyterLab 的 SageMaker Examples 标签页打开。你也可以在 SageMaker 之外运行,只需做少量修改,例如更新 IAM 角色并安装所需的库。
运行这些之前,我需要做哪些 AWS 设置?你需要一个 AWS 账户、正确配置的 IAM 用户和角色、一个 Amazon SageMaker Notebook Instance,以及一个 S3 存储桶。
我可以把任何示例笔记本作为 PR 提交吗?不可以,只接受那些展示仓库中尚未涵盖的 SageMaker 功能的笔记本;其他示例应提交到单独的 SageMaker Example Community 仓库。
这个仓库和 SageMaker Example Community 仓库有什么区别?这个仓库是由 Amazon SageMaker 团队直接维护的官方示例集,涵盖 SageMaker 的各项功能。Community 仓库则包含由 AWS 工程师和解决方案架构师维护的更多示例和参考方案。
模型定制类笔记本涵盖哪些微调技术?涵盖监督微调(SFT)、直接偏好优化(DPO)、可验证奖励的强化学习(RLVR)、基于 AI 反馈的强化学习(RLAIF)、多轮强化学习和持续预训练,还包括 JumpStart 微调,以及在 serverless、serverful 和 HyperPod 计算环境上的分布式微调。
推理类笔记本演示了哪些部署方式?实时、无服务器和异步端点,本地容器模式,多模型/多容器端点,A/B 测试和影子变体(shadow variant)发布,自动扩缩容,批量转换(batch transform),以及部署到 Amazon Bedrock 或 AWS Marketplace。
README 顶部提到的 SageMaker-Core 是什么?它是一个面向对象的全新 SageMaker Python SDK,支持资源链式调用、自动代码补全和类型提示,以简化对 TrainingJob、Model、Endpoint 等资源的管理。
Creator
aws
Size
691.7 MB
Stars
11K
Age
8y
Commits · 90 Days