Text Generation
Transformers
Safetensors
Hindi
English
qwen3
indic
small-language-model
tool-calling
function-calling
banking
conversational
text-generation-inference
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 files
README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- hi
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- indic
|
| 9 |
+
- small-language-model
|
| 10 |
+
- qwen3
|
| 11 |
+
- tool-calling
|
| 12 |
+
- function-calling
|
| 13 |
+
- banking
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# NextToken-model-2 β SAM (Small Action Model)
|
| 17 |
+
|
| 18 |
+
A 272.7M-parameter Hindi-English model fine-tuned into a **small action
|
| 19 |
+
model** for banking/NBFC customer service: given a user utterance
|
| 20 |
+
(English, Hindi, Hinglish, or Hindi-English code-mixed), it decides which
|
| 21 |
+
of 41 predefined banking actions (if any) to invoke and extracts the
|
| 22 |
+
arguments β it does not try to be a general chatbot or answer open-domain
|
| 23 |
+
questions as its primary job.
|
| 24 |
+
|
| 25 |
+
This checkpoint (`gc_v2`) is the current best available candidate, not a
|
| 26 |
+
final version β see **Status and limitations** below. This repository
|
| 27 |
+
will be updated in place as the model improves; the link will stay the
|
| 28 |
+
same across updates.
|
| 29 |
+
|
| 30 |
+
## What it does
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
User: Mera outstanding loan amount kitna hai?
|
| 34 |
+
Assistant: {"tool": "get_loan_balance", "arguments": {"loan_type": "personal"}}
|
| 35 |
+
|
| 36 |
+
User: Block my card ending 7788, it was stolen
|
| 37 |
+
Assistant: {"tool": "block_card", "arguments": {"card_last4": "7788", "reason": "stolen"}}
|
| 38 |
+
|
| 39 |
+
User: What if I closed my personal loan early?
|
| 40 |
+
Assistant: {"tool": null}
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
It also handles **multi-turn slot-filling** (asking a clarifying question
|
| 44 |
+
when a required argument is missing, then resolving the tool call from
|
| 45 |
+
the follow-up answer) and is trained to **not** fire an action on
|
| 46 |
+
hypothetical, past-tense, or third-person framings of a request.
|
| 47 |
+
|
| 48 |
+
The tool schema (41 tools across 9 categories: account info, loans,
|
| 49 |
+
transactions, payments/EMI, profile/KYC, cards, disputes, service
|
| 50 |
+
requests, loan lifecycle) is not passed in-context β the model was
|
| 51 |
+
trained via supervised fine-tuning directly on `(utterance β tool call)`
|
| 52 |
+
pairs, not schema-conditioned generation. It does not need a system
|
| 53 |
+
prompt listing the tools.
|
| 54 |
+
|
| 55 |
+
## Architecture
|
| 56 |
+
|
| 57 |
+
Same base architecture as `somasekhar-dev/NextToken-model-1`, pretrained
|
| 58 |
+
separately on Hindi + English only, then fully fine-tuned (not LoRA) for
|
| 59 |
+
tool-calling:
|
| 60 |
+
|
| 61 |
+
| | |
|
| 62 |
+
|---|---|
|
| 63 |
+
| Parameters | 272.7M |
|
| 64 |
+
| Attention | GQA β 16 query heads, 4 KV heads |
|
| 65 |
+
| Normalization | RMSNorm + per-head QK-norm |
|
| 66 |
+
| FFN | SwiGLU |
|
| 67 |
+
| Context length | 2048 (training examples are short, well under this) |
|
| 68 |
+
| Tokenizer | [`sarvamai/sarvam-1`](https://huggingface.co/sarvamai/sarvam-1), vocab 68,096 |
|
| 69 |
+
|
| 70 |
+
## Usage
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 74 |
+
import torch
|
| 75 |
+
|
| 76 |
+
model = AutoModelForCausalLM.from_pretrained("somasekhar-dev/NextToken-model-2")
|
| 77 |
+
tokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")
|
| 78 |
+
|
| 79 |
+
prompt = "User: Mera outstanding loan amount kitna hai?\nAssistant: "
|
| 80 |
+
ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids
|
| 81 |
+
out = model.generate(ids, max_new_tokens=60, do_sample=False,
|
| 82 |
+
eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
|
| 83 |
+
print(tokenizer.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
**Prompt format matters for correctness**: examples were tokenized with
|
| 87 |
+
each `User:`/`Assistant:` segment encoded separately and concatenated
|
| 88 |
+
(not the merged string re-tokenized as one call) β a real train/inference
|
| 89 |
+
mismatch was found and fixed during development. Building the prompt as a
|
| 90 |
+
plain Python f-string and tokenizing it in one call (as in the example
|
| 91 |
+
above) works correctly for a fresh single-turn prompt; if you're
|
| 92 |
+
extending this into a real multi-turn application, replicate the
|
| 93 |
+
segment-wise tokenization convention rather than concatenating raw
|
| 94 |
+
strings across turns.
|
| 95 |
+
|
| 96 |
+
## Training
|
| 97 |
+
|
| 98 |
+
Full fine-tune (not LoRA) off a Hindi-English pretrained base, using
|
| 99 |
+
synthetically generated data (teacher model: a self-hosted Gemma-4-12B).
|
| 100 |
+
~8,600 training examples across banking tool-calling (positive, negative,
|
| 101 |
+
and multi-turn examples) plus a general-capability slice (~1,900
|
| 102 |
+
examples: continuation, QA, summarization, instruction-following) added
|
| 103 |
+
specifically to reduce a failure mode where the model tried to invoke a
|
| 104 |
+
banking tool on prompts unrelated to banking.
|
| 105 |
+
|
| 106 |
+
## Status and limitations
|
| 107 |
+
|
| 108 |
+
Being upfront about what's actually verified vs. still weak, rather than
|
| 109 |
+
overstating readiness:
|
| 110 |
+
|
| 111 |
+
- **Negative-suppression is inconsistent** for past-tense ("I already
|
| 112 |
+
updated my address...") and third-person ("can someone else...")
|
| 113 |
+
phrasings β sometimes correctly refuses to act, sometimes doesn't.
|
| 114 |
+
Hypothetical framings ("what if I closed my loan early") are refused
|
| 115 |
+
reliably.
|
| 116 |
+
- **Free-text argument values are unreliable** β e.g. asked to update an
|
| 117 |
+
email address, the model sometimes generates a plausible-looking but
|
| 118 |
+
wrong value instead of copying the literal string from the utterance.
|
| 119 |
+
- **General-capability handling is improved but not fully robust** β the
|
| 120 |
+
model used to fire a banking tool on any prompt at all (including
|
| 121 |
+
"continue this story..."); that's now mostly fixed, but content
|
| 122 |
+
quality on genuinely non-banking prompts (general knowledge, open-ended
|
| 123 |
+
writing) is still weak, and the fix isn't 100% reliable.
|
| 124 |
+
- **Any state-changing action should be confirmed before executing**,
|
| 125 |
+
not trusted blindly from a single model output β this applies
|
| 126 |
+
regardless of the two points above, since no model this size will ever
|
| 127 |
+
be perfectly reliable at intent-suppression for financial actions.
|
| 128 |
+
- Conversion to this `Qwen3ForCausalLM` checkpoint was verified
|
| 129 |
+
numerically (100% argmax agreement vs. the original training-format
|
| 130 |
+
checkpoint on random inputs, plus a full save/reload round-trip).
|