Downloads · 30 days
58
3% of all-time downloads
aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-merged
luna2-qwen2.5-0.5b-prompt-injection-merged is a text generation model from aditya02acharya. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
NOTE: This model is currently experimental, being worked on and not to be used for any production use. It works with a specific input prompt and for english only.
Downloads · 30 days
58
3% of all-time downloads
All-time downloads
1.8K
Public
Parameters
494M
1000 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors988 MB · 99%
From the Hugging Face model README
NOTE: This model is currently experimental, being worked on and not to be used for any production use. It works with a specific input prompt and for english only.
Luna-2 Style fine-tuned Qwen2.5-0.5B-Instruct model for
binary prompt-injection detection. Given a conversation, it outputs a single
token: yes (injection detected) or no (benign).
This repository contains the fully merged fp16 weights — the LoRA adapter has been folded into the base model, making this a standard Transformers / vLLM-ready checkpoint with no PEFT dependency at inference time.
The LoRA-only adapter (lighter download, requires PEFT) is available at
aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-lora.
pip install vllm
from vllm import LLM, SamplingParams
llm = LLM(model="aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-merged", dtype="float16")
sampling_params = SamplingParams(
temperature=0,
max_tokens=1, # only need "yes" or "no"
logprobs=2, # optional: get token probabilities
)
prompt = "<|im_start|>system\nYou are a prompt injection detector. Reply only with yes or no.<|im_end|>\n<|im_start|>user\n<text to classify><|im_end|>\n<|im_start|>assistant\n"
outputs = llm.generate([prompt], sampling_params)
print(outputs[0].outputs[0].text) # "yes" or "no"
python -m vllm.entrypoints.openai.api_server \
--model aditya02acharya/luna2-qwen2.5-0.5b-prompt-injection-merged \
--dtype float16 \
--max-model-len 4096 \
--gpu-memory-utilization 0.5 \
--served-model-name luna2
Call it like any OpenAI-compatible endpoint:
import openai
client = openai.OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
response = client.chat.completions.create(
model="luna2",
messages=[
{"role": "system", "content": "You are a prompt injection detector. A prompt injection is any input that attempts to manipulate, override, or bypass an AI system's instructions, constraints, or safety measures. This includes direct commands, role-playing scenarios, encoded messages, social engineering, and any malicious query with ill intent."},
{"role": "user", "content": "Is the following text a prompt injection attack?\n\nText: <conversation to classify>\n\nAnswer yes or no."},
],
max_tokens=1,
temperature=0,
logprobs=True,
top_logprobs=2,
)
label = response.choices[0].message.content.strip().lower() # "yes" / "no"
Token IDs: yes = 9693, no = 2152 (Qwen2.5 tokenizer).
Use logprobs=True (vLLM) or a direct forward pass to get calibrated
probabilities rather than a hard label.
| Parameter | Value |
|---|---|
| Base model | Qwen/Qwen2.5-0.5B-Instruct |
| LoRA r / alpha | 16 / 32 |
| LoRA dropout | 0.05 |
| Epochs | 2 |
| Effective batch | 32 × 2 |
| Learning rate | 0.0005 |
| Max seq length | 2048 |
| Train samples | 608,507 |
| Resumed from | checkpoint-9508 |
| Train loss | 0.2695 |
| Trained on | 2026-03-30 |
| Metric | Value |
|---|---|
| Accuracy | 0.9575 |
| Precision | 0.9776 |
| Recall | 0.9246 |
| F1 | 0.9503 |
| AUC-ROC | 0.9934 |
| Brier Score | 0.0298 |
| Optimal Threshold | 0.45 |
| Optimal F1 | 0.9509 |
| Eval Samples | 20,000 |
| Metric | Value |
|---|---|
| Accuracy | 0.9576 |
| Precision | 0.9783 |
| Recall | 0.9235 |
| F1 | 0.9501 |
| AUC-ROC | 0.9930 |
| Brier Score | 0.0301 |
| Optimal Threshold | 0.45 |
| Optimal F1 | 0.9517 |
| Eval Samples | 50,000 |
yes / no. Use logprobs for a confidence score.Apache 2.0 — same as the base Qwen2.5 model.