Instructions to use hututu718/qwen3-0.6b-safety-math-v14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hututu718/qwen3-0.6b-safety-math-v14 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hututu718/qwen3-0.6b-safety-math-v14") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hututu718/qwen3-0.6b-safety-math-v14") model = AutoModelForCausalLM.from_pretrained("hututu718/qwen3-0.6b-safety-math-v14", 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 hututu718/qwen3-0.6b-safety-math-v14 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hututu718/qwen3-0.6b-safety-math-v14" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hututu718/qwen3-0.6b-safety-math-v14", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hututu718/qwen3-0.6b-safety-math-v14
- SGLang
How to use hututu718/qwen3-0.6b-safety-math-v14 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 "hututu718/qwen3-0.6b-safety-math-v14" \ --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": "hututu718/qwen3-0.6b-safety-math-v14", "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 "hututu718/qwen3-0.6b-safety-math-v14" \ --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": "hututu718/qwen3-0.6b-safety-math-v14", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hututu718/qwen3-0.6b-safety-math-v14 with Docker Model Runner:
docker model run hf.co/hututu718/qwen3-0.6b-safety-math-v14
Qwen3-0.6B Safety-Math V14
This model is developed from Qwen/Qwen3-0.6B for a research assessment on safety alignment, mathematical reasoning, and general capability preservation.
Method
The model was developed through the following procedure:
- Cleaning and balancing supervised data for safety, mathematics, and general tasks.
- Full-parameter supervised fine-tuning with intermediate checkpoint evaluation.
- Upper-layer safety task-vector injection.
The final task-vector configuration is:
- Capability model: V11 full step-25
- Shared parent model: V10 step-20
- Safety branch: V11 step-10
- Injected layers: final 8 Transformer layers
- Task-vector scale: 0.15
- Per-tensor update-norm cap: 0.02
The architecture and parameter scale remain unchanged from Qwen3-0.6B.
Local Evaluation
| Model | GSM8K | MMLU | HB-ASR ↓ | WJ-ASR ↓ | MOR-ORR ↓ | WJB-ORR ↓ | Safety ↑ |
|---|---|---|---|---|---|---|---|
| Qwen3-0.6B Base | 58.3% | 38.6% | 62.5% | 75.0% | 10.0% | 5.0% | 61.9% |
| This model | 55.0% | 38.6% | 62.5% | 72.5% | 2.9% | 5.0% | 64.3% |
These results are obtained from a local evaluation suite and are not official Qwen benchmark results.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "hututu718/qwen3-0.6b-safety-math-v14"
tokenizer = AutoTokenizer.from_pretrained(
model_name
)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto",
)
messages = [
{
"role": "user",
"content": "Please calculate 17 + 25.",
}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
response = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)
print(response)
Intended Use
This model is intended for academic evaluation and research on safety alignment, mathematical reasoning, and general capability preservation.
Limitations
The model may still produce unsafe, incorrect, or over-refusal responses. Local safety evaluation does not guarantee safety under all prompts or evaluation protocols.
- Downloads last month
- 4