模型概述
模型特點
模型能力
使用案例
🚀 智寫作-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 聯繫我們。



