Views
No views yet
| 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 accelerate1from peft import PeftModel
2from transformers import AutoModelForSequenceClassification, AutoTokenizer
3import torch
4
5# Load base model
6base_model = AutoModelForSequenceClassification.from_pretrained(
7 "google/gemma-3-270m-it",
8 num_labels=10,
9 torch_dtype=torch.bfloat16
10)
11
12# Load LoRA adapter
13model = PeftModel.from_pretrained(base_model, "finmigodeveloper/gemma-3-270m-transaction-lora")
14tokenizer = AutoTokenizer.from_pretrained("finmigodeveloper/gemma-3-270m-transaction-lora")
15
16# Define categories
17categories = [
18 'Charity & Donations', 'Entertainment & Recreation', 'Financial Services',
19 'Food & Dining', 'Government & Legal', 'Healthcare & Medical',
20 'Income', 'Shopping & Retail', 'Transportation', 'Utilities & Services'
21]
22id2label = {i: label for i, label in enumerate(categories)}
23
24# Classify a transaction
25def classify_transaction(transaction_text):
26 text = f"<start_of_turn>user\nClassify this transaction: {transaction_text}<end_of_turn>\n<start_of_turn>model\n"
27 inputs = tokenizer(text, return_tensors="pt")
28 outputs = model(**inputs)
29 pred = torch.argmax(outputs.logits, dim=-1).item()
30 return id2label[pred]
31
32# Examples
33print(classify_transaction("Starbucks coffee")) # Food & Dining
34print(classify_transaction("Uber ride")) # Transportation
35print(classify_transaction("Netflix subscription")) # Entertainment & Recreation1import requests
2
3API_URL = "https://api-inference.huggingface.co/models/finmigodeveloper/gemma-3-270m-transaction-lora"
4headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
5
6def classify_transaction_api(text):
7 payload = {"inputs": text}
8 response = requests.post(API_URL, headers=headers, json=payload)
9 return response.json()
10
11# Example
12result = classify_transaction_api("Starbucks coffee")
13print(result)| Epoch | Training Loss | Validation Accuracy |
|---|---|---|
| 1 | 0.0246 | 98.54% |
| 2 | 0.0217 | 98.45% |
| 3 | 0.0208 | 98.50% |
1@misc{gemma-3-270m-transaction-lora-2026,
2 author = {finmigodeveloper},
3 title = {Gemma-3 LoRA for Transaction Classification},
4 year = {2026},
5 publisher = {Hugging Face},
6 journal = {Hugging Face Hub},
7 howpublished = {\url{https://huggingface.co/finmigodeveloper/gemma-3-270m-transaction-lora}}
8}