使用自己或網路上的資料集透過unsloth微調已知的模型,參考unsloth提供的colab程式進行修改。
unsloth的原始網頁:https://github.com/unslothai/unsloth
本程式的colab連結:
https://colab.research.google.com/drive/1RIKgCR3NQfS-o-698vjYTR9n_ZdNMnms?usp=sharing
Step1)安裝程式
過程中出現錯誤「'int' object has no attribute 'mask_token'」,改安裝最新版的unsloth
Step2)下載Meta-Llama-3.1-8B模型
Step3)設定模型參數
Step4)從huggingface下載資料集進行添加,從以下網址下載資料集alpaca-taiwan-dataset.json。
https://huggingface.co/datasets/botp/alpaca-taiwan-dataset/blob/main/alpaca-taiwan-dataset.json
內容如下。
Step5)將前一步驟下載的alpaca-taiwan-dataset.json,上傳到Google雲端硬碟
掛載Google雲端硬碟
在Google雲端硬碟根目錄,新增子資料夾LLM,將alpaca-taiwan-dataset.json上傳到此資料夾。
Step6)載入資料集,總共有630435筆資料
Step7)建立訓練模型
Step8)開始訓練
Step9)測試模型結果,以「在台灣說謝謝再聯絡?」,輸入訓練資料為「表示不要再來,即「再見不送」。」。
最後結果與訓練資料不同,這部分對LLM應該有很大困擾,字面意思與真實意思不同。
['<|begin_of_text|>Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n在台灣說謝謝再聯絡?\n\n### Input:\n\n\n### Response:\n在台灣說「謝謝,再聯絡」是很常見的表達方式。它可以用來表示對人們的幫助、協助或意見的感激之情。它也可以用來表示對某個提議或建議的接受或同意。以下是一']
Step10)模型轉檔成gguf格式,儲存到model/unsloth.Q4_K_M.gguf
Step11)複製到Google雲端硬碟