Upload README.md
Browse files
README.md
CHANGED
|
@@ -4,86 +4,117 @@ tags:
|
|
| 4 |
---
|
| 5 |
# HR Conversations Multi-Label Classifier
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
## Model Details
|
| 10 |
|
| 11 |
| Attribute | Value |
|
| 12 |
|-----------|-------|
|
| 13 |
-
|
|
| 14 |
-
|
|
|
|
|
| 15 |
| Labels | 20 HR topics |
|
| 16 |
-
|
|
| 17 |
-
| Framework |
|
| 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
|
| 46 |
-
import
|
| 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 |
-
- **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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 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
|
|
|