# Taiwan-LLM >最後編輯日期:2024.02.04 18:11 >硬體: Macbook Pro M1 8G ## 第一步 下載 llama.cpp - 與 [Meta Llama 2 7B 架設](https://hackmd.io/W4Kv_A91QJqWh0mOEyO8kA?both) 相同 ## 第二步 下載 Taiwan-LLM 1. 打開新的終端機 2. 切換至桌面 ```= cd desktop ``` 3. 從`huggingface`下載`Taiwan-LLaMa v2.0 7B` > 需要先註冊 ```huggingface``` 帳戶,並申請 ```Access Tokens``` (在個人帳戶的設定頁面中) ```py= git clone https://huggingface.co/yentinglin/Taiwan-LLM-7B-v2.0.1-chat ``` 4. 依次輸入 `User Name` 與 `Access Tokens` 5. 將資料夾名稱變更成`Taiwan-LLM-7B` 6. 進入 [網站](https://huggingface.co/yentinglin/Taiwan-LLM-7B-v2.0.1-chat/tree/main) 手動下載 `model-00001-of-00002.safetensors` `model-00002-of-00002.safetensors` `tokenizer.model` ,替換原本 `Taiwan-LLM-7B` 內檔案 7. 將 ```Taiwan-LLM-7B``` 移入```desktop/llama.cpp/models``` ## 第三步 量化模型 1. 運行`convert.py`把模型轉換為 `f16.gguf`格式,以減少記憶體使用和算力需求 ```= python convert.py models/Taiwan-LLM-7B/ ``` >原貌:`python3 convert.py folder_path_to_model` 2. 量化成 `q4_0` or `q8_0` > 差別在 `q4_0` 速度較快,但損耗較多; `q8_0` 速度較慢,但損耗較少,也較吃記憶體( 但 M1 8G 會顯示 `status 5`記憶體不足 ) ```= ./quantize ./models/Taiwan-LLM-7B/ggml-model-f16.gguf ./models/Taiwan-LLM-7B/ggml-model-q4_0.gguf q4_0 ``` >原貌:`./quantize model_path new_model_path q4_0` 3. 建立腳本 ```= nano chat-with-bob.txt ``` 輸入以下內容: ```= Transcript of a dialog, where the User interacts with an Assistant named Bob. Bob is helpful, kind, honest, good at writing, and never fails to answer the User's requests mmediately and with precision. User: 你好,Bob。 Bob: 你好。今天我能為您提供什麼幫助? User: 目前台灣人口最多的都市? Bob: 新北市是台灣人口最多的城市。 User: ``` 4. 使用快捷鍵 `Control + X ` 保存,並退出 5. 運行模型 ```= ./main -m ./models/Taiwan-LLM-7B/ggml-model-q4_0.gguf -n -1 --repeat_penalty 1.0 --color --interactive-first -r "User:" -f ./chat-with-ai.txt ``` >原貌:`./main -m path_to_model -n 256 --repeat_penalty 1.0 --color -i -r "User:" -f prompts/chat-with-bob.txt` 6. 大功告成 ## 備註 再次開啟步驟: ```= cd desktop cd llama.cpp ./main -m ./models/Taiwan-LLM-7B/ggml-model-q4_0.gguf -n -1 --repeat_penalty 1.0 --color --interactive-first -r "User:" -f ./chat-with-ai.txt ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up