---
title: Qwen3.5-0.8B-TextPreprocessor
canonical_url: "https://www.modelscope.cn/models/w666j66666/Qwen3.5-0.8B-TextPreprocessor"
md_url: "https://www.modelscope.cn/models/w666j66666/Qwen3.5-0.8B-TextPreprocessor.md"
repository: w666j66666/Qwen3.5-0.8B-TextPreprocessor
last_updated: 2026-11-14
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - qwen3_5
architectures:
  - Qwen3_5ForConditionalGeneration
base_model:
  - Qwen/Qwen3.5-0.8B
base_model_relation: finetune
parameters: 853.0M
tensor_type:
  - F16
library_name:
  - transformer
  - safetensors
language:
  - zh
  - en
downloads: 11
stars: 1
tags:
  - text-cleaning
  - text-normalization
  - distillation
  - qwen3.5
---

# Qwen3.5-0.8B-TextPreprocessor

> Qwen3.5-0.8B-TextPreprocessor - w666j66666 在 ModelScope 开源的模型。Qwen3.5-0.8B-TextPreprocessor

w666j66666/Qwen3.5-0.8B-TextPreprocessor 是 ModelScope 魔搭社区上的 853.0M 参数text-generation模型，采用 apache-2.0 许可，基于 Qwen/Qwen3.5-0.8B 构建。

- **Repository**: w666j66666/Qwen3.5-0.8B-TextPreprocessor
- **License**: apache-2.0
- **Tasks**: text-generation
- **Parameters**: 853.0M
- **Base model**: Qwen/Qwen3.5-0.8B
- **Tags**: text-cleaning, text-normalization, distillation, qwen3.5
- **Downloads**: 11
- **Stars**: 1
- **Last updated**: 2026-11-14

Source: https://www.modelscope.cn/models/w666j66666/Qwen3.5-0.8B-TextPreprocessor

---

# Qwen3.5-0.8B-TextPreprocessor

把用户随手粘贴的**脏文本**清洗成可直接喂给下游大模型的**干净文本**。
蒸馏自 `deepseek-flash`（DeepSeek-V4.1-Flash），底座为 `Qwen/Qwen3.5-0.8B`。

**只改格式，不改内容**：不改写、不纠错、不翻译、不总结、不脱敏。

## 下载

