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
sep18_round2: 5-tool schema-conditioned redesign, verified 50-test head-to-head (Action-correct 68%->86%, Args-exact 68.6%->91.4% vs previous checkpoint)
Browse filesFiles changed (2)
- README.md+109-70
- model.safetensors+1-1
16 unmodified lines171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061621 unmodified line64656667686970717273741 unmodified line76777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913016 unmodified linesA 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.## ArchitectureSame base architecture as `somasekhar-dev/NextToken-model-1`, pretrainedseparately on Hindi + English only, then fully fine-tuned (not LoRA) fortool-calling:| | ||---|---|1 unmodified line| 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 torch1 unmodified linemodel = 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.## TrainingFull 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 limitationsBeing upfront about what's actually verified vs. still weak, rather thanoverstating readiness:- **Negative-suppression is inconsistent** for past-tense ("I alreadyupdated 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 refusedreliably.- **Free-text argument values are unreliable** β e.g. asked to update anemail address, the model sometimes generates a plausible-looking butwrong value instead of copying the literal string from the utterance.- **General-capability handling is improved but not fully robust** β themodel used to fire a banking tool on any prompt at all (including"continue this story..."); that's now mostly fixed, but contentquality on genuinely non-banking prompts (general knowledge, open-endedwriting) 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 appliesregardless of the two points above, since no model this size will everbe perfectly reliable at intent-suppression for financial actions.- 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).16 unmodified lines171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182831 unmodified line8586878889909192939495969798991001011021 unmodified line10410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816916 unmodified linesA 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%** |## ArchitectureSame base architecture as `somasekhar-dev/NextToken-model-1`:| | ||---|---|1 unmodified line| Attention | GQA β 16 query heads, 4 KV heads || Normalization | RMSNorm + per-head QK-norm || FFN | SwiGLU || Context length | 2048 || Tokenizer | [`sarvamai/sarvam-1`](https://huggingface.co/sarvamai/sarvam-1), vocab 68,096 |## 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, AutoTokenizerimport torch1 unmodified linemodel = AutoModelForCausalLM.from_pretrained("somasekhar-dev/NextToken-model-2")tokenizer = 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 ""that are stated in the conversation or can be computed from today's date -- never invent ""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 = []for seg in segments:ids.extend(tokenizer.encode(seg, add_special_tokens=False))ids_t = torch.tensor([ids])out = 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).
123version https://git-lfs.github.com/spec/v1oid sha256:9a4a3dd177a032821882cabca340c2c174e102e442f0ac29605105b9103f76a9size 1091141072123version https://git-lfs.github.com/spec/v1oid sha256:3ac1836c97c6d261128648e55f199cfb15848bd87937ee526e30a188ee27f0ebsize 1091141072
README.md+109-70
model.safetensors+1-1