CoolFace
Modelpublic

Janvi17/customer-support-ticket-classifier

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes25downloads
Model Card

Customer Support Ticket Classifier

A fine-tuned DistilBERT model that classifies customer support tickets into 11 issue categories. Designed for automatic routing, triage, and analytics of customer inquiries.

๐Ÿš€ [Try the live demo โ†’](https://huggingface.co/spaces/Janvi17/customer-support-ticket-classifier-demo)

Quick Start

python
from transformers import pipeline

classifier = pipeline("text-classification", model="Janvi17/customer-support-ticket-classifier")

result = classifier("I want to cancel my subscription immediately")
print(result)
# [{'label': 'SUBSCRIPTION', 'score': 0.997}]

Categories

The model classifies text into one of 11 customer support issue types:

LabelDescriptionExample
ACCOUNTAccount creation, deletion, password, profile changes"How do I change my account password?"
CANCELCancellation fees, policies, contract termination"What is the fee for canceling the contract?"
CONTACTReaching customer service, speaking to a human agent"I want to speak to a human agent"
DELIVERYDelivery options, shipping methods, delivery regions"Do you ship to Hungary?"
FEEDBACKReviews, complaints, submitting feedback"I'd like to leave a review for your services"
INVOICEViewing, requesting, or locating invoices/bills"Can you send me the invoice for order #12345?"
ORDERPlacing, tracking, modifying, or canceling orders"I need help cancelling order #55123"
PAYMENTPayment methods, issues, checkout errors"I get an error when I try to check out"
REFUNDRefund requests, refund policy, tracking refunds"I need a refund for my last purchase"
SHIPPINGShipping address changes, setup, modifications"I need to update my shipping address"
SUBSCRIPTIONNewsletter signup, unsubscribe, subscription management"Help me unsubscribe from your newsletter"

Usage Examples

Basic Classification

python
from transformers import pipeline

classifier = pipeline("text-classification", model="Janvi17/customer-support-ticket-classifier")

tickets = [
    "I want to cancel my subscription immediately",
    "Where is my package? I've been waiting for 2 weeks",
    "I need a refund for my last purchase",
    "How do I change my account password?",
    "I want to speak to a human agent",
    "Can you send me the invoice for order #12345?",
]

for ticket in tickets:
    result = classifier(ticket)
    print(f"  [{result[0]['label']:>12s}] (conf: {result[0]['score']:.3f}) {ticket}")

Output:

  [SUBSCRIPTION] (conf: 0.997) I want to cancel my subscription immediately
  [    DELIVERY] (conf: 0.997) Where is my package? I've been waiting for 2 weeks
  [      REFUND] (conf: 0.999) I need a refund for my last purchase
  [     ACCOUNT] (conf: 1.000) How do I change my account password?
  [     CONTACT] (conf: 0.999) I want to speak to a human agent
  [     INVOICE] (conf: 0.997) Can you send me the invoice for order #12345?

Batch Classification with Confidence Scores

python
from transformers import pipeline

classifier = pipeline(
    "text-classification",
    model="Janvi17/customer-support-ticket-classifier",
    top_k=3,  # return top 3 predictions
)

result = classifier("The payment for my subscription failed")
for pred in result[0]:
    print(f"  {pred['label']:>14s}: {pred['score']:.4f}")
# PAYMENT:       0.9661
# SUBSCRIPTION:  0.0153
# ORDER:         0.0068

Using with PyTorch Directly

python
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_name = "Janvi17/customer-support-ticket-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

text = "I need a refund for my last purchase"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)

with torch.no_grad():
    logits = model(**inputs).logits
    probs = torch.softmax(logits, dim=-1)
    pred_id = probs.argmax().item()

print(f"Predicted: {model.config.id2label[pred_id]} ({probs[0][pred_id]:.4f})")
# Predicted: REFUND (0.9995)

Production Usage with Confidence Threshold

For production systems, reject low-confidence predictions:

python
from transformers import pipeline

classifier = pipeline("text-classification", model="Janvi17/customer-support-ticket-classifier")
CONFIDENCE_THRESHOLD = 0.85

