mitulshah/transaction-categorization
Viewer โข Updated โข 4.5M โข 188 โข 11
How to use finmigodeveloper/gemma-3-270m-transaction-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification
base_model = AutoModelForSequenceClassification.from_pretrained("google/gemma-3-270m-it")
model = PeftModel.from_pretrained(base_model, "finmigodeveloper/gemma-3-270m-transaction-lora")This is a LoRA adapter for google/gemma-3-270m-it fine-tuned on transaction categorization. It classifies financial transactions into 10 categories with 98.54% accuracy.
| Category | Accuracy |
|---|---|
| Charity & Donations | 100.00% |
| Entertainment & Recreation | 100.00% |
| Financial Services | 100.00% |
| Food & Dining | 98.45% |
| Government & Legal | 97.40% |
| Healthcare & Medical | 97.90% |
| Income | 99.90% |
| Shopping & Retail | 93.35% |
| Transportation | 99.25% |
| Utilities & Services | 98.80% |
| Overall | 98.54% |
pip install torch transformers peft accelerate
from peft import PeftModel
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load base model
base_model = AutoModelForSequenceClassification.from_pretrained(
"google/gemma-3-270m-it",
num_labels=10,
torch_dtype=torch.bfloat16
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "finmigodeveloper/gemma-3-270m-transaction-lora")
tokenizer = AutoTokenizer.from_pretrained("finmigodeveloper/gemma-3-270m-transaction-lora")
# Define categories
categories = [
'Charity & Donations', 'Entertainment & Recreation', 'Financial Services',
'Food & Dining', 'Government & Legal', 'Healthcare & Medical',
'Income', 'Shopping & Retail', 'Transportation', 'Utilities & Services'
]
id2label = {i: label for i, label in enumerate(categories)}
# Classify a transaction
def classify_transaction(transaction_text):
text = f"<start_of_turn>user\nClassify this transaction: {transaction_text}<end_of_turn>\n<start_of_turn>model\n"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
pred = torch.argmax(outputs.logits, dim=-1).item()
return id2label[pred]
# Examples
print(classify_transaction("Starbucks coffee")) # Food & Dining
print(classify_transaction("Uber ride")) # Transportation
print(classify_transaction("Netflix subscription")) # Entertainment & Recreation
import requests
API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Ffinmigodeveloper%2Fgemma-3-270m-transaction-lora"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
def classify_transaction_api(text):
payload = {"inputs": text}
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# Example
result = classify_transaction_api("Starbucks coffee")
print(result)
Try the live demo on Hugging Face Spaces! (Create a Space first)
| Epoch | Training Loss | Validation Accuracy |
|---|---|---|
| 1 | 0.0246 | 98.54% |
| 2 | 0.0217 | 98.45% |
| 3 | 0.0208 | 98.50% |
If you use this model, please cite:
@misc{gemma-3-270m-transaction-lora-2026,
author = {finmigodeveloper},
title = {Gemma-3 LoRA for Transaction Classification},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/finmigodeveloper/gemma-3-270m-transaction-lora}}
}
This model is licensed under the Gemma license. See the original model page for details.
Feel free to open issues or PRs if you have suggestions for improvements!