Deploy a Hugging Face Transformers Model from S3 to Amazon SageMaker
Skills:
LLM Engineering90%
Key Takeaways
This video demonstrates how to deploy a Hugging Face Transformers model from S3 to Amazon SageMaker using the SageMaker Python SDK, highlighting the benefits of using the Hugging Face inference optimized solution.
Full Transcript
hi everyone my name is philli I a machine learning engineer at hugging phas and DET Tech lead for our partnership with AWS I will show you in a few minutes how you can deploy hiking F Transformers from S3 to Amazon sagemaker for an inference Amazon sagemaker is a fully managed machine learning service that provides everyone with the ability to build train and deploy machine learning models quickly together with a s we have built an inference optimized solution to deploy Transformer models as s maker endpoints let's get started we are going to use a sagemaker notebook instance to deploy our model using a sagemaker notebook instance is not a requirement to deploy your model you can also use sagemaker Studio or you can deploy it from your local machine to be able to deploy a model from S3 to Amazon sagemaker you need to create an archive called model. tower. GC which contains all the relevant model and tokenizer files if you have trained your model before using the Amazon sagemaker and the hugging F DLC for training this archive will be created automatically for you at the end of your training and upload it to as free so if you have already trained a model you can use this model for deployment in this case I will use a distal Bird model fine-tuned on the sst2 data set to deploy our model we first need to create a hugging face model class the hugging face model class contains all the relevant information for our endpoint as our model data where the model archive is sored on S fre a role for the permissions our Transformers version and the pych or tensorflow version the huging phase inference solution is um can be used with py toch or tensor flow after we created our huging face model class we can run deploy the dot deploy method will then create our stagemaker endpoint therefore we Define the initial instance count and the instance type the initial instance count defines how many instance will be used for our endpoint and the instance type defines which instance will be used in our example I use the M5 instance which is a CPU based instance after executing this s maker will create our endpoint which takes around 5 minutes the endpoint has been successfully deployed to sagemaker and can now be used for inference the benefit of using the python sagemaker SDK is that the deploy method automatically returns predictor class which we can use to request our endpoint therefore we can run predictor predict and provide our inputs as an input I have a yeah simple sentence phrase um executing predictor predict our endpoint successfully predicts the correct class of forour input and works at the end you can run predictor delete endpoint which makes sure everything will be deleted on Sage maker properly if you want to learn more about hugging face on Amazon sagemaker check out huging F.C stagemaker
Original Description
There are two ways to deploy your SageMaker trained Hugging Face model. You can either deploy it after your training is finished, or you can deploy it later, using the model_data pointing to your saved model on Amazon S3. In addition to the two below-mentioned options, you can also instantiate Hugging Face endpoints with lower-level SDK such as boto3 and AWS CLI, Terraform, and with CloudFormation templates.
https://huggingface.co/blog/deploy-hugging-face-models-easily-with-amazon-sagemaker
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from HuggingFace · HuggingFace · 47 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
▶
48
49
50
51
52
53
54
55
56
57
58
59
60
The Future of Natural Language Processing
HuggingFace
Trends in Model Size & Computational Efficiency in NLP
HuggingFace
Increasing Data Usage in Natural Language Processing
HuggingFace
In Domain & Out of Domain Generalization in the Future of NLP
HuggingFace
The Limits of NLU & the Rise of NLG in the Future of NLP
HuggingFace
The Lack of Robustness in the Future of NLP
HuggingFace
Inductive Bias, Common Sense, Continual Learning in The Future of NLP
HuggingFace
Train a Hugging Face Transformers Model with Amazon SageMaker
HuggingFace
What is Transfer Learning?
HuggingFace
The pipeline function
HuggingFace
Navigating the Model Hub
HuggingFace
Transformer models: Decoders
HuggingFace
The Transformer architecture
HuggingFace
Transformer models: Encoder-Decoders
HuggingFace
Transformer models: Encoders
HuggingFace
Keras introduction
HuggingFace
The push to hub API
HuggingFace
Fine-tuning with TensorFlow
HuggingFace
Learning rate scheduling with TensorFlow
HuggingFace
TensorFlow Predictions and metrics
HuggingFace
Welcome to the Hugging Face course
HuggingFace
The tokenization pipeline
HuggingFace
Supercharge your PyTorch training loop with Accelerate
HuggingFace
The Trainer API
HuggingFace
Batching inputs together (PyTorch)
HuggingFace
Batching inputs together (TensorFlow)
HuggingFace
Hugging Face Datasets overview (Pytorch)
HuggingFace
Hugging Face Datasets overview (Tensorflow)
HuggingFace
What is dynamic padding?
HuggingFace
What happens inside the pipeline function? (PyTorch)
HuggingFace
What happens inside the pipeline function? (TensorFlow)
HuggingFace
Instantiate a Transformers model (PyTorch)
HuggingFace
Instantiate a Transformers model (TensorFlow)
HuggingFace
Preprocessing sentence pairs (PyTorch)
HuggingFace
Preprocessing sentence pairs (TensorFlow)
HuggingFace
Write your training loop in PyTorch
HuggingFace
Managing a repo on the Model Hub
HuggingFace
Chapter 1 Live Session with Sylvain
HuggingFace
Chapter 2 Live Session with Lewis
HuggingFace
The push to hub API
HuggingFace
Chapter 2 Live Session with Sylvain
HuggingFace
Chapter 3 live sessions with Lewis (PyTorch)
HuggingFace
Day 1 Talks: JAX, Flax & Transformers 🤗
HuggingFace
Day 2 Talks: JAX, Flax & Transformers 🤗
HuggingFace
Day 3 Talks JAX, Flax, Transformers 🤗
HuggingFace
Chapter 4 live sessions with Omar
HuggingFace
Deploy a Hugging Face Transformers Model from S3 to Amazon SageMaker
HuggingFace
Deploy a Hugging Face Transformers Model from the Model Hub to Amazon SageMaker
HuggingFace
Run a Batch Transform Job using Hugging Face Transformers and Amazon SageMaker
HuggingFace
[Webinar] How to add machine learning capabilities with just a few lines of code
HuggingFace
Hugging Face + Zapier Demo Video
HuggingFace
Hugging Face + Google Sheets Demo
HuggingFace
Hugging Face Infinity Launch - 09/28
HuggingFace
Build and Deploy a Machine Learning App in 2 Minutes
HuggingFace
Hugging Face Infinity - GPU Walkthrough
HuggingFace
Otto - 🤗 Infinity Case Study
HuggingFace
Workshop: Getting started with Amazon Sagemaker Train a Hugging Face Transformers and deploy it
HuggingFace
Workshop: Going Production: Deploying, Scaling & Monitoring Hugging Face Transformer models
HuggingFace
🤗 Tasks: Causal Language Modeling
HuggingFace
🤗 Tasks: Masked Language Modeling
HuggingFace
More on: LLM Engineering
View skill →Related Reads
📰
📰
📰
📰
What Happens When Google Turns Off Your Project?
Medium · DevOps
Sixth challenge on DevOpsLedger
Medium · DevOps
K3s Üzerinde ArgoCD ve Kustomize ile Sıfırdan GitOps Altyapısı Kurulumu
Medium · DevOps
You’re Wasting Money on AWS: A Practical Guide to Terraform & Cost Optimization
Medium · DevOps
🎓
Tutor Explanation
DeepCamp AI