Skip to content

Commit 70a3db3

Browse files
committed
add section in how to
1 parent 9b75b41 commit 70a3db3

File tree

9 files changed

+156
-15
lines changed

9 files changed

+156
-15
lines changed

docs/sagemaker/_toctree.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121
- sections:
2222
- local: how-to/index
2323
title: Introduction
24-
- local: how-to/get-started-sagemaker-sdk
25-
title: Get started with the SageMaker SDK
24+
- local: how-to/sagemaker-sdk-quickstart
25+
title: SageMaker SDK Quickstart
26+
- local: how-to/jumpstart-quickstart
27+
title: Jumpstart Quickstart
28+
- local: how-to/bedrock-quickstart
29+
title: Bedrock Quickstart
30+
- local: how-to/compute-services-quickstart
31+
title: EC2, ECS and EKS Quickstart
2632
- local: how-to/deploy-sagemaker-sdk
2733
title: Deploy models with SageMaker SDK
2834
- local: how-to/training-sagemaker-sdk

docs/sagemaker/deploy.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,30 @@ Deploying Hugging Face models on AWS is streamlined through various services, ea
66

77
Amazon SageMaker is a fully managed AWS service for building, training, and deploying machine learning models at scale. The SageMaker SDK simplifies interacting with SageMaker programmatically. Amazon SageMaker SDK provides a seamless integration specifically designed for Hugging Face models, simplifying the deployment process of managed endpoints. With this integration, you can quickly deploy pre-trained Hugging Face models or your own fine-tuned models directly into SageMaker-managed endpoints, significantly reducing setup complexity and time to production.
88

9-
To get started, check out this tutorial.
9+
[Sagemaker SDK Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/sagemaker-sdk-quickstart)
1010

1111
## With Sagemaker Jumpstart
1212

