1from sentence_transformers import SentenceTransformer
2import pickle, json
3from huggingface_hub import hf_hub_download
4
5# Download artifacts
6classifier_path = hf_hub_download("AurelPx/hr-conversations-classifier", "setfit_classifier.pkl")
7label_path = hf_hub_download("AurelPx/hr-conversations-classifier", "setfit_label_config.json")
8
9# Load
10encoder = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
11with open(classifier_path, 'rb') as f:
12 classifier = pickle.load(f)
13with open(label_path) as f:
14 config = json.load(f)
15
16LABELS = config['label_names']
17
18# Classify
19sample = (
20 "USER: I haven't received my payslip for March yet. Could you please check what's going on?\n"
21 "AGENT: Good morning. I've checked the payroll system and it appears your March payslip "
22 "was generated on the 28th but there was a distribution delay. I've resent it to your "
23 "registered email. You should receive it within the next hour."
24)
25
26emb = encoder.encode([sample])
27proba = classifier.predict_proba(emb)
28preds = [LABELS[i] for i, p in enumerate(proba) if p[0][1] >= 0.5]
29print(preds) # ['Payroll']
Paste any HR conversation, adjust the threshold, and see predicted labels with probabilities instantly.