Instructions to use Yy245/Qwen3-0.6B-SafeMath-ZJU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Yy245/Qwen3-0.6B-SafeMath-ZJU with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Yy245/Qwen3-0.6B-SafeMath-ZJU") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Yy245/Qwen3-0.6B-SafeMath-ZJU") model = AutoModelForCausalLM.from_pretrained("Yy245/Qwen3-0.6B-SafeMath-ZJU", 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
- vLLM
How to use Yy245/Qwen3-0.6B-SafeMath-ZJU with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Yy245/Qwen3-0.6B-SafeMath-ZJU" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Yy245/Qwen3-0.6B-SafeMath-ZJU", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Yy245/Qwen3-0.6B-SafeMath-ZJU
- SGLang
How to use Yy245/Qwen3-0.6B-SafeMath-ZJU 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 "Yy245/Qwen3-0.6B-SafeMath-ZJU" \ --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": "Yy245/Qwen3-0.6B-SafeMath-ZJU", "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 "Yy245/Qwen3-0.6B-SafeMath-ZJU" \ --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": "Yy245/Qwen3-0.6B-SafeMath-ZJU", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Yy245/Qwen3-0.6B-SafeMath-ZJU with Docker Model Runner:
docker model run hf.co/Yy245/Qwen3-0.6B-SafeMath-ZJU
Qwen3-0.6B-SafeMath-ZJU
这是 ZJU 考核最终用于评分的完整合并模型,基于
Qwen/Qwen3-0.6B 进行安全与数学推理联合微调。
模型经过混合 SFT、失败驱动 SFT 和多目标 GRPO 三个阶段,最终选择固定评测加权分最高的
Round 3,而不是后续未通过防遗忘门禁的 Round 2b 或 Round 3b。
模型选择与结果
- 固定基座版本:
c1899de289a04d12100db370d81485cdf75e47ca - 最终模型:Round 3(GRPO)
- 参数量:596,049,920,与基座完全一致
- 权重 SHA-256:
64f97589d3743bfd531adc08863bfaee14c5b3fb3056f0cd023ed28bc4943773 - 安全代理分:79.60%
- 数学均值(GSM8K / MATH-500):36.00%
- 通用均值(MMLU / ARC-Challenge):32.92%
- 加权总分:52.51%,高于 Round 2b 的 52.09% 和 Round 3b 的 51.03%
加权规则为 0.4 × 安全 + 0.3 × 数学 + 0.3 × 通用。详细逐轮结果见
evaluation/model_selection.json,重训分支审计见
evaluation/retrain_comparison.json。
与原始 Qwen3-0.6B 无缝兼容
本仓库上传的是完整合并权重,不需要 PEFT/LoRA 适配器。架构、词表、token ID、聊天模板、
thinking 开关和默认生成配置均与原始 Qwen/Qwen3-0.6B 兼容。原调用代码只需替换模型 ID:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Yy245/Qwen3-0.6B-SafeMath-ZJU"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto",
)
messages = [{"role": "user", "content": "Give me a short introduction to large language models."}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=512)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]
print(tokenizer.decode(output_ids, skip_special_tokens=True))
enable_thinking=False、多轮对话、pipeline、SGLang 和 vLLM 的调用方式也与原模型一致。
例如原 vLLM 命令只需替换模型 ID:
vllm serve Yy245/Qwen3-0.6B-SafeMath-ZJU \
--enable-reasoning --reasoning-parser deepseek_r1
建议使用 transformers>=4.51.0;thinking 模式可沿用原模型的默认采样设置
(temperature 0.6、top-p 0.95、top-k 20)。
训练过程报告
完整的一页 PDF 可在 training_report.pdf 下载。
限制
这些分数来自固定代理评测,并不等同于真实部署中的绝对安全保证。模型仍可能对含糊但无害的 请求过度拒答,也可能在较难数学题、长上下文或分布外输入上生成错误内容;高风险场景应继续 使用独立安全策略、人工复核和领域评测。
- Downloads last month
- -
