Views
No views yet
pip install transformers torch peft1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "ahczhg/qwen3-0.6b-aegis-safety-lora"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13# Example: Content safety check
14prompt = "### Instruction:\nAnalyze this content for safety: 'Your text here'\n\n### Response:\n"
15inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
16
17with torch.no_grad():
18 outputs = model.generate(
19 **inputs,
20 max_new_tokens=128,
21 temperature=0.7,
22 do_sample=True,
23 top_p=0.95
24 )
25
26response = tokenizer.decode(outputs[0], skip_special_tokens=True)
27print(response)1from transformers import pipeline
2
3# Create text generation pipeline
4generator = pipeline(
5 "text-generation",
6 model="ahczhg/qwen3-0.6b-aegis-safety-lora",
7 torch_dtype=torch.float16,
8 device_map="auto"
9)
10
11# Generate safety analysis
12result = generator(
13 "### Instruction:\nIs this content safe? 'Hello, how are you?'\n\n### Response:\n",
14 max_new_tokens=128,
15 temperature=0.7,
16 do_sample=True
17)
18
19print(result[0]['generated_text'])1@misc{qwen3_0.6b_aegis_safety,
2 author = {ahczhg},
3 title = {Qwen3-0.6B Fine-tuned on Aegis AI Content Safety},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/ahczhg/qwen3-0.6b-aegis-safety-lora}},
7 note = {Fine-tuned on NVIDIA Aegis AI Content Safety Dataset 2.0}
8}