模型简介
模型特点
模型能力
使用案例
🚀 智写作-dsr1-14b
智写作-dsr1-14b是基于DeepSeek-R1-Distill-Qwen-14B微调的模型,专门针对创意写作能力进行了优化。通过多项基准测试评估,该模型在创意写作方面表现出显著提升。
🚀 快速开始
本地运行
智写作-dsr1-14b可以部署在多种硬件配置上,包括80GB内存的GPU、单张H20/A800/H800或两张RTX 4090。此外,INT4量化版本智写作-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)
# use bf16
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="auto", trust_remote_code=True, bf16=True).eval()
# use fp16
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="auto", trust_remote_code=True, fp16=True).eval()
# use cpu only
# model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="cpu", trust_remote_code=True).eval()
# use auto mode, automatically select precision based on the device.
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
device_map="auto",
trust_remote_code=True
).eval()
# Specify hyperparameters for generation. But if you use transformers>=4.32.0, there is no need to do this.
# 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 轻松启动服务:
# install vllm
pip install vllm>=0.6.4.post1
# huggingface model id
vllm serve Zhihu-ai/Zhi-writing-dsr1-14b --served-model-name Zhi-writing-dsr1-14b --port 8000
# local path
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 轻松启动服务:
# install SGLang
pip install "sglang[all]>=0.4.5" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer-python
# huggingface model id
python -m sglang.launch_server --model-path Zhihu-ai/Zhi-writing-dsr1-14b --served-model-name Zhi-writing-dsr1-14b --port 8000
# local path
python -m sglang.launch_server --model-path /path/to/model --served-model-name Zhi-writing-dsr1-14b --port 8000
# send request
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
✨ 主要特性
智写作-dsr1-14b在创意写作能力上有显著提升。在 大语言模型创意故事写作基准测试 中,该模型取得了 8.33 分的成绩,而其基础模型仅为 7.8 分。在 写作基准测试 评估框架中,它获得了 8.46 分,优于DeepSeek-R1-Distill-Qwen-14B的 7.93 分。在AlpacaEval数据集上使用GPT-4o进行评估时,与基础模型相比,该模型的胜率达到了 82.6%。
以下是在写作基准测试中不同领域的性能对比图:
📦 安装指南
根据不同的运行方式,安装步骤如下:
- Transformers:安装
transformers
库,代码中已包含从预训练模型加载的相关操作。 - ZhiLight:使用
docker
运行指定镜像。 - vllm:使用
pip install vllm>=0.6.4.post1
安装。 - SGLang:使用
pip install "sglang[all]>=0.4.5" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer-python
安装。 - ollama:通过 此链接 下载。
📚 详细文档
训练过程
数据
该模型的训练语料主要包含三个来源:经过严格筛选的开源数据集、思维链推理语料库以及精心整理的知乎问答对。为了实现最佳的领域覆盖,我们精心平衡了各种数据集的分布,包括 Dolphin-r1、Congliu/中文-DeepSeek-R1-蒸馏数据-110k、OpenThoughts-114k、Light-R1-SFTData 和 Light-R1-DPOData,以及知乎的高质量内容。所有数据集都通过我们的奖励模型(RM)过滤管道进行了全面的质量保证。
训练
- 监督微调(SFT):我们采用课程学习策略进行监督微调。这种有条理的方法系统地提升了创意写作能力,同时融入了不同领域的数据,以保持核心竞争力并减轻灾难性遗忘。
- 直接偏好优化(DPO):对于编辑距离较小的场景,我们使用Step-DPO (arxiv:2406.18629) 有选择地惩罚错误的标记,并在损失函数中纳入了如DPOP (arXiv:2402.13228) 所提出的正约束。
评估结果
评估结果表明,该模型在创意写作能力方面有显著提升。在大语言模型创意故事写作基准测试评估中,该模型取得了 8.33 分的成绩,高于基础模型的 7.87 分。在写作基准测试(一个全面评估大语言模型写作能力的框架)中,该模型获得了 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相比,该模型在创意写作、知识/推理和数学任务方面都保持了平衡的性能表现,这些特点使其可能适用于一系列通用应用。
🔧 技术细节
该模型基于DeepSeek-R1-Distill-Qwen-14B进行微调,在训练过程中采用了课程学习策略进行监督微调,并使用Step-DPO和DPOP进行直接偏好优化。通过精心筛选和平衡多种数据集,以及使用奖励模型过滤管道保证数据质量,使得模型在创意写作和通用能力方面都有提升。
💡 使用建议
- 设置温度在0.5 - 0.7之间(建议0.6),以防止出现无休止的重复或输出不连贯的情况。
- 在评估模型性能时,建议进行多次测试并取结果的平均值。(我们在数学任务中使用
n = 16
和max_tokens = 32768
,在其他任务中使用n = 2
) - 为确保模型像DeepSeek-R1系列模型一样进行深入推理,建议在每个输出的开头强制模型以“
\n”开始响应。
📄 许可证
本项目采用Apache-2.0许可证。
📚 引用
@misc{Zhi-writing-dsr1-14b,
title={Zhi-writing-dsr1-14b: Curriculum Reinforcement and Direct Preference Optimization for Robust Creative Writing in LLMs},
author={Jiewu Wang, Xu Chen, Wenyuan Su, Chao Huang, Hongkui Gao, Lin Feng, Shan Wang, Lu Xu, Penghe Liu, Zebin Ou},
year={2025},
eprint={},
archivePrefix={},
url={https://huggingface.co/Zhihu-ai/Zhi-writing-dsr1-14b},
}
📞 联系我们
如果您有任何问题,请提出问题或通过 ai@zhihu.com 联系我们。



