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
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 filesFiles changed (2)
- README.md+84-97
- model.safetensors+1-1
15 unmodified lines1617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787910 unmodified lines909192939495969798991001013 unmodified lines1051061071081091101111 unmodified line1131141151161171181191201211224 unmodified lines12712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816915 unmodified lines# 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) and a systemprompt listing the available tools, it decides whether one applies andextracts the arguments.This checkpoint (`sep18_round2`) replaces the earlier `gc_v2` checkpointand is a substantial redesign, not an incremental update — see**What changed** below. **Updated in place** — this repository tracks thecurrent best checkpoint; check back for updates.## What it does```System: You are a banking assistant for an Indian NBFC. Today's date is 2026-09-18 (Friday).Given the user's message, decide whether one of the tools below applies. If it does, call it:reply with a short natural-language line if appropriate, followed by a JSON object{"tool": "<name>", "arguments": {...}} on its own line. Only use arguments that are stated inthe conversation or can be computed from today's date -- never invent a value. If no toolapplies, reply in natural language only, or with {"tool": null} if a bare JSON response is expected.Available tools:{"name": "get_recent_transactions", "description": "Last N transactions", ...}{"name": "set_autopay", "description": "Enable/disable automatic EMI deduction", ...}...User: home loan ki abhi chinta mat karo -- bas recent transactions dikha do.Assistant: {"tool": "get_recent_transactions", "arguments": {}}```Unlike the previous checkpoint, **the tool schema is shown in the systemprompt every time** (JSON-Schema-style, one line per tool) — the model isschema-conditioned, not relying on having memorized a fixed 41-tool listfrom training alone. It also handles multi-turn slot-filling (asking aclarifying question when a required argument is missing) and is trainedto suppress hypothetical/past-tense/third-person framings.## What changed vs. the previous checkpoint (`gc_v2`)Deliberately narrowed scope for reliability: **5 tools + no-tool** (downfrom 41 — the full 41-tool schema alone is 3,359 tokens, more than thismodel's useful context budget can absorb well). Alongside the narrowing:| | Previous | This checkpoint ||---|---|---|| Prompt format | Bare `User:/Assistant:`, tools never shown | System prompt with tool schemas + reference date, shown every example || Argument values | Teacher free-generated utterance + values together | Canonical values generated first; teacher only rephrases around them || Negative examples | Single literal-string target `{"tool": null}` | Real natural-language replies, 6 distinct negative types || Train/test split | Row-level random | Stratified by template ID — tests unseen phrasing, not just unseen numbers || Training visibility | Single before/after loss number | Per-epoch train+val loss, best-checkpoint auto-save, automatic overfitting diagnosis |**50-test head-to-head result** (same 50 prompts, each model in its own native format):| Metric | Previous (41 tools) | This checkpoint (5 tools) ||---|---|---|| JSON validity | 98.0% | **100.0%** || Action-correct (call vs. no-call) | 68.0% | **86.0%** || Tool-correct | 85.7% | **91.4%** || Args-exact | 68.6% | **91.4%** |## Architecture10 unmodified lines## Usage**Tokenize each message segment separately and concatenate — do notre-tokenize a merged prompt string.** A real train/inference tokenizationmismatch was found and fixed earlier in this project (merging the stringbefore tokenizing can shift the last context token vs. what the modelwas actually trained on); the example below replicates the verified-correctconvention and was checked against a real training example before publishing:```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer3 unmodified linestokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")system_prompt = ("You are a banking assistant for an Indian NBFC. Today's date is 2026-09-18 (Friday).\n""Given the user's message, decide whether one of the tools below applies. If it does, ""call it: reply with a short natural-language line if appropriate, followed by a JSON ""object {\"tool\": \"<name>\", \"arguments\": {...}} on its own line. Only use arguments "1 unmodified line"a value. If no tool applies, reply in natural language only, or with {\"tool\": null} if ""a bare JSON response is expected.\n\n""Available tools:\n"'{"name": "get_recent_transactions", "description": "Last N transactions", ''"parameters": {"type": "object", "properties": {"count": {"type": "integer"}}, "required": []}}')user_utterance = "home loan ki abhi chinta mat karo -- bas recent transactions dikha do."segments = [f"System: {system_prompt}\n", f"User: {user_utterance}\n", "Assistant: "]ids = []4 unmodified linesout = model.generate(ids_t, 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_t.shape[1]:], skip_special_tokens=True))# -> {"tool": "get_recent_transactions", "arguments": {}}```## TrainingFull fine-tune (not LoRA) off the Hindi-English pretrained base. ~4,914examples (`kashyap/task-1/dataset.jsonl`) covering 5 tools + no-tool,balanced at ~16.7% each of 6 classes, split by template ID (not by row)so held-out examples test generalization to unseen phrasing. Canonicalargument values generated first (`entity_gen.py`), with the teacher modelonly rephrasing natural language around them — the teacher can neverinvent an argument value, which was a real failure mode in the previouscheckpoint.## Status and limitationsBeing upfront about what's actually verified vs. still open:- Verified via a same-prompt 50-example head-to-head against the previouscheckpoint (see table above) — not yet validated against a larger,independently-generated test set the way the previous checkpoint's200-scenario comparison was.- Narrowed to 5 tools deliberately; does not cover the other ~36 toolsthe previous (worse-performing) checkpoint attempted.- The system-prompt-with-schema format means correctness depends onthe exact tool-schema JSON given in-context matching trainingformatting closely — schemas very different in style from trainingare unverified.- Loss curves alone were actively misleading during this project's owndevelopment (a "good" loss looked wrong on real inference; arising-val-loss curve looked like overfitting but real testing showedthe later checkpoint was actually better) — always validate againstreal generated output, not the reported loss, before trusting acheckpoint.- **Any state-changing action should be confirmed before executing**,not trusted blindly from a single model output.- Conversion to this `Qwen3ForCausalLM` checkpoint was verifiednumerically (100% argmax agreement vs. the original training-formatcheckpoint on random inputs, plus a full save/reload round-trip, plusan independent check here against one real training example).15 unmodified lines1617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787910 unmodified lines9091929394959697983 unmodified lines1021031041051061071081 unmodified line1101111121131141151161171181191204 unmodified lines12512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615 unmodified lines# 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 and asystem prompt listing the available tools, it decides whether one appliesand extracts the arguments.This checkpoint (`sep19_round1`, end of epoch 1) replaces `sep18_round2`.**Updated in place** — this repository tracks the current best checkpoint;check back for updates.## What changed vs. `sep18_round2`Same 5-tool + no-tool scope, but a substantially larger and morecategorized training set: **15,894 examples** (14,196 train / 1,698 val),organized into 8 explicit buckets — 5 tools, `negative` (with 4sub-categories: chitchat, definitional, info, statement), `no_tool`, and a**`general_capability` bucket** (non-banking text: continuation,summarization, lists, creative writing) specifically to keep the modeluseful outside the banking domain and reduce over-firing a tool onunrelated prompts.**Early-stopped again, same lesson as before**: trained to epoch 1 (thischeckpoint), then epoch 2 showed the same overfitting signature alreadyseen in this project — val loss rose (1.5426 → 1.6514) while train losskept falling — so training was stopped before epoch 3. The publishedweights are the end-of-epoch-1 checkpoint, not a later one.## Verified accuracy — held-out 80-example eval, by categoryThis is the training team's own held-out evaluation (`eval_epoch1_results.json`,never trained on), broken down here rather than reported as one aggregatenumber:| Bucket | n | JSON valid | Action correct | Tool correct | Args exact ||---|---|---|---|---|---|| get_loan_balance | 8 | 100% | 100% | 100% | 100% || get_next_due_date | 8 | 100% | 100% | 100% | 100% || get_payment_status | 8 | 100% | 100% | 75% | 75% || get_recent_transactions | 8 | 100% | 100% | 100% | 100% || get_transaction_details | 8 | 100% | 100% | 100% | 100% || general_capability | 8 | 100% | 100% | — | — || negative_definitional | 8 | 100% | 100% | — | — || negative_info | 8 | 100% | 100% | — | — || **negative_chitchat** | 8 | 100% | **62.5%** | — | — || **negative_statement** | 8 | 100% | **0%** | — | — || **Overall** | **80** | **100%** | **86.2%** | **95.0%** (of 40 tool-target rows) | **95.0%** |**`negative_statement` is a real, systematic failure, not noise**: all 8examples in this bucket are past-tense/statement framings (e.g. "justchecking in about my home loan"), and the model fired the identical`get_loan_balance`/`get_payment_status`-style tool call on every singleone instead of giving a natural-language acknowledgment — the same"inconsistent negative-suppression for past-tense/third-person phrasing"limitation flagged on the previous checkpoint's card, now preciselyquantified rather than described qualitatively.Independently re-verified here (not just taking the training team'snumbers on faith): re-ran two real training examples (one `get_loan_balance`positive, one `negative_info`) through the converted HF checkpoint —both reproduced their exact target string.## Architecture10 unmodified lines## UsageTokenize each message segment separately and concatenate — do notre-tokenize a merged prompt string (a real train/inference tokenizationmismatch was found and fixed earlier in this project's history):```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer3 unmodified linestokenizer = AutoTokenizer.from_pretrained("somasekhar-dev/NextToken-model-2")system_prompt = ("You are a banking assistant for an Indian NBFC. Today's date is 2026-09-19 (Saturday).\n""Given the user's message, decide whether one of the tools below applies. If it does, ""call it: reply with a short natural-language line if appropriate, followed by a JSON ""object {\"tool\": \"<name>\", \"arguments\": {...}} on its own line. Only use arguments "1 unmodified line"a value. If no tool applies, reply in natural language only, or with {\"tool\": null} if ""a bare JSON response is expected.\n\n""Available tools:\n"'{"name": "get_loan_balance", "description": "Outstanding principal on a loan", ''"parameters": {"type": "object", "properties": {"loan_type": {"type": "string", ''"enum": ["home", "car", "personal", "gold", "business"]}}, "required": []}}')user_utterance = "मेरे लोन का कितना बकाया है, कृपया मुझे बताएं।"segments = [f"System: {system_prompt}\n", f"User: {user_utterance}\n", "Assistant: "]ids = []4 unmodified linesout = model.generate(ids_t, 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_t.shape[1]:], skip_special_tokens=True))# -> {"tool": "get_loan_balance", "arguments": {}}```## TrainingFull fine-tune (not LoRA), 15,894 examples (`kashyap/sep19/raw/*.jsonl`),8 buckets (5 tools, negative x4 sub-types, no_tool, general_capability),val loss 4.8757 -> 1.5426 by end of epoch 1. Stopped before epoch 3 ondetecting overfitting (see above).## Status and limitations- **`negative_statement` framing is unreliable — 0% on the held-out eval.**Do not rely on this checkpoint to correctly ignore past-tense/statementmentions of a loan or account; it is likely to fire a tool call anyway.- **`negative_chitchat` is inconsistent (62.5%)** — casual conversationalopeners sometimes still trigger a tool call.- Tool scope is deliberately narrow: 5 tools + no-tool. The full 41-toolschema (`model2_tools.json`) does not fit this model's 2048-tokencontext at all (3,359 tokens alone) — this is an architecturalconstraint, not just a training choice.- Free-text argument values and multi-turn slot-filling are not coveredby this round's eval — treat as unverified until tested.- **Any state-changing action should be confirmed before executing**,not trusted blindly from a single model output.- Conversion to this `Qwen3ForCausalLM` checkpoint was verifiednumerically (100% argmax agreement vs. the original training-formatcheckpoint on random inputs, a full save/reload round-trip, and tworeal training examples reproduced exactly).
123version https://git-lfs.github.com/spec/v1oid sha256:3ac1836c97c6d261128648e55f199cfb15848bd87937ee526e30a188ee27f0ebsize 1091141072123version https://git-lfs.github.com/spec/v1oid sha256:199c60dac8cbbae6d7edf451e205fc783817d95f7480bb67ff297d7db84e6333size 1091141072
README.md+84-97
model.safetensors+1-1