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
| """ | |
| pii_shield.py — Lightweight PII Masking | |
| ======================================= | |
| Masks sensitive data before logging or sending to external services. | |
| Pure regex, zero dependencies — works in 512MB environments. | |
| Detects & masks: | |
| - PAN numbers (ABCDE1234F pattern) | |
| - Aadhaar numbers (12 digits) | |
| - Bank account numbers (9-18 digits near keywords) | |
| - IFSC codes | |
| - Mobile numbers | |
| - Email addresses | |
| """ | |
| import re | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| PII_PATTERNS = [ | |
| { | |
| "name": "PAN", | |
| "pattern": r'\b([A-Z]{5}\d{4}[A-Z])\b', | |
| "mask": "XXXXX0000X", | |
| }, | |
| { | |
| "name": "Aadhaar", | |
| "pattern": r'\b(\d{4}[\s\-]?\d{4}[\s\-]?\d{4})\b', | |
| "mask": "XXXX-XXXX-XXXX", | |
| }, | |
| { | |
| "name": "Mobile", | |
| "pattern": r'(?:\+91[\s\-]?)?\b([6-9]\d{9})\b', | |
| "mask": "XXXXXXXXXX", | |
| }, | |
| { | |
| "name": "Email", | |
| "pattern": r'\b([a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,})\b', | |
| "mask": "***@***.***", | |
| }, | |
| { | |
| "name": "IFSC", | |
| "pattern": r'\b([A-Z]{4}0[A-Z0-9]{6})\b', | |
| "mask": "XXXX0XXXXXX", | |
| }, | |
| { | |
| "name": "BankAccount", | |
| "pattern": r'(?:account[\s\-:]*(?:no|number|num)?[\s\-:]*)\b(\d{9,18})\b', | |
| "mask": "XXXXXXXXXX", | |
| "case_insensitive": True, | |
| }, | |
| ] | |
| def mask_pii(text: str) -> str: | |
| """Mask all PII patterns in the given text. Returns sanitized text.""" | |
| masked = text | |
| for p in PII_PATTERNS: | |
| flags = re.IGNORECASE if p.get("case_insensitive") else 0 | |
| pattern = p["pattern"] | |
| mask = p["mask"] | |
| count = 0 | |
| def replace(m): | |
| nonlocal count | |
| count += 1 | |
| return mask | |
| masked = re.sub(pattern, replace, masked, flags=flags) | |
| if count > 0: | |
| logger.debug(f"PII Shield: masked {count} {p['name']}(s)") | |
| return masked | |
| def has_pii(text: str) -> bool: | |
| """Check if text contains any PII. Returns True if sensitive data detected.""" | |
| for p in PII_PATTERNS: | |
| flags = re.IGNORECASE if p.get("case_insensitive") else 0 | |
| if re.search(p["pattern"], text, flags): | |
| return True | |
| return False | |
| def shield_transaction(description: str) -> str: | |
| """Shield a single transaction description — masks PAN/Aadhaar but preserves merchant info.""" | |
| # Only mask PAN and Aadhaar — keep bank account numbers visible for classification | |
| for pattern_name in ["PAN", "Aadhaar"]: | |
| for p in PII_PATTERNS: | |
| if p["name"] == pattern_name: | |
| description = re.sub(p["pattern"], p["mask"], description) | |
| return description | |