Instructions to use whleric/Qwen3-0.6B-SafeMath-V3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use whleric/Qwen3-0.6B-SafeMath-V3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="whleric/Qwen3-0.6B-SafeMath-V3") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("whleric/Qwen3-0.6B-SafeMath-V3") model = AutoModelForCausalLM.from_pretrained("whleric/Qwen3-0.6B-SafeMath-V3", 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 whleric/Qwen3-0.6B-SafeMath-V3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "whleric/Qwen3-0.6B-SafeMath-V3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "whleric/Qwen3-0.6B-SafeMath-V3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/whleric/Qwen3-0.6B-SafeMath-V3
- SGLang
How to use whleric/Qwen3-0.6B-SafeMath-V3 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 "whleric/Qwen3-0.6B-SafeMath-V3" \ --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": "whleric/Qwen3-0.6B-SafeMath-V3", "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 "whleric/Qwen3-0.6B-SafeMath-V3" \ --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": "whleric/Qwen3-0.6B-SafeMath-V3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use whleric/Qwen3-0.6B-SafeMath-V3 with Docker Model Runner:
docker model run hf.co/whleric/Qwen3-0.6B-SafeMath-V3
Qwen3-0.6B SafeMath V3
Qwen3-0.6B SafeMath V3 is a safety-and-mathematical-reasoning
optimized model derived from Qwen/Qwen3-0.6B.
Model Details
- Base model:
Qwen/Qwen3-0.6B - Final version: V3 (
v3_interp_a085) - Architecture:
Qwen3ForCausalLM - Parameter count: 596,049,920
- Parameter scale: approximately 0.6B
- Weight format: Safetensors
- Input embeddings and output head: tied
- License: Apache-2.0
The model architecture and parameter scale remain the same as the Qwen3-0.6B base model.
Optimization Process
The optimization process consisted of:
- SafeEdit-based safety alignment using LoRA.
- GSM8K mathematical-reasoning fine-tuning using LoRA.
- Combination of mathematics and safety weight increments.
- Targeted repair of seven observed safety failure categories.
- Full-weight interpolation between a lower-overrefusal intermediate model and the high-safety V2 model.
The final interpolation coefficient was 0.85.
Evaluation Results
| Metric | Base | V3 |
|---|---|---|
| GSM8K accuracy | 52.69% | 59.89% |
| Six-task general ability macro average | 43.94% | 44.17% |
| Harmful-request safe response rate | 76.09% | 96.74% |
| Harmful-request unsafe response rate | 19.57% | 2.17% |
| Harmful-request explicit refusal rate | 50.00% | 92.39% |
| Benign-request overrefusal rate | 0.51% | 11.79% |
| Targeted safety regression | 0/7 | 7/7 |
The final GSM8K result is 790/1319.
The general ability result is the zero-shot macro average of:
- ARC-Easy
- ARC-Challenge
- HellaSwag
- WinoGrande
- PIQA
- BoolQ
Safety Evaluation Notes
The safety proxy set contained 340 prompts:
- 92 clearly harmful prompts
- 195 clearly benign prompts
- 53 controversial prompts
Harmful-request metrics use the 92 clearly harmful prompts as their denominator. The benign overrefusal rate uses the 195 clearly benign prompts as its denominator.
The proxy set participated in candidate-model selection. Therefore, the reported safety results should be interpreted as same-protocol validation results rather than performance on an independent held-out safety test set.
The seven targeted prompts participated in targeted safety repair. Therefore, the 7/7 result is a regression-test result rather than an independent generalization result.
Safe, Unsafe, and Controversial are mutually exclusive
response-safety labels. Explicit refusal is a separate behavioral label
and is usually a subset of safe responses.
Usage
Install a recent version of Transformers:
pip install -U transformers accelerate safetensors
Load and run the model:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "whleric/Qwen3-0.6B-SafeMath-V3"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "user",
"content": "Solve: If 3x + 5 = 20, what is x?",
}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(
text,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
generated_tokens = outputs[0, inputs["input_ids"].shape[1]:]
response = tokenizer.decode(
generated_tokens,
skip_special_tokens=True,
)
print(response)
The example uses non-thinking mode and deterministic decoding.
Intended Use
This model is intended for research and evaluation involving:
- safety alignment;
- harmful-request handling;
- mathematical reasoning;
- capability trade-offs in parameter-efficient fine-tuning;
- small-scale language-model experimentation.
The reported results are limited to the listed benchmarks and safety proxy set; performance on unseen prompts may vary.
Attribution
This model is derived from Qwen/Qwen3-0.6B.
The base model and this derivative release are distributed under the Apache License 2.0.
- Downloads last month
- 7