Views
No views yet
ricardozhy/Qwen1.5-7B-poem 领域基座在 v2 难样本(4 作者 598 条仿写配对)上做
4bit QLoRA SFT 得到的 纯中文仿写 LoRA Adapter。| 指标 | 基座 | SFT + 智能截断 |
|---|---|---|
| 含英文 | 24/24 (100%) | 0/24 ✅ |
| JSON 尾巴 | 19/24 (79%) | 0/24 ✅ |
| 回显污染 | 0 | 0 ✅ |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3from peft import PeftModel
4
5quant_cfg = BitsAndBytesConfig(
6 load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16,
7 bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True,
8)
9model_id = "ricardozhy/Qwen1.5-7B-poem"
10adapter_id = "shikunpunk/Qwen1.5-7B-Poem-SFT"
11
12tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
13model = AutoModelForCausalLM.from_pretrained(
14 model_id, trust_remote_code=True, device_map="auto",
15 dtype=torch.bfloat16, quantization_config=quant_cfg,
16)
17model = PeftModel.from_pretrained(model, adapter_id, is_trainable=False)
18model.eval()