1313
Amazon SageMaker JumpStart is a curated model catalog from which you can deploy a model with just a few clicks. We maintain a Hugging Face section in the catalog that will let you self-host the most famous open models in your VPC with performant default configurations, powered under the hood by Hugging Face Deep Learning Catalogs (DLCs). (#todo link to DLC intro)
1414

15-
To get started, check out this tutorial.
15+
[Sagemaker Jumpstart Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/jumpstart-quickstart)
1616

1717
## With AWS Bedrock
1818

1919
Amazon Bedrock enables developers to easily build and scale generative AI applications through a single API. With Bedrock Marketplace, you can now combine the ease of use of SageMaker JumpStart with the fully managed infrastructure of Amazon Bedrock, including compatibility with high-level APIs such as Agents, Knowledge Bases, Guardrails and Model Evaluations.
2020

21-
To get started, check out this [blogpost](https://huggingface.co/blog/bedrock-marketplace?).
21+
[AWS Bedrock Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/bedrock-quickstart)
2222

2323
## With Hugging Face Inference Endpoints
2424

2525
Hugging Face Inference Endpoints allow you to deploy models hosted directly by Hugging Face, fully managed and optimized for performance. It's ideal for quick deployment and scalable inference workloads.
2626

27-
[Get started with Hugging Face Inference Endpoints](https://huggingface.co/docs/inference-endpoints/main/en/index).
27+
[Hugging Face Inference Endpoints Quickstart](https://huggingface.co/docs/inference-endpoints/guides/create_endpoint).
2828

2929
## With ECS, EKS, and EC2
3030

3131
Hugging Face provides Inference Deep Learning Containers (DLCs) to AWS users, optimized environments preconfigured with Hugging Face libraries for inference, natively integrated in SageMaker SDK and JumpStart. However, the HF DLCs can also be used across other AWS services like ECS, EKS, and EC2.
3232

3333
AWS Elastic Container Service (ECS), Elastic Kubernetes Service (EKS), and Elastic Compute Cloud (EC2) allow you to leverage DLCs directly.
3434

35-
Get started with HF DLCs on EC2.
36-
Get started with HF DLCs on ECS.
37-
Get started with HF DLCs on EKS.
35+
[EC2, ECS and EKS Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/compute-services-quickstart)

docs/sagemaker/examples/index.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# Examples
1+
# Examples
2+
3+
Take a look at our examples about using Hugging Face models on AWS.
4+
5+
## Sagemaker SDK
6+
7+
-
8+
9+
## Jumpstart
10+
11+
-
12+
13+
## Bedrock
14+
15+
-
16+
17+
## EC2, ECS and EKS
18+
19+
-
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Use Hugging Face models with Amazon Bedrock
2+
3+
We are excited to announce that popular open models from Hugging Face are now available on Amazon Bedrock in the new Bedrock Marketplace! AWS customers can now deploy [83 open models](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/model-catalog) with Bedrock Marketplace to build their Generative AI applications.
4+
5+
Under the hood, Bedrock Marketplace model endpoints are managed by Amazon Sagemaker Jumpstart. With Bedrock Marketplace, you can now combine the ease of use of SageMaker JumpStart with the fully managed infrastructure of Amazon Bedrock, including compatibility with high-level APIs such as Agents, Knowledge Bases, Guardrails and Model Evaluations.
6+
7+
When registering your Sagemaker Jumpstart endpoints in Amazon Bedrock, you only pay for the Sagemaker compute resources and regular Amazon Bedrock APIs prices are applicable.
8+
9+
In this blog we will show you how to deploy [Gemma 2 27B Instruct](https://huggingface.co/google/gemma-2-27b-it) and use the model with Amazon Bedrock APIs. Learn how to:
10+
11+
1. Deploy Google Gemma 2 27B Instruct
12+
2. Send requests using the Amazon Bedrock APIs
13+
3. Clean Up
14+
15+
## Deploy Google Gemma 2 27B Instruct
16+
17+
There are two ways to deploy an open model to be used with Amazon Bedrock:
18+
19+
1. You can deploy your open model from the Bedrock Model Catalog.
20+
2. You can deploy your open model with Amazon Jumpstart and register it with Bedrock.
21+
22+
Both ways are similar, so we will guide you through the Bedrock Model catalog.
23+
24+
To get started, in the Amazon Bedrock console, make sure you are in one of the 14 regions where the Bedrock Marketplace is available. Then, you choose [“Model catalog”](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/model-catalog) in the “Foundation models” section of the navigation pane. Here, you can search for both serverless models and models available in Amazon Bedrock Marketplace. You filter results by “Hugging Face” provider and you can browse through the 83 open models available.
25+
26+
For example, let’s search and select Google Gemma 2 27B Instruct.
27+
28+
![model-catalog.png](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/bedrock-marketplace/model-catalog.png)
29+
30+
Choosing the model opens the model detail page where you can see more information from the model provider such as highlights about the model, and usage including sample API calls.
31+
32+
On the top right, let’s click on Deploy.
33+
34+
![model-card.png](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/bedrock-marketplace/model-card.png)
35+
36+
It brings you to the deployment page where you can select the endpoint name, the instance configuration and advanced settings related to networking configuration and service role used to perform the deployment in Sagemaker. Let’s use the default advanced settings and the recommended instance type.
37+
38+
You are also required to accept the End User License Agreement of the model provider.
39+
40+
On the bottom right, let’s click on Deploy.
41+
42+
![model-deploy.png](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/bedrock-marketplace/model-deploy.png)
43+
44+
We just launched the deployment of  GoogleGemma 2 27B Instruct model on a ml.g5.48xlarge instance, hosted in your Amazon Sagemaker tenancy, compatible with Amazon Bedrock APIs!
45+
46+
The endpoint deployment can take several minutes. It will appear in the “Marketplace deployments” page, which you can find in the “Foundation models” section of the navigation pane.
47+
48+
## Use the model with Amazon Bedrock APIs
49+
50+
You can quickly test the model in the Playground through the UI.  However, to invoke the deployed model programmatically with any Amazon Bedrock APIs, you need to get the endpoint ARN.
51+
52+
From the list of managed deployments, choose your model deployment to copy its endpoint ARN.
53+
54+
![model-arn.png](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/bedrock-marketplace/model-arn.png)
55+
56+
You can query your endpoint using the AWS SDK in your preferred language or with the AWS CLI.
57+
58+
Here is an example using Bedrock Converse API through the AWS SDK for Python (boto3):
59+
60+
```python
61+
import boto3
62+
63+
bedrock_runtime = boto3.client("bedrock-runtime")
64+
65+
# Add your bedrock endpoint arn here.
66+
endpoint_arn = "arn:aws:sagemaker:<AWS::REGION>:<AWS::AccountId>:endpoint/<Endpoint_Name>"
67+
68+
# Base inference parameters to use.
69+
inference_config = {
70+
"maxTokens": 256,
71+
"temperature": 0.1,
72+
"topP": 0.999,
73+
}
74+
75+
# Additional inference parameters to use.
76+
additional_model_fields = {"parameters": {"repetition_penalty": 0.9, "top_k": 250, "do_sample": True}}
77+
response = bedrock_runtime.converse(
78+
modelId=endpoint_arn,
79+
messages=[
80+
{
81+
"role": "user",
82+
"content": [
83+
{
84+
"text": "What is Amazon doing in the field of generative AI?",
85+
},
86+
]
87+
},
88+
],
89+
inferenceConfig=inference_config,
90+
additionalModelRequestFields=additional_model_fields,
91+
)
92+
print(response["output"]["message"]["content"][0]["text"])
93+
```
94+
95+
```python
96+
"Amazon is making significant strides in the field of generative AI, applying it across various products and services. Here's a breakdown of their key initiatives:\n\n**1. Amazon Bedrock:**\n\n* This is their **fully managed service** that allows developers to build and scale generative AI applications using models from Amazon and other leading AI companies. \n* It offers access to foundational models like **Amazon Titan**, a family of large language models (LLMs) for text generation, and models from Cohere"
97+
```
98+
99+
That’s it! If you want to go further, have a look at the [Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html).
100+
101+
## Clean up
102+
103+
Don’t forget to delete your endpoint at the end of your experiment to stop incurring costs! At the top right of the page where you grab the endpoint ARN, you can delete your endpoint by clicking on “Delete”.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# EC2, ECS and EKS Quickstart
2+
3+
This page is under construction, bear with us!

docs/sagemaker/how-to/index.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# How to
22

3+
Take a look at our tutorials about using Hugging Face models on AWS.
4+
35
## Sagemaker SDK
46

7+
- [Sagemaker SDK Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/sagemaker-sdk-quickstart)
8+
59
## Jumpstart
610

7-
## Bedrock
11+
- [Sagemaker Jumpstart Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/jumpstart-quickstart)
12+
13+
## Bedrock
14+
15+
- [AWS Bedrock Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/bedrock-quickstart)
16+
17+
## EC2, ECS and EKS
18+
19+
- [EC2, ECS and EKS Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/compute-services-quickstart)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Jumpstart Quickstart
2+
3+
This page is under construction, bear with us!
File renamed without changes.

docs/sagemaker/train.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ Training Hugging Face models on AWS is streamlined through various services. Her
66

77
Amazon SageMaker is a fully managed AWS service for building, training, and deploying machine learning models at scale. The SageMaker SDK simplifies interacting with SageMaker programmatically. Amazon SageMaker SDK provides a seamless integration specifically designed for Hugging Face models, simplifying the training job management. With this integration, you can quickly create your own fine-tuned models, significantly reducing setup complexity and time to production.
88

9-
To get started, check out this example.
9+
[Sagemaker SDK Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/sagemaker-sdk-quickstart)
1010

1111
## With ECS, EKS, and EC2
1212

1313
Hugging Face provides Training Deep Learning Containers (DLCs) to AWS users, optimized environments preconfigured with Hugging Face libraries for training, natively integrated in SageMaker SDK. However, the HF DLCs can also be used across other AWS services like ECS, EKS, and EC2.
1414

1515
AWS Elastic Container Service (ECS), Elastic Kubernetes Service (EKS), and Elastic Compute Cloud (EC2) allow you to leverage DLCs directly.
1616

17-
Get started with HF DLCs on EC2
18-
Get started with HF DLCs on ECS
19-
Get started with HF DLCs on EKS
17+
[EC2, ECS and EKS Quickstart](https://huggingface.co/docs/sagemaker/main/en/how-to/compute-services-quickstart)

0 commit comments

Comments
 (0)