def classify_ticket(text: str) -> dict:
    result = classifier(text)[0]
    if result["score"] < CONFIDENCE_THRESHOLD:
        return {"label": "UNKNOWN", "score": result["score"], "routed_to": "human_review"}
    return {"label": result["label"], "score": result["score"], "routed_to": "auto"}

# High-confidence โ†’ auto-routed
print(classify_ticket("I need a refund"))
# {'label': 'REFUND', 'score': 0.999, 'routed_to': 'auto'}

# Low-confidence โ†’ human review
print(classify_ticket("asdfghjkl"))
# {'label': 'UNKNOWN', 'score': 0.78, 'routed_to': 'human_review'}

Evaluation Results

Held-Out Test Set (2,464 samples)

MetricScore
Accuracy100.00%
Macro F1100.00%
Weighted F1100.00%

Per-Class Performance

CategoryPrecisionRecallF1-ScoreSupport
ACCOUNT1.00001.00001.0000545
CANCEL1.00001.00001.000095
CONTACT1.00001.00001.0000200
DELIVERY1.00001.00001.0000166
FEEDBACK1.00001.00001.0000199
INVOICE1.00001.00001.0000183
ORDER1.00001.00001.0000317
PAYMENT1.00001.00001.0000200
REFUND1.00001.00001.0000262
SHIPPING1.00001.00001.0000197
SUBSCRIPTION1.00001.00001.0000100

Confusion Matrix

Perfect diagonal โ€” zero off-diagonal errors on the held-out test set.

Training Trajectory

EpochTrain LossVal LossVal AccuracyVal Macro F1
10.02290.016399.76%99.78%
20.00420.010699.68%99.68%
30.00240.005499.88%99.88% โœฆ best
40.00080.009199.80%99.80%
50.00070.008899.80%99.80%

Best checkpoint selected at epoch 3 (highest validation macro F1). Early stopping was configured with patience=2.

Baselines

MethodAccuracyMacro F1
Random9.9%9.1%
Majority class22.1%3.3%
TF-IDF + Logistic Regression99.7%99.7%
This model (DistilBERT)100.0%100.0%

Training Details

Dataset

