learn-abc/banking77-intent-classifier
114
1---2library_name: transformers3license: mit4datasets:5- PolyAI/banking776language:7- en8base_model:9- google-bert/bert-base-uncased10---11 12**Repo:** `learn-abc/banking77-intent-classifier`13 14# Banking77 Intent Classifier (10-Intent)15 16## Overview17 18This model is a **fine-tuned BERT-based intent classifier** designed for **banking and financial customer queries**.19It is trained by **mapping the original 77 Banking77 intents into a smaller, production-friendly set of custom intents**, making it suitable for real-world conversational systems where simpler intent routing is required.20 21The model performs **single-label text classification** and is intended to be used as an **intent detection component**, not as a conversational or generative model.22 23---24 25## Model Details26 27* **Base model:** `bert-base-uncased`28* **Task:** Text Classification (Intent Classification)29* **Architecture:** `BertForSequenceClassification`30* **Languages:** English (robust to informal and conversational phrasing)31* **Max sequence length:** 64 tokens32* **Output:** One intent label with confidence score33 34---35 36## Custom Intent Schema37 38The original **77 Banking77 intents** were **mapped and consolidated** into the following **12 production intents**:39 40* `ACCOUNT_INFO`41* `ATM_SUPPORT`42* `CARD_ISSUE`43* `CARD_MANAGEMENT`44* `CARD_REPLACEMENT`45* `CHECK_BALANCE`46* `EDIT_PERSONAL_DETAILS`47* `FAILED_TRANSFER`48* `FEES`49* `LOST_OR_STOLEN_CARD`50* `MINI_STATEMENT`51* `FALLBACK`52 53Any user query that does not clearly belong to one of the supported categories is mapped to **FALLBACK**.54 55This design simplifies downstream business logic while retaining strong intent separation.56 57---58 59## Training Data60 61* **Primary dataset:** [PolyAI Banking77](https://huggingface.co/datasets/PolyAI/banking77)62* **Original training samples:** 10,00363* **Test samples:** 3,08064* **After intent mapping and augmentation:**65 66 * **Training samples:** 19,84667 * **Includes:** 280 explicitly added `FALLBACK` examples68 69### Training Intent Distribution (Post-Mapping)70 71| Intent | Samples |72| --------------------- | ------- |73| ACCOUNT_INFO | 1,983 |74| MINI_STATEMENT | 1,809 |75| FEES | 1,490 |76| FAILED_TRANSFER | 1,045 |77| CARD_MANAGEMENT | 1,026 |78| CARD_REPLACEMENT | 749 |79| ATM_SUPPORT | 743 |80| CARD_ISSUE | 456 |81| CHECK_BALANCE | 352 |82| LOST_OR_STOLEN_CARD | 229 |83| EDIT_PERSONAL_DETAILS | 121 |84| FALLBACK | 280 |85 86Class imbalance was handled using **class weighting** during training.87 88---89 90## Evaluation Results91 92Final evaluation on the Banking77 test set:93 94* **Accuracy:** 96.04%95* **F1 (Micro):** 0.96096* **F1 (Macro):** 0.95697 98These results indicate strong overall performance with good balance across both high-frequency and low-frequency intents.99 100---101 102## Usage103 104### Load the model105 106```python107from transformers import AutoTokenizer, AutoModelForSequenceClassification108import torch109 110model_id = "learn-abc/banking77-intent-classifier"111 112tokenizer = AutoTokenizer.from_pretrained(model_id)113model = AutoModelForSequenceClassification.from_pretrained(model_id)114 115def predict_intent(text):116 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=64)117 with torch.no_grad():118 outputs = model(**inputs)119 probs = torch.softmax(outputs.logits, dim=-1)120 pred_id = probs.argmax(dim=-1).item()121 confidence = probs[0][pred_id].item()122 123 return model.config.id2label[pred_id], confidence124 125# Example usage:126if __name__ == "__main__":127 test_texts = [128 "What is my account balance?",129 "Show me my last 10 transactions.",130 "I want to update my address.",131 "How do I apply for a loan?"132 ]133 134 for text in test_texts:135 intent, confidence = predict_intent(text)136 print(f"Input: {text}\nPredicted Intent: {intent} (Confidence: {confidence:.2f})\n")137```138 139---140 141## Intended Use142 143This model is suitable for:144 145* Banking chatbots146* Voice assistant intent routing147* Customer support automation148* FAQ classification systems149 150It is designed to be used **together with business rules**, confirmation flows, and fallback handling.151 152---153 154## Limitations and Safety Notes155 156* The model **does not perform authentication or authorization**157* It **must not directly trigger financial actions**158* High-risk intents (e.g. lost or stolen card) should always require explicit user confirmation159* Predictions should be validated with confidence thresholds and fallback logic160 161This model is **not a replacement for human review** in sensitive workflows.162 163---164 165## Notes on Model Warnings166 167During training, warnings related to missing or unexpected keys were observed.168These are expected when fine-tuning a pre-trained BERT checkpoint for a downstream classification task and **do not impact inference correctness**.169 170---171 172## Citation173 174If you use this model, please cite:175 176* Devlin et al., *BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding*177* PolyAI Banking77 Dataset178 179---180 181## Maintainer182 183Developed and fine-tuned for production-oriented banking intent classification.184 185---186 187[More Information Needed]188 189## More Information [optional]190 191[More Information Needed]192 193## Model Card Authors 194 195* **Author:** [Abhishek Singh](https://github.com/SinghIsWriting/)196* **LinkedIn:** [My LinkedIn Profile](https://www.linkedin.com/in/abhishek-singh-bba2662a9)197* **Portfolio:** [Abhishek Singh Portfolio](https://portfolio-abhishek-singh-nine.vercel.app/)198 199## Model Card Contact200 201[More Information Needed]