flylcw/seq_monkey_pretrain_sft_optimization_1.5B
012
license: mit libraryname: transformers basemodel:
- flylcw/seqmonkeypretrainbase1.5B language:
- zh tags:
- qwen2
- qwen
- sft
- instruction-tuning
- chinese
- chat datasets:
- BelleGroup/train3.5MCN
- m-a-p/COIG-CQIA ---
seqmonkeypretrainsftoptimization_1.5B(中文指令微调模型)
在 seq_monkey_pretrain_base_1.5B 之上,经过 两阶段全参 SFT 得到的中文指令对话模型:第一阶段用 BelleGroup 通用指令数据建立指令跟随能力,第二阶段用 COIG-CQIA 高质量数据进一步对齐。
模型结构(与 Base 完全一致)
SFT 仅更新权重,不改变模型架构,因此本模型的 config.json 与 Base 模型完全相同:
两阶段 SFT 流程
- 训练方式:全参 SFT(非 LoRA),Causal LM,仅对 assistant 回答部分计算 loss
- 对话模板:Qwen ChatML(
<|im_start|> / <|im_end|>) - 序列长度:1024
- 优化:bf16,cosine 学习率调度
- 第二阶段说明:在阶段一 checkpoint 基础上继续 SFT,学习率调小以防破坏已学能力
快速开始(对话)
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
name = "flylcw/seq_monkey_pretrain_sft_optimization_1.5B"
tok = AutoTokenizer.from_pretrained(name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
name, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
messages = [{"role": "user", "content": "用三句话介绍一下序列猴子数据集"}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
ids = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=256, do_sample=True,
temperature=0.7, top_p=0.9, repetition_penalty=1.1)
print(tok.decode(out[0], skip_special_tokens=True))
