Downloads · 30 days
5
7% of all-time downloads
ErfanSadeghiii/peft-cysec-qwen2.5
peft-cysec-qwen2.5 is a text generation model from ErfanSadeghiii. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
This model is a fine-tuned version of Qwen/Qwen2.5-7B-Instruct on the CySecBench dataset. It is designed to classify cybersecurity-related prompts into one of ten attack categories.
Downloads · 30 days
5
7% of all-time downloads
All-time downloads
68
Public
Repo size
646 MB
Likes
0
Public
Click a slice to open those files.
.safetensors646 MB · 100%
From the Hugging Face model README
peft-cysec-qwen2.5This model is a fine-tuned version of Qwen/Qwen2.5-7B-Instruct on the CySecBench dataset. It is designed to classify cybersecurity-related prompts into one of ten attack categories.
This model is intended for research and educational purposes in the field of cybersecurity. It is designed to categorize prompts, not to generate harmful content.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load base model and the adapter
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct", device_map="auto")
model = PeftModel.from_pretrained(model, "ErfanSadeghiii/peft-cysec-qwen2.5")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
def predict(prompt):
formatted_prompt = f"<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model\n"
inputs = tokenizer(formatted_prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=20, do_sample=False, temperature=0.0)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
category = response.split("<start_of_turn>model")[-1].strip()
return category.split("<end_of_turn>")[0].strip()