https://github.com/alpha-131/mlops-pipeline
This project deploys a pre-trained GPT-2 language model on Amazon SageMaker using Hugging Face Transformers. It encompasses model download, S3 upload, SageMaker deployment, Lambda function integration, and API Gateway setup. Dedicated scripts manage these tasks, supported by a CI/CD pipeline for efficient deployment.
https://github.com/alpha-131/mlops-pipeline
aws s3-bucket sagemaker-deployment
Last synced: about 2 months ago
JSON representation
This project deploys a pre-trained GPT-2 language model on Amazon SageMaker using Hugging Face Transformers. It encompasses model download, S3 upload, SageMaker deployment, Lambda function integration, and API Gateway setup. Dedicated scripts manage these tasks, supported by a CI/CD pipeline for efficient deployment.
- Host: GitHub
- URL: https://github.com/alpha-131/mlops-pipeline
- Owner: Alpha-131
- Created: 2024-01-15T11:44:09.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T14:23:25.000Z (over 2 years ago)
- Last Synced: 2025-03-12T09:44:44.827Z (over 1 year ago)
- Topics: aws, s3-bucket, sagemaker-deployment
- Language: Jupyter Notebook
- Homepage:
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GPT-2 SageMaker Deployment
## Overview
This project orchestrates the seamless deployment of a pre-trained GPT-2 model from the Hugging Face model hub onto Amazon SageMaker, enabling real-time inference. By leveraging AWS S3 for model storage and integrating the endpoint with AWS Lambda function and API Gateway, this deployment ensures efficient and scalable model serving.
## Architecture for MLOps Pipeline

The MLOps pipeline architecture illustrates the flow of activities involved in deploying and managing machine learning models. This comprehensive workflow encompasses various stages, including data preparation, model training, deployment, monitoring, and maintenance. Each stage plays a crucial role in ensuring the successful and efficient operation of machine learning systems.
## Project Structure
- `data/`: Houses all project-related data.
- `model/`: Stores the GPT-2 model weights.
- `notebooks/`: Contains comprehensive experimentation notebooks.
- `scripts/`: Hosts Python scripts for seamless local and remote execution.
- `src/`: Organizes the model as a package along with associated modules.
- `tests/`: Comprises a suite of tests to ensure model robustness.
- `requirements.txt`: Lists all project dependencies for reproducibility.
## Usage (MLOps Pipeline)
1. **Clone Repository:**
```bash
git clone https://github.com/Alpha-131/MYM-assessment-task.git
```
2. **Configure AWS Settings:**
- Modify AWS configurations in relevant scripts to match project requirements.
3. **Upload Model to S3:**
```bash
python upload_to_s3.py
```
4. **Deploy SageMaker Model:**
```bash
python deploy_to_sagemaker.py
```
5. **Setup Lambda Function:**
- Integrate the endpoint with a Lambda function for streamlined processing.
6. **API Gateway Configuration:**
- Utilize API Gateway to create a production or testing stage, linking it with the Lambda function for seamless API access.
7. **Access API URL:**
- Access the API URL for making model inference requests:
```
https://.execute-api..amazonaws.com//
```
## Remaining Tasks
- [X] Download GPT-2 model weights.
- [X] Create model.tar.gz file for artifacts.
- [X] Upload model.tar.gz to Amazon S3.
- [X] Write deployment script for sagemaker endpoint.
- [X] Establish CI/CD pipeline for automated deployment.
- [X] Define YAML configuration file for CI/CD pipeline.
- [X] Implement monitoring using AWS Cloudwatch for sagemaker endpoint.
- [X] Implement logging using Cloudtrail and store it in S3 bucket for SageMaker endpoints.
- [ ] Configure autoscaling for dynamic traffic-based scaling.