AurelPx commited on
Commit
611e26a
·
verified ·
1 Parent(s): e9f624f

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +92 -61
README.md CHANGED
@@ -4,86 +4,117 @@ tags:
4
  ---
5
  # HR Conversations Multi-Label Classifier
6
 
7
- A fine-tuned **DistilBERT-base-uncased** (66M parameters) for multi-label classification of HR support conversations.
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  ## Model Details
10
 
11
  | Attribute | Value |
12
  |-----------|-------|
13
- | Base Model | `distilbert/distilbert-base-uncased` |
14
- | Task | Multi-label text classification |
 
15
  | Labels | 20 HR topics |
16
- | Training Data | 100 synthetic HR conversations |
17
- | Framework | Hugging Face Transformers |
18
 
19
  ## 20 HR Topic Labels
20
 
21
- 1. Benefits
22
- 2. Career Development
23
- 3. Compliance & Legal
24
- 4. Contracts
25
- 5. Diversity, Equity & Inclusion
26
- 6. Expense Management
27
- 7. Harassment
28
- 8. Health
29
- 9. IT & Equipment
30
- 10. Leave & Absence
31
- 11. Mobility
32
- 12. Offboarding
33
- 13. Onboarding
34
- 14. Payroll
35
- 15. Performance Management
36
- 16. Recruitment
37
- 17. Safety
38
- 18. Timetracking
39
- 19. Training
40
  20. Work Arrangements
41
 
42
  ## Usage
43
 
44
  ```python
45
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
46
- import torch
47
-
48
- model_id = "AurelPx/hr-conversations-classifier"
49
- tokenizer = AutoTokenizer.from_pretrained(model_id)
50
- model = AutoModelForSequenceClassification.from_pretrained(model_id)
51
-
52
- LABELS = [
53
- "Benefits", "Career Development", "Compliance & Legal", "Contracts",
54
- "Diversity, Equity & Inclusion", "Expense Management", "Harassment", "Health",
55
- "IT & Equipment", "Leave & Absence", "Mobility", "Offboarding",
56
- "Onboarding", "Payroll", "Performance Management", "Recruitment",
57
- "Safety", "Timetracking", "Training", "Work Arrangements"
58
- ]
59
-
60
- def classify(text, threshold=0.3):
61
- inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
62
- with torch.no_grad():
63
- logits = model(**inputs).logits
64
- probs = torch.sigmoid(logits).numpy()[0]
65
- return [LABELS[i] for i, p in enumerate(probs) if p >= threshold]
66
-
67
- # Example
68
- conversation = "USER: I haven't received my payslip for March yet..."
69
- print(classify(conversation)) # ['Payroll']
 
 
 
 
70
  ```
71
 
72
- ## Training Notes
 
 
 
 
 
 
 
 
 
 
73
 
74
- - **Dataset size**: 100 conversations (small dataset)
75
- - **Split**: 80 train / 20 validation
76
- - **Epochs**: 4-8 with early stopping
77
- - **Limitations**: With only 100 samples across 20 classes, the model is in a very low-data regime. For production use, collect >500 samples per label or apply data augmentation.
78
 
79
- ## Links
 
 
 
 
 
 
 
 
80
 
