Text Generation
Transformers
Safetensors
English
qwen2
finance
banking
indian
upi
transaction-classification
qwen
fine-tuned
conversational
text-generation-inference
Instructions to use SahilGoel/indian-txn-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SahilGoel/indian-txn-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SahilGoel/indian-txn-classifier") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SahilGoel/indian-txn-classifier") model = AutoModelForCausalLM.from_pretrained("SahilGoel/indian-txn-classifier", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SahilGoel/indian-txn-classifier with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SahilGoel/indian-txn-classifier" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SahilGoel/indian-txn-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SahilGoel/indian-txn-classifier
- SGLang
How to use SahilGoel/indian-txn-classifier with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "SahilGoel/indian-txn-classifier" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SahilGoel/indian-txn-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "SahilGoel/indian-txn-classifier" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SahilGoel/indian-txn-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use SahilGoel/indian-txn-classifier with Docker Model Runner:
docker model run hf.co/SahilGoel/indian-txn-classifier
File size: 3,064 Bytes
19cd60d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | """Conservative company-name labels for transaction model training."""
from __future__ import annotations
import re
from typing import Optional
from pipeline.merchant_classifier import (
CURATED_TRANSACTION_MARKERS,
HANDLE_CATEGORY_MAP,
MERCHANT_ALIASES,
classify_upi_merchant,
extract_upi_handle,
get_merchant,
)
_PERSONAL_CATEGORIES = {
"personal_transfer",
"friends",
"family",
"staff_salary",
"rental",
"transfer",
"cash_withdrawal",
}
_GENERIC_NAMES = {
"",
"unknown upi counterparty",
"upi transfer",
"payment",
"transfer",
"unknown",
}
def _name_key(value: object) -> str:
return " ".join(re.sub(r"[^a-z0-9]+", " ", str(value or "").lower()).split())
_CANONICAL_COMPANIES = {
_name_key(company[0]): company[0]
for company in (
*MERCHANT_ALIASES.values(),
*CURATED_TRANSACTION_MARKERS.values(),
*HANDLE_CATEGORY_MAP.values(),
)
}
_CANONICAL_ALIASES = {
"indian cle": "Indian Clearing Corporation",
"iccl zerodha credit": "Indian Clearing Corporation",
"iccl zerod": "Indian Clearing Corporation",
"zerodha br": "Zerodha",
"zerodha deposit": "Zerodha",
}
def _clean_company_name(value: object) -> Optional[str]:
name = " ".join(str(value or "").split()).strip(" -/|")[:100]
if name.lower() in _GENERIC_NAMES:
return None
return name or None
def _canonical_company_name(value: object) -> Optional[str]:
cleaned = _clean_company_name(value)
if not cleaned:
return None
key = _name_key(cleaned)
if key.startswith("cred ") or key == "cred":
return "CRED"
return _CANONICAL_ALIASES.get(key) or _CANONICAL_COMPANIES.get(key)
def infer_company_name(
description: str,
*,
category: str = "",
explicit_name: object = None,
) -> Optional[str]:
"""Return a company only when merchant evidence is strong enough to label."""
if category in _PERSONAL_CATEGORIES:
return None
explicit = _canonical_company_name(explicit_name)
if explicit:
return explicit
handle = extract_upi_handle(description or "")
if handle:
try:
merchant = get_merchant(handle)
except Exception:
merchant = None
if (
merchant
and merchant.get("category") not in _PERSONAL_CATEGORIES | {"unclassified", "upi_spend"}
and float(merchant.get("confidence", 0.0)) >= 0.70
):
company = _canonical_company_name(merchant.get("display_name"))
if company:
return company
try:
evidence_description = "" if handle else (description or "")
inferred = classify_upi_merchant(handle or "", evidence_description, learn=False)
except Exception:
return None
if (
inferred.get("category") in _PERSONAL_CATEGORIES | {"unclassified"}
or float(inferred.get("confidence", 0.0)) < 0.70
):
return None
return _canonical_company_name(inferred.get("display_name"))
|