File size: 2,930 Bytes
8153a62
 
 
 
 
 
 
 
36a680b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8153a62
 
 
 
36a680b
8153a62
36a680b
 
300ec53
36a680b
 
 
 
8153a62
36a680b
8153a62
36a680b
8153a62
36a680b
8153a62
36a680b
 
8153a62
36a680b
 
 
8153a62
36a680b
 
8153a62
 
36a680b
300ec53
36a680b
300ec53
36a680b
8153a62
36a680b
8153a62
 
36a680b
8153a62
 
36a680b
8153a62
 
36a680b
 
 
 
8153a62
 
36a680b
8153a62
 
36a680b
8153a62
 
36a680b
8153a62
 
36a680b
8153a62
 
36a680b
8153a62
36a680b
8153a62
 
 
 
36a680b
8153a62
 
 
36a680b
8153a62
36a680b
 
 
8153a62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
library_name: transformers
pipeline_tag: text-classification
tags:
  - email
  - text-classification
language:
  - en
datasets:
  - FlowRank/labeled_emails
base_model: distilbert-base-uncased
license: mit
metrics:
  - accuracy
model-index:
  - name: mailSort
    results:
      - task:
          type: text-classification
        dataset:
          name: FlowRank/labeled_emails
          type: FlowRank/labeled_emails
        metrics:
          - type: accuracy
            value: 0.9601
widget:
  - text: "Subject: Insurance claim\n\nBody: Hello, I need to update my policy urgently before the deadline."
---

## mailSort

Classifieur d’e-mails **20 classes** (catégorie + urgence), basé sur DistilBERT.

Entraîné sur [`FlowRank/labeled_emails`](https://huggingface.co/datasets/FlowRank/labeled_emails) (révision `main`, ~19,8k exemples).  
**Accuracy test : 96,01 %** (1 900 / 1 979).

| Version | Labels | Révision dataset | Révision modèle |
|---------|--------|------------------|-----------------|
| **v2** (courante) | 20 | `main` ou `v2.0` | `main` ou `v2.0` |
| v1 | 10 | `v1.0` | `v1.0` |

### Labels (v2)

Chaque catégorie est déclinée en `_urgent` / `_not_urgent` : `family`, `finance`, `games`, `human resources`, `medical`, `pets`, `school`, `software engineering`, `sport`, `work/airbus`.

## Inférence

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline

tok = AutoTokenizer.from_pretrained("FlowRank/mailSort", subfolder="model")
model = AutoModelForSequenceClassification.from_pretrained("FlowRank/mailSort", subfolder="model")
clf = pipeline("text-classification", model=model, tokenizer=tok, truncation=True)

text = "Subject: Insurance claim\n\nBody: I need to update my policy urgently."
print(clf(text))
```

## Développement local

Repo Python minimal pour entraîner, évaluer et publier. Le script principal est `mailsort.train`.

Par défaut, le code charge la **dernière version du dataset** (`FlowRank/labeled_emails@main`).

### Installation

```bash
uv sync
```

### Entraîner + évaluer

```bash
uv run python -m mailsort.train \
  --model-name distilbert-base-uncased \
  --hub-model-id FlowRank/mailSort \
  --num-train-epochs 2
```

Pour épingler une version précise du dataset :

```bash
uv run python -m mailsort.train --dataset-revision v1.0
```

### Évaluer le modèle publié

```bash
uv run python -m mailsort.eval --split test
```

Évalue par défaut `FlowRank/mailSort` (sous-dossier `model/`) sur `FlowRank/labeled_emails@main`.

### Publier via Git (README + `model/`)

```bash
uv run python -m mailsort.prepare_model --outputs-dir outputs --model-dir model
git add README.md model
git commit -m "chore(model): update published artifacts"
git push
```

Le push Hub automatique via `Trainer` nécessite `HF_TOKEN` :

```bash
export HF_TOKEN="..."
uv run python -m mailsort.train --hub-model-id FlowRank/mailSort
```