81
- - Dataset: [AurelPx/ml-intern-a2d69eee-datasets](https://huggingface.co/datasets/AurelPx/ml-intern-a2d69eee-datasets)
82
 
83
- <!-- ml-intern-provenance -->
84
- ## Generated by ML Intern
85
 
86
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
87
 
88
- - Try ML Intern: https://smolagents-ml-intern.hf.space
89
- - Source code: https://github.com/huggingface/ml-intern
 
4
  ---
5
  # HR Conversations Multi-Label Classifier
6
 
7
+ SETFit-style classifier for **20 HR topic labels** on employee–agent conversations, trained with **5,000 synthetic + 100 real samples** and evaluated via **5-fold stratified cross-validation** (no data leakage).
8
+
9
+ ## Results
10
+
11
+ | Metric | Score |
12
+ |--------|-------|
13
+ | **F1-micro (5-fold CV)** | **0.7962 ± 0.0098** |
14
+ | **F1-macro (5-fold CV)** | **0.7721** |
15
+ | Fold 1 | 0.7851 |
16
+ | Fold 2 | 0.7989 |
17
+ | Fold 3 | 0.8031 |
18
+ | Fold 4 | 0.7846 |
19
+ | Fold 5 | **0.8091** |
20
 
21
  ## Model Details
22
 
23
  | Attribute | Value |
24
  |-----------|-------|
25
+ | Encoder | `sentence-transformers/all-MiniLM-L6-v2` (384-dim) |
26
+ | Classifier | Multi-output Logistic Regression (scikit-learn) |
27
+ | Training samples | 5,100 (5,000 synthetic + 100 real) |
28
  | Labels | 20 HR topics |
29
+ | Validation | 5-fold stratified cross-validation |
30
+ | Framework | Sentence-Transformers + scikit-learn |
31
 
32
  ## 20 HR Topic Labels
33
 
34
+ 1. Benefits
35
+ 2. Career Development
36
+ 3. Compliance & Legal
37
+ 4. Contracts
38
+ 5. Diversity, Equity & Inclusion
39
+ 6. Expense Management
40
+ 7. Harassment
41
+ 8. Health
42
+ 9. IT & Equipment
43
+ 10. Leave & Absence
44
+ 11. Mobility
45
+ 12. Offboarding
46
+ 13. Onboarding
47
+ 14. Payroll
48
+ 15. Performance Management
49
+ 16. Recruitment
50
+ 17. Safety
51
+ 18. Timetracking
52
+ 19. Training
53
  20. Work Arrangements
54
 
55
  ## Usage
56
 
57
  ```python
58
+ from sentence_transformers import SentenceTransformer
59
+ import pickle, json
60
+ from huggingface_hub import hf_hub_download
61
+
62
+ # Download artifacts
63
+ classifier_path = hf_hub_download("AurelPx/hr-conversations-classifier", "setfit_classifier.pkl")
64
+ label_path = hf_hub_download("AurelPx/hr-conversations-classifier", "setfit_label_config.json")
65
+
66
+ # Load
67
+ encoder = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
68
+ with open(classifier_path, 'rb') as f:
69
+ classifier = pickle.load(f)
70
+ with open(label_path) as f:
71
+ config = json.load(f)
72
+
73
+ LABELS = config['label_names']
74
+
75
+ # Classify
76
+ sample = (
77
+ "USER: I haven't received my payslip for March yet. Could you please check what's going on?\n"
78
+ "AGENT: Good morning. I've checked the payroll system and it appears your March payslip "
79
+ "was generated on the 28th but there was a distribution delay. I've resent it to your "
80
+ "registered email. You should receive it within the next hour."
81
+ )
82
+
83
+ emb = encoder.encode([sample])
84
+ proba = classifier.predict_proba(emb)
85
+ preds = [LABELS[i] for i, p in enumerate(proba) if p[0][1] >= 0.5]
86
+ print(preds) # ['Payroll']
87
  ```
88
 
89
+ ## Interactive Demo
90
+
91
+ Try it live: [**AurelPx/hr-classifier-demo**](https://huggingface.co/spaces/AurelPx/hr-classifier-demo)
92
+
93
+ Paste any HR conversation, adjust the threshold, and see predicted labels with probabilities instantly.
94
+
95
+ ## Training Approach
96
+
97
+ 1. **Data augmentation** — 5,000 synthetic HR conversations generated from real conversation templates (no LLM, no external API, no data leakage).
98
+ 2. **Stratified 5-fold CV** — splits by primary label, preserving label distribution in each fold.
99
+ 3. **SETFit-style pipeline** — MiniLM embeddings + Logistic Regression, fast and accurate on small data.
100
 
101
+ ## Files in this Repo
 
 
 
102
 
103
+ | File | Description |
104
+ |------|-------------|
105
+ | `setfit_classifier.pkl` | Trained Logistic Regression classifier |
106
+ | `setfit_encoder.pkl` | SentenceTransformer MiniLM encoder (optional, for offline use) |
107
+ | `setfit_cv_results.json` | Cross-validation scores per fold |
108
+ | `setfit_label_config.json` | Label names and classification threshold |
109
+ | `training_script.py` | Full training pipeline (augmentation + CV + inference) |
110
+ | `inference.py` | Standalone inference script (DistilBERT legacy — not recommended) |
111
+ | `model.safetensors` | Legacy DistilBERT checkpoint (kept for compatibility) |
112
 
113
+ ## Dataset
114
 
115
+ - [AurelPx/ml-intern-a2d69eee-datasets](https://huggingface.co/datasets/AurelPx/ml-intern-a2d69eee-datasets)
116
+ - 100 English HR conversations with multi-label annotations
117
 
118
+ ## License
119
 
120
+ Apache 2.0