Views
No views yet
distilbert-base-uncased| Field | Value |
|---|---|
| Base Model | distilbert-base-uncased |
| Dataset | SMS Spam Collection (UCI) |
| Framework | PyTorch with 🤗 Transformers |
| Epochs | 3 |
| Batch Size | 16 |
| Max Length | 128 tokens |
| Optimizer | AdamW |
| Loss | CrossEntropyLoss (token-level) |
| Device | Trained on CUDA-enabled GPU |
| Metric | Score |
|---|---|
| Accuracy | 0.99 |
| F1-Score | 0.96 |
| Precision | 0.98 |
| Recall | 0.93 |
1from transformers import BertTokenizerFast, BertForTokenClassification
2from transformers import pipeline
3import torch
4
5model_name = "AventIQ-AI/SMS-Spam-Detection-Model"
6tokenizer = BertTokenizerFast.from_pretrained(model_name)
7model = BertForTokenClassification.from_pretrained(model_name)
8model.eval()
9
10
11# Inference
12device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13model.to(device)
14
15def predict_sms(text):
16 inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
17 inputs = {k: v.to(device) for k, v in inputs.items()}
18 with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 predicted = torch.argmax(logits, dim=1).item()
22 return "spam" if predicted == 1 else "ham"
23
24# Test example
25print(predict_sms("You've won $1,000,000! Call now to claim your prize!"))
26.
├── model/ # Quantized model files
├── tokenizer_config/ # Tokenizer and vocab files
├── model.safensors/ # Fine-tuned model in safetensors format
├── README.md # Model card