Text Generation
Transformers
Safetensors
Hindi
English
qwen3
indic
small-language-model
tool-calling
function-calling
banking
conversational
text-generation-inference
Run this model with HF Jobs
Run somasekhar-dev/NextToken-model-2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/somasekhar-dev/NextToken-model-2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/somasekhar-dev/NextToken-model-2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/somasekhar-dev/NextToken-model-2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/somasekhar-dev/NextToken-model-2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use somasekhar-dev/NextToken-model-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use somasekhar-dev/NextToken-model-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="somasekhar-dev/NextToken-model-2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2") model = AutoModelForCausalLM.from_pretrained("somasekhar-dev/NextToken-model-2", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use somasekhar-dev/NextToken-model-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "somasekhar-dev/NextToken-model-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "somasekhar-dev/NextToken-model-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/somasekhar-dev/NextToken-model-2
- SGLang
How to use somasekhar-dev/NextToken-model-2 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 "somasekhar-dev/NextToken-model-2" \ --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": "somasekhar-dev/NextToken-model-2", "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 "somasekhar-dev/NextToken-model-2" \ --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": "somasekhar-dev/NextToken-model-2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use somasekhar-dev/NextToken-model-2 with Docker Model Runner:
docker model run hf.co/somasekhar-dev/NextToken-model-2
Upload README.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130---language: - hi - enlibrary_name: transformerspipeline_tag: text-generationtags: - indic - small-language-model - qwen3 - tool-calling - function-calling - banking---
# NextToken-model-2 β SAM (Small Action Model)
A 272.7M-parameter Hindi-English model fine-tuned into a **small actionmodel** for banking/NBFC customer service: given a user utterance(English, Hindi, Hinglish, or Hindi-English code-mixed), it decides whichof 41 predefined banking actions (if any) to invoke and extracts thearguments β it does not try to be a general chatbot or answer open-domainquestions as its primary job.
This checkpoint (`gc_v2`) is the current best available candidate, not afinal version β see **Status and limitations** below. This repositorywill be updated in place as the model improves; the link will stay thesame across updates.
## What it does
```User: Mera outstanding loan amount kitna hai?Assistant: {"tool": "get_loan_balance", "arguments": {"loan_type": "personal"}}
User: Block my card ending 7788, it was stolenAssistant: {"tool": "block_card", "arguments": {"card_last4": "7788", "reason": "stolen"}}
User: What if I closed my personal loan early?Assistant: {"tool": null}```
It also handles **multi-turn slot-filling** (asking a clarifying questionwhen a required argument is missing, then resolving the tool call fromthe follow-up answer) and is trained to **not** fire an action onhypothetical, past-tense, or third-person framings of a request.
The tool schema (41 tools across 9 categories: account info, loans,transactions, payments/EMI, profile/KYC, cards, disputes, servicerequests, loan lifecycle) is not passed in-context β the model wastrained via supervised fine-tuning directly on `(utterance β tool call)`pairs, not schema-conditioned generation. It does not need a systemprompt listing the tools.
## Architecture
Same base architecture as `somasekhar-dev/NextToken-model-1`, pretrainedseparately on Hindi + English only, then fully fine-tuned (not LoRA) fortool-calling:
| | ||---|---|| Parameters | 272.7M || Attention | GQA β 16 query heads, 4 KV heads || Normalization | RMSNorm + per-head QK-norm || FFN | SwiGLU || Context length | 2048 (training examples are short, well under this) || Tokenizer | [`sarvamai/sarvam-1`](https://huggingface.co/sarvamai/sarvam-1), vocab 68,096 |
## Usage
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch
model = AutoModelForCausalLM.from_pretrained("somasekhar-dev/NextToken-model-2")tokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")
prompt = "User: Mera outstanding loan amount kitna hai?\nAssistant: "ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_idsout = model.generate(ids, max_new_tokens=60, do_sample=False, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)print(tokenizer.decode(out[0, ids.shape[1]:], skip_special_tokens=True))```
**Prompt format matters for correctness**: examples were tokenized witheach `User:`/`Assistant:` segment encoded separately and concatenated(not the merged string re-tokenized as one call) β a real train/inferencemismatch was found and fixed during development. Building the prompt as aplain Python f-string and tokenizing it in one call (as in the exampleabove) works correctly for a fresh single-turn prompt; if you'reextending this into a real multi-turn application, replicate thesegment-wise tokenization convention rather than concatenating rawstrings across turns.
## Training
Full fine-tune (not LoRA) off a Hindi-English pretrained base, usingsynthetically generated data (teacher model: a self-hosted Gemma-4-12B).~8,600 training examples across banking tool-calling (positive, negative,and multi-turn examples) plus a general-capability slice (~1,900examples: continuation, QA, summarization, instruction-following) addedspecifically to reduce a failure mode where the model tried to invoke abanking tool on prompts unrelated to banking.
## Status and limitations
Being upfront about what's actually verified vs. still weak, rather thanoverstating readiness:
- **Negative-suppression is inconsistent** for past-tense ("I already updated my address...") and third-person ("can someone else...") phrasings β sometimes correctly refuses to act, sometimes doesn't. Hypothetical framings ("what if I closed my loan early") are refused reliably.- **Free-text argument values are unreliable** β e.g. asked to update an email address, the model sometimes generates a plausible-looking but wrong value instead of copying the literal string from the utterance.- **General-capability handling is improved but not fully robust** β the model used to fire a banking tool on any prompt at all (including "continue this story..."); that's now mostly fixed, but content quality on genuinely non-banking prompts (general knowledge, open-ended writing) is still weak, and the fix isn't 100% reliable.- **Any state-changing action should be confirmed before executing**, not trusted blindly from a single model output β this applies regardless of the two points above, since no model this size will ever be perfectly reliable at intent-suppression for financial actions.- Conversion to this `Qwen3ForCausalLM` checkpoint was verified numerically (100% argmax agreement vs. the original training-format checkpoint on random inputs, plus a full save/reload round-trip).README.mdAdded+130