| 平台 | 地址 | 说明 |
|---|---|---|
| ModelScope | https://www.modelscope.cn/models/w666j66666/Qwen3.5-0.8B-TextPreprocessor | 国内推荐，`snapshot_download` 直接拉 |
| Hugging Face | https://huggingface.co/wjwjwjwjwjww/Qwen3.5-0.8B-TextPreprocessor | 国际社区，`from_pretrained` 直接拉 |
| GitHub | https://github.com/wj239951/Qwen3.5-0.8B-TextPreprocessor | 代码、训练/评测脚本、评测数据 |
| 权重打包 | [v1.0.0.zip](https://github.com/wj239951/Qwen3.5-0.8B-TextPreprocessor/releases/download/v1.0.0/Qwen3.5-0.8B-TextPreprocessor-v1.0.0.zip) | 1.34 GB，解压即用 |

## 效果

| 测试集 | 样本数 | 完全一致 | 字符相似度 | 漏删率 | 新增率 |
|---|---|---|---|---|---|
| 规则合成测试集 rule/test | 600 | 91.5% | 0.994 | 0.007 | 0.004 |
| 规则合成测试集（规则基线） rule/test | 600 | 100.0% | 1.000 | 0.000 | 0.000 |
| 老师生成测试集 teacher/test_v3 | 148 | 86.5% | 0.997 | 0.003 | 0.003 |
| 老师生成测试集（规则基线） teacher/test_v3 | 148 | 100.0% | 1.000 | 0.000 | 0.000 |


*规则基线 = `src/cleaner/normalizer.py`，同一套规范的可执行实现。*

## 用法

```python
from transformers import AutoModelForImageTextToText, AutoTokenizer

SYSTEM = ("你是输入文本预处理器。对用户给出的原始文本做清洗规范化：删除不可见字符与噪声、"
          "修复乱码、去掉 HTML 标签、统一全角半角与标点、压缩无意义重复、整理空白与断行。"
          "只改格式不改内容，直接输出清洗后的文本，不要解释。")

repo = "Qwen3.5-0.8B-TextPreprocessor"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype="float16", device_map="auto")

raw = "<p>我我我&nbsp;明天  去北京！！！</p>"
msgs = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": raw}]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
inputs = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# 我明天 去北京！
```

生成参数：**贪心解码**（`do_sample=False`），`max_new_tokens` 取输入长度的 1.4 倍左右。

> 上面这段系统提示词是**训练时的原文，请逐字使用**。其中"修复乱码"一项对应的是
> 规范层的 `repair_mojibake()`，不是本模型的能力——训练数据里不含乱码样本，
> 模型遇到乱码会原样保留（这是刻意的，见下文）。

## 能做什么 / 不能做什么

| 会做 | 不会做 |
|---|---|
| 删零宽字符、BOM、控制符 | **修乱码**（见下） |
| 去 HTML 标签、解码实体 | 纠错别字 |
| 全角字母数字转半角 | 翻译、繁简转换 |
| 中文里的半角标点转全角 | 摘要、扩写、补全 |
| 压缩 ≥3 次的重复字符 | 手机号/邮箱/身份证脱敏 |
| 整理空白、合并排版折断的行 | 调整段落顺序 |
| 判断"这段本来就干净，别动" | 保留表格列对齐 |

### 乱码不是这个模型的活

`æ˜Žå¤©` → `明天` 需要逐字节重排。0.8B 模型学不会这件事，硬教的结果是它记住
"看到乱码就输出一段中文"，进而在真实输入上**凭空编造整段内容**——这比不修危险得多。

所以乱码请在调用本模型之前，用配套的确定性实现处理掉：

```python
from cleaner.normalizer import repair_mojibake, clean

text = repair_mojibake(raw)[0]   # 字节层还原，纯代码，零幻觉
text = clean(text)               # 可选：规则层兜底（纯代码方案）
text = model_clean(text)         # 本模型：格式层
```

完整规则见同目录的 [`TASK_SPEC.md`](TASK_SPEC.md)。

## 训练数据

| 来源 | 规模 | 说明 |
|---|---|---|
| 规则合成 | 9012 | 11 种噪声注入，标签由规则 oracle 精确生成 |
| 老师生成 | 1774 | DeepSeek-V4.1-Flash 造真实脏输入 + 交叉校验 |


**规则合成**：干净种子语料 → 11 种注入器弄脏 → 规则引擎清洗得到标签。注入器与清洗步骤
一一对应，可逆性自检 100%，标签精确。

**老师生成**：DeepSeek-V4.1-Flash 按场景造出真实分布的脏输入，其清洗结果需与规则 oracle
相似度 ≥0.90 才被采用；标签最终以规范为准，用于抓老师"越界改写"。

## 训练细节

| 项 | 值 |
|---|---|
| 底座 | `Qwen/Qwen3.5-0.8B`（Ahmed 结构，24 层混合线性注意力 + 视觉塔，本任务只用文本通道） |
| 方法 | LoRA SFT |
| LoRA | r=16, alpha=32, dropout=0.05, 可训练参数 7.3M |
| 精度 | bfloat16 |
| 序列长度 | 512 |
| 有效 batch | 1x16 |
| 学习率 | 0.0001 |
| epoch | 2.0 |
| 硬件 | NVIDIA GeForce RTX 4060 |
| 峰值显存 | 3.15 GiB |
| 训练步数 | 1348 |

## 局限

- 输入超过约 3000 字时建议分段调用。
- 二次损坏的乱码（如 GBK/UTF-8 反复转码）无法修复，保持原样。
- 表格的列对齐会被空格压缩破坏。
- 对 2 字重复（`去去`、`不不会会`）不做处理：两字叠词在中文里是合法词，误伤代价太高。

## 许可证与致谢

Apache-2.0。底座 `Qwen3.5-0.8B` 由阿里千问开源（Apache-2.0）；
老师 `DeepSeek-V4.1-Flash` 由 DeepSeek 提供，本项目仅将其生成的文本作为训练目标，
老师的权重未参与分发。

生成日期：2026-11-14
