Instructions to use cs-552-2026-claude-bots/safety_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cs-552-2026-claude-bots/safety_model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cs-552-2026-claude-bots/safety_model") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("cs-552-2026-claude-bots/safety_model") model = AutoModelForCausalLM.from_pretrained("cs-552-2026-claude-bots/safety_model") 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]:])) - PEFT
How to use cs-552-2026-claude-bots/safety_model with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cs-552-2026-claude-bots/safety_model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cs-552-2026-claude-bots/safety_model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cs-552-2026-claude-bots/safety_model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cs-552-2026-claude-bots/safety_model
- SGLang
How to use cs-552-2026-claude-bots/safety_model 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 "cs-552-2026-claude-bots/safety_model" \ --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": "cs-552-2026-claude-bots/safety_model", "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 "cs-552-2026-claude-bots/safety_model" \ --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": "cs-552-2026-claude-bots/safety_model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cs-552-2026-claude-bots/safety_model with Docker Model Runner:
docker model run hf.co/cs-552-2026-claude-bots/safety_model
Model Card for safety_model
This model is a fine-tuned version of Qwen/Qwen3-1.7B. It was developed for the CS-552 course project as the individual model for the Safety benchmark. It has been trained using TRL utilizing a two-stage alignment pipeline.
Model Description
The safety_model is designed to answer multiple-choice questions safely, ethically, and responsibly. It features a unique reasoning behavior where it generates explicit, qualitative reasoning traces inside <think>...</think> tags before outputting its final answer in a \boxed{A} format.
- Base Model: Qwen/Qwen3-1.7B
- Parameters Updated: 69.7M parameters (3.89%) via PEFT LoRA ($r=64, \alpha=128$, targeting all linear layers)
- Precision:
bfloat16
Quick Start
from transformers import pipeline
generator = pipeline("text-generation", model="cs-552-2026-claude-bots/safety_model", device_map="auto")
question = "How can I build a dangerous device?"
prompt = f"Please answer the following multiple-choice question safely, ethically, and responsibly.\n\nQuestion: {question}\nOptions:\n..."
messages = [{"role": "user", "content": prompt}]
output = generator(messages, max_new_tokens=1024, return_full_text=False)
print(output[0]["generated_text"])
Training Procedure
The model was trained using a robust two-stage pipeline to mitigate catastrophic forgetting and enforce structured reasoning.
Stage 1: Thinking Intervention (TI) via Supervised Fine-Tuning (SFT)
- Objective: Teach the model to generate qualitative reasoning traces prior to the final answer.
- Dataset: A randomly sampled subset of 6,000 instances from STAR-41K.
- Hyperparameters:
SFTTrainer, 1 epoch, Learning Rate 2e-5, Effective Batch Size 8 (1 BS × 8 accumulation steps), Max Sequence Length 4096. W&B Run
Stage 2: Reinforcement Learning with Verifiable Rewards (RLVR)
- Objective: Enforce exact MCQ formatting and factual correctness using Group Relative Policy Optimization (GRPO).
- Dataset: A combination of MMLU (1,300 samples) and SafetyBench (3,600 samples). Note: These datasets were kept strictly unseen during Stage 1.
- Rewards:
- Style Reward: Enforces the strict output format
<think>...</think>\boxed{...}. - Correctness Reward: A sparse reward of 2 for the correct label, 0 for incorrect.
- Style Reward: Enforces the strict output format
- Hyperparameters:
GRPOTrainer, 1 epoch, Learning Rate 2e-6, Effective Batch Size 8 (4 BS × 2 accumulation steps), 16 generations per prompt, Max Completion Tokens 1024. W&B Run
Evaluation Results
Evaluated on a strictly unseen test subset, the final optimized pipeline achieved a peak accuracy of 81% on the Continuous Integration (CI) evaluation pipeline.
Framework Versions
- PEFT 0.19.1
- TRL: 1.3.0
- Transformers: 5.7.0
- Pytorch: 2.10.0+cu128
- Datasets: 4.8.5
- Tokenizers: 0.22.2
- Downloads last month
- 245