模型简介
模型特点
模型能力
使用案例
license: apache-2.0 datasets:
- Congliu/Chinese-DeepSeek-R1蒸馏数据-110k
- cognitivecomputations/dolphin-r1
- open-thoughts/OpenThoughts-114k
- qihoo360/轻量级R1-SFT数据
- qihoo360/轻量级R1-DPO数据 language:
- 中文
- 英文 base_model:
- 知乎/Zhi-writing-dsr1-14b tags:
- qwen2 library_name: transformers
Zhi-writing-dsr1-14b
1. 模型简介
Zhi-writing-dsr1-14b是基于DeepSeek-R1-Distill-Qwen-14B微调的创作增强模型。多项基准测试表明该模型在创意写作能力上有所提升。
在LLM创意故事写作基准测试中,模型得分为8.33,优于基础模型的7.8。在WritingBench评估框架下得分为8.46,较DeepSeek-R1-Distill-Qwen-14B的7.93有所提升。使用GPT-4o在AlpacaEval数据集上的评估显示,相比基础模型获得了**82.6%**的胜率。
下图展示了WritingBench各领域表现对比:
2. 训练过程
数据构成
训练语料包含三大来源:严格筛选的开源数据集、思维链推理语料以及知乎精选问答对。
为实现最优领域覆盖,我们精心平衡了Dolphin-r1、Congliu/Chinese-DeepSeek-R1-Distill-data-110k、OpenThoughts-114k、Light-R1-SFTData和Light-R1-DPOData等数据集分布,并融合知乎优质内容。所有数据均通过奖励模型(RM)过滤管道完成质量验证。
训练方法
监督微调(SFT):采用课程学习策略进行监督微调,系统化提升创意写作能力,同时融入多领域数据保持核心能力,避免灾难性遗忘。
直接偏好优化(DPO):针对最小编辑距离场景,使用Step-DPO(arxiv:2406.18629)选择性惩罚错误token,同时结合DPOP(arXiv:2402.13228)在损失函数中加入正向约束。
3. 评估结果
评估显示模型创意写作能力显著提升。在LLM创意故事写作基准测试中得分为8.33,较基础模型7.87有所提高。在综合性大模型写作能力评估框架WritingBench中取得8.46分,接近DeepSeek-R1表现,优于DeepSeek-R1-Distill-Qwen-14B的7.93分。
通用能力方面,评估显示在知识推理任务(CMMLU, MMLU-Pro)上有2%-5%提升,在AIME-2024、AIME-2025和GSM8K等数学推理基准上也取得进展。结果表明模型在创意写作、知识推理和数学任务上较DeepSeek-R1-Distill-Qwen-14B保持均衡提升,适合多种通用场景。
4. 本地运行指南
Zhi-writing-dsr1-14b可部署于80GB显存GPU、单卡H20/A800/H800或双RTX 4090。INT4量化版本Zhi-writing-dsr1-14b-gptq-int4可单卡RTX 4090部署。
Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation import GenerationConfig
MODEL_NAME = "Zhihu-ai/Zhi-writing-dsr1-14b"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
# 使用bf16
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="auto", trust_remote_code=True, bf16=True).eval()
# 使用fp16
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="auto", trust_remote_code=True, fp16=True).eval()
# 仅使用CPU
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="cpu", trust_remote_code=True).eval()
# 自动模式,根据设备自动选择精度
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
device_map="auto",
trust_remote_code=True
).eval()
# 指定生成超参数。若使用transformers>=4.32.0则无需此操作
# model.generation_config = GenerationConfig.from_pretrained(MODEL_NAME, trust_remote_code=True)
generate_configs = {
"temperature": 0.6,
"do_sample": True,
"top_p": 0.95,
"max_new_tokens": 4096
}
prompt = "请你以鲁迅的口吻,写一篇介绍西湖醋鱼的文章"
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
**generate_configs
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
ZhiLight
可通过ZhiLight快速启动服务
docker run -it --net=host --gpus='"device=0"' -v /path/to/model:/mnt/models --entrypoints="" ghcr.io/zhihu/zhilight/zhilight:0.4.17-cu124 python -m zhilight.server.openai.entrypoints.api_server --model-path /mnt/models --port 8000 --enable-reasoning --reasoning-parser deepseek-r1 --served-model-name Zhi-writing-dsr1-14b
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Zhi-writing-dsr1-14b",
"prompt": "请你以鲁迅的口吻,写一篇介绍西湖醋鱼的文章",
"max_tokens": 4096,
"temperature": 0.6,
"top_p": 0.95
}'
vllm
例如可通过vLLM快速启动服务
# 安装vllm
pip install vllm>=0.6.4.post1
# huggingface模型ID
vllm serve Zhihu-ai/Zhi-writing-dsr1-14b --served-model-name Zhi-writing-dsr1-14b --port 8000
# 本地路径
vllm serve /path/to/model --served-model-name Zhi-writing-dsr1-14b --port 8000
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Zhi-writing-dsr1-14b",
"prompt": "请你以鲁迅的口吻,写一篇介绍西湖醋鱼的文章",
"max_tokens": 4096,
"temperature": 0.6,
"top_p": 0.95
}'
SGLang
也可通过SGLang快速启动服务
# 安装SGLang
pip install "sglang[all]>=0.4.5" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer-python
# huggingface模型ID
python -m sglang.launch_server --model-path Zhihu-ai/Zhi-writing-dsr1-14b --served-model-name Zhi-writing-dsr1-14b --port 8000
# 本地路径
python -m sglang.launch_server --model-path /path/to/model --served-model-name Zhi-writing-dsr1-14b --port 8000
# 发送请求
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Zhi-writing-dsr1-14b",
"prompt": "请你以鲁迅的口吻,写一篇介绍西湖醋鱼的文章",
"max_tokens": 4096,
"temperature": 0.6,
"top_p": 0.95
}'
ollama
可通过此链接下载ollama
- 量化版本: Q4_K_M
ollama run zhihu/zhi-writing-dsr1-14b
- bf16版本
ollama run zhihu/zhi-writing-dsr1-14b:bf16
5. 使用建议
建议遵循以下配置使用Zhi-writing-dsr1-14b(包括基准测试)以获得预期效果:
-
温度值建议设置在0.5-0.7之间(推荐0.6),避免无限循环或逻辑混乱
-
评估模型性能时建议多次测试取平均值(数学任务使用
n=16
和max_tokens=32768
,其他任务n=2
) -
为确保模型像DeepSeek-R1系列一样充分推理,建议强制模型在每次输出开头添加"<think>\n"
6. 引用文献
@misc{Zhi-writing-dsr1-14b,
title={Zhi-writing-dsr1-14b: 基于课程强化学习与直接偏好优化的大模型稳健创作框架},
author={王杰武, 陈旭, 苏文渊, 黄超, 高宏奎, 冯琳, 王山, 徐璐, 刘鹏鹤, 欧泽彬},
year={2025},
eprint={},
archivePrefix={},
url={https://huggingface.co/Zhihu-ai/Zhi-writing-dsr1-14b},
}
7. 联系我们
如有疑问请提交issue或发送邮件至ai@zhihu.com


