Instructions to use beileng/rewrite2-4b-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use beileng/rewrite2-4b-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf beileng/rewrite2-4b-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf beileng/rewrite2-4b-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf beileng/rewrite2-4b-gguf:Q4_K_M
Use Docker
docker model run hf.co/beileng/rewrite2-4b-gguf:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use beileng/rewrite2-4b-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "beileng/rewrite2-4b-gguf" # 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/rewrite2-4b-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/beileng/rewrite2-4b-gguf:Q4_K_M
- Ollama
How to use beileng/rewrite2-4b-gguf with Ollama:
ollama run hf.co/beileng/rewrite2-4b-gguf:Q4_K_M
- Unsloth Desktop
- Pi
How to use beileng/rewrite2-4b-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "beileng/rewrite2-4b-gguf:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use beileng/rewrite2-4b-gguf with Docker Model Runner:
docker model run hf.co/beileng/rewrite2-4b-gguf:Q4_K_M
- Lemonade
How to use beileng/rewrite2-4b-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull beileng/rewrite2-4b-gguf:Q4_K_M
Run and chat with the model
lemonade run user.rewrite2-4b-gguf-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use beileng/rewrite2-4b-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default beileng/rewrite2-4b-gguf:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use beileng/rewrite2-4b-gguf with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf beileng/rewrite2-4b-gguf:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "beileng/rewrite2-4b-gguf:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Rewrite2 4B · GGUF Q8_0 / Q4_K_M
中文小说改写专用 4B 模型的 llama.cpp GGUF。Qwen3.5-4B + V12.5 rewrite-only LoRA 合并后转换;只训练改写,没有扩写。 提供 Q8_0(4.48 GB) 和 Q4_K_M(2.71 GB) 两个文件;4B 在 Q4 已经足够小,所以没有做 Q3。
长度与切分
单段原文建议 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。请直接使用下面的固定提示词:
你是一位小说编辑,正在帮作者改文。请把下面这段小说片段改写成自然、有作者个人风格的中文,保持情节走向、人物设定和主要事件不变。无论原文是否通顺、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 是撞到上限,需要调大或切短。重复惩罚只能降低复读概率,不能完全消除。
快速开始(llama.cpp)
Q8_0:
llama-server \
-m rewrite2-4b-Q8_0.gguf \
-ngl 99 -c 4096 --parallel 1 \
--jinja --no-webui \
--host 0.0.0.0 --port 8080 \
--repeat-penalty 1.08
Q4_K_M 把文件名换成 rewrite2-4b-Q4_K_M.gguf 即可。--jinja 是必须的;GGUF 内嵌的模板已经把生成前缀固定成空 <think></think>,默认不会进入 thinking。
格式与显存
| 文件 | 体积 | 实测进程显存 | 说明 |
|---|---|---|---|
rewrite2-4b-Q8_0.gguf |
4.48 GB | 约 5.7 GB | 更接近 BF16,优先质量 |
rewrite2-4b-Q4_K_M.gguf |
2.71 GB | 约 4.0 GB | 更小更快,压缩/照抄略多 |
同一条 646 字 heldout 输入(temperature 0.7、seed 42、max_tokens 800、repetition_penalty 1.08):
| 版本 | 输出 | 改写率 | 最长照抄 | dup8 | 速度 |
|---|---|---|---|---|---|
| Q8_0 | 587 字 | 35.0% | 19 | 0 | 约 159 tok/s |
| Q4_K_M | 545 字 | 43.0% | 20 | 0 | 约 199 tok/s |
两者都自然收尾。Q4 的输出更短、压缩更明显;要更接近原长度请优先 Q8_0,或按 500–700 字切段。
说明
- 转换:
convert_hf_to_gguf.py --outtype f16 --no-mtp,再llama-quantize生成 Q8_0 / Q4_K_M - 没有内嵌 MTP;GGUF 是纯文本模型,视觉塔不参与
BUILD.json记录来源、量化类型和文件大小;SHA256SUMS提供校验- 输入上限按 4096 context;长文按场景/段落切 500–700 字
全部版本(4B 系列)
| 格式 | 体积 | Hugging Face | ModelScope |
|---|---|---|---|
| BF16 合并 | 8.47 GiB | rewrite2-4b-bf16 | rewrite2-4b-bf16 |
| FP8 W8A8 | 5.15 GiB | rewrite2-4b-fp8 | rewrite2-4b-fp8 |
| NVFP4 W4A4 | 3.70 GiB | rewrite2-4b-nvfp4 | rewrite2-4b-nvfp4 |
| GGUF Q8_0 / Q4_K_M | 4.48 GB / 2.71 GB | rewrite2-4b-gguf | rewrite2-4b-gguf |
4B 是独立实验线,和 27B Rewrite2 权重不通用;27B 见 rewrite2-27b-bf16。
已知限制
- 4B 的容量有限,不要按 27B 的质量预期使用;复杂长段、多人物场景仍建议人工校对。
- 默认压缩改写:800–950 字输入的训练目标中位输出约 540 字(约 0.63 倍);需要全文覆盖时请切段,并在提示词后明确要求覆盖全文。
- 有概率复读或死循环。部署时启用重复惩罚(建议 1.08 起步),同时设置硬性
max_tokens和超时。 - 本版只训练了改写,没有扩写能力;不要使用扩写提示词。
- 视觉塔保留在权重里,但没有做图像训练;本仓库只保证文本改写。
- 低比特量化会放大压缩和复读倾向;Q4_K_M 比 Q8_0 更明显,正式使用前请按自己的文本验收。
- 不保证通用聊天、代码、数学、翻译或跨章节长篇一致性。
- Downloads last month
- 454
4-bit
8-bit