SpamShield AI

Enterprise spam detection using DistilBERT transformers, deployed on AWS SageMaker with Terraform infrastructure-as-code.

Overview

A production-grade spam detection system built as an end-to-end ML pipeline. Fine-tuned DistilBERT on the SMS Spam Collection dataset, served via FastAPI, wrapped in a Streamlit UI, containerised with Docker, and deployed to AWS SageMaker with Terraform-managed infrastructure.

System Architecture

1

Model

DistilBERT

Fine-tuned transformer for binary spam classification. 40M parameters, 60% faster than BERT with 97% of the performance.

2

Training

PyTorch + Hugging Face

Fine-tuned on SMS Spam Collection dataset with early stopping, learning rate scheduling, and class-weighted loss.

3

Inference API

FastAPI

REST API serving predictions via /predict endpoint. Input text → output: spam/ham + confidence score.

4

Frontend

Streamlit

Interactive UI with single-text prediction, batch CSV upload, model metrics, and architecture overview.

5

Deployment

AWS SageMaker

Model hosted on SageMaker endpoint with auto-scaling. CloudWatch monitoring for latency and errors.

6

Infrastructure

Terraform

Full IaC provisioning S3, IAM roles, SageMaker model/endpoint, and CloudWatch alarms.

7

Containerisation

Docker

FastAPI and Streamlit containerised with multi-stage builds for minimal image size.

Results

99.5%

Accuracy

98.7%

Precision

97.8%

Recall

98.2%

F1 Score

0.998

ROC-AUC

Tech Stack

PythonPyTorchDistilBERTHugging FaceFastAPIStreamlitSageMakerS3CloudWatchTerraformDocker