Views
No views yet
本仓库保存的是 LoRA adapter,加载时需配合基座模型 Qwen/Qwen3.8-27B 使用。
| 项目 | 说明 |
|---|---|
| 基础模型 | Qwen/Qwen3.8-27B(Qwen3.8,2026-08 最新版) |
| 参数量 | 27B(基座) |
| 训练方法 | QLoRA(4bit NF4 量化,rank=16, alpha=32) |
| 训练数据 | 顾城诗歌 183 首(gucheng_train.jsonl,人类标注一致样本 113 首可并入) |
| 训练硬件 | NVIDIA A100-PCIE-40GB(云服务) |
| 训练轮数 | 8 epochs,train_loss 1.69 → 0.47 |
| 关闭思考模式 | 推理时 enable_thinking=False,直接生成诗歌 |
1import torch
2from transformers import AutoModelForCausalLM, AutoProcessor, BitsAndBytesConfig
3from peft import PeftModel
4
5model_id = "Qwen/Qwen3.8-27B"
6adapter_id = "shikunpunk/Qwen3.8-27B-GuCheng"
7
8processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
9model = AutoModelForCausalLM.from_pretrained(
10 model_id, trust_remote_code=True,
11 dtype=torch.bfloat16, device_map="auto",
12 quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16,
13 bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True),
14)
15model = PeftModel.from_pretrained(model, adapter_id)
16model.eval()
17
18msgs = [
19 {"role": "system", "content": "你是一位深谙顾城诗歌风格的现代诗人。顾城的诗以简洁的意象、童话般的想象和对生命本质的追问为特征,语言纯净而富有灵气,常带一丝忧郁与梦幻。"},
20 {"role": "user", "content": "请以《小巷》为题,创作一首现代诗。"},
21]
22text = processor.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
23enc = processor(text=text, return_tensors="pt").to(model.device)
24out = model.generate(**enc, max_new_tokens=200, temperature=1.0, top_p=0.9,
25 repetition_penalty=1.05, do_sample=True)
26print(processor.tokenizer.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True))| 版本 | 基座 | 参数量 | 说明 |
|---|---|---|---|
| Qwen2.5-3B-GuCheng(旧) | Qwen2.5-3B-Instruct | 3B | 本地 RTX 4060 训练 |
| Qwen3.8-27B-GuCheng(本仓库) | Qwen3.8-27B | 27B | A100 云服务训练,风格模仿能力更强 |
gucheng_train.jsonl(183 首顾城诗歌,ShareGPT 格式)scripts/sft_style.py(ChineseHardJudgePoem 仓库)1@misc{chinesehardjudgepoem2026,
2 title={ChineseHardJudgePoem: A Hard Dataset for Chinese Poetry Authenticity Discrimination},
3 author={shikunpunk},
4 year={2026},
5 howpublished={\url{https://github.com/shikunpneg/ChineseHardJudgePoem}}
6}