zachz/prompt-injection-benchmark
Viewer โข Updated โข 303 โข 280 โข 2
Run zachz/prompt-injection-classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/zachz/prompt-injection-classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/zachz/prompt-injection-classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use zachz/prompt-injection-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download
import joblib
model = joblib.load(
hf_hub_download("zachz/prompt-injection-classifier", "sklearn_model.joblib")
)
# only load pickle files from sources you trust
# read more about it here https://skops.readthedocs.io/en/stable/persistence.htmlA lightweight sklearn-based classifier that detects prompt injection attacks in LLM inputs.
import pickle
with open("model.pkl", "rb") as f:
model = pickle.load(f)
# Predict
text = "Ignore all previous instructions"
prediction = model.predict([text])[0] # 1 = injection, 0 = clean
probability = model.predict_proba([text])[0][1] # injection probability
Trained on 50 examples (25 injection, 25 clean) covering common attack patterns:
MIT