Downloads · 30 days
13
18% of all-time downloads
junshengma/qwen2.5-7b-gzh-writing-qlora
qwen2.5-7b-gzh-writing-qlora is a text generation model from junshengma. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
基于 Qwen2.5-7B-Instruct,用 QLoRA 在单卡 RTX 5090D(32GB)上微调的中文公众号深度长文写作适配器。目标是生成"有思考、有论据、有逻辑论证"的深度评论/科普文章,而非套话堆砌。
Downloads · 30 days
13
18% of all-time downloads
All-time downloads
74
Public
Repo size
173 MB
Likes
0
Public
Click a slice to open those files.
.safetensors162 MB · 93%
From the Hugging Face model README
基于 Qwen2.5-7B-Instruct,用 QLoRA 在单卡 RTX 5090D(32GB)上微调的中文公众号深度长文写作适配器。目标是生成"有思考、有论据、有逻辑论证"的深度评论/科普文章,而非套话堆砌。
| 指标 | 基座 | 本适配器 |
|---|---|---|
| 综合质量分 | 2.44 | 2.47 |
| 论据充分度 | 1.38 | 1.62 |
| 无版式垃圾 | 5.00 | 4.81 |
| 平均正文字数 | 1752 | 2878 |
数据消融实验表明:清洗训练数据(版式噪声 67%→4.5%)后,模型综合分从低于基座(2.09)回升并反超(2.47)。
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
BASE = "Qwen/Qwen2.5-7B-Instruct"
ADAPTER = "junshengma/qwen2.5-7b-gzh-writing-qlora"
bnb = BitsAndBytesConfig(
load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True,
)
tok = AutoTokenizer.from_pretrained(BASE)
model = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=bnb, device_map="cuda:0")
model = PeftModel.from_pretrained(model, ADAPTER)
messages = [
{"role": "system", "content": "你是一位科技领域的深度评论员。请先分析技术趋势背后的产业逻辑与争议点,再撰写一篇有论据、有观点、不蹭热度的科技评论文章。"},
{"role": "user", "content": "主题:AI Agent 会取代 App 吗\n受众:关注科技的互联网从业者\n要求:先输出 <thinking> 再输出 <article>,观点鲜明、有论据"},
]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok(text, return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=3072, temperature=0.7, top_p=0.9, repetition_penalty=1.05, do_sample=True)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
输出格式为 <thinking>规划式思考链</thinking> + <article>正文</article>,推理时可仅取 <article> 部分。
| 参数 | 值 |
|---|---|
| lora_rank / alpha | 16 / 32 |
| learning_rate | 1e-4 (cosine) |
| epochs | 3 |
| cutoff_len | 6144 |
| batch × grad_accum | 1 × 8 |
| optimizer | paged_adamw_8bit |
完整训练/数据管线见 GitHub 仓库:https://github.com/JUNSHENG428/gzh-deep-writing-qlora