Team Ai
Modelpublic

TinyModels/Setfit-banking-intent

sourceHugging Faceapache-2.0updated 9d agoView on Hugging Face
1likes32downloads
Model Card

<div align="center">

<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20,24,30&height=220&section=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&center=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/>

Task Library Backbone Classes F1

Python PyTorch Transformers SentenceTransformers scikit-learn

Status Maintained PRs License

<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> &nbsp;β€’&nbsp; <a href="#-architecture"><kbd>πŸ—οΈ Architecture</kbd></a> &nbsp;β€’&nbsp; <a href="#-quick-start"><kbd>πŸš€ Quick Start</kbd></a> &nbsp;β€’&nbsp; <a href="#-model-labels-77-classes"><kbd>🏷️ Labels</kbd></a> &nbsp;β€’&nbsp; <a href="#-training-details"><kbd>πŸŽ“ Training</kbd></a> &nbsp;β€’&nbsp; <a href="#-bias-risks--limitations"><kbd>⚠️ Risks</kbd></a> &nbsp;β€’&nbsp; <a href="#-citation"><kbd>πŸ“œ Citation</kbd></a>

</div>


πŸ“– Model Description

<div align="center">

πŸ”πŸ’‘
Model TypeSetFit β€” Efficient Few-Shot Learning
Author[TinyModels](https://huggingface.co/TinyModels)
Sentence Transformer`BAAI/bge-small-en-v1.5`
Classification Head`sklearn.linear_model.LogisticRegression`
Max Sequence Length512 tokens
Number of Classes77 banking intents
Training Samples4 per class β€” 308 total
LanguageEnglish πŸ‡¬πŸ‡§
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">

Classes Categories

</div>

<details> <summary>πŸ’³ <b>Card Management</b> β€” <i>20 classes</i></summary>

LabelExample Utterance
activate_my_cardI have a new card and need to activate it
card_about_to_expireDo I need to do something to get a new card once it expires?
card_acceptanceWhere can I use my Mastercard?
card_arrivalWhere is the card I ordered 2 weeks ago?
card_delivery_estimateWhat is the delivery time for US?
card_linkingMy new card isn't in my app, how do I get it in there?
card_not_workingWhat do I do? My card is broken.
card_swallowedPlease send a new card; the ATM ate mine.
contactless_not_workingWhy is my contactless not working?
country_supportWill my new card work outside of the EU?
disposable_card_limitsIs there a limit to how many times I can use my disposable virtual card?
get_disposable_virtual_cardWhere can I order a disposable virtual card?
get_physical_cardIn the app, where do I find my card PIN?
getting_spare_cardIs it possible to get another card?
getting_virtual_cardHow do I receive a virtual card?
lost_or_stolen_cardI've lost my card. What can I do about that?
order_physical_cardHow do I ask for a physical card?
supported_cards_and_currenciesWhat currencies are approved to add money?
virtual_card_not_workingWhy isn't my disposable virtual card working?
visa_or_mastercardWhich one are you? Visa or Mastercard?

</details>

<details> <summary>πŸ’Έ <b>Payments</b> β€” <i>9 classes</i></summary>

LabelExample Utterance
apple_pay_or_google_payHow can I get my Google pay top up to work?
card_payment_fee_chargedWhy am I getting charged more for using my card?
card_payment_not_recognisedI don't understand where this charge came from.
card_payment_wrong_exchange_rateMy exchange rate isn't correct.
declined_card_paymentYou have declined my payment.
extra_charge_on_statementWhy is there a $1 charge on my statement?
pending_card_paymentA 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_twiceI have a duplicate charge.

</details>

<details> <summary>πŸ” <b>Transfers</b> β€” <i>12 classes</i></summary>

LabelExample Utterance
balance_not_updated_after_bank_transferI just transferred some money and do not see it updated yet.
beneficiary_not_allowedWhy can't I use my beneficiary?
cancel_transferPlease cancel the transfer I just made.
declined_transferI got a message that my transfer was declined.
failed_transferI can't seem to make a standard bank transfer.
pending_transferI am still waiting for a transfer to show up.
receiving_moneyHow can my boss pay me directly to the card?
transfer_fee_chargedWhy was I charged a fee for transferring money?
transfer_into_accountHow can I transfer money to this account from another bank?
transfer_not_received_by_recipientI transferred money and it didn't get there.
transfer_timingHow long until transfers from Europe go through?
top_up_by_bank_transfer_chargeIf I top up by transfer, am I going to be charged?

</details>

<details> <summary>⬆️ <b>Top-ups</b> β€” <i>9 classes</i></summary>

LabelExample Utterance
automatic_top_upHow can I setup automatic top-up?
pending_top_upWhy is the top-up I made still pending?
top_up_by_card_chargeDo you have any fees if I want to add money using an international card?
top_up_by_cash_or_chequeCan I top up with check?
top_up_failedI don't think that my top-up worked.
top_up_limitsWhat's the top-up limit?
top_up_revertedWhy did my top-up get reverted?
topping_up_by_cardI can't see my top up in my wallet!
verify_top_upHow are top-ups verified?

</details>

<details> <summary>🏧 <b>Cash & ATM</b> β€” <i>8 classes</i></summary>

LabelExample Utterance
atm_supportWhere should I withdraw money from?
balance_not_updated_after_cheque_or_cash_depositWhy isn't my cash deposit showing up in my account?
cash_withdrawal_chargeI got charged fees for withdrawing cash!
cash_withdrawal_not_recognisedI see cash withdrawals that I did not authorize.
declined_cash_withdrawalIs my card broken? I can't get cash out of the ATM.
pending_cash_withdrawalMy ATM withdrawal is taking forever.
wrong_amount_of_cash_receivedI only got $20 of the $100 that I attempted to withdraw.
wrong_exchange_rate_for_cash_withdrawalI received the incorrect exchange rate.

</details>

<details> <summary>πŸ” <b>Security & PIN</b> β€” <i>5 classes</i></summary>

LabelExample Utterance
change_pinCan you tell me how to change my PIN?
compromised_cardThe card has suffered a security breach.
lost_or_stolen_phoneMy app was on the phone and I was mugged.
passcode_forgottenI thought I knew my password but I guess I was wrong.
pin_blockedHelp me unblock my account. I entered the PIN wrong too many times.

</details>

<details> <summary>πŸͺͺ <b>Identity Verification</b> β€” <i>4 classes</i></summary>

LabelExample Utterance
unable_to_verify_identityThe app is not able to realize that it is me.
verify_my_identityCan I get information on the identity checks?
verify_source_of_fundsI'd like to know where my funds come from.
why_verify_identityWhat is the function of the identity check?

</details>

<details> <summary>πŸ‘€ <b>Account Management</b> β€” <i>3 classes</i></summary>

LabelExample Utterance
age_limitAt what age can a person open an account?
edit_personal_detailsI just got married and need to change my name on the account.
terminate_accountHow can I delete my account?

</details>

<details> <summary>πŸ’± <b>Fees & Currency</b> β€” <i>4 classes</i></summary>

LabelExample Utterance
exchange_chargeWhat are the currency exchange fees?
exchange_rateHow are the exchange rates determined?
exchange_via_appCan I exchange USD and GBP from the app?
fiat_currency_supportHow many currencies can I have?

</details>

<details> <summary>🧾 <b>Refunds & Disputes</b> β€” <i>3 classes</i></summary>

LabelExample Utterance
direct_debit_payment_not_recognisedI have an unauthorized charge.
Refund_not_showing_upWhy can't I see my refund in my statement?
request_refundI 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

ParameterValueParameterValue
batch_size(32, 32)num_epochs(1, 1)
max_steps-1sampling_strategyoversampling
num_iterations2body_learning_rate2e-05
head_learning_rate2e-05lossCosineSimilarityLoss
distance_metriccosine_distancemargin0.25
end_to_endFalseuse_ampFalse
warmup_proportion0.1l2_weight0.01
seed42load_best_model_at_endFalse

</div>

πŸ“š Training Set Statistics

<div align="center">

MetricMinMedianMax
πŸ“ Word count411.6678
🏷️ Samples per class444
πŸ—‚οΈ Total samplesβ€”308β€”

</div>

πŸ“‰ Training Curve

EpochStepTraining LossValidation Loss
0.025610.2141β€”

πŸ§ͺ Framework Versions

<div align="center">

Python SetFit SentenceTransformers Transformers PyTorch Datasets Tokenizers

</div>


⚠️ Bias, Risks & Limitations

<details> <summary><b>πŸ” Click to expand</b></summary>

⚠️ AreaπŸ“ Notes
Data sizeOnly 4 examples per class β€” rare phrasings may be misclassified.
LanguageTrained only on English β€” will not generalize to other languages without re-training.
Domain shiftVocabulary is banking-specific; out-of-domain inputs may produce confident but wrong labels.
Class ambiguitySome classes are semantically close (e.g. pending_transfer vs. transfer_not_received_by_recipient).
No calibrationLogReg probabilities are not temperature-calibrated β€” treat confidence as approximate.
PIIDo 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

TermMeaning
SetFitSentence Transformer Fine-tuning β€” few-shot text classification technique.
Contrastive LearningTraining method that pulls similar pairs together, pushes dissimilar apart.
Sentence TransformerEncoder that maps text β†’ dense vector embedding.
LogisticRegression HeadSimple linear classifier on top of embeddings.
IntentThe 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

<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&section=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>