This report provides a detailed breakdown of how the Indian transaction classification models were developed, where their training data originated, their exact architectures, trainable parameters, and training hyperparameters.
Two distinct modeling approaches exist for Indian bank transaction categorization:
| Attribute | 1. Qwen LoRA Classifier (rs-transation-clasifer) |
2. SetFit Categorizer (indian-transaction-categorizer) |
|---|---|---|
| Model Type | Generative LLM (Autoregressive Decoder) | Embedding-based Sentence Transformer + Logistic Head |
| Base Foundation | Qwen/Qwen2.5-0.5B (~490M params) |
sentence-transformers/all-MiniLM-L6-v2 (~22.7M params) |
| Adapter / Head Size | 4.15 MB (adapter_model.safetensors) |
86.65 MB (model.safetensors) |
| Total Disk Footprint | ~1.0 GB (Base) + 4 MB (Adapter) | ~87.6 MB (Standalone) |
| Target Output | Structured JSON string with merchant inference | Direct single category label |
| Recommended Compute | GPU (CUDA / Apple Silicon MPS) | CPU or GPU (Extremely lightweight) |
The goal of this model is to parse complex, unstructured Indian bank narrations (UPI, NEFT, IMPS, RTGS, NACH) and output a clean JSON response containing:
is_income){
"category": "trading_deposit",
"company_name": "Zerodha",
"is_income": false,
"confidence": 0.90
}
The training dataset was generated through a multi-stage synthetic and augmentation pipeline:
Transaction Templates:
UPI/DR/.../MERCHANT/BANK/...), NEFT salary credits, and NACH auto-debits.Merchant Directory & Mapping (merchant_directory.json):
PII Shielding (pii_shield.py):
Conflict Resolution & Balancing (augment_training_data.py):
From adapter_config.json:
| Parameter | Value | Description |
|---|---|---|
task_type |
CAUSAL_LM |
Causal language modeling objective |
r (Rank) |
8 |
Low-rank decomposition dimension |
lora_alpha |
16 |
Multiplier scale applied to the LoRA updates |
lora_dropout |
0.05 |
5% dropout probability for regularization |
target_modules |
["q_proj", "k_proj", "v_proj", "o_proj"] |
Injected into all multi-head attention projection layers |
bias |
"none" |
Base model biases were not modified |
From finetune_qwen.py and trainer_state.json:
| Hyperparameter | Value | Description |
|---|---|---|
| Framework | TRL SFTTrainer + PEFT |
Hugging Face Supervised Fine-Tuning library |
| Optimizer | adamw_torch |
AdamW optimizer |
| Learning Rate | 1e-4 (continued) / 2e-4 (fresh) |
Peak learning rate with warmup |
| Warmup Ratio | 0.05 |
5% linear warmup steps |
| Per-Device Batch Size | 2 |
Batch size per GPU/accelerator |
| Gradient Accumulation | 8 |
Effective batch size = 16 |
| Max Sequence Length | 512 |
Token context window |
| Epochs | 1.0 – 2.0 |
Number of passes over training set |
| Final Loss | 0.0563 |
Reduced from 0.1013 at step 10 down to 0.0563 at step 30 |
| Token Accuracy | 98.56% |
Evaluated on generated completion tokens |
Sumeetgpt/indian-transaction-categorizer)Built using SetFit (Sentence Transformer Fine-Tuning), this model is designed for rapid few-shot classification. It maps narrations directly into 21 personal finance categories:
Groceries · Eating Out · Mobile Recharge / Utilities · Entertainment & Subscriptions · Transportation & Gas · Travel · Shopping & Clothing · Medicine & Pharmacy · Hospital & Medical · Rent & Mortgage · Loan Payment · Investments & Savings Transfer · Salary · Income & Deposits · Internal Transfer · ATM & Cash · Fees & Interest · Kids Activities · Personal Care · Education
Sumeetgpt/indian-transaction-categorization-syntheticsynthetic_indian_generator.py).From config_setfit.json:
| Hyperparameter | Value | Description |
|---|---|---|
| Body Backbone | all-MiniLM-L6-v2 |
6-layer transformer encoder producing 384-dim embeddings |
| Classification Head | LogisticRegression |
Scikit-learn multi-class logistic regression |
| Loss Function | CosineSimilarityLoss |
Contrastive loss encouraging positive pairs closer and negatives apart |
num_iterations |
20 |
Number of positive & negative text pairs generated per sentence |
num_epochs |
2 |
Training passes for contrastive fine-tuning |
batch_size |
16 |
Mini-batch size for embedding tuning |
| Accuracy | 94.6% |
Held-out synthetic test set accuracy |
You can run both the categorizer web apps and the fine-tuned Qwen LoRA model on Google Colab completely free.
Go to colab.research.google.com and create a New Notebook. (A standard CPU runtime is sufficient).
In the first code cell, run:
!pip install -q "sentence-transformers>=3.0.0" "setfit>=1.0.0" "gradio>=4.0.0" pandas numpy
Run this cell to fetch either app.py (clean 3 columns) or sample.py (full ledger analytics) directly from Hugging Face:
# To download the clean 3-column app:
!wget -O app.py https://huggingface.co/souvik-biswas/rs-transation-clasifer/raw/main/app.py
# OR to download the full ledger analytics app:
!wget -O sample.py https://huggingface.co/souvik-biswas/rs-transation-clasifer/raw/main/sample.py
Enable public sharing so you can open the app in any browser:
# Launch the 3-column app:
!python -c "import app; app.demo.launch(share=True)"
# OR launch the full analytics app:
# !python -c "import sample; sample.demo.launch(share=True)"
Colab will generate a public link: https://xxxxxxxx.gradio.live.
sir.json).To run the fine-tuned generative model souvik-biswas/rs-transation-clasifer:
In Colab, go to Runtime $\rightarrow$ Change runtime type $\rightarrow$ select T4 GPU $\rightarrow$ Save.
!pip install -q transformers peft accelerate torch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-0.5B"
LORA_ADAPTER = "souvik-biswas/rs-transation-clasifer"
print("Loading base model and LoRA adapter...")
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, LORA_ADAPTER)
model.eval()
# Transaction to classify:
tx = "UPI/DR/127199526678/BIGTREE /UTIB/bookmyshow/UPI"
prompt = (
"### System:\n"
"You are a bank transaction classifier for Indian bank statements. "
"Given a raw transaction description, infer both its category and the actual company when evidence exists. "
"Respond with ONLY a JSON object: {\"category\": \"<category>\", \"company_name\": \"<company_or_null>\", \"is_income\": false, \"confidence\": 0.0}.\n\n"
f"### Input:\n{tx}\n\n"
"### Output:\n"
)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=80, temperature=0.1, do_sample=False)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print("Model Output:\n", response)
# Output: {"category": "Entertainment & Subscriptions", "company_name": "BookMyShow", "is_income": false, "confidence": 0.95}
If you want to use the model locally inside LM Studio, you can merge the LoRA weights and export a .gguf file in Google Colab:
# 1. Merge base model + LoRA
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B")
model = PeftModel.from_pretrained(base, "souvik-biswas/rs-transation-clasifer")
merged = model.merge_and_unload()
merged.save_pretrained("./qwen-merged")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
tokenizer.save_pretrained("./qwen-merged")
# 2. Clone llama.cpp and convert to GGUF
!git clone --depth 1 https://github.com/ggerganov/llama.cpp.git
!pip install -r llama.cpp/requirements.txt
!python llama.cpp/convert_hf_to_gguf.py ./qwen-merged --outfile rs-transation-clasifer.gguf --outtype q8_0
# 3. Download the GGUF file to your computer
from google.colab import files
files.download("rs-transation-clasifer.gguf")
Once downloaded, drag rs-transation-clasifer.gguf into your LM Studio model folder (~/.cache/lm-studio/models/).
uv)# To run the 3-column app:
uv run --with sentence-transformers --with setfit --with gradio --with pandas python app.py
# To run the full analytics app:
uv run --with sentence-transformers --with setfit --with gradio --with pandas python sample.py
venv)python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install sentence-transformers setfit gradio pandas numpy
python app.py # or: python sample.py
Open your browser at http://127.0.0.1:7860.
Both scripts expect a standard JSON bank statement format (e.g., sir.json):
[
{
"success": true,
"data": {
"bankInfo": {
"accountNumber": "XXXX",
"ifscCode": "XXXX000XXXX",
"branchName": "XXXX BRANCH"
},
"transactions": [
{
"date": "2026-XX-XX",
"description": "UPI/CR/XXXXXXXXXXXX/BENEFICIARY NAME/XXXX/user@xxx/UPI",
"credit": 5000.00,
"debit": 0,
"balance": 25000.00
},
{
"date": "2026-XX-XX",
"description": "UPI/DR/XXXXXXXXXXXX/Airtel/AIRP/airtelpaym/Pay Via",
"credit": 0,
"debit": 199.00,
"balance": 24801.00
}
]
}
}
]
Mobile Recharge: All Airtel, Jio, Vi, Vodafone, BSNL, and Euronet transactions are automatically routed to Mobile Recharge instead of the general Utilities tag.BIGTREE $\rightarrow$ BookMyShow, AVENUE S $\rightarrow$ DMart, ROPPEN $\rightarrow$ Rapido, GROFERS $\rightarrow$ Blinkit).Loan Payment.lora-adapter/checkpoint-16/optimizer.pt 9 MBlora-adapter/checkpoint-33/optimizer.pt 9 MBlora-adapter/adapter_model.safetensors 4 MBlora-adapter/checkpoint-16/adapter_model.safetensors 4 MBlora-adapter/checkpoint-33/adapter_model.safetensors 4 MBlora-adapter/checkpoint-16/rng_state.pth 14.5 kBlora-adapter/checkpoint-33/rng_state.pth 14.5 kBlora-adapter/checkpoint-16/training_args.bin 6.5 kBlora-adapter/checkpoint-33/training_args.bin 6.5 kBlora-adapter/checkpoint-16/scheduler.pt 1.5 kBlora-adapter/checkpoint-33/scheduler.pt 1.5 kBQwen/Qwen2.5-0.5B