This repository contains tools and scripts for deploying Hugging Face models on AWS using SageMaker and Lambda functions.
- Deploy_HuggingFace_Model.ipynb: Jupyter notebook for deploying Hugging Face transformer models to AWS SageMaker.
- Lambda4SagemakerEndpoint.ipynb: Jupyter notebook demonstrating how to create and configure Lambda functions to interact with SageMaker endpoints.
- lambda_function.py: Python script containing the AWS Lambda function code for invoking SageMaker endpoints.
- export_iam.py: Utility script for exporting and managing IAM roles and policies required for the deployment.
- AWS Account with appropriate permissions
- Python 3.x
- AWS CLI configured
- Required Python packages:
- boto3
- sagemaker
- transformers
- jupyter
- Clone this repository
- Install required dependencies:
pip install boto3 sagemaker transformers jupyter
- Configure your AWS credentials:
aws configure
-
Prepare your Hugging Face model:
- Open
Deploy_HuggingFace_Model.ipynbto prepare and deploy your model to SageMaker
- Open
-
Set up Lambda function:
- Use
Lambda4SagemakerEndpoint.ipynbto understand how to create a Lambda function - Customize
lambda_function.pyfor your specific model and use case
- Use
-
Configure IAM permissions:
- Run
export_iam.pyto set up the necessary IAM roles and policies
- Run
The deployment requires specific IAM permissions:
- SageMaker execution role with S3 access
- Lambda execution role with permissions to invoke SageMaker endpoints
- Trust relationships between services
After deployment, you can invoke your model through:
- Direct SageMaker endpoint calls
- Lambda function invocations
- API Gateway (if configured)
Common issues:
- IAM permission errors: Ensure your roles have the correct policies and trust relationships
- S3 access issues: Verify your model artifacts are in the correct region and accessible
- Lambda timeout: Adjust timeout settings for larger models
[Specify your license here]
Contributions are welcome! Please feel free to submit a Pull Request.
Too many current requests. Your queue position is 1. Please wait for a while or switch to other models for a smoother experience.# deploy_higgingface_model