Instructions to use maaz-zaidi/transaction-classifier-minilm-en-ca with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use maaz-zaidi/transaction-classifier-minilm-en-ca with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="maaz-zaidi/transaction-classifier-minilm-en-ca")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("maaz-zaidi/transaction-classifier-minilm-en-ca") model = AutoModelForSequenceClassification.from_pretrained("maaz-zaidi/transaction-classifier-minilm-en-ca", device_map="auto") - sentence-transformers
How to use maaz-zaidi/transaction-classifier-minilm-en-ca with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("maaz-zaidi/transaction-classifier-minilm-en-ca") 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
Transaction Classifier — Enriched MiniLM (v7)
A fine-tuned sentence-transformers/all-MiniLM-L6-v2 model that classifies raw bank transaction strings into 10 budget categories. Trained on metadata-enriched transaction descriptions using merchant knowledge from the Foursquare OS Places dataset.
This is the 7th and current best iteration in a progressive model development series for real-world Canadian bank transaction classification.
Model Details
| Property | Value |
|---|---|
| Base model | sentence-transformers/all-MiniLM-L6-v2 (22M params) |
| Task | Multi-class text classification (10 categories) |
| Training samples | 55,750 (metadata-enriched) |
| Epochs | 2 |
| Batch size | 64 |
| Learning rate | 5e-6 |
| Max sequence length | 96 tokens |
| Format | SafeTensors |
| Trained | 2026-04-06 |
Categories
| ID | Category |
|---|---|
| 0 | Food & Dining |
| 1 | Transportation |
| 2 | Shopping & Retail |
| 3 | Entertainment & Recreation |
| 4 | Healthcare & Medical |
| 5 | Utilities & Services |
| 6 | Financial Services |
| 7 | Income |
| 8 | Government & Legal |
| 9 | Charity & Donations |
Performance
Evaluated on 505 unique real-world RBC (Royal Bank of Canada) transactions (3,113 weighted by occurrence frequency, spanning 2019-2026).
Overall
| Metric | Score |
|---|---|
| Real-world accuracy (weighted) | 83.6% |
| Real-world accuracy (unique) | 73.9% |
| ML-only accuracy | 77.1% |
| Validation accuracy | 93.0% |
Per-Category Accuracy
| Category | Accuracy |
|---|---|
| Income | 100.0% |
| Healthcare & Medical | 100.0% |
| Financial Services | 94.7% |
| Food & Dining | 89.3% |
| Entertainment & Recreation | 88.6% |
| Transportation | 83.3% |
| Shopping & Retail | 78.9% |
| Utilities & Services | 68.4% |
| Government & Legal | 54.5% |
| Charity & Donations | 0.0% |
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "maaz-zaidi/transaction-classifier-minilm-en-ca"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
categories = [
"Food & Dining", "Transportation", "Shopping & Retail",
"Entertainment & Recreation", "Healthcare & Medical",
"Utilities & Services", "Financial Services", "Income",
"Government & Legal", "Charity & Donations"
]
text = "MCDONALD'S #12345 TORONTO ON"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=96)
with torch.no_grad():
logits = model(**inputs).logits
predicted = torch.argmax(logits, dim=-1).item()
print(f"Category: {categories[predicted]}")
# Output: Category: Food & Dining
Training Data
- Primary: mitulshah/transaction-categorization - 3.6M synthetic transaction records (gated dataset)
- Enrichment: foursquare/fsq-os-places - merchant metadata (place types) used to enrich training descriptions
- Evaluation: 505 real-world RBC bank transactions (2019-2026), labeled via OpenAI Codex
Full Pipeline Context
This model is designed as the ML component of a multi-stage classification pipeline:
- Direction Detection (rules) - identifies credits vs debits (100% accuracy)
- Rules Engine - YAML-based pattern matching for structural patterns (92.3%)
- Merchant Knowledge Base - dense retrieval + cross-encoder reranking against 1.8M Canadian merchants (94.3%)
- ML Ensemble - this model (77.1% standalone, 83.6% with KB metadata enrichment)
The model performs best when transaction descriptions are enriched with merchant category metadata from the knowledge base before classification. Without enrichment, standalone accuracy is lower.
Full Report
A comprehensive PDF report covering the full research journey, architecture decisions, evaluation methodology, and results across all 7 phases is included in this repository: Transaction_Classifier_Report.pdf
What is Metadata Enrichment?
This model was trained on transaction strings enriched with merchant place-type metadata. During training, raw transaction text like "MCDONALD'S #12345" was augmented to "MCDONALD'S #12345 [restaurant, fast_food]" using category information from the Foursquare OS Places dataset. This teaches the model to leverage semantic merchant-type signals when available, while still functioning on raw text alone.
Model Evolution
This model is part of a 7-version development series. All versions are available in the Transaction Classifier collection.
| Version | Model | Real Accuracy | Key Change |
|---|---|---|---|
| v1 | SGD | 53.7% | TF-IDF baseline |
| v2 | FastText | 55.7% | Subword embeddings |
| v3 | SetFit | 80.5% | Contrastive learning |
| v4 | Fine-tuned MiniLM | 86.5% | Cross-entropy fine-tuning |
| v5 | Augmented MiniLM | - | Data augmentation (experiment) |
| v6 | CANINE | - | Character-level (experiment) |
| v7 | Enriched MiniLM (this model) | 83.6% | Metadata enrichment |
Note: v4 achieved 86.5% after preprocessing fixes specific to the evaluation pipeline (Phase 4b). The enriched model (v7) achieves the best ML-only accuracy at 77.1% and is the production model.
Limitations
- Charity & Donations: 0% accuracy - insufficient training examples
- Government & Legal: 54.5% - often confused with Financial Services
- Domain specificity: Trained on Canadian banking transaction formats; may not generalize to other regions
- Standalone vs pipeline: Best results require the full pipeline (knowledge base + rules); the model alone achieves 77.1%
- Training data gap: Trained on synthetic data, evaluated on real bank statements - domain shift is the primary challenge
Source Code
The full pipeline source code (rules engine, merchant knowledge base, retrieval, API) is available at: github.com/maaz-zaidi/transaction-classifier
Citation
@misc{zaidi2026txnclassifier,
title={Transaction Classifier: Multi-Stage Bank Transaction Categorization},
author={Maaz Zaidi},
year={2026},
url={https://huggingface.co/maaz-zaidi/transaction-classifier-minilm-en-ca}
}
- Downloads last month
- 59
Model tree for maaz-zaidi/transaction-classifier-minilm-en-ca
Base model
nreimers/MiniLM-L6-H384-uncasedDataset used to train maaz-zaidi/transaction-classifier-minilm-en-ca
Collection including maaz-zaidi/transaction-classifier-minilm-en-ca
Evaluation results
- Real-World Accuracy (Weighted)self-reported0.836
- ML-Only Accuracyself-reported0.771
- Validation Accuracyself-reported0.930