CoolFace
Modelpublic

maaz-zaidi/transaction-classifier-minilm-en-ca

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes39downloads
Model Card

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

PropertyValue
Base modelsentence-transformers/all-MiniLM-L6-v2 (22M params)
TaskMulti-class text classification (10 categories)
Training samples55,750 (metadata-enriched)
Epochs2
Batch size64
Learning rate5e-6
Max sequence length96 tokens
FormatSafeTensors
Trained2026-04-06

Categories

IDCategory
0Food & Dining
1Transportation
2Shopping & Retail
3Entertainment & Recreation
4Healthcare & Medical
5Utilities & Services
6Financial Services
7Income
8Government & Legal
9Charity & Donations

Performance

Evaluated on 505 unique real-world RBC (Royal Bank of Canada) transactions (3,113 weighted by occurrence frequency, spanning 2019-2026).

Overall

MetricScore
Real-world accuracy (weighted)83.6%
Real-world accuracy (unique)73.9%
ML-only accuracy77.1%
Validation accuracy93.0%

Per-Category Accuracy

CategoryAccuracy
Income100.0%
Healthcare & Medical100.0%
Financial Services94.7%
Food & Dining89.3%
Entertainment & Recreation88.6%
Transportation83.3%
Shopping & Retail78.9%
Utilities & Services68.4%
Government & Legal54.5%
Charity & Donations0.0%

Usage

python
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:

  1. 1.Direction Detection (rules) - identifies credits vs debits (100% accuracy)
  2. 2.Rules Engine - YAML-based pattern matching for structural patterns (92.3%)
  3. 3.Merchant Knowledge Base - dense retrieval + cross-encoder reranking against 1.8M Canadian merchants (94.3%)
  4. 4.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](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.

VersionModelReal AccuracyKey Change
v1SGD53.7%TF-IDF baseline
v2FastText55.7%Subword embeddings
v3SetFit80.5%Contrastive learning
v4Fine-tuned MiniLM86.5%Cross-entropy fine-tuning
v5Augmented MiniLM-Data augmentation (experiment)
v6CANINE-Character-level (experiment)
v7Enriched 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

bibtex
@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}
}