Text Classification
setfit
Safetensors
sentence-transformers
English
bert
generated_from_setfit_trainer
text-embeddings-inference
Instructions to use TinyModels/Setfit-banking-intent with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- setfit
How to use TinyModels/Setfit-banking-intent with setfit:
from setfit import SetFitModel model = SetFitModel.from_pretrained("TinyModels/Setfit-banking-intent") preds = model.predict(["i loved the spiderman movie!", "pineapple on pizza is the worst"]) print(preds) - sentence-transformers
How to use TinyModels/Setfit-banking-intent with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("TinyModels/Setfit-banking-intent") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
File size: 21,226 Bytes
a71f2d2 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 753f67a 89fae58 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | ---
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
widget:
- text: What do I do? My card is broken.
- text: Where should I withdraw money from?
- text: >-
I can't seem to make a standard bank transfer. I have tried at least five
times already but none of them are going through. Please tell me what is
wrong?
- text: What are the currency exchange fees?
- text: I have an unauthorized charge.
metrics:
- accuracy
pipeline_tag: text-classification
library_name: setfit
inference: true
base_model: BAAI/bge-small-en-v1.5
model_name: TinyModels/setfit-banking-intent
license: apache-2.0
language:
- en
---
<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">
| π | π‘ |
|:--:|:--|
| **Model Type** | `SetFit` β Efficient Few-Shot Learning |
| **Author** | **[TinyModels](https://huggingface.co/TinyModels)** |
| **Sentence Transformer** | [`BAAI/bge-small-en-v1.5`](https://huggingface.co/BAAI/bge-small-en-v1.5) |
| **Classification Head** | [`sklearn.linear_model.LogisticRegression`](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) |
| **Max Sequence Length** | `512` tokens |
| **Number of Classes** | `77` banking intents |
| **Training Samples** | `4` per class β `308` total |
| **Language** | English π¬π§ |
| **Domain** | π¦ Banking / Fintech customer support |
</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
```mermaid
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>
```bash
pip install setfit
```
```python
from 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>
```python
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>
```python
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>
| Label | Example Utterance |
|:------|:------------------|
| `activate_my_card` | *I have a new card and need to activate it* |
| `card_about_to_expire` | *Do I need to do something to get a new card once it expires?* |
| `card_acceptance` | *Where can I use my Mastercard?* |
| `card_arrival` | *Where is the card I ordered 2 weeks ago?* |
| `card_delivery_estimate` | *What is the delivery time for US?* |
| `card_linking` | *My new card isn't in my app, how do I get it in there?* |
| `card_not_working` | *What do I do? My card is broken.* |
| `card_swallowed` | *Please send a new card; the ATM ate mine.* |
| `contactless_not_working` | *Why is my contactless not working?* |
| `country_support` | *Will my new card work outside of the EU?* |
| `disposable_card_limits` | *Is there a limit to how many times I can use my disposable virtual card?* |
| `get_disposable_virtual_card` | *Where can I order a disposable virtual card?* |
| `get_physical_card` | *In the app, where do I find my card PIN?* |
| `getting_spare_card` | *Is it possible to get another card?* |
| `getting_virtual_card` | *How do I receive a virtual card?* |
| `lost_or_stolen_card` | *I've lost my card. What can I do about that?* |
| `order_physical_card` | *How do I ask for a physical card?* |
| `supported_cards_and_currencies` | *What currencies are approved to add money?* |
| `virtual_card_not_working` | *Why isn't my disposable virtual card working?* |
| `visa_or_mastercard` | *Which one are you? Visa or Mastercard?* |
</details>
<details>
<summary>πΈ <b>Payments</b> β <i>9 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `apple_pay_or_google_pay` | *How can I get my Google pay top up to work?* |
| `card_payment_fee_charged` | *Why am I getting charged more for using my card?* |
| `card_payment_not_recognised` | *I don't understand where this charge came from.* |
| `card_payment_wrong_exchange_rate` | *My exchange rate isn't correct.* |
| `declined_card_payment` | *You have declined my payment.* |
| `extra_charge_on_statement` | *Why is there a $1 charge on my statement?* |
| `pending_card_payment` | *A card payment on my account is shown as pending.* |
| `reverted_card_payment?` | *I did a payment but it was reverted by the app.* |
| `transaction_charged_twice` | *I have a duplicate charge.* |
</details>
<details>
<summary>π <b>Transfers</b> β <i>12 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `balance_not_updated_after_bank_transfer` | *I just transferred some money and do not see it updated yet.* |
| `beneficiary_not_allowed` | *Why can't I use my beneficiary?* |
| `cancel_transfer` | *Please cancel the transfer I just made.* |
| `declined_transfer` | *I got a message that my transfer was declined.* |
| `failed_transfer` | *I can't seem to make a standard bank transfer.* |
| `pending_transfer` | *I am still waiting for a transfer to show up.* |
| `receiving_money` | *How can my boss pay me directly to the card?* |
| `transfer_fee_charged` | *Why was I charged a fee for transferring money?* |
| `transfer_into_account` | *How can I transfer money to this account from another bank?* |
| `transfer_not_received_by_recipient` | *I transferred money and it didn't get there.* |
| `transfer_timing` | *How long until transfers from Europe go through?* |
| `top_up_by_bank_transfer_charge` | *If I top up by transfer, am I going to be charged?* |
</details>
<details>
<summary>β¬οΈ <b>Top-ups</b> β <i>9 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `automatic_top_up` | *How can I setup automatic top-up?* |
| `pending_top_up` | *Why is the top-up I made still pending?* |
| `top_up_by_card_charge` | *Do you have any fees if I want to add money using an international card?* |
| `top_up_by_cash_or_cheque` | *Can I top up with check?* |
| `top_up_failed` | *I don't think that my top-up worked.* |
| `top_up_limits` | *What's the top-up limit?* |
| `top_up_reverted` | *Why did my top-up get reverted?* |
| `topping_up_by_card` | *I can't see my top up in my wallet!* |
| `verify_top_up` | *How are top-ups verified?* |
</details>
<details>
<summary>π§ <b>Cash & ATM</b> β <i>8 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `atm_support` | *Where should I withdraw money from?* |
| `balance_not_updated_after_cheque_or_cash_deposit` | *Why isn't my cash deposit showing up in my account?* |
| `cash_withdrawal_charge` | *I got charged fees for withdrawing cash!* |
| `cash_withdrawal_not_recognised` | *I see cash withdrawals that I did not authorize.* |
| `declined_cash_withdrawal` | *Is my card broken? I can't get cash out of the ATM.* |
| `pending_cash_withdrawal` | *My ATM withdrawal is taking forever.* |
| `wrong_amount_of_cash_received` | *I only got $20 of the $100 that I attempted to withdraw.* |
| `wrong_exchange_rate_for_cash_withdrawal` | *I received the incorrect exchange rate.* |
</details>
<details>
<summary>π <b>Security & PIN</b> β <i>5 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `change_pin` | *Can you tell me how to change my PIN?* |
| `compromised_card` | *The card has suffered a security breach.* |
| `lost_or_stolen_phone` | *My app was on the phone and I was mugged.* |
| `passcode_forgotten` | *I thought I knew my password but I guess I was wrong.* |
| `pin_blocked` | *Help me unblock my account. I entered the PIN wrong too many times.* |
</details>
<details>
<summary>πͺͺ <b>Identity Verification</b> β <i>4 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `unable_to_verify_identity` | *The app is not able to realize that it is me.* |
| `verify_my_identity` | *Can I get information on the identity checks?* |
| `verify_source_of_funds` | *I'd like to know where my funds come from.* |
| `why_verify_identity` | *What is the function of the identity check?* |
</details>
<details>
<summary>π€ <b>Account Management</b> β <i>3 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `age_limit` | *At what age can a person open an account?* |
| `edit_personal_details` | *I just got married and need to change my name on the account.* |
| `terminate_account` | *How can I delete my account?* |
</details>
<details>
<summary>π± <b>Fees & Currency</b> β <i>4 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `exchange_charge` | *What are the currency exchange fees?* |
| `exchange_rate` | *How are the exchange rates determined?* |
| `exchange_via_app` | *Can I exchange USD and GBP from the app?* |
| `fiat_currency_support` | *How many currencies can I have?* |
</details>
<details>
<summary>π§Ύ <b>Refunds & Disputes</b> β <i>3 classes</i></summary>
| Label | Example Utterance |
|:------|:------------------|
| `direct_debit_payment_not_recognised` | *I have an unauthorized charge.* |
| `Refund_not_showing_up` | *Why can't I see my refund in my statement?* |
| `request_refund` | *I need a refund for something I bought.* |
</details>
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%">
---
## π Training Details
<div align="center">
### βοΈ Hyperparameters
| Parameter | Value | | Parameter | Value |
|:----------|:-----:|-|:----------|:-----:|
| `batch_size` | `(32, 32)` | | `num_epochs` | `(1, 1)` |
| `max_steps` | `-1` | | `sampling_strategy` | `oversampling` |
| `num_iterations` | `2` | | `body_learning_rate` | `2e-05` |
| `head_learning_rate` | `2e-05` | | `loss` | `CosineSimilarityLoss` |
| `distance_metric` | `cosine_distance` | | `margin` | `0.25` |
| `end_to_end` | `False` | | `use_amp` | `False` |
| `warmup_proportion` | `0.1` | | `l2_weight` | `0.01` |
| `seed` | `42` | | `load_best_model_at_end` | `False` |
</div>
### π Training Set Statistics
<div align="center">
| Metric | Min | Median | Max |
|:-------|:---:|:------:|:---:|
| π Word count | **4** | **11.66** | **78** |
| π·οΈ Samples per class | **4** | **4** | **4** |
| ποΈ Total samples | β | **308** | β |
</div>
### π Training Curve
| Epoch | Step | Training Loss | Validation Loss |
|:-----:|:----:|:-------------:|:---------------:|
| `0.0256` | `1` | **0.2141** | β |
### π§ͺ Framework Versions
<div align="center">







</div>
---
## β οΈ Bias, Risks & Limitations
<details>
<summary><b>π Click to expand</b></summary>
| β οΈ Area | π Notes |
|:--------|:---------|
| **Data size** | Only **4 examples per class** β rare phrasings may be misclassified. |
| **Language** | Trained **only on English** β will not generalize to other languages without re-training. |
| **Domain shift** | Vocabulary is banking-specific; out-of-domain inputs may produce confident but wrong labels. |
| **Class ambiguity** | Some classes are semantically close (e.g. `pending_transfer` vs. `transfer_not_received_by_recipient`). |
| **No calibration** | LogReg probabilities are not temperature-calibrated β treat confidence as approximate. |
| **PII** | Do **not** feed real customer PII into shared demos; use anonymized text. |
</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
```yaml
π― 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:
```bibtex
@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
| Term | Meaning |
|:-----|:--------|
| **SetFit** | Sentence Transformer Fine-tuning β few-shot text classification technique. |
| **Contrastive Learning** | Training method that pulls similar pairs together, pushes dissimilar apart. |
| **Sentence Transformer** | Encoder that maps text β dense vector embedding. |
| **LogisticRegression Head** | Simple linear classifier on top of embeddings. |
| **Intent** | The user's goal behind a message (e.g. `cancel_transfer`). |
---
## π 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](https://huggingface.co/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> |