---
title: WSAI-Math
canonical_url: "https://www.modelscope.cn/models/wangshenai/WSAI-Math"
md_url: "https://www.modelscope.cn/models/wangshenai/WSAI-Math.md"
repository: wangshenai/WSAI-Math
chinese_name: WSAI-Math
last_updated: 2026-08-30
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: adapter
parameters: 853.0M
tensor_type:
  - BF16
library_name:
  - pytorch
  - transformer
  - lora
  - safetensors
language:
  - en
downloads: 12
stars: 1
tags:
  - mathematics
  - reasoning
  - chain-of-thought
  - distillation
  - sft
  - lora
  - decontaminated
  - ollama
---

# WSAI-Math

> WSAI-Math - wangshenai 在 ModelScope 开源的模型。WSAI-Math 是 WSAI 开发的数学推理大语言模型，基于 Qwen3.5-0.8B 后训练而成：以 DeepSeek-V4-Flash 为教师进行长思维链训练冷启动，训练数据逐条经最严格原始口径判分验证，并对评测集实施 8-gram 去污染。模型采用 LoRA SFT（r=64，仅训练 2.91% 参数），从 3,867 条严格验证的蒸馏思维链中抽样 1,410 条训练 50 步，以 BF16…

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

- **Repository**: wangshenai/WSAI-Math
- **License**: apache-2.0
- **Tasks**: text-generation
- **Parameters**: 853.0M
- **Base model**: Qwen/Qwen3.5-0.8B
- **Tags**: mathematics, reasoning, chain-of-thought, distillation, sft, lora, decontaminated, ollama
- **Downloads**: 12
- **Stars**: 1
- **Last updated**: 2026-08-30

Source: https://www.modelscope.cn/models/wangshenai/WSAI-Math

---

# WSAI-Math

