Run this model with HF Jobs

Run beileng/rewrite2-4b-fp8 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/rewrite2-4b-fp8. 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/rewrite2-4b-fp8 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/rewrite2-4b-fp8. 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/rewrite2-4b-fp8. 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.
File size: 5,965 Bytes
4ef2841
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a316ab8
4ef2841
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a316ab8
 
 
 
4ef2841
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
language:
- zh
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
tags:
- rewrite2
- novel-rewrite
- qwen3.5
- 4b
- fp8
---

# Rewrite2 4B · FP8 W8A8

> 中文小说**改写专用** 4B 模型。Qwen3.5-4B + V12.5 rewrite-only LoRA 合并后量化;只训练改写,没有扩写。
> 本仓库是 **FP8 W8A8**,约 5.5 GB(5.15 GiB)。ModelOpt 0.47.0 FP8 W8A8(e4m3),校准 128 条 V12.5 原文;排除 vision、MTP、linear_attn 的 conv1d / in_proj_a / in_proj_b 和 lm_head/embed_tokens。

## 长度与切分

> **单段原文建议 500–1,200 汉字。** 1,200–1,500 汉字可用,但输出会更压缩、连续照抄和重复风险会上升;超过 1,500 汉字建议按场景/段落切成 500–700 字后再逐段输入。模型默认是**压缩式改写**,不是等长改写。
>
> 在 1,000–1,300 字的 heldout 小测里,改写率和 700–1,000 字基本一致;长输入的主要代价不是“改不动”,而是输出变短(约为原文的 0.6–0.9 倍)和连续照抄变多。

| 原文长度 | 建议 |
|---|---|
| ≤ 1,200 字 | 单段直接输入 |
| 1,200–1,500 字 | 可用;`max_tokens` 给到 1500–1600,抽查长度比和照抄 |
| > 1,500 字 | 按场景/段落切 500–700 字,逐段改写后拼接 |

## 必用提示词

这个模型是任务特化 SFT,不是通用润色助手。训练时只有一条 user 消息,没有 system prompt,也没有 thinking。请直接使用下面的固定提示词:

```text
你是一位小说编辑,正在帮作者改文。请把下面这段小说片段改写成自然、有作者个人风格的中文,保持情节走向、人物设定和主要事件不变。无论原文是否通顺、AI味是轻是重,都要重新组织语言,禁止连续照抄原文超过15字;原文越好,越要用同义改写而不是照搬。

原文:
```

拼接方式:`INSTRUCTION_rewrite.txt` 的内容 + 原文,直接作为一条 user 消息。仓库内附 `INSTRUCTION_rewrite.txt`。**不要**把 `enable_thinking` 当成开关:模板已经固定为空 `<think>\n\n</think>\n\n`,模型只输出正文。

## 推荐参数

| 项目 | 建议 |
|---|---|
| temperature | `0.7`;固定复现实验用 `0` |
| top_p | `0.9` |
| top_k | `50`(vLLM / llama.cpp 支持时) |
| max_tokens | 改写 1200;1,200–1,500 字输入用 1500–1600 |
| 重复惩罚 | `repetition_penalty=1.08` 起步;llama.cpp `--repeat-penalty 1.08` |
| 原文长度 | 单段 500–1,200 汉字;超过就切 |

看 `finish_reason`:`stop` 是自然收尾,`length` 是撞到上限,需要调大或切短。重复惩罚只能降低复读概率,不能完全消除。


## 快速开始(vLLM)

```bash
vllm serve /path/to/rewrite2-4B-fp8 \
  --served-model-name rewrite2-4b-fp8 \
  --trust-remote-code \
  --max-model-len 4096 \
  --gpu-memory-utilization 0.40
```

vLLM 会自动识别 ModelOpt 的 `FP8 W8A8` 配置;如果提示未知量化,请加 `--quantization modelopt_fp8`。

## 格式与显存

| 项 | 本仓库 |
|---|---|
| 版本 | FP8 W8A8 |
| 权重 | 约 5.5 GB(5.15 GiB) |
| 推理权重显存 | 约 5.35 GiB 权重 |
| 建议 | 16GB 级显卡;NVFP4 在 Blackwell 上收益最大 |
| 推理栈 | vLLM(ModelOpt 量化格式) |

- `model.safetensors`、`config.json`、`hf_quant_config.json`、`generation_config.json`
- `tokenizer.json`、`tokenizer_config.json`、`chat_template.jinja`
- `preprocessor_config.json`、`video_preprocessor_config.json`、`processor_config.json`
- `INSTRUCTION_rewrite.txt`、`README.md`、`SHA256SUMS`

## 验证

同一条 646 字 heldout 输入(temperature 0.7、seed 42、max_tokens 800、repetition_penalty 1.08):

- FP8 W8A8:输出 903 字,改写率 42.3%,`dup8` 0,自然收尾
- 两条都正常加载并生成;量化后的差异主要是输出长度和照抄率,不是格式错误

## 训练概况

- 基座:`Qwen/Qwen3.5-4B`,revision `851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a`
- 数据:V12.5 clean,25,647 条纯 rewrite;LoRA rank 32、1 epoch、2,934 steps
- 量化:ModelOpt 0.47.0,校准 128 条 V12.5 原文;没有 KV cache 量化

## 全部版本(4B 系列)

| 格式 | 体积 | Hugging Face | ModelScope |
|---|---:|---|---|
| BF16 合并 | 8.47 GiB | [rewrite2-4b-bf16](https://huggingface.co/aikexue170/rewrite2-4b-bf16) | [rewrite2-4b-bf16](https://modelscope.cn/models/alkaid55555/rewrite2-4b-bf16) |
| FP8 W8A8 | 5.15 GiB | [rewrite2-4b-fp8](https://huggingface.co/aikexue170/rewrite2-4b-fp8) | [rewrite2-4b-fp8](https://modelscope.cn/models/alkaid55555/rewrite2-4b-fp8) |
| NVFP4 W4A4 | 3.70 GiB | [rewrite2-4b-nvfp4](https://huggingface.co/aikexue170/rewrite2-4b-nvfp4) | [rewrite2-4b-nvfp4](https://modelscope.cn/models/alkaid55555/rewrite2-4b-nvfp4) |
| GGUF Q8_0 / Q4_K_M | 4.48 GB / 2.71 GB | [rewrite2-4b-gguf](https://huggingface.co/aikexue170/rewrite2-4b-gguf) | [rewrite2-4b-gguf](https://modelscope.cn/models/alkaid55555/rewrite2-4b-gguf) |

4B 是独立实验线,和 27B Rewrite2 权重不通用;27B 见 [rewrite2-27b-bf16](https://huggingface.co/aikexue170/rewrite2-27b-bf16)。

## 已知限制

- 4B 的容量有限,不要按 27B 的质量预期使用;复杂长段、多人物场景仍建议人工校对。
- 默认压缩改写:800–950 字输入的训练目标中位输出约 540 字(约 0.63 倍);需要全文覆盖时请切段,并在提示词后明确要求覆盖全文。
- 有概率复读或死循环。部署时启用重复惩罚(建议 1.08 起步),同时设置硬性 `max_tokens` 和超时。
- 本版只训练了改写,**没有扩写能力**;不要使用扩写提示词。
- 视觉塔保留在权重里,但没有做图像训练;本仓库只保证文本改写。
- 低比特量化会放大压缩和复读倾向;Q4_K_M 比 Q8_0 更明显,正式使用前请按自己的文本验收。
- 不保证通用聊天、代码、数学、翻译或跨章节长篇一致性。