Text Generation
Transformers
Safetensors
Chinese
qwen3_5_text
rewrite4
rewrite4-medium
novel-rewrite
chinese
web-novel
jev
mtp
bf16
conversational
Run this model with HF Jobs
Run beileng/rewrite4-medium-bf16 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/beileng/rewrite4-medium-bf16. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/beileng/rewrite4-medium-bf16 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/beileng/rewrite4-medium-bf16. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/beileng/rewrite4-medium-bf16. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use beileng/rewrite4-medium-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use beileng/rewrite4-medium-bf16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="beileng/rewrite4-medium-bf16") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("beileng/rewrite4-medium-bf16") model = AutoModelForCausalLM.from_pretrained("beileng/rewrite4-medium-bf16", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use beileng/rewrite4-medium-bf16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "beileng/rewrite4-medium-bf16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite4-medium-bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/beileng/rewrite4-medium-bf16
- SGLang
How to use beileng/rewrite4-medium-bf16 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "beileng/rewrite4-medium-bf16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite4-medium-bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "beileng/rewrite4-medium-bf16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite4-medium-bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use beileng/rewrite4-medium-bf16 with Docker Model Runner:
docker model run hf.co/beileng/rewrite4-medium-bf16
docs: add model overview and prompt format guide
Browse files36 unmodified lines3738394041424344454647484950146 unmodified lines19719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625736 unmodified lines </div></div>
## 模型概要
`rewrite4-medium` 是面向中文小说/网文的**「去 AI 味改写」专用模型**(基于 `Qwen/Qwen3.8-27B`,并非从零创作或续写模型)。
它的典型工作流是接收一段大模型直出的劣化小说正文(逐句末尾附带 `jevnovel3 0.8B` 打出的 AI 八股概率 `【0.xxx】`,无打分器时也可填 `【NA】`),先像真人编辑一样输出**改写思维链**,逐段诊断八股套话、翻译腔、动作拆解与节奏问题,再在 `</think>` 之后输出**大方向与人设不变、语言自然有活人感的改写正文**。
相比上一代 `rewrite3`,本代核心升级在于 **NSFW 表达特化**、**前端状态栏/HTML 标签无损保持**与**多语种/方言保持**,并在 `v15` 数据集(已同步开源至 [beileng/rewrite-v15](https://huggingface.co/datasets/beileng/rewrite-v15))上采用了按模块有效秩定制的分层 LoRA 与 On-policy KL 蒸馏 MTP 投机头。
## 推荐版本与家族规划
本仓库是 **BF16** 版本,权重 **54.7 GB(50.9 GiB)**。146 unmodified lines- 低比特格式(特别是 3-bit GGUF)在长上下文下仍可能轻微放大偶发复读或细节偏移,正式使用前建议先拿自己的文本抽测几条。- 模型继承基座模型的局限性与输入文本倾向,**仅用作研究需求,请勿用于任何违法违纪内容生成**。本仓库权重遵循 Apache-2.0 协议,具体许可条款以 Qwen 官方规定为准。
## 提示词结构与拼接方式
本模型训练与生产均采用**单条 `user` 消息**(不使用 `system` 角色),将本仓库自带的 `INSTRUCTION.txt` 全文与带句级打分标记的原文**直接字符串拼接**(`INSTRUCTION.txt` 末尾已自带 `原文:
`,中间无需再加额外分隔符):
```text<INSTRUCTION.txt 全文(以 "原文:
" 结尾)><带【分数】标记的小说正文>```
### 1. 输入正文标记格式示例
每句(或每个切分单元)末尾紧跟 `【0.000】`~`【1.000】` 的 `jevnovel3 0.8B` 劣质概率;如果没有部署打分器,直接在句尾或段尾填 `【NA】` 即可:
```text(有 jevnovel 打分器)雨下大了,敲在窗玻璃上噼啪作响。【0.042】他的眼神中闪过一丝不易察觉的复杂情绪,仿佛压抑着某种深沉的悸动。【0.785】“进来吧,别淋湿了。”【0.018】
(无打分器时的降级写法)雨下大了,敲在窗玻璃上噼啪作响。【NA】他的眼神中闪过一丝不易察觉的复杂情绪,仿佛压抑着某种深沉的悸动。【NA】“进来吧,别淋湿了。”【NA】```
### 2. Python / OpenAI 兼容 API 拼接与切分示例
```pythonfrom pathlib import Pathfrom openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8893/v1", api_key="EMPTY")instruction = Path("INSTRUCTION.txt").read_text(encoding="utf-8")marked_text = "雨下大了,敲在窗玻璃上噼啪作响。【0.042】……"
resp = client.chat.completions.create( model="rewrite4-medium", messages=[{"role": "user", "content": instruction + marked_text}], temperature=0.85, top_p=0.90, extra_body={"top_k": 20, "repetition_penalty": 1.0}, max_tokens=10240,)
raw = resp.choices[0].message.contentcot, rewritten_body = raw.split("</think>", 1) if "</think>" in raw else ("", raw)print(rewritten_body.strip())```
> 再次提醒:请务必使用**本仓库自带的最新版 `INSTRUCTION.txt`**,不要混用 `rewrite3` 的旧提示词,也不要将 `INSTRUCTION.txt` 拆到 `system` 角色里。
## 文件清单
本仓库(BF16)包含 `model-00001-of-00014.safetensors` … `model-00014-of-00014.safetensors`、内嵌 MTP 权重 `mtp.safetensors`、`MTP_EMBED_INFO.json`、`config.json`、`generation_config.json`、`model.safetensors.index.json`、`tokenizer.json`、`tokenizer_config.json`、`chat_template.jinja`、`INSTRUCTION.txt`。README.md+63