Uttam1695/Spam-Shield-AI
SpamShield AI: Advanced LLM Spam Classification System ๐ก๏ธ
Welcome to SpamShield AI, an intelligent, end-to-end spam classification web application. This project demonstrates the implementation of a custom-built Large Language Model (LLM) utilizing a transformer architecture to classify text messages (SMS/Emails) into Spam or Ham (Not Spam).
Every component of this pipelineโfrom data preprocessing and model architecture to the modern web interfaceโwas engineered entirely from scratch.
๐ Features
- Custom Transformer Architecture: Implemented entirely in PyTorch, leveraging attention mechanisms optimized for natural language processing.
- High-Performance Inference: Real-time classification of text streams via an integrated Streamlit frontend.
- Modern User Interface: A responsive, beautifully designed frontend using Streamlit with custom CSS injection featuring glassmorphism and animated backgrounds.
- Robust Training Pipeline: Includes custom PyTorch Datasets/DataLoaders, automated validation loops, and learning rate scheduling (detailed in the Jupyter Notebook).
๐ง Model Architecture & Training
The core of SpamShield AI is the review_classifier.pth model. It was trained on the benchmark SMS Spam Collection dataset.
Key Highlights:
- Data Engineering: Processed over 5,500 SMS messages, handling class imbalances and applying advanced tokenization strategies.
- Custom Embeddings: Built custom word and positional embeddings to capture deep semantic meaning and sequence context.
- Loss & Accuracy Tracking: The training process achieved exceptional accuracy, significantly reducing false positives (as visualized in
accuracy-plot.pdfandloss-plot.pdf). - State Dict: The trained weights (
review_classifier.pth) are loaded seamlessly into the Streamlit application for low-latency predictions using@st.cache_resource.
๐ป Tech Stack
- Deep Learning: PyTorch
- Backend & Frontend: Python, Streamlit
- Data Processing: Pandas, NumPy
- Environment: Jupyter Notebook (for model research and development)
๐ ๏ธ Installation & Setup
To run this application locally on your machine, follow these steps:
Prerequisites
Make sure you have Python 3.8+ installed.
1. Clone the repository
git clone https://github.com/yourusername/Spam_Classifier_using_LLM_from_scratch.git
cd Spam_Classifier_using_LLM_from_scratch2. Install Dependencies
Install the required Python packages (it is recommended to use a virtual environment):
pip install -r requirements.txt3. Run the Application
Start the Streamlit application:
streamlit run app.pyThe interface will automatically open in your default web browser (typically at http://localhost:8501).
๐ธ Screenshots & UI Design
The web interface was meticulously designed to provide a premium user experience. It features:
- Glassmorphism: Sleek, transparent UI elements that blur the dynamic background.
- Real-time Feedback: Animated loading states and dynamic result cards that adapt based on the prediction confidence.
- Responsive Layout: Flawless execution across desktop and mobile devices.
๐ Future Enhancements
- API Rate Limiting: Implementing Redis to manage request throttling.
- Model Quantization: Reducing the model size for edge deployment without sacrificing accuracy.
- Multi-lingual Support: Expanding the vocabulary to detect spam in multiple languages.
Designed and engineered by Uttam Kumar Mahato