**WSAI-Math** 是由 WSAI 开发的数学推理大语言模型，基于 [Qwen/Qwen3.5-0.8B](https://modelscope.cn/models/Qwen/Qwen3.5-0.8B) 后训练而成：以 DeepSeek `deepseek-v4-flash` 为教师进行长思维链（long chain-of-thought）蒸馏冷启动，训练数据每一条都经过**最严格原始口径判分**验证，并对评测集实施 8-gram 去污染。

- **Ollama**：`ollama run wangshen/wsai-math`
- **数据集**：[WSAI-Math-Distill]([WSAI-Math-Distill](https://modelscope.cn/datasets/wangshenai/WSAI-Math-Distill))—— 3,867 条严格验证的 v4-flash 蒸馏思维链
- **精度**：BF16 全量权重

## 模型信息

| 项    | 值                                                                                                                                     |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------- |
| 基座   | Qwen3.5-0.8B（0.85B 参数；Qwen3-Next 风格混合线性注意力架构：Gated DeltaNet 线性注意力与全注意力按 3:1 交错，24 层，GQA 8H/2KV，head_dim 256，词表 248,320，原生上下文 262,144） |
| 参数量  | 878,544,960（其中可训练 25,559,040，占 2.91%）                                                                                                 |
| 权重精度 | bfloat16（LoRA 合并后的全量权重，`model.safetensors` 1.7GB）                                                                                     |
| 训练方法 | LoRA SFT（r=64, α=128, dropout=0，注入全部 q/k/v/o/gate/up/down 投影）→ `merge_and_unload` 导出                                                  |
| 训练数据 | WSAI-Math-Distill v1.0 的 1,410 条子集（自 3,867 条严格验证样本按固定种子抽样）                                                                            |
| 训练量  | 50 个优化步（有效 batch 16，共见约 800 条样本，1,410 条中的 57%）                                                                                        |
| 验证损失 | val_loss = 0.711（固定 1% 验证集，n=14，与训练 loss 同步下降，无过拟合）                                                                                   |

## 训练流水线

```
OpenR1-Math-220k（93,733 题，AoPS/竞赛来源，Apache-2.0）
  │ 题面清洗：去空 / md5 去重 / 长度过滤(≤2500字符) / 来源筛选(amc_aime·olympiads·aops_forum)
  ▼
候选题池
  │ 8-gram 去污染 vs AIME2024(30) + AIME2025(30) + HLE文本全集(2,158)
  │ ——指纹 264,265 个，剔除 3,444 题
  ▼
干净题库（6,245 题，均带 gold 标准答案）
  │ DeepSeek v4-flash 逐题蒸馏（thinking 模式，max_tokens=16384，共 6,449 次求解）
  ▼
严格判分（见下）—— 61% 通过 → 3,867 条验证正确（WSAI-Math-Distill）
  │ 固定种子抽样 1,410 条 + 质量过滤（reasoning 800–30,000 字符）
  ▼
LoRA SFT（50 步）→ 合并导出 → WSAI-Math
```

**严格判分协议**（训练数据与评测同口径）：

1. 仅提取回答中**最后一个** `\boxed{...}` 的内容作为预测；
2. 与 gold 按精确字符串 / math_verify（无预处理）/ 纯数字精确相等三判，全过才记正确；
3. **零规范化**：不补 LaTeX 花括号、不去 `\text{}` 包裹、不剥选项字母、不提取子串数字、无模糊匹配——格式不同即判错，宁缺毋滥。

## 评测结果

**协议**：thinking 模式，Qwen 官方采样参数（temperature=1.0, top_p=0.95, top_k=20, min_p=0），每题 1 采样，最大生成 5120 token，批生成，本地 CPU bf16 推理。

### AIME

| 基准                | WSAI-Math | 基座 Qwen3.5-0.8B | 提升幅度   |
| ----------------- | --------- | --------------- | ------ |
| AIME 2024 (avg@1) | **3.3%**  | 0.0%            | +3.3pp |
| AIME 2025 (avg@1) | 0.0%      | 0.0%            | —      |

**行为学对比**（同协议，更显著的差异）：

| 观测项           | WSAI-Math                             | 基座 Qwen3.5-0.8B                      |
| ------------- | ------------------------------------- | ------------------------------------ |
| AIME24/25 截断率 | 43% / 77%                             | **100% / 100%**（60/60 全部打转至 5120 上限） |
| 平均输出长度        | 3,552 / 4,328 tok                     | 5,120 / 5,120 tok（全部打满）              |
| 思维链风格         | 教师化：简练、直奔要点、复核关键计算、`\boxed{}` 收尾、干净终止 | 大量"Wait…"原地循环，无法收敛                   |
| 简单数学（如 17×23） | 146 token 直出 `\boxed{391}`            | 数百 token 徘徊后勉强作答                     |

## 使用

### Ollama

```bash
ollama run wangshen/wsai-math:latest
```

### transformers

```python
from transformers import AutoTokenizer, AutoModelForImageTextToText
import torch

tok = AutoTokenizer.from_pretrained("WSAI-Math")
model = AutoModelForImageTextToText.from_pretrained(
    "WSAI-Math", dtype=torch.bfloat16, device_map="cpu")

messages = [{"role": "user", "content": "您的数学题"}]
text = tok.apply_chat_template(messages, tokenize=False,
                               add_generation_prompt=True, enable_thinking=True)
inputs = tok(text, return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=5120,
                     do_sample=True, temperature=1.0, top_p=0.95, top_k=20)
```

思维链位于 `<think>...</think>`，最终答案以 `\boxed{...}` 给出。

## 训练细节

- **损失**：仅对 assistant 段计算（`<think>` 思维链 + 解答），prompt 全掩码；
- **大词表处理**：248,320 词表的 logits 分块计算（chunk=1024）并用 gradient checkpoint 包裹反向重算，将峰值内存从全量 materialize 的 ~8GB 压到 <1GB；
- **优化器**：AdamW（β=0.9/0.95, eps=1e-8, lr=1e-4, 无 weight decay），梯度裁剪 1.0，有效 batch 16（micro-batch 2 × 累积 8）；
- **监控**：每 micro 步打印 loss 与 ema20，每 10 优化步评估固定验证集（1% 切分，种子固定可复现），每 25 步存档；
- **损失轨迹**：train ema20 从 1.10 稳定降至 ~0.64-0.73 区间，val_loss 0.711。

## 致谢

- 基座：[Qwen/Qwen3.5-0.8B](https://modelscope.cn/models/Qwen/Qwen3.5-0.8B)
- 教师：DeepSeek `deepseek-v4-flash`
- 题源：open-r1/OpenR1-Math-220k（Apache-2.0，派生自 NuminaMath）

## 许可

Apache-2.0
