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
sep19_round1: 15,894-example dataset (8 buckets incl. general_capability), early-stopped end of epoch 1 -- 86.2% action-correct / 95% tool+args on held-out eval, negative_statement flagged as 0% (real weakness)
Browse files- README.md +84 -97
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -16,64 +16,64 @@ tags:
|
|
| 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 |
-
|
| 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 |
## Architecture
|
| 79 |
|
|
@@ -90,12 +90,9 @@ Same base architecture as `somasekhar-dev/NextToken-model-1`:
|
|
| 90 |
|
| 91 |
## Usage
|
| 92 |
|
| 93 |
-
|
| 94 |
-
re-tokenize a merged prompt string
|
| 95 |
-
mismatch was found and fixed earlier in this project
|
| 96 |
-
before tokenizing can shift the last context token vs. what the model
|
| 97 |
-
was actually trained on); the example below replicates the verified-correct
|
| 98 |
-
convention and was checked against a real training example before publishing:
|
| 99 |
|
| 100 |
```python
|
| 101 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -105,7 +102,7 @@ model = AutoModelForCausalLM.from_pretrained("somasekhar-dev/NextToken-model-2")
|
|
| 105 |
tokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")
|
| 106 |
|
| 107 |
system_prompt = (
|
| 108 |
-
"You are a banking assistant for an Indian NBFC. Today's date is 2026-09-
|
| 109 |
"Given the user's message, decide whether one of the tools below applies. If it does, "
|
| 110 |
"call it: reply with a short natural-language line if appropriate, followed by a JSON "
|
| 111 |
"object {\"tool\": \"<name>\", \"arguments\": {...}} on its own line. Only use arguments "
|
|
@@ -113,10 +110,11 @@ system_prompt = (
|
|
| 113 |
"a value. If no tool applies, reply in natural language only, or with {\"tool\": null} if "
|
| 114 |
"a bare JSON response is expected.\n\n"
|
| 115 |
"Available tools:\n"
|
| 116 |
-
'{"name": "
|
| 117 |
-
'"parameters": {"type": "object", "properties": {"
|
|
|
|
| 118 |
)
|
| 119 |
-
user_utterance = "
|
| 120 |
|
| 121 |
segments = [f"System: {system_prompt}\n", f"User: {user_utterance}\n", "Assistant: "]
|
| 122 |
ids = []
|
|
@@ -127,43 +125,32 @@ ids_t = torch.tensor([ids])
|
|
| 127 |
out = model.generate(ids_t, max_new_tokens=60, do_sample=False,
|
| 128 |
eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
|
| 129 |
print(tokenizer.decode(out[0][ids_t.shape[1]:], skip_special_tokens=True))
|
| 130 |
-
# -> {"tool": "
|
| 131 |
```
|
| 132 |
|
| 133 |
## Training
|
| 134 |
|
| 135 |
-
Full fine-tune (not LoRA)
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
argument values generated first (`entity_gen.py`), with the teacher model
|
| 140 |
-
only rephrasing natural language around them — the teacher can never
|
| 141 |
-
invent an argument value, which was a real failure mode in the previous
|
| 142 |
-
checkpoint.
|
| 143 |
|
| 144 |
## Status and limitations
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
are unverified.
|
| 158 |
-
- Loss curves alone were actively misleading during this project's own
|
| 159 |
-
development (a "good" loss looked wrong on real inference; a
|
| 160 |
-
rising-val-loss curve looked like overfitting but real testing showed
|
| 161 |
-
the later checkpoint was actually better) — always validate against
|
| 162 |
-
real generated output, not the reported loss, before trusting a
|
| 163 |
-
checkpoint.
|
| 164 |
- **Any state-changing action should be confirmed before executing**,
|
| 165 |
not trusted blindly from a single model output.
|
| 166 |
- Conversion to this `Qwen3ForCausalLM` checkpoint was verified
|
| 167 |
numerically (100% argmax agreement vs. the original training-format
|
| 168 |
-
checkpoint on random inputs,
|
| 169 |
-
|
|
|
|
| 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 and a
|
| 20 |
+
system prompt listing the available tools, it decides whether one applies
|
| 21 |
+
and extracts the arguments.
|
| 22 |
+
|
| 23 |
+
This checkpoint (`sep19_round1`, end of epoch 1) replaces `sep18_round2`.
|
| 24 |
+
**Updated in place** — this repository tracks the current best checkpoint;
|
| 25 |
+
check back for updates.
|
| 26 |
+
|
| 27 |
+
## What changed vs. `sep18_round2`
|
| 28 |
+
|
| 29 |
+
Same 5-tool + no-tool scope, but a substantially larger and more
|
| 30 |
+
categorized training set: **15,894 examples** (14,196 train / 1,698 val),
|
| 31 |
+
organized into 8 explicit buckets — 5 tools, `negative` (with 4
|
| 32 |
+
sub-categories: chitchat, definitional, info, statement), `no_tool`, and a
|
| 33 |
+
**`general_capability` bucket** (non-banking text: continuation,
|
| 34 |
+
summarization, lists, creative writing) specifically to keep the model
|
| 35 |
+
useful outside the banking domain and reduce over-firing a tool on
|
| 36 |
+
unrelated prompts.
|
| 37 |
+
|
| 38 |
+
**Early-stopped again, same lesson as before**: trained to epoch 1 (this
|
| 39 |
+
checkpoint), then epoch 2 showed the same overfitting signature already
|
| 40 |
+
seen in this project — val loss rose (1.5426 → 1.6514) while train loss
|
| 41 |
+
kept falling — so training was stopped before epoch 3. The published
|
| 42 |
+
weights are the end-of-epoch-1 checkpoint, not a later one.
|
| 43 |
+
|
| 44 |
+
## Verified accuracy — held-out 80-example eval, by category
|
| 45 |
+
|
| 46 |
+
This is the training team's own held-out evaluation (`eval_epoch1_results.json`,
|
| 47 |
+
never trained on), broken down here rather than reported as one aggregate
|
| 48 |
+
number:
|
| 49 |
+
|
| 50 |
+
| Bucket | n | JSON valid | Action correct | Tool correct | Args exact |
|
| 51 |
+
|---|---|---|---|---|---|
|
| 52 |
+
| get_loan_balance | 8 | 100% | 100% | 100% | 100% |
|
| 53 |
+
| get_next_due_date | 8 | 100% | 100% | 100% | 100% |
|
| 54 |
+
| get_payment_status | 8 | 100% | 100% | 75% | 75% |
|
| 55 |
+
| get_recent_transactions | 8 | 100% | 100% | 100% | 100% |
|
| 56 |
+
| get_transaction_details | 8 | 100% | 100% | 100% | 100% |
|
| 57 |
+
| general_capability | 8 | 100% | 100% | — | — |
|
| 58 |
+
| negative_definitional | 8 | 100% | 100% | — | — |
|
| 59 |
+
| negative_info | 8 | 100% | 100% | — | — |
|
| 60 |
+
| **negative_chitchat** | 8 | 100% | **62.5%** | — | — |
|
| 61 |
+
| **negative_statement** | 8 | 100% | **0%** | — | — |
|
| 62 |
+
| **Overall** | **80** | **100%** | **86.2%** | **95.0%** (of 40 tool-target rows) | **95.0%** |
|
| 63 |
+
|
| 64 |
+
**`negative_statement` is a real, systematic failure, not noise**: all 8
|
| 65 |
+
examples in this bucket are past-tense/statement framings (e.g. "just
|
| 66 |
+
checking in about my home loan"), and the model fired the identical
|
| 67 |
+
`get_loan_balance`/`get_payment_status`-style tool call on every single
|
| 68 |
+
one instead of giving a natural-language acknowledgment — the same
|
| 69 |
+
"inconsistent negative-suppression for past-tense/third-person phrasing"
|
| 70 |
+
limitation flagged on the previous checkpoint's card, now precisely
|
| 71 |
+
quantified rather than described qualitatively.
|
| 72 |
+
|
| 73 |
+
Independently re-verified here (not just taking the training team's
|
| 74 |
+
numbers on faith): re-ran two real training examples (one `get_loan_balance`
|
| 75 |
+
positive, one `negative_info`) through the converted HF checkpoint —
|
| 76 |
+
both reproduced their exact target string.
|
| 77 |
|
| 78 |
## Architecture
|
| 79 |
|
|
|
|
| 90 |
|
| 91 |
## Usage
|
| 92 |
|
| 93 |
+
Tokenize each message segment separately and concatenate — do not
|
| 94 |
+
re-tokenize a merged prompt string (a real train/inference tokenization
|
| 95 |
+
mismatch was found and fixed earlier in this project's history):
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
```python
|
| 98 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 102 |
tokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")
|
| 103 |
|
| 104 |
system_prompt = (
|
| 105 |
+
"You are a banking assistant for an Indian NBFC. Today's date is 2026-09-19 (Saturday).\n"
|
| 106 |
"Given the user's message, decide whether one of the tools below applies. If it does, "
|
| 107 |
"call it: reply with a short natural-language line if appropriate, followed by a JSON "
|
| 108 |
"object {\"tool\": \"<name>\", \"arguments\": {...}} on its own line. Only use arguments "
|
|
|
|
| 110 |
"a value. If no tool applies, reply in natural language only, or with {\"tool\": null} if "
|
| 111 |
"a bare JSON response is expected.\n\n"
|
| 112 |
"Available tools:\n"
|
| 113 |
+
'{"name": "get_loan_balance", "description": "Outstanding principal on a loan", '
|
| 114 |
+
'"parameters": {"type": "object", "properties": {"loan_type": {"type": "string", '
|
| 115 |
+
'"enum": ["home", "car", "personal", "gold", "business"]}}, "required": []}}'
|
| 116 |
)
|
| 117 |
+
user_utterance = "मेरे लोन का कितना बकाया है, कृपया मुझे बताएं।"
|
| 118 |
|
| 119 |
segments = [f"System: {system_prompt}\n", f"User: {user_utterance}\n", "Assistant: "]
|
| 120 |
ids = []
|
|
|
|
| 125 |
out = model.generate(ids_t, max_new_tokens=60, do_sample=False,
|
| 126 |
eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
|
| 127 |
print(tokenizer.decode(out[0][ids_t.shape[1]:], skip_special_tokens=True))
|
| 128 |
+
# -> {"tool": "get_loan_balance", "arguments": {}}
|
| 129 |
```
|
| 130 |
|
| 131 |
## Training
|
| 132 |
|
| 133 |
+
Full fine-tune (not LoRA), 15,894 examples (`kashyap/sep19/raw/*.jsonl`),
|
| 134 |
+
8 buckets (5 tools, negative x4 sub-types, no_tool, general_capability),
|
| 135 |
+
val loss 4.8757 -> 1.5426 by end of epoch 1. Stopped before epoch 3 on
|
| 136 |
+
detecting overfitting (see above).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
## Status and limitations
|
| 139 |
|
| 140 |
+
- **`negative_statement` framing is unreliable — 0% on the held-out eval.**
|
| 141 |
+
Do not rely on this checkpoint to correctly ignore past-tense/statement
|
| 142 |
+
mentions of a loan or account; it is likely to fire a tool call anyway.
|
| 143 |
+
- **`negative_chitchat` is inconsistent (62.5%)** — casual conversational
|
| 144 |
+
openers sometimes still trigger a tool call.
|
| 145 |
+
- Tool scope is deliberately narrow: 5 tools + no-tool. The full 41-tool
|
| 146 |
+
schema (`model2_tools.json`) does not fit this model's 2048-token
|
| 147 |
+
context at all (3,359 tokens alone) — this is an architectural
|
| 148 |
+
constraint, not just a training choice.
|
| 149 |
+
- Free-text argument values and multi-turn slot-filling are not covered
|
| 150 |
+
by this round's eval — treat as unverified until tested.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
- **Any state-changing action should be confirmed before executing**,
|
| 152 |
not trusted blindly from a single model output.
|
| 153 |
- Conversion to this `Qwen3ForCausalLM` checkpoint was verified
|
| 154 |
numerically (100% argmax agreement vs. the original training-format
|
| 155 |
+
checkpoint on random inputs, a full save/reload round-trip, and two
|
| 156 |
+
real training examples reproduced exactly).
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1091141072
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:199c60dac8cbbae6d7edf451e205fc783817d95f7480bb67ff297d7db84e6333
|
| 3 |
size 1091141072
|