Downloads · 30 days
21
12% of all-time downloads
ahczhg/deepseek-r1-distill-qwen-1.5b-aegis-safety-lora
deepseek-r1-distill-qwen-1.5b-aegis-safety-lora is a text generation model from ahczhg. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
This is a fine-tuned version of DeepSeek-R1-Distill-Qwen-1.5B, specialized for content safety and moderation tasks. The model was fine-tuned using LoRA (Low-Rank Adaptation) on the NVIDIA Aegis AI Content Safety Datas…
Downloads · 30 days
21
12% of all-time downloads
All-time downloads
181
Public
Parameters
1.8B
3.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.6 GB · 100%
From the Hugging Face model README
This is a fine-tuned version of DeepSeek-R1-Distill-Qwen-1.5B, specialized for content safety and moderation tasks. The model was fine-tuned using LoRA (Low-Rank Adaptation) on the NVIDIA Aegis AI Content Safety Dataset 2.0, which contains diverse examples of safe and unsafe content across multiple categories.
DeepSeek-R1-Distill-Qwen-1.5B is a distilled version of DeepSeek-R1, optimized for efficiency while maintaining strong reasoning and language understanding capabilities. This makes it ideal for content moderation tasks that require both speed and accuracy.
| Metric | Value |
|---|---|
| Average Perplexity | 14.20 |
| Training Time | 13.71 minutes |
| Training Samples | 1000 |
| Evaluation Samples | 100 |
| Training Epochs | 3 |
| GPU Used | NVIDIA T4 (Google Colab) |
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projpip install transformers torch peft accelerate bitsandbytes
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
# Configure 4-bit quantization for memory efficiency
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True
)
# Load model and tokenizer
model_name = "ahczhg/deepseek-r1-distill-qwen-1.5b-aegis-safety-lora"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
# Example: Content safety check
prompt = """### Instruction:
Analyze this content for safety: 'Hello! How can I help you today?'
### Response:
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=128,
temperature=0.7,
do_sample=True,
top_p=0.95
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
from transformers import pipeline
import torch
# Create text generation pipeline
generator = pipeline(
"text-generation",
model="ahczhg/deepseek-r1-distill-qwen-1.5b-aegis-safety-lora",
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
# Generate safety analysis
prompt = "### Instruction:\nIs this content safe? 'Let's collaborate on this project!'\n\n### Response:\n"
result = generator(
prompt,
max_new_tokens=128,
temperature=0.7,
do_sample=True,
top_p=0.95
)
print(result[0]['generated_text'])
# Process multiple content items
content_items = [
"Hello, how are you?",
"Let's work together!",
"I appreciate your help."
]
for content in content_items:
prompt = f"### Instruction:\nAnalyze this content for safety: '{content}'\n\n### Response:\n"
result = generator(prompt, max_new_tokens=128, do_sample=True, temperature=0.7)
print(f"Content: {content}")
print(f"Analysis: {result[0]['generated_text'].split('### Response:')[-1].strip()}")
print("-" * 80)
class ContentSafetyChecker:
def __init__(self, model_name="ahczhg/deepseek-r1-distill-qwen-1.5b-aegis-safety-lora"):
self.generator = pipeline(
"text-generation",
model=model_name,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
def check_safety(self, content: str) -> dict:
prompt = f"""### Instruction:
Analyze this content for safety and provide a classification (safe/unsafe): '{content}'
### Response:
"""
result = self.generator(
prompt,
max_new_tokens=128,
temperature=0.3, # Lower temperature for more consistent classification
do_sample=True
)
response = result[0]['generated_text'].split('### Response:')[-1].strip()
return {{
'content': content,
'analysis': response,
'is_safe': 'safe' in response.lower() and 'unsafe' not in response.lower()
}}
# Usage
checker = ContentSafetyChecker()
result = checker.check_safety("Hello, nice to meet you!")
print(f"Safe: {result['is_safe']}")
print(f"Analysis: {result['analysis']}")
The model was evaluated on a held-out test set from the Aegis AI Content Safety Dataset:
The model was fine-tuned on the NVIDIA Aegis AI Content Safety Dataset 2.0, which includes:
Training Subset: 1000 samples randomly selected from the full dataset
If you use this model in your research or applications, please cite:
@misc{{deepseek_r1_distill_qwen_safety,
author = {{ahczhg}},
title = {{DeepSeek-R1-Distill-Qwen-1.5B Fine-tuned for Content Safety}},
year = {{2025}},
publisher = {{HuggingFace}},
howpublished = {{\url{{ahczhg/deepseek-r1-distill-qwen-1.5b-aegis-safety-lora}}}},
note = {{Fine-tuned on NVIDIA Aegis AI Content Safety Dataset 2.0}}
}}
@misc{{deepseek_r1,
title = {{DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning}},
author = {{DeepSeek-AI}},
year = {{2024}},
publisher = {{HuggingFace}},
howpublished = {{\url{{https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B}}}}
}}
For questions, issues, or feedback:
This model is released under the MIT License, matching the DeepSeek-R1-Distill base model license.
The NVIDIA Aegis AI Content Safety Dataset 2.0 has its own license terms. Please refer to the dataset page for details.
This model card was generated automatically during the fine-tuning process in Google Colab.
Last updated: 2025-11-13