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
| """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")) | |