TinyModels/Setfit-banking-intent
<div align="center">
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20,24,30&height=220§ion=header&text=SetFit%20Banking%20Intent&fontSize=54&fontColor=ffffff&animation=fadeIn&fontAlignY=32&desc=77-Class%20Intent%20Classification%20%E2%80%A2%20Few-Shot%20Learning%20%E2%80%A2%20SetFit&descAlignY=55&descSize=18&descColor=e0d7ff" width="100%"/>
<a href="https://huggingface.co/TinyModels/setfit-banking-intent"> <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=24&duration=2800&pause=900&color=A78BFA¢er=true&vCenter=true&multiline=true&width=800&height=90&lines=Classify+banking+intents+in+one+line+of+code.;77+classes+%7C+4+samples+per+class+%7C+SetFit+few-shot.;Powered+by+BAAI%2Fbge-small-en-v1.5.;Built+with+%E2%9D%A4%EF%B8%8F+by+TinyModels." alt="Typing SVG" /> </a>
<br/>
<br/>
<img src="https://media.giphy.com/media/3o7aCTfyhYawdOXcFW/giphy.gif" width="140" alt="animated spark"/>
<br/><br/>
### π¦ A tiny, fast, and accurate SetFit classifier that routes banking customer intents β trained with just 4 examples per class (308 sentences total).
</div>
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%">
<div align="center">
π§ Table of Contents
<a href="#-model-description"><kbd>π Description</kbd></a> β’ <a href="#-architecture"><kbd>ποΈ Architecture</kbd></a> β’ <a href="#-quick-start"><kbd>π Quick Start</kbd></a> β’ <a href="#-model-labels-77-classes"><kbd>π·οΈ Labels</kbd></a> β’ <a href="#-training-details"><kbd>π Training</kbd></a> β’ <a href="#-bias-risks--limitations"><kbd>β οΈ Risks</kbd></a> β’ <a href="#-citation"><kbd>π Citation</kbd></a>
</div>
π Model Description
<div align="center">
</div>
π Why SetFit?
SetFit achieves strong accuracy without prompts and without large labeled datasets. It first fine-tunes a sentence embedding model with contrastive learning, then trains a lightweight classifier on top β perfect for low-data, high-class-count problems like this one.
ποΈ Architecture
flowchart LR
A["π Input Text<br/>(customer message)"] --> B["π€ BAAI/bge-small-en-v1.5<br/>Sentence Transformer"]
B --> C["𧬠Sentence Embedding<br/>(384-dim)"]
C --> D["π― LogisticRegression<br/>Classification Head"]
D --> E["π·οΈ Predicted Intent<br/>(1 of 77 classes)"]
subgraph TRAIN["π Training Pipeline"]
direction TB
T1["Contrastive Fine-tuning<br/>(CosineSimilarityLoss)"] --> T2["Embedding Extraction"]
T2 --> T3["LogReg Head Training"]
end
style A fill:#6C63FF,color:#fff,stroke:#4B4BFF,stroke-width:2px
style B fill:#FF6F91,color:#fff,stroke:#E0567A,stroke-width:2px
style C fill:#00C2A8,color:#fff,stroke:#009E88,stroke-width:2px
style D fill:#F7B32B,color:#000,stroke:#D99A1F,stroke-width:2px
style E fill:#34D399,color:#000,stroke:#25A67A,stroke-width:2px
style TRAIN fill:#1a1a2e,color:#fff,stroke:#6C63FF,stroke-dasharray: 5 5<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%">
π Quick Start
<details open> <summary><b>π Python β one-liner inference</b></summary>
pip install setfitfrom setfit import SetFitModel
# π½ Load from the Hub
model = SetFitModel.from_pretrained("TinyModels/setfit-banking-intent")
# π― Run inference
preds = model("I have an unauthorized charge.")
print(preds)
# β ['direct_debit_payment_not_recognised']</details>
<details> <summary><b>π¦ Batch inference with confidence scores</b></summary>
from setfit import SetFitModel
import numpy as np
model = SetFitModel.from_pretrained("TinyModels/setfit-banking-intent")
texts = [
"What do I do? My card is broken.",
"Where should I withdraw money from?",
"What are the currency exchange fees?",
"I have an unauthorized charge.",
]
# Predicted labels
labels = model(texts)
print(labels)
# Probability distribution per class
probs = model.predict_proba(texts)
top_idx = np.argmax(probs, axis=1)
top_conf = probs[np.arange(len(texts)), top_idx]
for t, l, c in zip(texts, labels, top_conf):
print(f"[{c:0.2%}] {l:<40} β {t}")</details>
<details> <summary><b>β‘ FastAPI microservice snippet</b></summary>
from fastapi import FastAPI
from pydantic import BaseModel
from setfit import SetFitModel
app = FastAPI(title="Banking Intent API")
model = SetFitModel.from_pretrained("TinyModels/setfit-banking-intent")
class Query(BaseModel):
text: str
@app.post("/classify")
def classify(q: Query):
label = model([q.text])[0]
return {"intent": label, "text": q.text}</details>
π·οΈ Model Labels (77 Classes)
<div align="center">
</div>
<details> <summary>π³ <b>Card Management</b> β <i>20 classes</i></summary>
</details>
<details> <summary>πΈ <b>Payments</b> β <i>9 classes</i></summary>
</details>
<details> <summary>π <b>Transfers</b> β <i>12 classes</i></summary>
</details>
<details> <summary>β¬οΈ <b>Top-ups</b> β <i>9 classes</i></summary>
</details>
<details> <summary>π§ <b>Cash & ATM</b> β <i>8 classes</i></summary>
</details>
<details> <summary>π <b>Security & PIN</b> β <i>5 classes</i></summary>
</details>
<details> <summary>πͺͺ <b>Identity Verification</b> β <i>4 classes</i></summary>
</details>
<details> <summary>π€ <b>Account Management</b> β <i>3 classes</i></summary>
</details>
<details> <summary>π± <b>Fees & Currency</b> β <i>4 classes</i></summary>
</details>
<details> <summary>π§Ύ <b>Refunds & Disputes</b> β <i>3 classes</i></summary>
</details>
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%">
π Training Details
<div align="center">
βοΈ Hyperparameters
</div>
π Training Set Statistics
<div align="center">
</div>
π Training Curve
π§ͺ Framework Versions
<div align="center">
</div>
β οΈ Bias, Risks & Limitations
<details> <summary><b>π Click to expand</b></summary>
</details>
π« Out-of-Scope Use
- β Legal, medical, or financial advice generation
- β Production decision-making without human-in-the-loop
- β Non-English customer messages
- β Emotion / sentiment / toxicity detection
π§© Model Card Recipe
π― base_model: BAAI/bge-small-en-v1.5
π§ head: LogisticRegression
π technique: SetFit (few-shot contrastive)
π·οΈ classes: 77
π metric: accuracy
π€ max_tokens: 512
π± seed: 42πΊοΈ Roadmap
- [x] Train on 77 banking intents
- [x] Publish to Hugging Face Hub
- [ ] Add calibrated confidence scores
- [ ] Multilingual variant (XLM-R backbone)
- [ ] ONNX / quantized export for edge
- [ ] Evaluation on public banking benchmark
π Citation
If you use this model, please cite the SetFit paper:
@article{tunstall2022setfit,
doi = {10.48550/ARXIV.2209.11055},
url = {https://arxiv.org/abs/2209.11055},
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences},
title = {Efficient Few-Shot Learning Without Prompts},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}π Glossary
π Star History
<div align="center">
<a href="https://star-history.com/#TinyModels/setfit-banking-intent&Date"> <img src="https://api.star-history.com/svg?repos=TinyModels/setfit-banking-intent&type=Date" width="600" alt="Star History Chart"/> </a>
</div>
<div align="center">
π Made with love by TinyModels
<a href="https://huggingface.co/TinyModels/setfit-banking-intent"> <img src="https://img.shields.io/badge/π€%20Hugging%20Face-Model%20Card-FFD21E?style=for-the-badge&logoColor=black"/> </a> <a href="https://github.com/huggingface/setfit"> <img src="https://img.shields.io/badge/GitHub-SetFit-181717?style=for-the-badge&logo=github"/> </a> <a href="https://arxiv.org/abs/2209.11055"> <img src="https://img.shields.io/badge/arXiv-2209.11055-B31B1B?style=for-the-badge&logo=arxiv"/> </a>
<br/><br/>
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20,24,30&height=140§ion=footer&text=Thanks%20for%20stopping%20by!&fontSize=24&fontColor=ffffff&animation=twinkling&fontAlignY=60" width="100%"/>
<sub>β If this model helped you, consider leaving a like on the Hub/Repo!</sub>
</div>
