Views
No views yet
distilbert-base-uncased for routing customer support tweets into seven categories: billing, technical, account, delivery, product, support, general.1import pickle
2import torch
3from transformers import AutoTokenizer, AutoModelForSequenceClassification
4from huggingface_hub import hf_hub_download
5
6REPO = "Vishesh062/customer-support-tweet-classifier"
7tokenizer = AutoTokenizer.from_pretrained(REPO)
8model = AutoModelForSequenceClassification.from_pretrained(REPO)
9model.eval()
10
11# Label encoder maps class indices to category names
12le_path = hf_hub_download(repo_id=REPO, filename="label_encoder.pkl")
13with open(le_path, "rb") as f:
14 le = pickle.load(f)
15
16def classify(text):
17 inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
18 with torch.no_grad():
19 logits = model(**inputs).logits
20 return le.inverse_transform([logits.argmax(-1).item()])[0]
21
22classify("I've been overcharged on my last bill")
23# → 'billing'