微调unsloth系列模型
This commit is contained in:
parent
1f0a420d7d
commit
d14fe58e58
@ -23,18 +23,23 @@ dataset = dataset.map(to_chatml)
|
|||||||
# print("\n", dataset[0])
|
# print("\n", dataset[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 加载预训练模型
|
# 加载预训练模型
|
||||||
model, tokenizer = FastLanguageModel.from_pretrained(
|
model, tokenizer = FastLanguageModel.from_pretrained(
|
||||||
# model_name = "unsloth/Qwen3-1.7B-unsloth-bnb-4bit",
|
# model_name = "unsloth/Qwen3-1.7B-unsloth-bnb-4bit",
|
||||||
# model_name = "unsloth/Qwen3-8B-unsloth-bnb-4bit",
|
model_name = "unsloth/Qwen3-8B-unsloth-bnb-4bit",
|
||||||
model_name = "deepseek-ai/DeepSeek-V2-Lite",
|
# model_name = "deepseek-ai/DeepSeek-V2-Lite",
|
||||||
# model_name = "unsloth/Qwen3-4B-unsloth-bnb-4bit",
|
# model_name = "unsloth/Qwen3-4B-unsloth-bnb-4bit",
|
||||||
trust_remote_code=True, # ✅ 允許遠端自訂程式碼, deepseek 系列模型使用
|
trust_remote_code=True, # ✅ 允許遠端自訂程式碼, deepseek 系列模型使用
|
||||||
max_seq_length = 2048, # Context length - can be longer, but uses more memory
|
max_seq_length = 2048, # Context length - can be longer, but uses more memory
|
||||||
|
# max_seq_length = 512, # Context length - can be longer, but uses more memory
|
||||||
load_in_4bit = True, # 4bit uses much less memory , 启用QLoRA
|
load_in_4bit = True, # 4bit uses much less memory , 启用QLoRA
|
||||||
load_in_8bit = False, # A bit more accurate, uses 2x memory
|
load_in_8bit = False, # A bit more accurate, uses 2x memory
|
||||||
full_finetuning = False, # We have full finetuning now!
|
full_finetuning = False, # We have full finetuning now!
|
||||||
# token = "hf_...", # use one if using gated models
|
# token = "hf_...", # use one if using gated models
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
model = FastLanguageModel.get_peft_model(
|
model = FastLanguageModel.get_peft_model(
|
||||||
@ -100,7 +105,7 @@ _ = model.generate(
|
|||||||
# model.cpu()
|
# model.cpu()
|
||||||
|
|
||||||
model.save_pretrained_gguf(
|
model.save_pretrained_gguf(
|
||||||
"DeepSeek-V2-Lite",
|
"Qwen3-8B",
|
||||||
tokenizer,
|
tokenizer,
|
||||||
# quantization_method="q4_k_m", # 或 "q8_0" # 量化模式--默认 q8_0, 可选f16, "q4_k_m", "q8_0", "q5_k_m",
|
# quantization_method="q4_k_m", # 或 "q8_0" # 量化模式--默认 q8_0, 可选f16, "q4_k_m", "q8_0", "q5_k_m",
|
||||||
maximum_memory_usage=0.7 # 限制使用 GPU 显存为总容量的 50%
|
maximum_memory_usage=0.7 # 限制使用 GPU 显存为总容量的 50%
|
||||||
|
|||||||
@ -130,7 +130,7 @@ class UnslothAlignPropConfig(AlignPropConfig):
|
|||||||
)
|
)
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
exp_name = '003加载自己的数据集微调',
|
exp_name = '003微调deepseek',
|
||||||
run_name = '',
|
run_name = '',
|
||||||
seed = 3407,
|
seed = 3407,
|
||||||
log_with = None,
|
log_with = None,
|
||||||
|
|||||||
@ -146,7 +146,7 @@ class UnslothDDPOConfig(DDPOConfig):
|
|||||||
)
|
)
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
exp_name = '003加载自己的数据集微调',
|
exp_name = '003微调deepseek',
|
||||||
run_name = '',
|
run_name = '',
|
||||||
seed = 3407,
|
seed = 3407,
|
||||||
log_with = None,
|
log_with = None,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user