aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-lora
026
Luna-2 Style — Prompt Injection Detector (LoRA Adapter)
Luna-2 Style LoRA adapter for Qwen2.5-0.5B-Instruct, fine-tuned for binary prompt-injection detection (yes / no).
This repository contains only the adapter weights (≈ a few MB). You need PEFT to use it. If you want a standalone checkpoint with no dependencies, use the merged model at aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-merged.
Quickstart (PEFT)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-0.5B-Instruct",
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base, "aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-lora")
tokenizer = AutoTokenizer.from_pretrained("aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-lora")
messages = [
{"role": "system", "content": "You are a prompt injection detector. Reply only with yes or no."},
{"role": "user", "content": "<text to classify>"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False,
add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1, temperature=0, do_sample=False)
label = tokenizer.decode(out[0, -1]).strip() # "yes" or "no"vLLM Deployment
vLLM supports LoRA adapters natively. Use the merged repo for simplest deployment, or load the adapter dynamically:
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen2.5-0.5B-Instruct \
--enable-lora \
--lora-modules luna2=aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-lora \
--max-lora-rank 16 \
--max-model-len 4096 \
--dtype float16Training Details
Evaluation
Test Set
Validation Set
License
Apache 2.0 — same as the base Qwen2.5 model.
