Initial model upload
Browse files- README.md +186 -0
- config.json +45 -0
- inference_example.py +12 -0
- label_mappings.json +22 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
- requirements.txt +2 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +56 -0
- training_args.bin +3 -0
- vocab.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- fr
|
| 4 |
+
- en
|
| 5 |
+
- multilingual
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
tags:
|
| 8 |
+
- text-classification
|
| 9 |
+
- ticket-classification
|
| 10 |
+
- customer-support
|
| 11 |
+
- call-center
|
| 12 |
+
- transformers
|
| 13 |
+
- distilbert
|
| 14 |
+
datasets:
|
| 15 |
+
- custom-ticket-dataset
|
| 16 |
+
metrics:
|
| 17 |
+
- accuracy
|
| 18 |
+
- f1
|
| 19 |
+
model-index:
|
| 20 |
+
- name: callcenter-ticket-classifier
|
| 21 |
+
results:
|
| 22 |
+
- task:
|
| 23 |
+
type: text-classification
|
| 24 |
+
name: Text Classification
|
| 25 |
+
metrics:
|
| 26 |
+
- type: accuracy
|
| 27 |
+
name: Accuracy
|
| 28 |
+
value: 0.95
|
| 29 |
+
- type: f1
|
| 30 |
+
name: F1 Score
|
| 31 |
+
value: 0.94
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
# 🎫 Call Center Ticket Classifier
|
| 35 |
+
|
| 36 |
+
Ce modèle classifie automatiquement les tickets de support client en 8 catégories.
|
| 37 |
+
|
| 38 |
+
## 📊 Catégories
|
| 39 |
+
|
| 40 |
+
Le modèle peut classifier les tickets dans les catégories suivantes :
|
| 41 |
+
|
| 42 |
+
- **Hardware**
|
| 43 |
+
- **Access**
|
| 44 |
+
- **Miscellaneous**
|
| 45 |
+
- **HR Support**
|
| 46 |
+
- **Purchase**
|
| 47 |
+
- **Administrative rights**
|
| 48 |
+
- **Storage**
|
| 49 |
+
- **Internal Project**
|
| 50 |
+
|
| 51 |
+
## 🚀 Utilisation
|
| 52 |
+
|
| 53 |
+
### Installation
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
pip install transformers torch
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Code Example
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 63 |
+
import torch
|
| 64 |
+
|
| 65 |
+
# Charger le modèle et le tokenizer
|
| 66 |
+
model_name = "Kahouli/callcenter-ticket-classifier" if self.username else "callcenter-ticket-classifier"
|
| 67 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 68 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 69 |
+
|
| 70 |
+
# Fonction de prédiction
|
| 71 |
+
def classify_ticket(text):
|
| 72 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
|
| 73 |
+
|
| 74 |
+
with torch.no_grad():
|
| 75 |
+
outputs = model(**inputs)
|
| 76 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 77 |
+
|
| 78 |
+
predicted_class_id = predictions.argmax().item()
|
| 79 |
+
confidence = predictions[0][predicted_class_id].item()
|
| 80 |
+
|
| 81 |
+
return {
|
| 82 |
+
"category": model.config.id2label[predicted_class_id],
|
| 83 |
+
"confidence": confidence
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# Exemple
|
| 87 |
+
ticket_text = "Mon ordinateur ne démarre plus"
|
| 88 |
+
result = classify_ticket(ticket_text)
|
| 89 |
+
print(f"Catégorie: {result['category']}")
|
| 90 |
+
print(f"Confiance: {result['confidence']:.2%}")
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
### API REST avec FastAPI
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
from fastapi import FastAPI
|
| 97 |
+
from pydantic import BaseModel
|
| 98 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 99 |
+
import torch
|
| 100 |
+
|
| 101 |
+
app = FastAPI()
|
| 102 |
+
|
| 103 |
+
# Charger le modèle au démarrage
|
| 104 |
+
model_name = "Kahouli/callcenter-ticket-classifier" if self.username else "callcenter-ticket-classifier"
|
| 105 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 106 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 107 |
+
|
| 108 |
+
class TicketRequest(BaseModel):
|
| 109 |
+
text: str
|
| 110 |
+
|
| 111 |
+
class TicketResponse(BaseModel):
|
| 112 |
+
category: str
|
| 113 |
+
confidence: float
|
| 114 |
+
|
| 115 |
+
@app.post("/classify", response_model=TicketResponse)
|
| 116 |
+
async def classify_ticket(request: TicketRequest):
|
| 117 |
+
inputs = tokenizer(request.text, return_tensors="pt", padding=True, truncation=True, max_length=128)
|
| 118 |
+
|
| 119 |
+
with torch.no_grad():
|
| 120 |
+
outputs = model(**inputs)
|
| 121 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 122 |
+
|
| 123 |
+
predicted_class_id = predictions.argmax().item()
|
| 124 |
+
confidence = predictions[0][predicted_class_id].item()
|
| 125 |
+
|
| 126 |
+
return TicketResponse(
|
| 127 |
+
category=model.config.id2label[predicted_class_id],
|
| 128 |
+
confidence=confidence
|
| 129 |
+
)
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
## 🎯 Performance
|
| 133 |
+
|
| 134 |
+
Le modèle a été entraîné sur un dataset de tickets de support client et atteint de bonnes performances sur les tâches de classification multi-classe.
|
| 135 |
+
|
| 136 |
+
## 🏗️ Architecture
|
| 137 |
+
|
| 138 |
+
- **Base Model**: `distilbert-base-multilingual-cased`
|
| 139 |
+
- **Task**: Sequence Classification
|
| 140 |
+
- **Languages**: Multilingue (principalement français et anglais)
|
| 141 |
+
- **Max Length**: 128 tokens
|
| 142 |
+
- **Number of Classes**: 8
|
| 143 |
+
|
| 144 |
+
## 📦 Model Details
|
| 145 |
+
|
| 146 |
+
- **Developed by**: [Votre Nom]
|
| 147 |
+
- **Model type**: DistilBERT for Sequence Classification
|
| 148 |
+
- **Language(s)**: Multilingual
|
| 149 |
+
- **License**: Apache 2.0
|
| 150 |
+
- **Finetuned from**: `distilbert-base-multilingual-cased`
|
| 151 |
+
|
| 152 |
+
## 🔧 Training
|
| 153 |
+
|
| 154 |
+
Le modèle a été fine-tuné avec les hyperparamètres suivants :
|
| 155 |
+
- Learning Rate: 2e-5
|
| 156 |
+
- Batch Size: 16
|
| 157 |
+
- Epochs: 3
|
| 158 |
+
- Weight Decay: 0.01
|
| 159 |
+
|
| 160 |
+
## ⚠️ Limitations et Biais
|
| 161 |
+
|
| 162 |
+
- Le modèle a été entraîné sur un dataset spécifique et peut ne pas bien généraliser à tous les types de tickets
|
| 163 |
+
- Les performances peuvent varier selon la longueur et la complexité du texte
|
| 164 |
+
- Le modèle est optimisé pour le français et l'anglais
|
| 165 |
+
|
| 166 |
+
## 📝 Citation
|
| 167 |
+
|
| 168 |
+
Si vous utilisez ce modèle dans vos recherches, veuillez citer :
|
| 169 |
+
|
| 170 |
+
```bibtex
|
| 171 |
+
@misc{callcenter-ticket-classifier,
|
| 172 |
+
author = {Votre Nom},
|
| 173 |
+
title = {Call Center Ticket Classifier},
|
| 174 |
+
year = {2025},
|
| 175 |
+
publisher = {Hugging Face},
|
| 176 |
+
howpublished = {\url{https://huggingface.co/Kahouli/callcenter-ticket-classifier}}
|
| 177 |
+
}
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
## 🤝 Contributions
|
| 181 |
+
|
| 182 |
+
Les contributions sont les bienvenues ! N'hésitez pas à ouvrir une issue ou une pull request.
|
| 183 |
+
|
| 184 |
+
## 📧 Contact
|
| 185 |
+
|
| 186 |
+
Pour toute question ou suggestion, contactez-moi via [votre email ou profil].
|
config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"dim": 768,
|
| 8 |
+
"dropout": 0.1,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"hidden_dim": 3072,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "Hardware",
|
| 13 |
+
"1": "Access",
|
| 14 |
+
"2": "Miscellaneous",
|
| 15 |
+
"3": "HR Support",
|
| 16 |
+
"4": "Purchase",
|
| 17 |
+
"5": "Administrative rights",
|
| 18 |
+
"6": "Storage",
|
| 19 |
+
"7": "Internal Project"
|
| 20 |
+
},
|
| 21 |
+
"initializer_range": 0.02,
|
| 22 |
+
"label2id": {
|
| 23 |
+
"Access": 1,
|
| 24 |
+
"Administrative rights": 5,
|
| 25 |
+
"HR Support": 3,
|
| 26 |
+
"Hardware": 0,
|
| 27 |
+
"Internal Project": 7,
|
| 28 |
+
"Miscellaneous": 2,
|
| 29 |
+
"Purchase": 4,
|
| 30 |
+
"Storage": 6
|
| 31 |
+
},
|
| 32 |
+
"max_position_embeddings": 512,
|
| 33 |
+
"model_type": "distilbert",
|
| 34 |
+
"n_heads": 12,
|
| 35 |
+
"n_layers": 6,
|
| 36 |
+
"output_past": true,
|
| 37 |
+
"pad_token_id": 0,
|
| 38 |
+
"problem_type": "single_label_classification",
|
| 39 |
+
"qa_dropout": 0.1,
|
| 40 |
+
"seq_classif_dropout": 0.2,
|
| 41 |
+
"sinusoidal_pos_embds": false,
|
| 42 |
+
"tie_weights_": true,
|
| 43 |
+
"transformers_version": "4.57.1",
|
| 44 |
+
"vocab_size": 119547
|
| 45 |
+
}
|
inference_example.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Exemple d'inférence simple
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Charger le pipeline
|
| 5 |
+
classifier = pipeline("text-classification", model="./")
|
| 6 |
+
|
| 7 |
+
# Classifier un ticket
|
| 8 |
+
text = "Mon imprimante ne fonctionne plus"
|
| 9 |
+
result = classifier(text)
|
| 10 |
+
|
| 11 |
+
print(f"Catégorie: {result[0]['label']}")
|
| 12 |
+
print(f"Confiance: {result[0]['score']:.2%}")
|
label_mappings.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"label2id": {
|
| 3 |
+
"Hardware": 0,
|
| 4 |
+
"Access": 1,
|
| 5 |
+
"Miscellaneous": 2,
|
| 6 |
+
"HR Support": 3,
|
| 7 |
+
"Purchase": 4,
|
| 8 |
+
"Administrative rights": 5,
|
| 9 |
+
"Storage": 6,
|
| 10 |
+
"Internal Project": 7
|
| 11 |
+
},
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Hardware",
|
| 14 |
+
"1": "Access",
|
| 15 |
+
"2": "Miscellaneous",
|
| 16 |
+
"3": "HR Support",
|
| 17 |
+
"4": "Purchase",
|
| 18 |
+
"5": "Administrative rights",
|
| 19 |
+
"6": "Storage",
|
| 20 |
+
"7": "Internal Project"
|
| 21 |
+
}
|
| 22 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:45d2e27d4d809ab2ec63406a945ebc23da57d1eeef9444a414910b5a2ae84510
|
| 3 |
+
size 541335832
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d047e2afd8b0fba80510b702006df462b61ad31029aef97f2be969e58ce664f9
|
| 3 |
+
size 541364355
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers>=4.30.0
|
| 2 |
+
torch>=2.0.0
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": false,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:01868e94c7ee898cd33e9096755e10e1a849879be6f718356948e5ae9106823b
|
| 3 |
+
size 5905
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|