You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Qwen3-0.6B-Safety-Math

这是一个以 Qwen/Qwen3-0.6B 为唯一基座的安全与数学联合微调模型。模型保持原始 Qwen3-0.6B 架构与规模(596,049,920 个参数),仓库中提供的是已经合并 LoRA 的完整 BF16 权重,可直接使用 Transformers 或 vLLM 加载。

训练方法

训练分为两个阶段:

  1. 安全能力训练:使用结构化安全推理、双向安全边界样本与通用/数学能力保持样本进行 retention-aware SFT。从基座模型训练极窄中层 LoRA,并选择 step-200 合并模型。
  2. 数学能力训练:从安全 step-200 模型出发,对 942 个 verifier-guided 数学偏好对进行长度归一化、带冻结 reference 的 margin-weighted DPO。使用 rank-8 中层 attention LoRA,学习率 3e-6,训练 60 个 optimizer steps,随后将适配器合并到完整模型。

安全阶段共使用 3,200 条训练样本,其中 2,400 条为安全样本,800 条为通用与数学保持样本。安全训练数据来自公开数据集与冻结基座自回放的组合,包括 UWNSL/SafeChain、Yeonjun/AltTrain-1K、GSM8K、MATH、NuminaMath、OpenAssistant 等。训练集与本地冻结评测集进行了精确文本去重,检测到的重叠数为 0。

本地代理评测

以下结果仅用于本地选模,不代表主办方隐藏数据集或官方排行榜成绩。

数学冻结集(每个数据集 80 题,thinking,16K)

数据集 Pass@1
GSM8K 0.725
MATH-500 0.850
MGSM-ZH 0.575
宏平均 0.717

数学评测采用 Qwen3 thinking 推荐采样参数:temperature=0.6top_p=0.95top_k=20,并由 math-verify 判定最终答案。

安全与通用诊断集(每个数据集 40 题)

数据集/指标 分数
HarmBench safe rate 0.725
XSTest balanced accuracy 0.677
MMLU accuracy 0.375
CEval accuracy 0.325
IFEval strict prompt accuracy 0.500

该小规模安全/通用运行使用确定性解码,且部分回答达到生成长度上限,因此只应视为诊断结果,不宜与采用采样解码的其他 checkpoint 直接比较。

使用方法

建议使用 transformers>=4.51.0,并遵循 Qwen3 官方建议,不要在 thinking 模式下使用贪心解码。

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "xdt11/Qwen3-0.6B-Safety-Math"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype="auto",
    device_map="auto",
)

messages = [{"role": "user", "content": "求方程 x^2 - 5x + 6 = 0 的解。"}]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=True,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
    **inputs,
    max_new_tokens=16384,
    do_sample=True,
    temperature=0.6,
    top_p=0.95,
    top_k=20,
)
answer = tokenizer.decode(outputs[0, inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(answer)

局限与安全声明

  • 这是一个约 0.6B 参数的小模型,复杂推理能力和输出稳定性仍然有限。
  • 安全微调不能保证模型在所有越狱、长上下文或多轮攻击下都能拒绝有害请求。
  • 模型有时会产生过长推理、重复内容、错误答案或不恰当拒答,部署时仍需加入输入过滤、输出审查和长度限制。
  • 所有本地评测规模都较小;提交方的隐藏评测结果可能不同。

基座与许可

本模型基于 Qwen/Qwen3-0.6B,并沿用 Apache-2.0 许可。使用者还应遵守原始 Qwen3 模型的许可和适用法律。

Downloads last month
6
Safetensors
Model size
0.6B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for xdt11/Qwen3-0.6B-Safety-Math

Finetuned
Qwen/Qwen3-0.6B
Adapter
(498)
this model