MLOPs: Sentiment Analysis with DISTILBert

AfroLogicInsect | Apr 6, 2024 min read

Emotion Classification API Summary

A production-ready MLOps solution for text emotion classification using a fine-tuned DistilBERT model.

Key Features

  • 🚀 FastAPI service for low-latency inference
  • 🤗 Hugging Face model hosting (AfroLogicInsect/emotionClassifier)
  • 🔄 Automated CI/CD pipeline with GitHub Actions
  • 🐳 Containerized deployment on Render

Technical Stack

  • Model: DistilBERT fine-tuned for 6 emotions (anger, fear, joy, love, sadness, surprise)
  • Infrastructure: Docker, GitHub Actions, Render
  • Monitoring: Basic metrics via Render dashboard

Usage Examples

# cURL
curl -X POST "https://mlops-sentiment-distilbert.onrender.com/predict" \
  -H "Content-Type: application/json" \
  -d '{"text": "I'm excited!"}'
# Python
import requests
response = requests.post("https://mlops-sentiment-distilbert.onrender.com/predict", 
                        json={"text": "I'm excited!"})
print(response.json())

Project Structure

emotion-classifier/
├── app/                    # FastAPI application
├── tests/                  # Unit tests
├── .github/workflows/      # CI/CD automation
└── Dockerfile              # Container config

Resources

Workflow Diagrams

  1. Training to Deployment
  2. CI/CD Pipeline
  3. Model Serving

The solution demonstrates complete MLOps implementation from model training to production deployment.

Youtube URL: https://t.co/EeyxBO9hmM