Views
No views yet
⚠️ Important : Ce modèle nécessite une version spécifique detransformerspour fonctionner correctement.
pip install 'transformers>=4.40.0,<4.46.0' torch sentencepiece protobuf| Package | Version |
|---|---|
| transformers | >=4.40.0,<4.46.0 |
| torch | >=2.0.0 |
| sentencepiece | >=0.1.99 |
| protobuf | >=3.20.0 |
⚠️ Attention : Les versionstransformers>=4.46.0(notamment 5.x) peuvent causer des faux positifs sur les contenus techniques formatés. Utilisez impérativement une version<4.46.0.
| Métrique | Valeur |
|---|---|
| Accuracy | 99.84% |
| Temps d'entraînement | ~1 minute |
1from transformers import CamembertTokenizer, CamembertForSequenceClassification
2import torch
3
4# Charger le modèle (utiliser le tokenizer du repo, pas camembert-base)
5tokenizer = CamembertTokenizer.from_pretrained("nellaw/camembert-spam-detector-fr")
6model = CamembertForSequenceClassification.from_pretrained("nellaw/camembert-spam-detector-fr")
7
8# Prédiction
9def predict(text):
10 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256, padding=True)
11 with torch.no_grad():
12 outputs = model(**inputs)
13 probs = torch.softmax(outputs.logits, dim=1)
14 pred = torch.argmax(probs, dim=1).item()
15 return "Spam" if pred == 1 else "Légitime", probs[0][pred].item()
16
17# Test
18label, confidence = predict("Comment faire une boucle for en Python ?")
19print(f"{label} ({confidence:.1%})") # Légitime (97.6%)
20
21label, confidence = predict("Gagnez 5000€/mois avec notre méthode !")
22print(f"{label} ({confidence:.1%})") # Spam (97.6%)| Message | Prédiction | Confiance |
|---|---|---|
| "Comment faire une boucle for en Python ?" | Légitime | 97.7% |
| "Gagnez 5000€/mois avec notre méthode !" | Spam | 97.6% |
| "Je ne vends pas ma formation" | Légitime | 97.5% |
| "Formation à vendre pour 99€ !" | Spam | 97.4% |
| "Est-ce que c'est une pub ?" | Légitime | 97.5% |
| "Services d'intégration API (OAuth, JWT, REST)" | Légitime | 95.4% |
| Paramètre | Valeur |
|---|---|
| Modèle de base | camembert-base |
| Dataset | 174 735 exemples (52% légitimes, 48% spam) |
| Batch size | 64 |
| Learning rate | 2e-5 |
| Epochs | 3 (early stopping) |
| Mixed precision | FP16 |
| GPU | NVIDIA RTX 5090 |
0 : Légitime (question technique, discussion, aide)1 : Spam/Promotion (publicité, arnaque, vente)pip show transformers → doit être <4.46.0nellaw/camembert-spam-detector-fr, pas camembert-base1# Corriger le problème
2pip install 'transformers>=4.40.0,<4.46.0'