- 建立指令微調資料集
- 開源資料集 https://github.com/jianzhnie/awesome-instruction-datasets
- 自行建立資料範例
[
{
"instruction": "鄭永誠長得帥嗎?",
"input": "",
"output": "還行,但是鄭建澤和張仲凱才是公認的帥哥"
},
{
"instruction": "要如何學習一門新的語言?",
"input": "",
"output": "可以通過多聽、多說、多讀、多寫,和母語者交流等方法來進行。"
}
]
- 建立資料夾、放入指令微調json檔案
# 於該行修改對應檔案(雲端)路徑
dataset = load_dataset("填入檔案位置", split = "train")
- 模型設定為儲存修改為True
# Just LoRA adapters
if True: model.save_pretrained_merged("model", tokenizer, save_method = "lora",)
if False: model.push_to_hub_merged("hf/model", tokenizer, save_method = "lora", token = "")
- 可下載模型至對應google雲端路徑在下載(參考)
import shutil
# 本地文件路徑
local = "/content/model-unsloth.Q4_K_M.gguf"
# 目標 Google Drive 路徑
google_drive = "/content/drive/My Drive/model-unsloth.Q4_K_M.gguf"
# 複製文件到 Google Drive
shutil.copy(local, google_drive)
print("複製成功!")
概念說明: https://axk51013.medium.com/llm-10大觀念-3-快速建造自己個instruction-tuning-dataset-ab391eba61e5
- 方法1. Argilla
- 方法2. Tuna
https://blog.langchain.dev/introducing-tuna-a-tool-for-rapidly-generating-synthetic-fine-tuning-datasets/ https://replit.com/@olafblitz/tuna-asyncio?ref=blog.langchain.dev#main.py
Hugging Face上運行連結:
https://blog.stoeng.site/20240602.html
也可參考說明完整的影片教學: