--- license: apache-2.0 base_model: distilbert-base-uncased tags: - text-classification - email-classification - distilbert - pytorch - transformers language: - en datasets: - custom widget: - text: "🎉 FLASH SALE! 50% OFF everything! Limited time offer - Don't miss out!" example_title: "Promotions Email" - text: "Your verification code is: 123456. This code will expire in 10 minutes." example_title: "Verification Code" - text: "Welcome to our technical discussion forum! Join developers worldwide." example_title: "Forum Discussion" - text: "CONGRATULATIONS! You've won $1,000,000! Click here to claim your prize!" example_title: "Spam Email" metrics: - accuracy model-index: - name: email-classifier-distilbert-base-uncased results: - task: type: text-classification name: Email Classification metrics: - type: accuracy value: 1.0 name: Accuracy --- # Email Classifier - DistilBERT Base Uncased ## Model Description This model is a fine-tuned version of `distilbert-base-uncased` for email classification tasks. It can classify emails into 6 different categories: - **forum**: Forum discussions and technical conversations - **promotions**: Marketing emails and promotional content - **social_media**: Social media notifications and updates - **spam**: Spam and unwanted emails - **updates**: System updates and subscription renewals - **verify_code**: Verification codes and authentication emails ## Model Performance The model achieves **100% accuracy** on the test dataset with perfect precision, recall, and F1-scores across all categories. ### Test Results | Category | Precision | Recall | F1-Score | Support | |--------------|-----------|--------|----------|---------| | forum | 1.000 | 1.000 | 1.000 | 3 | | promotions | 1.000 | 1.000 | 1.000 | 3 | | social_media | 1.000 | 1.000 | 1.000 | 3 | | spam | 1.000 | 1.000 | 1.000 | 3 | | updates | 1.000 | 1.000 | 1.000 | 3 | | verify_code | 1.000 | 1.000 | 1.000 | 3 | | **Overall** | **1.000** | **1.000** | **1.000** | **18** | ## Usage ```python from transformers import DistilBertTokenizer, DistilBertForSequenceClassification import torch # Load model and tokenizer model_name = "your-username/email-classifier-distilbert-base-uncased" tokenizer = DistilBertTokenizer.from_pretrained(model_name) model = DistilBertForSequenceClassification.from_pretrained(model_name) # Example usage def classify_email(text): inputs = tokenizer(text, return_tensors="pt", max_length=384, padding=True, truncation=True) with torch.no_grad(): outputs = model(**inputs) predictions = torch.nn.functional.softmax(outputs.logits, dim=-1) predicted_class_id = predictions.argmax().item() confidence = predictions[0][predicted_class_id].item() labels = ["forum", "promotions", "social_media", "spam", "updates", "verify_code"] return labels[predicted_class_id], confidence # Test the model email_text = "Your verification code is 567890" category, confidence = classify_email(email_text) print(f"Category: {category}, Confidence: {confidence:.3f}") ``` ## Training Details ### Model Architecture - **Base Model**: distilbert-base-uncased - **Model Type**: DistilBERT for Sequence Classification - **Parameters**: ~66M parameters - **Max Sequence Length**: 384 tokens - **Number of Classes**: 6 ### Training Configuration - **Vocabulary Size**: 30,522 - **Hidden Size**: 768 - **Number of Attention Heads**: 12 - **Number of Hidden Layers**: 6 - **Intermediate Size**: 3,072 - **Activation Function**: GELU - **Dropout**: 0.1 - **Attention Dropout**: 0.1 ## Intended Use This model is designed for email classification tasks and can be used to: - Automatically sort incoming emails - Filter spam and promotional content - Organize email communications - Prioritize important messages like verification codes ## Limitations - The model is trained on English emails only - Performance may vary on emails with different formatting or domains - The test dataset is relatively small (18 samples) - May need retraining for domain-specific email patterns ## Ethical Considerations - This model should not be used to violate privacy or read personal emails without consent - Consider data protection regulations when implementing in production - Be aware of potential biases in email classification ## Citation If you use this model, please consider citing: ```bibtex @misc{email-classifier-distilbert, title={Email Classifier DistilBERT Base Uncased}, author={Your Name}, year={2024}, howpublished={\url{https://huggingface.co/your-username/email-classifier-distilbert-base-uncased}} } ``` ## Contact For questions or issues, please contact [your-email@example.com]