ThanatosDi commited on
Commit
d6bfb1a
·
verified ·
1 Parent(s): ad75d2a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +335 -0
README.md ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.2
3
+ language:
4
+ - en
5
+ - zh
6
+ base_model:
7
+ - meta-llama/Llama-3.2-3B
8
+ - lianghsun/Llama-3.2-3B-F1-Base
9
+ library_name: transformers
10
+ tags:
11
+ - Taiwan
12
+ - R.O.C
13
+ - zhtw
14
+ - SLM
15
+ - Llama-32
16
+ datasets:
17
+ - lianghsun/tw-reasoning-instruct
18
+ - minyichen/tw-instruct-R1-200k
19
+ - minyichen/tw_mm_R1
20
+ model-index:
21
+ - name: Llama-3.2-3B-F1-Reasoning-Instruct
22
+ results:
23
+ - task:
24
+ type: question-answering
25
+ name: Single Choice Question
26
+ dataset:
27
+ type: ikala/tmmluplus
28
+ name: tmmlu+
29
+ config: all
30
+ split: test
31
+ revision: c0e8ae955997300d5dbf0e382bf0ba5115f85e8c
32
+ metrics:
33
+ - name: single choice
34
+ type: accuracy
35
+ value: 46.16
36
+ - task:
37
+ type: question-answering
38
+ name: Single Choice Question
39
+ dataset:
40
+ type: cais/mmlu
41
+ name: mmlu
42
+ config: all
43
+ split: test
44
+ revision: c30699e
45
+ metrics:
46
+ - name: single choice
47
+ type: accuracy
48
+ value: 51.22
49
+ - task:
50
+ type: question-answering
51
+ name: Single Choice Question
52
+ dataset:
53
+ type: lianghsun/tw-legal-benchmark-v1
54
+ name: tw-legal-benchmark-v1
55
+ config: all
56
+ split: test
57
+ revision: 66c3a5f
58
+ metrics:
59
+ - name: single choice
60
+ type: accuracy
61
+ value: 34.92
62
+ metrics:
63
+ - accuracy
64
+ ---
65
+
66
+ # Model Card for Llama-3.2-3B-F1-Reasoning-Instruct (a.k.a __Formosa-1-Reasoning__ or __F1-Reasoning__)
67
+
68
+ <div align="center" style="line-height: 1;">
69
+ <a href="https://discord.gg/Cx737yw4ed" target="_blank" style="margin: 2px;">
70
+ <img alt="Discord" src="https://img.shields.io/badge/Discord-Twinkle%20AI-7289da?logo=discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
71
+ </a>
72
+ <a href="https://huggingface.co/twinkle-ai" target="_blank" style="margin: 2px;">
73
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Twinkle%20AI-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
74
+ </a>
75
+ </div>
76
+
77
+ <div align="center" style="line-height: 1;">
78
+ <a href="https://huggingface.co/meta-llama/Llama-3.2-1B/blob/main/LICENSE.txt" style="margin: 2px;">
79
+ <img alt="License" src="https://img.shields.io/badge/License-llama3.2-f5de53?&color=0081fb" style="display: inline-block; vertical-align: middle;"/>
80
+ </a>
81
+ </div>
82
+
83
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/618dc56cbc345ca7bf95f3cd/lBonfNs_7lzYguD4kJo6z.png)
84
+
85
+ <!-- Provide a quick summary of what the model is/does. -->
86
+ **Llama-3.2-3B-F1-Reasoning-Instruct**(a.k.a **Formosa-1-Reasoning** or **F1-Reasoning**) 是由 **[Twinkle AI](https://huggingface.co/twinkle-ai)** 與 **[APMIC](https://www.apmic.ai/)** 合作開發,並在[國家高速網路與計算中心](https://www.nchc.org.tw/)技術指導之下,針對中華民國台灣語境與任務需求所微調之繁體中文語言模型,涵蓋法律、教育、生活應用等多元場景,並以高指令跟隨能力為目標進行強化。
87
+
88
+ ## Model Details
89
+
90
+ ### Model Description
91
+
92
+ <!-- Provide a longer summary of what this model is. -->
93
+
94
+ - **Developed by:** [Liang Hsun Huang](https://huggingface.co/lianghsun)、[Min Yi Chen](https://huggingface.co/minyichen)、[Wen Bin Lin](https://huggingface.co/tedslin)、[Chao Chun Chuang](https://huggingface.co/c00cjz00) & [Dave Sung](https://huggingface.co/k1dave6412) (All authors have contributed equally to this work.)
95
+ - **Funded by:** [APMIC](https://www.apmic.ai/)
96
+ - **Model type:** LlamaForCausalLM
97
+ - **Language(s) (NLP):** Tranditional Chinese & English
98
+ - **License:** [llama3.2](https://huggingface.co/meta-llama/Llama-3.2-1B/blob/main/LICENSE.txt)
99
+
100
+ ### Model Sources
101
+ <!-- Provide the basic links for the model. -->
102
+
103
+ - **Repository:** [twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct](https://huggingface.co/twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct)
104
+ - **Paper:** (TBA)
105
+ - **Demo:** [Playground](https://3b02.coolify.apmic.ai/)
106
+
107
+ ## Evaluation
108
+
109
+ ### Results
110
+
111
+ 下表採用 [🌟 Twinkle Eval](https://github.com/ai-twinkle/Eval) 評測框架
112
+ | 模型 | 評測模式 | TMMLU+(%) | 台灣法律(%) | MMLU(%) | 測試次數 | 選項排序 |
113
+ |------------------------------------|---------|----------------|----------------|----------------|---------|---------|
114
+ | [mistralai/Mistral-Small-24B-Instruct-2501](https://huggingface.co/mistralai/Mistral-Small-24B-Instruct-2501) | box | 56.15 (±0.0172) | 37.48 (±0.0098) | 74.61 (±0.0154) | 3 | 隨機 |
115
+ | [meta-llama/Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct) | box | 15.49 (±0.0104) | 25.68 (±0.0200) | 6.90 (±0.0096) | 3 | 隨機 |
116
+ | [meta-llama/Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct) | pattern | 35.85 (±0.0174) | 32.22 (±0.0023) | 59.33 (±0.0168) | 3 | 隨機 |
117
+ | [MediaTek-Research/Llama-Breeze2-3B-Instruct](https://huggingface.co/MediaTek-Research/Llama-Breeze2-3B-Instruct) | pattern | 40.32 (±0.0181) | 38.92 (±0.0193) | 55.37 (±0.0180) | 3 | 隨機 |
118
+ | [twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct](https://huggingface.co/twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct) (ours) | box | 46.16 (±0.0198) | 34.92 (±0.0243) | 51.22 (±0.0206) | 3 | 隨機 |
119
+
120
+ 下表用 lighteval 評測框架
121
+ | 模型 | MATH-500 | GPQA Diamond |
122
+ |--------------------------------------------|----------|--------------|
123
+ | [meta-llama/Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct) | 44.40 | 27.78 |
124
+ | [twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct](https://huggingface.co/twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct) (ours) | **51.40**| **33.84** |
125
+
126
+
127
+ ---
128
+
129
+ ## 🔧 Tool Calling
130
+
131
+ 本模型使用 Hermes 格式訓練,並支援平行呼叫(Parallel calling),以下為完整範例流程。
132
+ Tool call 模板已經為大家寫好放進 chat-template 了,Enjoy it!
133
+
134
+ ### 1️⃣ 啟動 vLLM 後端
135
+ > **⚠️ 注意:需要 vLLM 版本 >= 0.8.3,否則 `enable-reasoning`、`enable-auto-tool-choice` 無法同時開啟**
136
+
137
+ ```bash
138
+ vllm serve twinkle-ai/Llama-3.2-3B-F1-Reasoning-Instruct \
139
+ --port 8001 \
140
+ --enable-reasoning \
141
+ --reasoning-parser deepseek_r1 \
142
+ --enable-auto-tool-choice \
143
+ --tool-call-parser hermes
144
+ ```
145
+
146
+ ### 2️⃣ 定義工具(Functions)
147
+
148
+ ```python
149
+ def get_weather(location: str, unit: str):
150
+ return f"{location}的氣溫是{unit}26度,晴朗無風"
151
+
152
+ def search(query: str):
153
+ return "川普終於宣布對等關稅政策,針對 18 個經濟體課徵一半的對等關稅,並從 4/5 起對所有進口產品徵收10%的基準關稅!美國將針對被認定為不當貿易行為(不公平貿易) 的國家,於 4/9 起課徵報復型對等關稅 (Discounted Reciprocal Tariff),例如:日本將被課徵 24% 的關稅,歐盟則為 20%,以取代普遍性的 10% 關稅。\n針對中國則開啟新一波 34% 關稅,並疊加於先前已實施的關稅上,這將使中國進口商品的基本關稅稅率達到 54%,而且這尚未包含拜登總統任內或川普第一任期所施加的額外關稅。加拿大與墨西哥則不適用這套對等關稅制度,但川普認為這些國家在芬太尼危機與非法移民問題尚未完全解決,因此計畫對這兩國的大多數進口商品施加 25% 關稅。另外原本針對汽車與多數其他商品的關稅豁免將於 4/2 到期。\n台灣的部分,美國擬向台灣課徵32%的對等關稅,雖然並未針對晶片特別課徵關稅,但仍在記者會中提到台灣搶奪所有的電腦與半導體晶片,最終促成台積電對美國投資計劃額外加碼 1,000 億美元的歷史性投資;歐盟則課徵20%的對等關稅。最後是汽車關稅將於 4/2 起,對所有外國製造的汽車課徵25% 關稅。"
154
+
155
+ tools = [
156
+ {
157
+ "type": "function",
158
+ "function": {
159
+ "name": "get_weather",
160
+ "description": "Get the current weather in a given location",
161
+ "parameters": {
162
+ "type": "object",
163
+ "properties": {
164
+ "location": {"type": "string", "description": "國家或城市名, e.g., 'Taipei'、'Jaipei'"},
165
+ "unit": {"type": "string", "description": "氣溫單位,亞洲城市使用攝氏;歐美城市使用華氏", "enum": ["celsius", "fahrenheit"]}
166
+ },
167
+ "required": ["location", "unit"]
168
+ }
169
+ }
170
+ },
171
+ {
172
+ "type": "function",
173
+ "function": {
174
+ "name": "search",
175
+ "description": "這是一個類似 Google 的搜尋引擎,關於知識、天氣、股票、電影、小說、百科等等問題,如果你不確定答案就搜尋一下。",
176
+ "parameters": {
177
+ "type": "object",
178
+ "properties": {
179
+ "query": {"type": "string", "description": "should be a search query, e.g., '2024 南韓 戒嚴'"}
180
+ },
181
+ "required": ["query"]
182
+ }
183
+ }
184
+ }
185
+ ]
186
+ ```
187
+
188
+ ### 3️⃣ 執行工具調用(Tool Calls)
189
+
190
+ > **⚠️ 注意:system_prompt 可以不用帶,除非是需要時間基準的工具。**
191
+ ```python
192
+ response = client.chat.completions.create(
193
+ model=client.models.list().data[0].id,
194
+ messages=[
195
+ {"role": "system", "content": "記住你的知識截止於 2024/12,今天是 2025/4/7"},
196
+ {"role": "user", "content": "台北氣溫如何? 另外,告訴我川普最新關稅政策"},
197
+ ],
198
+ max_tokens=1500,
199
+ temperature=0.6,
200
+ top_p=0.95,
201
+ tools=tools,
202
+ tool_choice="auto"
203
+ )
204
+
205
+ print(response.choices[0].message.reasoning_content)
206
+ print(response.choices[0].message.tool_calls)
207
+ ```
208
+
209
+ #### 🧠 推理內容輸出(僅顯示部分)
210
+ > 好的,我需要幫助這個使用者解決他們的問題。他們問了兩件事:首先,臺北市的天氣情況,以及第二,關於川普最近的關稅政策。
211
+ > 對於第一���分,他們提到了“臺北”,所以應該呼叫 get_weather 函式…
212
+ > 接下來是關於川普的新關稅政策…
213
+ > 總結一下,我需要分別進行兩次 API 呼叫,每次都有各自正確填寫的參數…
214
+
215
+ #### ⚙️ Tool Calls List
216
+
217
+
218
+ ```json
219
+ [ChatCompletionMessageToolCall(id='chatcmpl-tool-35e74420119349999913a10133b84bd3', function=Function(arguments='{"location": "Taipei", "unit": "celsius"}', name='get_weather'), type='function'), ChatCompletionMessageToolCall(id='chatcmpl-tool-7ffdcb98e59f4134a6171defe7f2e31b', function=Function(arguments='{"query": "Donald Trump latest tariffs policy"}', name='search'), type='function')]
220
+ ```
221
+
222
+ ### 4️⃣ 產生最終回答
223
+
224
+ ```python
225
+ response = client.chat.completions.create(
226
+ model=client.models.list().data[0].id,
227
+ messages=[
228
+ {"role": "system", "content": "記住你的知識截止於 2024/12,今天是 2025/4/7"},
229
+ {"role": "user", "content": "台北氣溫如何? 另外,告訴我川普最新關稅政策"},
230
+ {
231
+ "role": "assistant",
232
+ "content": "",
233
+ "tool_calls": [
234
+ {
235
+ "id": response.choices[0].message.tool_calls[0].id,
236
+ "type": "function",
237
+ "function": {
238
+ "name": response.choices[0].message.tool_calls[0].function.name,
239
+ "arguments": response.choices[0].message.tool_calls[0].function.arguments
240
+ }
241
+ },
242
+ {
243
+ "id": response.choices[0].message.tool_calls[1].id,
244
+ "type": "function",
245
+ "function": {
246
+ "name": response.choices[0].message.tool_calls[1].function.name,
247
+ "arguments": response.choices[0].message.tool_calls[1].function.arguments
248
+ }
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "role": "tool",
254
+ "content": search(**json.loads(response.choices[0].message.tool_calls[0].function.arguments)),
255
+ "tool_call_id": response.choices[0].message.tool_calls[0].id # tool_call_id 必須要帶,才能正確配對 工具 及 tool_call
256
+ },
257
+ {
258
+ "role": "tool",
259
+ "content": get_weather(**json.loads(response.choices[0].message.tool_calls[1].function.arguments)),
260
+ "tool_call_id": response.choices[0].message.tool_calls[1].id # tool_call_id 必須要帶,才能正確配對 工具 及 tool_call
261
+ }
262
+ ],
263
+ max_tokens=1500,
264
+ temperature=0.6,
265
+ top_p=0.95,
266
+ tools=tools,
267
+ tool_choice="auto"
268
+ )
269
+
270
+ print(response.choices[0].message.reasoning_content)
271
+ print(response.choices[0].message.content)
272
+ ```
273
+
274
+ #### 🧠 推理內容輸出(僅顯示部分)
275
+ > 首先,我需要處理使用者的查詢,他們要求了解臺北市的當下氣溫以及川普最近的關稅政策…
276
+ > 在呼叫了 `get_weather` 後得到了臺北市氣溫為 26 度(攝氏)…
277
+ > 接著,使用 `search` 搜尋「川普最新關稅政策 2025」…
278
+ > 整合後,我提供如下摘要:
279
+
280
+ #### 📋 最終輸出內容
281
+
282
+ ```text
283
+ 以下是您請求的資訊:
284
+
285
+ **臺北市氣溫**
286
+ - 目前的氣溫為 **26°C**(攝氏)
287
+ - 天候狀況:晴朗無風
288
+
289
+ **川普最新關稅政策概述**
290
+ 1. **對等關稅政策**
291
+ - 對 18 個經濟體課徵 50% 的對等關稅
292
+ - 自 4 月 5 日起,所有進口產品全面徵收 10% 基本關稅
293
+
294
+ 2. **報復型對等關稅**
295
+ - 日本 24%、歐盟 20%
296
+
297
+ 3. **對中國的高額關稅**
298
+ - 增加至 54%(原有關稅 + 新增 34%)
299
+
300
+ 4. **特殊案例**
301
+ - 加拿大與墨西哥不適用,但其他商品課徵 25%
302
+ - 汽車與部分商品的免稅即將到期
303
+
304
+ 5. **對台灣的影響**
305
+ - 美國計畫對台灣課徵 32% 關稅,但晶片暫無額外課稅
306
+
307
+ 6. **全球視角**
308
+ - 歐盟與日本關稅比例相對較高
309
+ ```
310
+
311
+
312
+ ## Citation
313
+
314
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
315
+ ```yaml
316
+ @misc{twinkleai2025llama3.2f1,
317
+ title = {Llama-3.2-3B-F1-Reasoning-Instruct: A Traditional Chinese Instruction-Tuned Reasoning Language Model for Taiwan},
318
+ author = {Huang, Liang Hsun and Chen, Min Yi and Lin, Wen Bin and Chuang, Chao Chun and Sung, Dave},
319
+ year = {2025},
320
+ howpublished = {\url{https://huggingface.co/twinkle-ai/Llama-3.2-3B-F1-Instruct}},
321
+ note = {Twinkle AI and APMIC. All authors contributed equally.}
322
+ }
323
+ ```
324
+
325
+ ## Acknowledge
326
+ - 特此感謝[國家高速網路與計算中心](https://www.nchc.org.tw/)的指導與 [APMIC](https://www.apmic.ai/) 的算力支援,才得以讓本專案訓利完成。
327
+ - 特此致謝黃啟聖老師、許武龍(哈爸)、臺北市立第一女子高級中學物理科陳姿燁老師、[奈視科技](https://nanoseex.com/) CTO Howard、[AIPLUX Technology](https://aiplux.com/)、郭家嘉老師以及所有在資料集製作過程中��供寶貴協助的夥伴。
328
+
329
+ ## Model Card Authors
330
+
331
+ [Twinkle AI](https://huggingface.co/twinkle-ai)
332
+
333
+ ## Model Card Contact
334
+
335
+ [Twinkle AI](https://huggingface.co/twinkle-ai)