bjo4 commited on
Commit
d439cb4
·
verified ·
1 Parent(s): cec8a1e

Upload Phase 2 Closed-Book (CEEC + Formosa 70.77%) LoRA adapter

Browse files
phase2_closed_book_lora/README.md ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ license: apache-2.0
5
+ base_model: thinkingmachines/Inkling-2-Mini
6
+ library_name: peft
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - taiwan
10
+ - traditional-chinese
11
+ - zh-tw
12
+ - sovereign-ai
13
+ - moe
14
+ - sft
15
+ - dpo
16
+ - rlvr
17
+ - grpo
18
+ - raft
19
+ - chain-of-thought
20
+ - model-soup
21
+ - opentwbench
22
+ - tmmluplus
23
+ - taiwan-law
24
+ - ceec
25
+ datasets:
26
+ - ikala/tmmluplus
27
+ - yiting/tw-instruct-500k
28
+ - lianghsun/tw-legal-chat
29
+ - lianghsun/tw-legal-benchmark-v1
30
+ - OpenTWBench/tw-exam-bench
31
+ - OpenTWBench/tw-formosa-bench
32
+ model-index:
33
+ - name: Inkling-2-Mini-TW-Sovereign
34
+ results:
35
+ - task:
36
+ type: text-generation
37
+ name: Taiwan Sovereign 1058-Question Hold-Out Benchmark
38
+ dataset:
39
+ name: Combined Hold-Out (Formosa-bench + tw-legal-v1 + TMMLU+ + CEEC-300)
40
+ type: custom
41
+ metrics:
42
+ - type: accuracy
43
+ value: 68.53
44
+ name: Overall Accuracy (Phase 3 Model Soup + CoT + RAFT)
45
+ - type: accuracy
46
+ value: 69.66
47
+ name: Overall Accuracy (Adaptive RAG Routing)
48
+ - task:
49
+ type: text-generation
50
+ name: Formosa-bench (Taiwan Everyday & Civic Knowledge)
51
+ dataset:
52
+ name: OpenTWBench/tw-formosa-bench
53
+ type: OpenTWBench/tw-formosa-bench
54
+ metrics:
55
+ - type: accuracy
56
+ value: 70.77
57
+ name: Accuracy (Phase 2 Closed-Book)
58
+ - type: accuracy
59
+ value: 68.48
60
+ name: Accuracy (Phase 3 CoT + RAFT)
61
+ - task:
62
+ type: text-generation
63
+ name: Taiwan Statutory & Bar Exam Benchmark
64
+ dataset:
65
+ name: lianghsun/tw-legal-benchmark-v1
66
+ type: lianghsun/tw-legal-benchmark-v1
67
+ metrics:
68
+ - type: accuracy
69
+ value: 61.24
70
+ name: Accuracy (+32.53% over base model)
71
+ - task:
72
+ type: text-generation
73
+ name: TMMLU+ Taiwan National Examinations
74
+ dataset:
75
+ name: ikala/tmmluplus
76
+ type: ikala/tmmluplus
77
+ metrics:
78
+ - type: accuracy
79
+ value: 65.50
80
+ name: Accuracy (+12.50% over base model)
81
+ - task:
82
+ type: text-generation
83
+ name: Taiwan CEEC University Entrance Exams (GSAT & AST 民國73-115年)
84
+ dataset:
85
+ name: CEEC-Bench-300
86
+ type: custom
87
+ metrics:
88
+ - type: accuracy
89
+ value: 76.00
90
+ name: Accuracy (AST Subject Test 90.00%)
91
+ ---
92
+
93
+ # 🇹🇼 Inkling-2-Mini-TW-Sovereign
94
+
95
+ **Inkling-2-Mini-TW-Sovereign** 是以 [`thinkingmachines/Inkling-2-Mini`](https://huggingface.co/thinkingmachines/Inkling-2-Mini)(10B Total Parameters / ~2B Active Parameters, Sparse Mixture-of-Experts 架構)為基底,專為**台灣繁體中文(zh-TW)語境、中華民國五院憲政與六法體系、台灣國家考試(高普考/專技高考)以及大學入學測驗(學測/指考/分科測驗)**打造之輕量級台灣主權語言模型。
96
+
97
+ 本模型於 **GPUtw 台灣自有機房(NVIDIA RTX 5090 32GB)** 完成三階段演進微調:
98
+ 1. **Phase 1(方案 A:台灣主權黃金配比)**:串聯 `Response-Only SFT`(19 組台灣核心開源語料)$\rightarrow$ `DPO`(正簡體與兩岸詞彙偏好對齊,100% 台灣慣用語偏好率、0% 簡體字洩漏)$\rightarrow$ `RLVR / GRPO`(可驗證獎勵之群組相對策略優化)。
99
+ 2. **Phase 2(大考中心歷屆試題與專科弱項精煉)**:注入民國 73–115 學年度大考中心歷屆學測(GSAT)、指考(AST)與分科測驗共 **5,769 題官方試題與詳解**,以及台灣專技高考(專利師、會計師審計、稅法)與教育部台語文語料。
100
+ 3. **Phase 3(Model Soup 權重插值 + 單通雙軌 CoT 思維鏈 + RAFT 檢索增強微調)**:先以線性插值($\theta_{\text{soup}} = 0.65\theta_{\text{P2}} + 0.35\theta_{\text{P1}}$)融合前兩階段之 LoRA 權重,再結合 **21,729 條台灣法規與考科知識庫(BM25 Index)** 執行 **RAFT(70% 含黃金條文 + 30% 純干擾項抗噪訓練)** 與 `<|content_thinking|>` 結構化思維鏈微調。
101
+
102
+ ---
103
+
104
+ ## 📊 核心評測結果(1,058 題 100% 物理隔離 Hold-Out 基準測試)
105
+
106
+ | 評測基準集 (Benchmark) | 題數 | 原始 `Inkling-2-Mini` | Phase 1 (SFT+DPO+RLVR) | Phase 2 (閉卷 + 大考中心) | **Phase 3 (Model Soup + CoT + RAFT)** | 累計淨提升 ($\Delta$) |
107
+ | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
108
+ | **`Formosa-bench`** (台灣日常/地理/政府/歷史/社會) | 349 | `56.73%` | `67.34%` | **`70.77%`** | `68.48%` | **`+11.75% ~ +14.04%`** |
109
+ | **`tw-legal-benchmark-v1`** (中華民國六法與司法實務) | 209 | `28.71%` | `44.50%` | `49.76%` | **`61.24%`** | **`🔥 +32.53% (2.13x)`** |
110
+ | **`TMMLU+ Test Split`** (台灣 66 科國家考試基準) | 200 | `53.00%` | `61.50%` | `63.50%` | **`65.50%`** | **`+12.50%`** |
111
+ | **`CEEC-Bench-300`** (歷屆大學學測/指考/分科測驗) | 300 | `63.00%` | `73.00%` | **`76.00%`** | `75.67%` | **`+12.67% ~ +13.00%`** |
112
+ | **🏆 1,058 題綜合總準確率 (Overall)** | **1,058** | **`52.27%`** | **`62.57%`** | **`66.73%`** | **`68.53%`** *(動態路由 `69.66%`)* | **`🚀 +16.26% (+172 題)`** |
113
+
114
+ ### 🏆 在 `OpenTWBench` 官方排行榜(110 個模型)之對位���現
115
+ - **總榜排名**:由未微調前之 **第 `#58 ~ #63 名`** 大幅躍升至 **第 `#37 ~ #39 名` / 111**(前進 `+21 ~ +24 名`),超越 `Qwen3-30B-A3B (66.75%)`、`NVIDIA-Nemotron-3-Super-120B-A12B (65.17%)`、`gpt-oss-120b (64.46%)`、`QwQ-32B (63.42%)`、`Llama-3.3-70B-Instruct (56.80%)`。
116
+ - **同量級(`≤ 14B`)排名**:於全榜所有 14B 以下輕量級模型中位居 **第 `#1 名`**(領先原第一名 `#44 Ornith-1.5-9B 60.79%` 達 `+5.12% ~ +7.74%`)。
117
+ - **`tw-formosa-bench`(台灣生活常識單項分榜)**:以 **`70.77%` 高居全榜第 `#27 名`**,超越 `MiniMax-M2.5 (70.52%)`、`GLM-4.7 (69.28%)`、`DeepSeek-V3.2 (68.40%)`、`Qwen2.5-72B-Instruct (66.98%)`。
118
+
119
+ ---
120
+
121
+ ## 🚀 快速開始(Quickstart Usage)
122
+
123
+ ### 1. 載入基底模型與 LoRA 權重
124
+
125
+ ```python
126
+ import torch
127
+ from transformers import AutoModelForCausalLM, AutoTokenizer
128
+ from peft import PeftModel
129
+
130
+ BASE_MODEL = "thinkingmachines/Inkling-2-Mini"
131
+ LORA_ADAPTER = "bjo4/Inkling-2-Mini-TW-Sovereign" # 預設載入 Phase 3 (Model Soup + CoT + RAFT) 主權重;亦可指定 subfolder="phase2_closed_book_lora"
132
+
133
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
134
+ base_model = AutoModelForCausalLM.from_pretrained(
135
+ BASE_MODEL,
136
+ torch_dtype=torch.bfloat16,
137
+ device_map="auto",
138
+ trust_remote_code=True,
139
+ )
140
+ model = PeftModel.from_pretrained(base_model, LORA_ADAPTER)
141
+ model.eval()
142
+ ```
143
+
144
+ ### 2. 使用雙通道思維鏈(`<|content_thinking|>`)與 RAFT 法條檢索推論
145
+
146
+ ```python
147
+ system_prompt = (
148
+ "你是台灣主權 AI 專家助手,精通中華民國(台灣)五院憲政體制、六法全書、高普考與專技高考學科、"
149
+ "大考中心學測與分科測驗各科知識及台灣在地文化。"
150
+ "請先在思考區塊中進行考點識別、法條比對與選項消去法,再輸出繁體中文詳解與『最終答案:X』。"
151
+ )
152
+
153
+ user_question = """[檢索參考資料]
154
+ - [法規知識 #1] 依中華民國《民法》第 12 條規定(民國 110 年修正,112 年 1 月 1 日施行):「滿十八歲為成年。」
155
+ - [法規知識 #2] 《民法》第 13 條:「未滿七歲之未成年人,無行為能力。滿七歲以上之未成年人,有限制行為能力。」
156
+
157
+ 問題:依現行中華民國《民法》規定,幾歲為成年,具備完全行為能力?
158
+ (A) 滿 16 歲
159
+ (B) 滿 18 歲
160
+ (C) 滿 20 歲
161
+ (D) 滿 21 歲"""
162
+
163
+ messages = [
164
+ {"role": "system", "content": system_prompt},
165
+ {"role": "user", "content": user_question},
166
+ ]
167
+
168
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
169
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
170
+
171
+ with torch.no_grad():
172
+ outputs = model.generate(
173
+ **inputs,
174
+ max_new_tokens=256,
175
+ do_sample=False,
176
+ pad_token_id=tokenizer.eos_token_id,
177
+ )
178
+
179
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
180
+ print(response)
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 📦 儲存庫結構(Repository Contents)
186
+
187
+ 本儲存庫提供三個階段之最佳 LoRA 權重與台灣主權法規知識庫,方便依場景自由掛載:
188
+ - `phase3_cot_raft_final_lora/` *(預設主目錄)*:**Phase 3 終極版權重(Model Soup + CoT + RAFT)**,適合搭配法規/企業知識庫檢索(RAG)與高難度國考解題(1,058 題總分 **`68.53%`**、台灣法規 **`61.24%`**、TMMLU+ **`65.50%`**)。
189
+ - `phase2_closed_book_lora/`:**Phase 2 閉卷最佳權重**,適合無外部檢索器之純直覺對話、台灣文化常識與台語文問答(`Formosa-bench` **`70.77%`**、大考中心 `CEEC-300` **`76.00%`**、台語文 **`100.0%`**)。
190
+ - `phase3_model_soup_lora/`:**Model Soup 融合基底權重($0.65 \times \text{Phase 2} + 0.35 \times \text{Phase 1}$)**。
191
+ - `raft_index/taiwan_sovereign_kb.jsonl`(選配):**21,729 條台灣法規與考科知識切片**,可直接載入 `rank_bm25` 進行毫秒級本地檢索。
192
+
193
+ ---
194
+
195
+ ## 📝 引用格式(Citation)
196
+
197
+ ```bibtex
198
+ @techreport{inkling2_mini_tw_sovereign_2026,
199
+ title={Inkling-2-Mini-TW-Sovereign: Multi-Stage Post-Training Alignment, Model Soup Adapter Interpolation, and Retrieval-Augmented Chain-of-Thought for a Lightweight Taiwan Sovereign Language Model},
200
+ author={Warren},
201
+ year={2026},
202
+ month={November},
203
+ institution={Trained on GPUtw Taiwan Self-Owned RTX 5090 Data Center},
204
+ note={Base model: thinkingmachines/Inkling-2-Mini}
205
+ }
206
+ ```
phase2_closed_book_lora/adapter_config.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "astra_config": null,
6
+ "auto_mapping": {
7
+ "base_model_class": "Inkling2LoopForConditionalGeneration",
8
+ "parent_library": "unsloth_compiled_module_inkling2_loop",
9
+ "unsloth_fixed": true,
10
+ "unsloth_fused_expert_lora": {
11
+ "lora_A_layout": "grouped_by_expert",
12
+ "lora_B_layout": "rank_major",
13
+ "parameters": {
14
+ "down_proj": {
15
+ "lora_B_layout": "rank_major",
16
+ "num_experts": 128
17
+ },
18
+ "gate_up_proj": {
19
+ "lora_B_layout": "rank_major",
20
+ "num_experts": 128
21
+ }
22
+ }
23
+ }
24
+ },
25
+ "base_model_name_or_path": "thinkingmachines/Inkling-2-Mini",
26
+ "bias": "none",
27
+ "corda_config": null,
28
+ "ensure_weight_tying": false,
29
+ "eva_config": null,
30
+ "exclude_modules": null,
31
+ "fan_in_fan_out": false,
32
+ "inference_mode": true,
33
+ "init_lora_weights": true,
34
+ "kasa_config": null,
35
+ "layer_replication": null,
36
+ "layers_pattern": null,
37
+ "layers_to_transform": null,
38
+ "loftq_config": {},
39
+ "lora_B_layout": "rank_major",
40
+ "lora_alpha": 32,
41
+ "lora_bias": false,
42
+ "lora_dropout": 0,
43
+ "lora_ga_config": null,
44
+ "megatron_config": null,
45
+ "megatron_core": "megatron.core",
46
+ "modules_to_save": null,
47
+ "monteclora_config": null,
48
+ "peft_type": "LORA",
49
+ "peft_version": "0.22.0",
50
+ "qalora_group_size": 16,
51
+ "r": 16,
52
+ "rank_pattern": {},
53
+ "revision": null,
54
+ "target_modules": [
55
+ "v_proj.linear",
56
+ "o_proj.linear",
57
+ "gate_proj",
58
+ "q_proj.linear",
59
+ "k_proj.linear"
60
+ ],
61
+ "target_parameters": [
62
+ "mlp.experts.gate_up_proj",
63
+ "mlp.experts.down_proj"
64
+ ],
65
+ "task_type": "CAUSAL_LM",
66
+ "trainable_token_indices": null,
67
+ "unsloth_fused_expert_lora": {
68
+ "lora_A_layout": "grouped_by_expert",
69
+ "lora_B_layout": "rank_major",
70
+ "parameters": {
71
+ "down_proj": {
72
+ "lora_B_layout": "rank_major",
73
+ "num_experts": 128
74
+ },
75
+ "gate_up_proj": {
76
+ "lora_B_layout": "rank_major",
77
+ "num_experts": 128
78
+ }
79
+ }
80
+ },
81
+ "use_bdlora": null,
82
+ "use_dora": false,
83
+ "use_qalora": false,
84
+ "use_rslora": false,
85
+ "velora_config": null
86
+ }
phase2_closed_book_lora/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57f155ff7e206e9010cc02bb2da58dcdced0f49bb1e653d34b1117edd2aa3ac1
3
+ size 1620496408
phase2_closed_book_lora/chat_template.jinja ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set effort_map = {"none": 0.0, "minimal": 0.1, "low": 0.2, "medium": 0.7, "high": 0.9, "xhigh": 0.99, "max": 0.99} -%}
2
+ {%- set role_token = {"user": "<|message_user|>", "assistant": "<|message_model|>", "system": "<|message_system|>", "tool": "<|message_tool|>"} -%}
3
+
4
+ {%- macro emit_thinking_effort() -%}
5
+ {%- set eff = reasoning_effort if reasoning_effort is defined and reasoning_effort is not none else 0.9 -%}
6
+ {%- if eff is string -%}
7
+ {%- set key = eff | trim -%}
8
+ {%- if key not in effort_map -%}
9
+ {{- raise_exception("Unknown reasoning_effort: " ~ eff) -}}
10
+ {%- endif -%}
11
+ {%- set num = effort_map[key] -%}
12
+ {%- else -%}
13
+ {%- set num = eff | float -%}
14
+ {%- endif -%}
15
+ {%- if num < 0.0 or num > 0.99 -%}
16
+ {{- raise_exception("reasoning_effort must be in [0.0, 0.99]") -}}
17
+ {%- endif -%}
18
+ {{- "<|message_system|><|content_text|>Thinking effort level: " -}}
19
+ {%- if num == 0.0 -%}0{%- else -%}{{ num }}{%- endif -%}
20
+ {{- "<|end_message|>" -}}
21
+ {%- endmacro -%}
22
+
23
+ {%- if tools -%}
24
+ {%- set tool_state = namespace(specs=[]) -%}
25
+ {%- for tool in tools -%}
26
+ {%- set fn = tool.function if tool.function is defined else tool -%}
27
+ {%- set spec = {
28
+ "description": (fn.description if fn.description is defined and fn.description else ""),
29
+ "name": fn.name,
30
+ "parameters": (fn.parameters if fn.parameters is defined and fn.parameters else {}),
31
+ "type": (tool.type if tool.type is defined and tool.type else "function"),
32
+ } -%}
33
+ {%- set tool_state.specs = tool_state.specs + [spec] -%}
34
+ {%- endfor -%}
35
+ {{- "<|message_system|>tool_declare<|content_xml|>" -}}
36
+ {{- tool_state.specs | tojson(sort_keys=true, separators=(",", ":")) -}}
37
+ {{- "<|end_message|>" -}}
38
+ {%- endif -%}
39
+
40
+ {%- set state = namespace(effort_emitted=false) -%}
41
+ {%- for message in messages -%}
42
+ {%- if message.role not in role_token -%}
43
+ {{- raise_exception("Unknown message role: " ~ message.role) -}}
44
+ {%- endif -%}
45
+ {%- if not state.effort_emitted and message.role != "system" -%}
46
+ {{- emit_thinking_effort() -}}
47
+ {%- set state.effort_emitted = true -%}
48
+ {%- endif -%}
49
+
50
+ {%- set header = namespace(text=role_token[message.role]) -%}
51
+ {%- if message.role == "tool" -%}
52
+ {%- if message.name is defined and message.name -%}
53
+ {%- set header.text = header.text ~ message.name -%}
54
+ {%- elif message.tool_call_id is defined and message.tool_call_id -%}
55
+ {%- for prev in messages -%}
56
+ {%- if prev.role == "assistant" and prev.tool_calls -%}
57
+ {%- for tc in prev.tool_calls -%}
58
+ {%- if tc.id is defined and tc.id == message.tool_call_id and tc.function.name is defined -%}
59
+ {%- set header.text = header.text ~ tc.function.name -%}
60
+ {%- endif -%}
61
+ {%- endfor -%}
62
+ {%- endif -%}
63
+ {%- endfor -%}
64
+ {%- endif -%}
65
+ {%- elif message.role == "assistant" and message.name is defined and message.name -%}
66
+ {%- set header.text = header.text ~ message.name -%}
67
+ {%- endif -%}
68
+ {%- set rtok = header.text -%}
69
+ {%- set rendered -%}
70
+
71
+ {%- if message.role == "assistant" and message.reasoning_content is defined and message.reasoning_content -%}
72
+ {{- rtok ~ "<|content_thinking|>" ~ message.reasoning_content ~ "<|end_message|>" -}}
73
+ {%- endif -%}
74
+
75
+ {%- if message.content is string and (message.content or not (message.role == "assistant" and (message.tool_calls or message.reasoning_content))) -%}
76
+ {{- rtok ~ "<|content_text|>" ~ message.content ~ "<|end_message|>" -}}
77
+ {%- elif message.content -%}
78
+ {%- for part in message.content -%}
79
+ {%- if part is string -%}
80
+ {{- rtok ~ "<|content_text|>" ~ part ~ "<|end_message|>" -}}
81
+ {%- elif part.type is not defined or part.type in ("text", "input_text") -%}
82
+ {%- set text_part = (part.text if part.text is defined and part.text is string else "") -%}
83
+ {{- rtok ~ "<|content_text|>" ~ text_part ~ "<|end_message|>" -}}
84
+ {%- elif part.type in ("image", "input_image", "image_url") -%}
85
+ {%- if message.role not in ("user", "tool") -%}
86
+ {{- raise_exception("Image content is only supported for user and tool messages") -}}
87
+ {%- endif -%}
88
+ {{- rtok ~ "<|content_image|><|unused_200054|><|end_message|>" -}}
89
+ {%- elif part.type in ("audio", "input_audio", "audio_url") -%}
90
+ {{- raise_exception("Inkling 2 does not accept audio input") -}}
91
+ {%- else -%}
92
+ {{- raise_exception("Unsupported content part type: " ~ part.type) -}}
93
+ {%- endif -%}
94
+ {%- endfor -%}
95
+ {%- endif -%}
96
+
97
+ {%- if message.role == "assistant" and message.tool_calls -%}
98
+ {%- for tc in message.tool_calls -%}
99
+ {%- set fn = tc.function -%}
100
+ {%- if fn.name is not defined or fn.name is not string -%}
101
+ {{- raise_exception("tool call function name must be a string") -}}
102
+ {%- endif -%}
103
+ {%- if message.name is defined and message.name and message.name != fn.name -%}
104
+ {{- raise_exception("assistant name " ~ message.name ~ " does not match its tool call " ~ fn.name) -}}
105
+ {%- endif -%}
106
+ {%- set args = fn.arguments if fn.arguments is defined and fn.arguments else {} -%}
107
+ {%- if args is string -%}
108
+ {{- raise_exception("tool call arguments must be a parsed object, not a JSON string; canonicalize upstream") -}}
109
+ {%- endif -%}
110
+ {%- if args is not mapping -%}
111
+ {{- raise_exception("tool call arguments must be an object") -}}
112
+ {%- endif -%}
113
+ {{- "<|message_model|>" ~ fn.name ~ "<|content_invoke_tool_json|>" -}}
114
+ {{- '{"name":' ~ (fn.name | tojson(sort_keys=true, separators=(",", ":"))) ~ ',"args":' -}}
115
+ {{- "{" -}}
116
+ {%- for key, value in args | dictsort(case_sensitive=true) -%}
117
+ {{- (key | tojson) ~ ":" ~ (value | tojson(separators=(",", ":"))) -}}
118
+ {%- if not loop.last -%},{%- endif -%}
119
+ {%- endfor -%}
120
+ {{- "}}<|end_message|>" -}}
121
+ {%- endfor -%}
122
+ {%- endif -%}
123
+
124
+ {%- if message.role == "assistant" -%}
125
+ {{- "<|content_model_end_sampling|>" -}}
126
+ {%- endif -%}
127
+ {%- endset -%}
128
+ {%- if message.role == "assistant" -%}
129
+ {%- generation -%}{{- rendered -}}{%- endgeneration -%}
130
+ {%- else -%}
131
+ {{- rendered -}}
132
+ {%- endif -%}
133
+ {%- endfor -%}
134
+
135
+ {%- if not state.effort_emitted -%}
136
+ {{- emit_thinking_effort() -}}
137
+ {%- endif -%}
phase2_closed_book_lora/processor_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "Inkling2ImageProcessor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "rescale_factor": 0.00392156862745098,
18
+ "size": {
19
+ "height": 40,
20
+ "width": 40
21
+ }
22
+ },
23
+ "image_token": "<|unused_200054|>",
24
+ "processor_class": "Inkling2Processor"
25
+ }
phase2_closed_book_lora/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f332727f9a3f093dd452a39cc978e6757627e5dad1b0673aa4e75174f236dd6
3
+ size 26178678
phase2_closed_book_lora/tokenizer_config.json ADDED
@@ -0,0 +1,568 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "begin_of_text": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "content_image": "<|content_image|>",
6
+ "content_invoke_tool_json": "<|content_invoke_tool_json|>",
7
+ "content_invoke_tool_text": "<|content_invoke_tool_text|>",
8
+ "content_model_end_sampling": "<|content_model_end_sampling|>",
9
+ "content_text": "<|content_text|>",
10
+ "content_thinking": "<|content_thinking|>",
11
+ "content_tool_error": "<|content_tool_error|>",
12
+ "content_xml": "<|content_xml|>",
13
+ "end_message": "<|end_message|>",
14
+ "endoftext": "<|endoftext|>",
15
+ "eos_token": "<|content_model_end_sampling|>",
16
+ "fix_mistral_regex": false,
17
+ "is_local": true,
18
+ "local_files_only": false,
19
+ "message_model": "<|message_model|>",
20
+ "message_system": "<|message_system|>",
21
+ "message_tool": "<|message_tool|>",
22
+ "message_user": "<|message_user|>",
23
+ "model_max_length": 1048576,
24
+ "model_specific_special_tokens": {
25
+ "begin_of_text": "<|begin_of_text|>",
26
+ "content_image": "<|content_image|>",
27
+ "content_invoke_tool_json": "<|content_invoke_tool_json|>",
28
+ "content_invoke_tool_text": "<|content_invoke_tool_text|>",
29
+ "content_model_end_sampling": "<|content_model_end_sampling|>",
30
+ "content_text": "<|content_text|>",
31
+ "content_thinking": "<|content_thinking|>",
32
+ "content_tool_error": "<|content_tool_error|>",
33
+ "content_xml": "<|content_xml|>",
34
+ "end_message": "<|end_message|>",
35
+ "endoftext": "<|endoftext|>",
36
+ "message_model": "<|message_model|>",
37
+ "message_system": "<|message_system|>",
38
+ "message_tool": "<|message_tool|>",
39
+ "message_user": "<|message_user|>"
40
+ },
41
+ "pad_token": "<|endoftext|>",
42
+ "padding_side": "right",
43
+ "processor_class": "Inkling2Processor",
44
+ "response_template": {
45
+ "defaults": {
46
+ "role": "assistant"
47
+ },
48
+ "fields": {
49
+ "content": {
50
+ "close": "<|end_message|>",
51
+ "content": "text",
52
+ "content_args": {
53
+ "strip": false
54
+ },
55
+ "join": "",
56
+ "open_pattern": "(?:<\\|message_model\\|>[^<]*)?<\\|content_(?:text|tool_error|invoke_tool_text)\\|>",
57
+ "repeats": true
58
+ },
59
+ "reasoning_content": {
60
+ "close": "<|end_message|>",
61
+ "content": "text",
62
+ "content_args": {
63
+ "strip": false
64
+ },
65
+ "join": "",
66
+ "open_pattern": "(?:<\\|message_model\\|>[^<]*)?<\\|content_thinking\\|>",
67
+ "repeats": true
68
+ },
69
+ "tool_calls": {
70
+ "close": "<|end_message|>",
71
+ "content": "json",
72
+ "open_pattern": "(?:<\\|message_model\\|>[^<]*)?<\\|content_invoke_tool_json\\|>",
73
+ "repeats": true,
74
+ "transform": {
75
+ "function": {
76
+ "arguments": "{content.args}",
77
+ "name": "{content.name}"
78
+ },
79
+ "type": "function"
80
+ }
81
+ }
82
+ },
83
+ "start_anchor_pattern": "<\\|end_message\\|>|<\\|content_model_end_sampling\\|>"
84
+ },
85
+ "tokenizer_class": "PreTrainedTokenizerFast",
86
+ "added_tokens_decoder": {
87
+ "199998": {
88
+ "content": "<|unused|>",
89
+ "single_word": false,
90
+ "lstrip": false,
91
+ "rstrip": false,
92
+ "normalized": false,
93
+ "special": true
94
+ },
95
+ "199999": {
96
+ "content": "<|endoftext|>",
97
+ "single_word": false,
98
+ "lstrip": false,
99
+ "rstrip": false,
100
+ "normalized": false,
101
+ "special": true
102
+ },
103
+ "200000": {
104
+ "content": "<|message_user|>",
105
+ "single_word": false,
106
+ "lstrip": false,
107
+ "rstrip": false,
108
+ "normalized": false,
109
+ "special": true
110
+ },
111
+ "200001": {
112
+ "content": "<|message_model|>",
113
+ "single_word": false,
114
+ "lstrip": false,
115
+ "rstrip": false,
116
+ "normalized": false,
117
+ "special": true
118
+ },
119
+ "200002": {
120
+ "content": "<|message_system|>",
121
+ "single_word": false,
122
+ "lstrip": false,
123
+ "rstrip": false,
124
+ "normalized": false,
125
+ "special": true
126
+ },
127
+ "200003": {
128
+ "content": "<|message_tool|>",
129
+ "single_word": false,
130
+ "lstrip": false,
131
+ "rstrip": false,
132
+ "normalized": false,
133
+ "special": true
134
+ },
135
+ "200004": {
136
+ "content": "<|content_text|>",
137
+ "single_word": false,
138
+ "lstrip": false,
139
+ "rstrip": false,
140
+ "normalized": false,
141
+ "special": true
142
+ },
143
+ "200005": {
144
+ "content": "<|content_image|>",
145
+ "single_word": false,
146
+ "lstrip": false,
147
+ "rstrip": false,
148
+ "normalized": false,
149
+ "special": true
150
+ },
151
+ "200006": {
152
+ "content": "<|content_model_end_sampling|>",
153
+ "single_word": false,
154
+ "lstrip": false,
155
+ "rstrip": false,
156
+ "normalized": false,
157
+ "special": true
158
+ },
159
+ "200007": {
160
+ "content": "<|unused_200007|>",
161
+ "single_word": false,
162
+ "lstrip": false,
163
+ "rstrip": false,
164
+ "normalized": false,
165
+ "special": true
166
+ },
167
+ "200008": {
168
+ "content": "<|content_thinking|>",
169
+ "single_word": false,
170
+ "lstrip": false,
171
+ "rstrip": false,
172
+ "normalized": false,
173
+ "special": true
174
+ },
175
+ "200009": {
176
+ "content": "<|unused_200009|>",
177
+ "single_word": false,
178
+ "lstrip": false,
179
+ "rstrip": false,
180
+ "normalized": false,
181
+ "special": true
182
+ },
183
+ "200010": {
184
+ "content": "<|end_message|>",
185
+ "single_word": false,
186
+ "lstrip": false,
187
+ "rstrip": false,
188
+ "normalized": false,
189
+ "special": true
190
+ },
191
+ "200011": {
192
+ "content": "<|unused_200011|>",
193
+ "single_word": false,
194
+ "lstrip": false,
195
+ "rstrip": false,
196
+ "normalized": false,
197
+ "special": true
198
+ },
199
+ "200012": {
200
+ "content": "<|unused_200012|>",
201
+ "single_word": false,
202
+ "lstrip": false,
203
+ "rstrip": false,
204
+ "normalized": false,
205
+ "special": true
206
+ },
207
+ "200013": {
208
+ "content": "<|unused_200013|>",
209
+ "single_word": false,
210
+ "lstrip": false,
211
+ "rstrip": false,
212
+ "normalized": false,
213
+ "special": true
214
+ },
215
+ "200014": {
216
+ "content": "<|unused_200014|>",
217
+ "single_word": false,
218
+ "lstrip": false,
219
+ "rstrip": false,
220
+ "normalized": false,
221
+ "special": true
222
+ },
223
+ "200015": {
224
+ "content": "<|unused_200015|>",
225
+ "single_word": false,
226
+ "lstrip": false,
227
+ "rstrip": false,
228
+ "normalized": false,
229
+ "special": true
230
+ },
231
+ "200016": {
232
+ "content": "<|unused_200016|>",
233
+ "single_word": false,
234
+ "lstrip": false,
235
+ "rstrip": false,
236
+ "normalized": false,
237
+ "special": true
238
+ },
239
+ "200017": {
240
+ "content": "<|unused_200017|>",
241
+ "single_word": false,
242
+ "lstrip": false,
243
+ "rstrip": false,
244
+ "normalized": false,
245
+ "special": true
246
+ },
247
+ "200018": {
248
+ "content": "<|unused_200018|>",
249
+ "single_word": false,
250
+ "lstrip": false,
251
+ "rstrip": false,
252
+ "normalized": false,
253
+ "special": true
254
+ },
255
+ "200019": {
256
+ "content": "<|unused_200019|>",
257
+ "single_word": false,
258
+ "lstrip": false,
259
+ "rstrip": false,
260
+ "normalized": false,
261
+ "special": true
262
+ },
263
+ "200020": {
264
+ "content": "<|unused_200020|>",
265
+ "single_word": false,
266
+ "lstrip": false,
267
+ "rstrip": false,
268
+ "normalized": false,
269
+ "special": true
270
+ },
271
+ "200021": {
272
+ "content": "<|unused_200021|>",
273
+ "single_word": false,
274
+ "lstrip": false,
275
+ "rstrip": false,
276
+ "normalized": false,
277
+ "special": true
278
+ },
279
+ "200022": {
280
+ "content": "<|content_tool_error|>",
281
+ "single_word": false,
282
+ "lstrip": false,
283
+ "rstrip": false,
284
+ "normalized": false,
285
+ "special": true
286
+ },
287
+ "200023": {
288
+ "content": "<|unused_200023|>",
289
+ "single_word": false,
290
+ "lstrip": false,
291
+ "rstrip": false,
292
+ "normalized": false,
293
+ "special": true
294
+ },
295
+ "200024": {
296
+ "content": "<|content_xml|>",
297
+ "single_word": false,
298
+ "lstrip": false,
299
+ "rstrip": false,
300
+ "normalized": false,
301
+ "special": true
302
+ },
303
+ "200025": {
304
+ "content": "<|unused_200025|>",
305
+ "single_word": false,
306
+ "lstrip": false,
307
+ "rstrip": false,
308
+ "normalized": false,
309
+ "special": true
310
+ },
311
+ "200026": {
312
+ "content": "<|unused_200026|>",
313
+ "single_word": false,
314
+ "lstrip": false,
315
+ "rstrip": false,
316
+ "normalized": false,
317
+ "special": true
318
+ },
319
+ "200027": {
320
+ "content": "<|unused_200027|>",
321
+ "single_word": false,
322
+ "lstrip": false,
323
+ "rstrip": false,
324
+ "normalized": false,
325
+ "special": true
326
+ },
327
+ "200028": {
328
+ "content": "<|begin_of_text|>",
329
+ "single_word": false,
330
+ "lstrip": false,
331
+ "rstrip": false,
332
+ "normalized": false,
333
+ "special": true
334
+ },
335
+ "200029": {
336
+ "content": "<|unused_200029|>",
337
+ "single_word": false,
338
+ "lstrip": false,
339
+ "rstrip": false,
340
+ "normalized": false,
341
+ "special": true
342
+ },
343
+ "200030": {
344
+ "content": "<|unused_200030|>",
345
+ "single_word": false,
346
+ "lstrip": false,
347
+ "rstrip": false,
348
+ "normalized": false,
349
+ "special": true
350
+ },
351
+ "200031": {
352
+ "content": "<|unused_200031|>",
353
+ "single_word": false,
354
+ "lstrip": false,
355
+ "rstrip": false,
356
+ "normalized": false,
357
+ "special": true
358
+ },
359
+ "200032": {
360
+ "content": "<|unused_200032|>",
361
+ "single_word": false,
362
+ "lstrip": false,
363
+ "rstrip": false,
364
+ "normalized": false,
365
+ "special": true
366
+ },
367
+ "200033": {
368
+ "content": "<|unused_200033|>",
369
+ "single_word": false,
370
+ "lstrip": false,
371
+ "rstrip": false,
372
+ "normalized": false,
373
+ "special": true
374
+ },
375
+ "200034": {
376
+ "content": "<|unused_200034|>",
377
+ "single_word": false,
378
+ "lstrip": false,
379
+ "rstrip": false,
380
+ "normalized": false,
381
+ "special": true
382
+ },
383
+ "200035": {
384
+ "content": "<|unused_200035|>",
385
+ "single_word": false,
386
+ "lstrip": false,
387
+ "rstrip": false,
388
+ "normalized": false,
389
+ "special": true
390
+ },
391
+ "200036": {
392
+ "content": "<|unused_200036|>",
393
+ "single_word": false,
394
+ "lstrip": false,
395
+ "rstrip": false,
396
+ "normalized": false,
397
+ "special": true
398
+ },
399
+ "200037": {
400
+ "content": "<|unused_200037|>",
401
+ "single_word": false,
402
+ "lstrip": false,
403
+ "rstrip": false,
404
+ "normalized": false,
405
+ "special": true
406
+ },
407
+ "200038": {
408
+ "content": "<|unused_200038|>",
409
+ "single_word": false,
410
+ "lstrip": false,
411
+ "rstrip": false,
412
+ "normalized": false,
413
+ "special": true
414
+ },
415
+ "200039": {
416
+ "content": "<|unused_200039|>",
417
+ "single_word": false,
418
+ "lstrip": false,
419
+ "rstrip": false,
420
+ "normalized": false,
421
+ "special": true
422
+ },
423
+ "200040": {
424
+ "content": "<|unused_200040|>",
425
+ "single_word": false,
426
+ "lstrip": false,
427
+ "rstrip": false,
428
+ "normalized": false,
429
+ "special": true
430
+ },
431
+ "200041": {
432
+ "content": "<|unused_200041|>",
433
+ "single_word": false,
434
+ "lstrip": false,
435
+ "rstrip": false,
436
+ "normalized": false,
437
+ "special": true
438
+ },
439
+ "200042": {
440
+ "content": "<|unused_200042|>",
441
+ "single_word": false,
442
+ "lstrip": false,
443
+ "rstrip": false,
444
+ "normalized": false,
445
+ "special": true
446
+ },
447
+ "200043": {
448
+ "content": "<|unused_200043|>",
449
+ "single_word": false,
450
+ "lstrip": false,
451
+ "rstrip": false,
452
+ "normalized": false,
453
+ "special": true
454
+ },
455
+ "200044": {
456
+ "content": "<|unused_200044|>",
457
+ "single_word": false,
458
+ "lstrip": false,
459
+ "rstrip": false,
460
+ "normalized": false,
461
+ "special": true
462
+ },
463
+ "200045": {
464
+ "content": "<|unused_200045|>",
465
+ "single_word": false,
466
+ "lstrip": false,
467
+ "rstrip": false,
468
+ "normalized": false,
469
+ "special": true
470
+ },
471
+ "200046": {
472
+ "content": "<|unused_200046|>",
473
+ "single_word": false,
474
+ "lstrip": false,
475
+ "rstrip": false,
476
+ "normalized": false,
477
+ "special": true
478
+ },
479
+ "200047": {
480
+ "content": "<|unused_200047|>",
481
+ "single_word": false,
482
+ "lstrip": false,
483
+ "rstrip": false,
484
+ "normalized": false,
485
+ "special": true
486
+ },
487
+ "200048": {
488
+ "content": "<|unused_200048|>",
489
+ "single_word": false,
490
+ "lstrip": false,
491
+ "rstrip": false,
492
+ "normalized": false,
493
+ "special": true
494
+ },
495
+ "200049": {
496
+ "content": "<|content_invoke_tool_json|>",
497
+ "single_word": false,
498
+ "lstrip": false,
499
+ "rstrip": false,
500
+ "normalized": false,
501
+ "special": true
502
+ },
503
+ "200050": {
504
+ "content": "<|unused_200050|>",
505
+ "single_word": false,
506
+ "lstrip": false,
507
+ "rstrip": false,
508
+ "normalized": false,
509
+ "special": true
510
+ },
511
+ "200051": {
512
+ "content": "<|unused_200051|>",
513
+ "single_word": false,
514
+ "lstrip": false,
515
+ "rstrip": false,
516
+ "normalized": false,
517
+ "special": true
518
+ },
519
+ "200052": {
520
+ "content": "<|unused_200052|>",
521
+ "single_word": false,
522
+ "lstrip": false,
523
+ "rstrip": false,
524
+ "normalized": false,
525
+ "special": true
526
+ },
527
+ "200053": {
528
+ "content": "<|unused_200053|>",
529
+ "single_word": false,
530
+ "lstrip": false,
531
+ "rstrip": false,
532
+ "normalized": false,
533
+ "special": true
534
+ },
535
+ "200054": {
536
+ "content": "<|unused_200054|>",
537
+ "single_word": false,
538
+ "lstrip": false,
539
+ "rstrip": false,
540
+ "normalized": false,
541
+ "special": true
542
+ },
543
+ "200055": {
544
+ "content": "<|unused_200055|>",
545
+ "single_word": false,
546
+ "lstrip": false,
547
+ "rstrip": false,
548
+ "normalized": false,
549
+ "special": true
550
+ },
551
+ "200056": {
552
+ "content": "<|unused_200056|>",
553
+ "single_word": false,
554
+ "lstrip": false,
555
+ "rstrip": false,
556
+ "normalized": false,
557
+ "special": true
558
+ },
559
+ "200057": {
560
+ "content": "<|content_invoke_tool_text|>",
561
+ "single_word": false,
562
+ "lstrip": false,
563
+ "rstrip": false,
564
+ "normalized": false,
565
+ "special": true
566
+ }
567
+ }
568
+ }