[Bitext Customer Support LLM Chatbot Training Dataset](https://huggingface.co/datasets/bitext/Bitext-customer-support-llm-chatbot-training-dataset)

  • โ€”License: CDLA-Sharing-1.0
  • โ€”Publisher: Bitext
  • โ€”Size: 26,872 rows โ†’ 24,635 after deduplication
  • โ€”Splits used: 80% train (19,708) / 10% validation (2,463) / 10% test (2,464), stratified
  • โ€”Language: English
  • โ€”Format: Synthetic, template-generated customer support messages with intentional typos, case variations, and paraphrasing. Includes {{placeholder}} tokens for entities like order numbers and names.

The dataset contains 11 high-level issue categories and 27 fine-grained intents. This model classifies at the category level.

Class Distribution (Training Set)
CategoryCount%
ACCOUNT4,35422.1%
ORDER2,53412.9%
REFUND2,09810.6%
CONTACT1,5998.1%
PAYMENT1,5988.1%
FEEDBACK1,5988.1%
SHIPPING1,5768.0%
INVOICE1,4647.4%
DELIVERY1,3276.7%
SUBSCRIPTION7994.1%
CANCEL7603.9%

Imbalance ratio: 5.7ร— (ACCOUNT vs CANCEL). Despite this, macro F1 is perfect โ€” all classes are well-separated in semantic space.

Preprocessing

  1. 1.Exact-duplicate removal (26,872 โ†’ 24,635 samples)
  2. 2.Stratified train/val/test split (80/10/10, seed=42)
  3. 3.Tokenization with distilbert-base-uncased tokenizer, max_length=128
  4. 4.Dynamic padding via DataCollatorWithPadding

No text was truncated โ€” the longest tokenized input is 32 tokens.

Hyperparameters

ParameterValue
Base modeldistilbert/distilbert-base-uncased (67M params)
Learning rate2e-5
Batch size32
Epochs5 (best checkpoint at epoch 3)
Weight decay0.01
Warmup steps308 (10% of total)
LR schedulerCosine
Early stoppingPatience = 2 (metric: macro F1)
Precisionfp32 (trained on CPU)
Seed42

Framework Versions

  • โ€”Transformers 5.7.0
  • โ€”PyTorch 2.11.0
  • โ€”Datasets 4.8.5
  • โ€”Tokenizers 0.22.2

Demo

[๐Ÿš€ Try the live Gradio demo](https://huggingface.co/spaces/Janvi17/customer-support-ticket-classifier-demo) โ€” paste any support ticket and see real-time classification with confidence breakdown.

Limitations and Risks

Known Failure Modes

This model was stress-tested with 28 adversarial inputs. Four systematic weaknesses were identified:

1. Negation Blindness ๐Ÿ”ด

The model ignores negation. "Don't refund me, just fix the product" is classified as REFUND (99.95% confidence). The training data contains no negated intents, and DistilBERT's 6-layer architecture has limited compositional reasoning.

Mitigation: Add negated intent examples to training data, or post-process with a negation detector.

2. No Out-of-Distribution Rejection ๐Ÿ”ด

The model assigns a label to any input, including gibberish, empty strings, and unrelated text. Examples:

InputPredictionConfidence
"asdfghjkl"ORDER78.1%
"" (empty)ORDER73.7%
"The quick brown fox..."CONTACT84.9%

Mitigation: Use a confidence threshold (recommended: 0.85) to reject uncertain predictions. See the production usage example above.

3. Heavy Typo Fragility ๐ŸŸก

While the model handles mild typos well (the training data includes ~34% typo-augmented samples), severely misspelled text can cause misclassification:

InputExpectedPredictedConfidence
"hwere is my pakage"DELIVERYDELIVERY48.1% โš ๏ธ
"I wnat to spek to a humna"CONTACTORDER81.8% โŒ

Mitigation: Add a spell-correction preprocessing step, or augment training data with heavier typo injection.

4. Single-Label on Multi-Intent Tickets ๐ŸŸก

Real support tickets often span multiple categories. The model picks one:

InputPredictedAlso relevant
"Cancel my subscription and give me a refund"REFUNDCANCEL, SUBSCRIPTION
"Your delivery is terrible, I want to complain"DELIVERYFEEDBACK

Mitigation: For full coverage, return top-k predictions or switch to multi-label classification.

Dataset Limitations

  • โ€”Synthetic data: The training set is template-generated, not sourced from real customer interactions. Real-world text may contain slang, code-switching, or domain-specific jargon not represented in training.
  • โ€”English only: The model is trained exclusively on English text.
  • โ€”Limited vocabulary: Some categories have as few as 184 unique words (CANCEL), meaning the model relies heavily on keyword matching rather than deep semantic understanding.
  • โ€”Placeholder artifacts: Training data contains {{Order Number}}, {{Person Name}}, etc. The model has learned to ignore these, but unusual entity formats in real data could affect performance.

Bias and Fairness

  • โ€”The synthetic dataset does not represent any specific demographic or dialect distribution.
  • โ€”Performance on non-standard English (e.g., AAVE, Indian English, ESL patterns) has not been evaluated.
  • โ€”The model may perform differently across age groups, regions, or communication styles.

When NOT to Use This Model

  • โ€”Safety-critical routing: Do not use as the sole decision-maker for urgent or safety-related tickets without human review.
  • โ€”Non-English text: The model will produce unreliable predictions on non-English input.
  • โ€”Fine-grained intent classification: This model classifies into 11 broad categories, not 27 fine-grained intents. If you need intent-level predictions (e.g., distinguishing cancel_order from check_cancellation_fee), retrain with the intent column.

Citation

If you use this model, please cite the training dataset:

bibtex
@misc{bitext2023customer,
  title={Bitext - Customer Service Tagged Training Dataset for LLM-based Virtual Assistants},
  author={Bitext},
  year={2023},
  publisher={Hugging Face},
  url={https://huggingface.co/datasets/bitext/Bitext-customer-support-llm-chatbot-training-dataset}
}

License

This model is released under the Apache 2.0 License. The training dataset is licensed under CDLA-Sharing-1.0.