aashish1904 commited on
Commit
1dc1bad
·
verified ·
1 Parent(s): 17d5cd8

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +348 -0
README.md ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ base_model: meta-llama/Llama-3.2-3B
5
+ library_name: transformers
6
+ datasets:
7
+ - lianghsun/tw-novel-1.1B
8
+ - lianghsun/tw-finance-159M
9
+ - lianghsun/tw-legal-news-24M
10
+ - lianghsun/tw-gov-news-90M
11
+ - lianghsun/tw-gov-556k
12
+ - lianghsun/tw-news-551M
13
+ - lianghsun/tw-health-43M
14
+ - lianghsun/tw-science-24M
15
+ - lianghsun/tw-book-43M
16
+ - lianghsun/tw-society-88M
17
+ - lianghsun/tw-law-article-evolution
18
+ - lianghsun/tw-processed-judgments
19
+ - lianghsun/tw-legal-methodology
20
+ - lianghsun/tw-legal-qa
21
+ - lianghsun/tw-judgment-gist
22
+ - lianghsun/reasoning-base-20k
23
+ - lianghsun/wikipedia-zh-filtered
24
+ - AWeirdDev/zh-tw-pts-articles-sm
25
+ - bhxiang/c4_calibrate_mini
26
+ - benchang1110/pretrainedtw
27
+ - benchang1110/sciencetw
28
+ - intfloat/multilingual_cc_news
29
+ language:
30
+ - zh
31
+ - en
32
+ license: llama3.2
33
+ tags:
34
+ - ROC
35
+ - Taiwan
36
+ - zh-tw
37
+ - llama-factory
38
+ new_version: lianghsun/Llama-3.2-Taiwan-3B-Instruct
39
+ pipeline_tag: text-generation
40
+ widget:
41
+ - text: 中華民國憲法第一條
42
+
43
+ ---
44
+
45
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
46
+
47
+
48
+ # QuantFactory/Llama-3.2-Taiwan-3B-GGUF
49
+ This is quantized version of [lianghsun/Llama-3.2-Taiwan-3B](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-3B) created using llama.cpp
50
+
51
+ # Original Model Card
52
+
53
+
54
+ # Model Card for lianghsun/Llama-3.2-Taiwan-3B
55
+
56
+ <!-- Provide a quick summary of what the model is/does. -->
57
+ <a href="https://discord.gg/fj6WbHMvfs" target="_blank">[Discord]</a>
58
+
59
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/618dc56cbc345ca7bf95f3cd/v_cfMxTtVE6_eh0rzcy5L.png)
60
+ *圖像生成來自 [OpenArt](https://openart.ai/home):An anime-style 🦙 standing proudly atop the summit of Taiwan’s [Yushan (Jade Mountain)](https://zh.wikipedia.org/wiki/%E7%8E%89%E5%B1%B1), gazing forward.*
61
+
62
+ 採用 [meta-llama/Llama-3.2-3B](https://huggingface.co/meta-llama/Llama-3.2-3B) 為[基礎模型(foundation model)](https://en.wikipedia.org/wiki/Foundation_model),使用大量[中華民國台灣](https://zh.wikipedia.org/zh-tw/%E8%87%BA%E7%81%A3)的繁體中文語料和多國語料進行模型[持績預訓練(continual pretraining, CPT)](https://docs.unsloth.ai/basics/continued-pretraining),旨在訓練出具有中華民國台灣知識及風格的[小語言模型(small langugae model, SLM)](https://www.ibm.com/think/topics/small-language-models)。
63
+
64
+ <details>
65
+ <summary><b>Model Change Log</b></summary>
66
+
67
+ | Update Date | Model Version | Key Changes |
68
+ |--------------|-----------------------|-------------------------------------|
69
+ | 2025-01-01 | v2024.12.28 | This version is trained on a larger corpus of Traditional Chinese texts and multilingual data. |
70
+ | 2024-11-15 | v2024.11.15 | The model continues training on multilingual and Traditional Chinese corpora. |
71
+
72
+ </details>
73
+
74
+ ## Model Details
75
+
76
+ 本模型基於 `meta-llama/Llama-3.2-3B` 持續預訓練,整合了大量繁體中文語料和多國語系語料。繁體中文語料主要來自中華民國政府官方與其他可信賴的繁體中文來源,確保語料純正,避免模型生成時出現繁簡中文用語混雜的情況。同時,此舉也使模型能更準確地貼近中華民國台灣社會的語言使用習慣。
77
+
78
+ 採用小語言模型(相較於 7B+)的設計目標之一是降低硬體資源需求,即便在較少 GPU 硬體資源的環境中,也能讓使用者能更輕鬆地進行[指令微調(instruction fine-tuning)](https://www.ibm.com/topics/instruction-tuning)或部署推論端點(inference endpoint)。
79
+
80
+ > 需要大量繁體中文語料和高算力的部分,這個基礎模型已經處理好了,各位訓練家只要專注在微調的部分 💪。
81
+
82
+ *👋 如果你有更多公開資料想讓模型進行預訓練或者你對指令微調有什麼想法,也請歡迎來信討論。請不吝嗇給予 ❤️ 以支持此開源專案。以下提供本基礎模型的持續預訓練細節,協助各位減少探索所需的時間。*
83
+
84
+ ### Model Description
85
+
86
+ <!-- Provide a longer summary of what this model is. -->
87
+ - **Developed by:** [Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
88
+ - **Model type:** LlamaForCausalLM
89
+ - **Language(s) (NLP):** zh-tw
90
+ - **License:** [llama3.2](https://huggingface.co/meta-llama/Llama-3.2-1B/blob/main/LICENSE.txt)
91
+ - **Continual pre-trained from model:** [meta-llama/Llama-3.2-3B](https://huggingface.co/meta-llama/Llama-3.2-3B)
92
+
93
+ ### Model Sources
94
+
95
+ <!-- Provide the basic links for the model. -->
96
+ - **Repository:** [lianghsun/Llama-3.2-Taiwan-3B](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-3B)
97
+ - **Demo**:
98
+ ```markdown
99
+ # v2024.11.15
100
+
101
+ prompt: 台灣是
102
+ text: 個有地震風險的地方,地震的地層不斷變化
103
+
104
+ prompt: 中華民國總統
105
+ text: 當選人賴清德今日抵台揭露住所。
106
+
107
+ prompt: 學��營養午餐
108
+ text: 之食物營養成分及食材數量評鑑手冊
109
+ ```
110
+
111
+ ## Uses
112
+
113
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
114
+
115
+ ### Direct Use
116
+
117
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
118
+ 本基礎模型透過大量繁體中文和多國語料進行持續預訓練,在不進行指令微調的前題下,你可以佈署此基礎模型觀察其對繁中語料的接龍程度,從中得知是否具備一定的繁中能力。
119
+
120
+ ```markdown
121
+ # v2024.11.15
122
+ prompt: 刑法第一條
123
+ text: 規定之立法目的,以維護社會生活的和諧之
124
+ ```
125
+
126
+ ### Downstream Use
127
+
128
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
129
+ 本基礎模型透過大量繁體中文和多國語料進行持續預訓練,經檢查模型的輸出已經具有繁中用語能力,使用者可以以此基礎模型進行指令微調成具有指令回調的模型,以下是我們使用大量繁體中文指令集進行微調後的模型結果:
130
+ ```markdown
131
+ # lianghsun/Llama-3.2-Taiwan-3B-Instruct (not released yet)
132
+ user: 請介紹台灣
133
+ assistant: 台灣,位於亞洲東部,地處太平洋與菲律賓海之間,面積約36,000平方公里,人口約2,300萬,是民主自由的國家,經濟實力強勁,擁有世界第10大經濟體。台灣以美食、文化、自然美景著稱,還有豐富的歷史與傳統,吸引全球遊客。台灣語為官方語言,但中文也廣為使用,英語也常用於國際交流。台灣政治多元,執政黨為民進黨,台灣是全球科技產業的重鎮,擁有先進的製造業與服務業。台灣氣候溫暖潮濕,四季分明,夏季炎熱,冬季涼爽,雨季則在5月至10月。台灣的美食以小吃為主,如滷肉飯、珍珠
134
+ ```
135
+
136
+ ### Out-of-Scope Use
137
+
138
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
139
+ 我們用來訓練此基礎模型的繁體中文資料集涵蓋許多不同年代,基礎模型如果在未微調的前題下,進一步詢問有關具有時效性的問題可能會得到非預期的結果,比如
140
+ ```markdown
141
+ # v2024.11.15
142
+ prompt: 民法第184條
143
+ text: 第1項立法目的及易淹水事件開放安全窗 # 錯誤
144
+ ```
145
+
146
+ ## Bias, Risks, and Limitations
147
+
148
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
149
+ 雖然此模型已經透過大量繁體中文的薰陶,並且資料集中含有大量中華民國台灣政府的公開資訊,但仍可能出現時空背景錯誤、使用非台灣本地用語或其他誤植回覆的可能性(我們持績在補充更多的繁中語料)。使用者在參考這些資料時,應謹慎檢查生成的內容,並避免將模型輸出視為正確回覆。建議可以再透過 *持績預訓練* 或 *指令微調* 進一步降低前述的問題。
150
+
151
+ ### Recommendations
152
+
153
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
154
+
155
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
156
+
157
+ ## How to Get Started with the Model
158
+
159
+ <!-- Use the code below to get started with the model. -->
160
+
161
+ 要使用 [vLLM Docker image](https://docs.vllm.ai/en/latest/serving/deploying_with_docker.html) 來啟動此模型,您可以按照以下操作:
162
+ ```bash
163
+ docker run --runtime nvidia --gpus all \
164
+ -v ~/.cache/huggingface:/root/.cache/huggingface \
165
+ --env "HUGGING_FACE_HUB_TOKEN=<secret>" \
166
+ -p 8000:8000 \
167
+ --ipc=host \
168
+ vllm/vllm-openai:latest \
169
+ --model lianghsun/Llama-3.2-Taiwan-3B
170
+ ```
171
+
172
+ 請注意,如果想要使用不同版本的 checkpoint,請加上 `--revision <tag_name>`
173
+ ```bash
174
+ docker run --runtime nvidia --gpus all \
175
+ -v ~/.cache/huggingface:/root/.cache/huggingface \
176
+ --env "HUGGING_FACE_HUB_TOKEN=<secret>" \
177
+ -p 8000:8000 \
178
+ --ipc=host \
179
+ vllm/vllm-openai:latest \
180
+ --model lianghsun/Llama-3.2-Taiwan-3B --revision <tag_name>
181
+ ```
182
+
183
+ ## Training Details
184
+
185
+ ### Training Data
186
+
187
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
188
+ <details>
189
+ <summary><b>繁體中文語料資料集</b></summary>
190
+
191
+ - [lianghsun/tw-novel-1.1B](https://huggingface.co/datasets/lianghsun/tw-novel-1.1B)
192
+ - [lianghsun/tw-finance-159M](https://huggingface.co/datasets/lianghsun/tw-finance-159M)
193
+ - [lianghsun/tw-legal-news-24M](https://huggingface.co/datasets/lianghsun/tw-legal-news-24M)
194
+ - [lianghsun/tw-gov-news-90M](https://huggingface.co/datasets/lianghsun/tw-gov-news-90M)
195
+ - [lianghsun/tw-news-408M](https://huggingface.co/datasets/lianghsun/tw-news-408M)
196
+ - [lianghsun/tw-health-36M](https://huggingface.co/datasets/lianghsun/tw-health-36M)
197
+ - [lianghsun/tw-law-article-evolution](https://huggingface.co/datasets/lianghsun/tw-law-article-evolution)
198
+ - [lianghsun/tw-processed-judgments](https://huggingface.co/datasets/lianghsun/tw-processed-judgments)
199
+ - [lianghsun/tw-legal-methodology](https://huggingface.co/datasets/lianghsun/tw-legal-methodology)
200
+ - [lianghsun/tw-legal-qa](https://huggingface.co/datasets/lianghsun/tw-legal-qa)
201
+ - [lianghsun/tw-judgment-gist](https://huggingface.co/datasets/lianghsun/tw-judgment-gist)
202
+ - [lianghsun/reasoning-base-20k](https://huggingface.co/datasets/lianghsun/reasoning-base-20k)
203
+ - [AWeirdDev/zh-tw-pts-articles-sm](https://huggingface.co/datasets/AWeirdDev/zh-tw-pts-articles-sm)
204
+ - [bhxiang/c4_calibrate_mini](https://huggingface.co/datasets/bhxiang/c4_calibrate_mini)
205
+ - [benchang1110/pretrainedtw](https://huggingface.co/datasets/benchang1110/pretrainedtw)
206
+ - [benchang1110/sciencetw](https://huggingface.co/datasets/benchang1110/sciencetw)
207
+
208
+ </details>
209
+
210
+ <details>
211
+ <summary><b>多國語系語料資料集</b></summary>
212
+
213
+ - [intfloat/multilingual_cc_news](https://huggingface.co/datasets/intfloat/multilingual_cc_news)
214
+
215
+ </details>
216
+
217
+
218
+ ### Training Procedure
219
+
220
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
221
+
222
+ #### Preprocessing
223
+
224
+ 1. **語料格式化:** 繁體中文資料集面臨一些格式化的問題,句子中如果有中英文混雜,或者更通用的情況是全型和半型的文字及標點符號混合時,如果資料來源處未加注意,格式往往會是全型半型符號各種交錯使用、中文句子中間用半型逗號相接、中英文直接連在一起,這些源頭可能源自於從小使用 Microsoft Word 的習慣,因為 Word 會在「視覺上」幫中英文之間加上空格,導致繁體中文地區的撰寫者習慣會忽略在適當的位置加上空格及全型半型文字交錯時的正確格式,我們在此稱之為「不工整格式」。上述問題會導致採用如此的資料集的語言模型學到不工整的輸出,比如:
225
+
226
+ ```markdown
227
+ # 不工整文本
228
+ - 你好嗎Jack這是我們的10c.c
229
+ - 他說:"Hello, how are you?"
230
+
231
+ ```
232
+
233
+ 為了解決這個問題,我們撰寫一個負責格式化文本的管道(pipeline)處理全型半型混合語料。
234
+
235
+ ```markdown
236
+ # 格式化後的文本
237
+ - 你好嗎 Jack 這是我們的 10 c.c
238
+ - 他說:"Hello, how are you?"
239
+
240
+ ```
241
+
242
+ 2. **截斷長度:** 在選擇資料時,我們直接去除大於訓練模型的截斷長度(cutoff length)的文本,讓每一筆訓練的文本是完整的句子。基於上述觀察,我們將這個模型的截斷長度設置為 `4096`,並取總 token 數量小於 `4096` 文本。請注意這裡我們是以 `llama-3.2-*B` 的切詞器(tokenizer)去計算總 token 數量。
243
+
244
+ #### Training Hyperparameters
245
+
246
+ - **learning_rate:** 5e-6
247
+ - **min_learning_rate:** 5e-7
248
+ - **train_batch_size:** 8
249
+ - **eval_batch_size:** 4
250
+ - **seed:** 42
251
+ - **distributed_type:** single-node
252
+ - **num_devices:** 4
253
+ - **gradient_accumulation_steps:** 50
254
+ - **total_train_batch_size:** 1,600 (train_batch_size * gradient_accumulation_steps * num_devices)
255
+ - **optimizer:** adamw_torch_fused
256
+ - **lr_scheduler_type:** cosine
257
+ - **lr_scheduler_warmup_ratio:** 0.01
258
+ - **num_epochs:** 10
259
+ - **grad_norm:** 0.14920360027631302
260
+ - **global_step:** 2,770
261
+
262
+ #### Speeds, Sizes, Times
263
+
264
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
265
+ - **Duration**: 8d 1h 46m 24s
266
+ - **Train runtime**: 697,584.9221
267
+ - **Train samples per second**: 6.376
268
+ - **Train steps per second**: 0.004
269
+ - **Total training FLOPs**: 18,625,327,792,128,000
270
+ - **Train loss**: 1.7512
271
+
272
+ ## Environmental Impact
273
+
274
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
275
+
276
+ - **Hardware Type:** 🚀
277
+ - **Hours used:** ⏳⏳⌛
278
+ - **Cloud Provider:** [鴻鵠國際股份有限公司](https://www.honghutech.com/)
279
+ - **Compute Region:** 🇹🇼
280
+ - **Carbon Emitted:** ♻️
281
+
282
+ ## Technical Specifications [optional]
283
+
284
+ ### Model Architecture and Objective
285
+
286
+ [More Information Needed]
287
+
288
+ ### Compute Infrastructure
289
+
290
+ [More Information Needed]
291
+
292
+ #### Hardware
293
+
294
+ [More Information Needed]
295
+
296
+ #### Software
297
+
298
+ [More Information Needed]
299
+
300
+ ## Citation
301
+
302
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
303
+ ```
304
+ @misc{
305
+ lianghsun2024llama32taiwan3b,
306
+ author = {Huang, Liang Hsun},
307
+ title = {Llama-3.2-Taiwan-3B},
308
+ year = {2024},
309
+ publisher = {Hugging Face},
310
+ howpublished = {\url{https://huggingface.co/lianghsun/Llama-3.2-Taiwan-3B}},
311
+ note = {Accessed: 2024-11-25}
312
+ }
313
+ ```
314
+
315
+ ## Glossary
316
+
317
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
318
+ N/A
319
+
320
+ ## More Information
321
+
322
+ ### Acknowledge
323
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/618dc56cbc345ca7bf95f3cd/28u7rOLoeUgn67clYEKuZ.png)
324
+ 在此致謝[鴻鵠國際股份有限公司](https://www.honghutech.com/)蔡長明先生無償地贊助算力,以及曾經幫忙過:廖振翔、chweng、Ben、kevin、Maxxchu、Lam 和陳林彥…等朋友們,才能讓這個模型得以訓練完成,提供算力者乃人生父母。
325
+
326
+ ### Usage
327
+ 如果你基於此基礎模型進行微調,希望能不吝嗇在 **模型卡片(model card)** 裡標註 **基礎模型** 為:
328
+ ```
329
+ base_model: lianghsun/Llama-3.2-Taiwan-3B
330
+ ```
331
+
332
+ 標註和 ❤️ 是給予我們最大的鼓勵,謝謝。😀
333
+
334
+ ## Model Card Authors
335
+
336
+ [Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
337
+
338
+ ## Model Card Contact
339
+
340
+ [Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
341
+
342
+ ### Framework versions
343
+
344
+ - Transformers 4.45.2
345
+ - Pytorch 2.4.1+cu121
346
+ - Datasets 2.21.0
347
+ - Tokenizers 0.20.0
348
+