Instructions to use ChisatoY/Qwen2.5-7B-ReWrite with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ChisatoY/Qwen2.5-7B-ReWrite with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ChisatoY/Qwen2.5-7B-ReWrite") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ChisatoY/Qwen2.5-7B-ReWrite") model = AutoModelForCausalLM.from_pretrained("ChisatoY/Qwen2.5-7B-ReWrite", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ChisatoY/Qwen2.5-7B-ReWrite 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 ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M # Run inference directly in the terminal: llama cli -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M # Run inference directly in the terminal: llama cli -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Use Docker
docker model run hf.co/ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use ChisatoY/Qwen2.5-7B-ReWrite with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ChisatoY/Qwen2.5-7B-ReWrite" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ChisatoY/Qwen2.5-7B-ReWrite", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
- SGLang
How to use ChisatoY/Qwen2.5-7B-ReWrite 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 "ChisatoY/Qwen2.5-7B-ReWrite" \ --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": "ChisatoY/Qwen2.5-7B-ReWrite", "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 "ChisatoY/Qwen2.5-7B-ReWrite" \ --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": "ChisatoY/Qwen2.5-7B-ReWrite", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use ChisatoY/Qwen2.5-7B-ReWrite with Ollama:
ollama run hf.co/ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
- Unsloth Studio
How to use ChisatoY/Qwen2.5-7B-ReWrite with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ChisatoY/Qwen2.5-7B-ReWrite to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ChisatoY/Qwen2.5-7B-ReWrite to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ChisatoY/Qwen2.5-7B-ReWrite to start chatting
- Pi
How to use ChisatoY/Qwen2.5-7B-ReWrite with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ChisatoY/Qwen2.5-7B-ReWrite: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:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ChisatoY/Qwen2.5-7B-ReWrite with Docker Model Runner:
docker model run hf.co/ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
- Lemonade
How to use ChisatoY/Qwen2.5-7B-ReWrite with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Run and chat with the model
lemonade run user.Qwen2.5-7B-ReWrite-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use ChisatoY/Qwen2.5-7B-ReWrite with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ChisatoY/Qwen2.5-7B-ReWrite: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:8080/v1 hermes config set model.default ChisatoY/Qwen2.5-7B-ReWrite:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ChisatoY/Qwen2.5-7B-ReWrite with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ChisatoY/Qwen2.5-7B-ReWrite: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:8080/v1 \ --custom-model-id "ChisatoY/Qwen2.5-7B-ReWrite: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"
AI-ReWrite Qwen2.5-7B Humanize
这是一个用于将中英文 AI 风格文本改写为更自然的人类写作风格的模型。模型基于
Qwen2.5-7B-Instruct,通过 LoRA 进行监督微调(SFT),并将最佳 LoRA adapter
完整合并回基础模型。当前目录包含可直接通过 Transformers 加载的 BF16
Safetensors 权重,不需要额外挂载 LoRA adapter。
模型信息
| 项目 | 值 |
|---|---|
| 基础模型 | Qwen2.5-7B-Instruct |
| 模型架构 | Qwen2ForCausalLM |
| 参数规模 | 约 7.6B |
| 导出精度 | BF16 |
| 权重格式 | Safetensors(4 个分片) |
| 上下文上限 | 32,768 tokens |
| 训练最大长度 | 1,024 tokens |
| 最佳 checkpoint | step 2600(epoch 1.968) |
| 最佳验证损失 | 0.641895 |
训练任务
训练数据统一为以下格式:
{
"instruction": "Rewrite the provided text in a natural, human-written style while preserving its original meaning, facts, language, and formatting. Do not add explanations. 请将给定文本改写为自然的人类写作风格,保持原意、事实、语言和格式不变,不要添加解释。",
"input": "需要改写的 AI 风格文本",
"output": "目标人类写作风格文本"
}
训练时使用 Qwen ChatML 模板,将 instruction 作为 system message、input 作为
user message、output 作为 assistant message。损失只计算 assistant 回复部分,system
和 user tokens 均被 mask。
训练数据
清洗合并后共有 43,124 条训练候选数据,按固定随机种子从中划分 42,261 条用于训练、 863 条用于验证(验证比例 2%)。另外保留 100 条英文人工改写数据作为最终测试集, 该测试集没有参与训练、early stopping 或最佳模型选择。
中文数据
中文数据来自 XiangJinYu/Qwen3.5-9B-Humanize-Dataset,共保留 24,999 条:
| 原始文件 | 转换方式 | 保留条数 |
|---|---|---|
v15_sft_18k.jsonl |
input → output |
18,000 |
v16_dpo_4000_formal2000_casual2000.jsonl |
rejected → chosen |
4,000 |
v17next_dpo_1500_clean_no_ckpt.jsonl |
rejected → chosen |
1,000 |
v20_dpo_2000_v18rejected.jsonl |
rejected → chosen |
1,999 |
该数据以中文学术摘要和正式写作为主,数据集标注许可证为 CC BY-NC 4.0。
英文数据
英文训练数据来自 KNipun/ai-humanizer,共保留 18,125 条:
| 原始文件 | 保留条数 |
|---|---|
train_data.jsonl |
16,311 |
val_data.jsonl |
1,814 |
该数据从原始长 prompt 的 Input: 区段中抽取源文本,以 completion 作为目标文本,
数据集标注许可证为 Apache 2.0。
独立测试集
测试集来自 alexreversegpt/ai-writing-tells,包含 100 组人工编写的英文
ai_text → human_text 改写对,数据集标注许可证为 CC BY 4.0。
数据清洗
清洗过程包括:
- 统一中英文 system instruction;
- 将 SFT、DPO 和英文 prompt 数据转换为统一的
instruction/input/output格式; - Unicode NFKC、换行和多余空白规范化;
- 删除空文本、过短或异常超长文本;
- 删除
input与output完全相同的样本; - 删除完全重复的输入输出对;
- 检查训练集与独立测试集不存在完全重复的样本对。
微调超参数
| 超参数 | 值 |
|---|---|
| 训练方法 | LoRA SFT |
LoRA rank (r) |
16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| LoRA bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| LoRA 可训练参数 | 40,370,176(约 0.5273%) |
| 最大序列长度 | 1,024 |
| 单卡训练 batch size | 4 |
| 单卡验证 batch size | 4 |
| 梯度累积步数 | 8 |
| 有效 batch size | 32 |
| 最大 epoch | 3 |
| 实际停止 epoch | 2.4225 |
| 初始学习率 | 1e-4 |
| 学习率调度 | Cosine |
| Warmup ratio | 0.03 |
| Weight decay | 0.01 |
| 最大梯度范数 | 1.0 |
| 优化器 | Fused AdamW (adamw_torch_fused) |
| 训练精度 | BF16,TF32 enabled |
| Attention 实现 | PyTorch SDPA |
| Gradient checkpointing | Enabled,non-reentrant |
| Dynamic batching | 按长度分组 (group_by_length) |
| 随机种子 | 42 |
| 日志间隔 | 10 steps |
| 验证间隔 | 200 steps |
| 保存间隔 | 200 steps |
| Checkpoint 保留数 | 2(最佳与最近) |
| 最佳模型指标 | eval_loss,越低越好 |
| Early stopping patience | 3 次验证 |
训练使用单张 NVIDIA RTX A6000 48 GB GPU。完整训练耗时约 25,515 秒(约 7 小时 5 分钟),吞吐量约 4.97 samples/s。
训练结果
验证损失在 step 2600 达到最低点:
| Step | Epoch | Eval loss |
|---|---|---|
| 200 | 0.151 | 0.681554 |
| 1000 | 0.757 | 0.652373 |
| 1800 | 1.363 | 0.648567 |
| 2200 | 1.666 | 0.645911 |
| 2400 | 1.817 | 0.645167 |
| 2600 | 1.968 | 0.641895 |
| 2800 | 2.120 | 0.661740 |
| 3000 | 2.271 | 0.668160 |
| 3200 | 2.422 | 0.663423 |
step 2600 之后连续三次验证没有改善,因此 early stopping 在 step 3200 终止训练, 并恢复 step 2600 的最佳权重。全程汇总训练损失为 0.652253。
在保留的 100 条英文测试集上,使用 completion-only teacher-forced loss 进行对比:
| 模型 | Test loss | Perplexity |
|---|---|---|
| 原始 Qwen2.5-7B-Instruct | 7.9728 | 2900.89 |
| 本模型 | 3.4172 | 30.48 |
测试 loss 相对下降约 57.14%。由于每个输入只有一个参考改写,该指标适合比较微调前后 的相对变化,不能替代人工评价。
Transformers 使用示例
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "export/best-safetensors"
system_prompt = (
"Rewrite the provided text in a natural, human-written style while preserving "
"its original meaning, facts, language, and formatting. Do not add explanations. "
"请将给定文本改写为自然的人类写作风格,保持原意、事实、语言和格式不变,"
"不要添加解释。"
)
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "需要改写的文本"},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
repetition_penalty=1.05,
)
result = tokenizer.decode(
outputs[0, inputs["input_ids"].shape[1]:],
skip_special_tokens=True,
)
print(result)
已知限制
- 中文训练数据以学术摘要和正式文本为主,对口语、小说、社交媒体等文体覆盖不足。
- 中文输出可能使用半角逗号和句号,这是训练目标文本中的格式特征。
- 模型更擅长压缩句子和简化表达,不一定能完全消除宣传腔、议论文模板或空泛修饰。
- 改写可能引入措辞变化或事实偏移,重要内容应进行人工复核。
- 独立测试集规模较小且只有英文,尚不能代表完整的中英文生成质量。
- 使用本模型时仍需遵守基础模型以及各训练数据集的许可证和使用限制。
- Downloads last month
- -