somasekhar-dev commited on
Commit
bef9487
·
verified ·
1 Parent(s): 66b9bb5

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
Files changed (2) hide show
  1. README.md +84 -97
  2. 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
- (English, Hindi, Hinglish, or Hindi-English code-mixed) and a system
21
- prompt listing the available tools, it decides whether one applies and
22
- extracts the arguments.
23
-
24
- This checkpoint (`sep18_round2`) replaces the earlier `gc_v2` checkpoint
25
- and is a substantial redesign, not an incremental update — see
26
- **What changed** below. **Updated in place** — this repository tracks the
27
- current best checkpoint; check back for updates.
28
-
29
- ## What it does
30
-
31
- ```
32
- System: You are a banking assistant for an Indian NBFC. Today's date is 2026-09-18 (Friday).
33
- Given the user's message, decide whether one of the tools below applies. If it does, call it:
34
- reply with a short natural-language line if appropriate, followed by a JSON object
35
- {"tool": "<name>", "arguments": {...}} on its own line. Only use arguments that are stated in
36
- the conversation or can be computed from today's date -- never invent a value. If no tool
37
- applies, reply in natural language only, or with {"tool": null} if a bare JSON response is expected.
38
-
39
- Available tools:
40
- {"name": "get_recent_transactions", "description": "Last N transactions", ...}
41
- {"name": "set_autopay", "description": "Enable/disable automatic EMI deduction", ...}
42
- ...
43
-
44
- User: home loan ki abhi chinta mat karo -- bas recent transactions dikha do.
45
- Assistant: {"tool": "get_recent_transactions", "arguments": {}}
46
- ```
47
-
48
- Unlike the previous checkpoint, **the tool schema is shown in the system
49
- prompt every time** (JSON-Schema-style, one line per tool) — the model is
50
- schema-conditioned, not relying on having memorized a fixed 41-tool list
51
- from training alone. It also handles multi-turn slot-filling (asking a
52
- clarifying question when a required argument is missing) and is trained
53
- to suppress hypothetical/past-tense/third-person framings.
54
-
55
- ## What changed vs. the previous checkpoint (`gc_v2`)
56
-
57
- Deliberately narrowed scope for reliability: **5 tools + no-tool** (down
58
- from 41 — the full 41-tool schema alone is 3,359 tokens, more than this
59
- model's useful context budget can absorb well). Alongside the narrowing:
60
-
61
- | | Previous | This checkpoint |
62
- |---|---|---|
63
- | Prompt format | Bare `User:/Assistant:`, tools never shown | System prompt with tool schemas + reference date, shown every example |
64
- | Argument values | Teacher free-generated utterance + values together | Canonical values generated first; teacher only rephrases around them |
65
- | Negative examples | Single literal-string target `{"tool": null}` | Real natural-language replies, 6 distinct negative types |
66
- | Train/test split | Row-level random | Stratified by template ID — tests unseen phrasing, not just unseen numbers |
67
- | Training visibility | Single before/after loss number | Per-epoch train+val loss, best-checkpoint auto-save, automatic overfitting diagnosis |
68
-
69
- **50-test head-to-head result** (same 50 prompts, each model in its own native format):
70
-
71
- | Metric | Previous (41 tools) | This checkpoint (5 tools) |
72
- |---|---|---|
73
- | JSON validity | 98.0% | **100.0%** |
74
- | Action-correct (call vs. no-call) | 68.0% | **86.0%** |
75
- | Tool-correct | 85.7% | **91.4%** |
76
- | Args-exact | 68.6% | **91.4%** |
77
 
78
  ## Architecture
79
 
@@ -90,12 +90,9 @@ Same base architecture as `somasekhar-dev/NextToken-model-1`:
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 (merging the string
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-18 (Friday).\n"
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": "get_recent_transactions", "description": "Last N transactions", '
117
- '"parameters": {"type": "object", "properties": {"count": {"type": "integer"}}, "required": []}}'
 
118
  )
119
- user_utterance = "home loan ki abhi chinta mat karo -- bas recent transactions dikha do."
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": "get_recent_transactions", "arguments": {}}
131
  ```
132
 
133
  ## Training
134
 
135
- Full fine-tune (not LoRA) off the Hindi-English pretrained base. ~4,914
136
- examples (`kashyap/task-1/dataset.jsonl`) covering 5 tools + no-tool,
137
- balanced at ~16.7% each of 6 classes, split by template ID (not by row)
138
- so held-out examples test generalization to unseen phrasing. Canonical
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
- Being upfront about what's actually verified vs. still open:
147
-
148
- - Verified via a same-prompt 50-example head-to-head against the previous
149
- checkpoint (see table above) — not yet validated against a larger,
150
- independently-generated test set the way the previous checkpoint's
151
- 200-scenario comparison was.
152
- - Narrowed to 5 tools deliberately; does not cover the other ~36 tools
153
- the previous (worse-performing) checkpoint attempted.
154
- - The system-prompt-with-schema format means correctness depends on
155
- the exact tool-schema JSON given in-context matching training
156
- formatting closely — schemas very different in style from training
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, plus a full save/reload round-trip, plus
169
- an independent check here against one real training example).
 
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:3ac1836c97c6d261128648e55f199cfb15848bd87937ee526e30a188ee27f0eb
3
  size 1091141072
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:199c60dac8cbbae6d7edf451e205fc783817d95f7480bb67ff297d7db84e6333
3
  size 1091141072