belrem/llm-prompt-intent-classifier
0
LLM Prompt Intent Classifier
Classifies user prompts sent to LLMs into four intent categories using all-MiniLM-L6-v2 sentence embeddings and a Logistic Regression classification head.
Labels
Classifier comparison
Best model: Logistic Regression
precision recall f1-score support
creative 0.78 0.89 0.83 45
informational 0.84 0.77 0.80 48
task 0.80 0.89 0.85 37
adversarial 0.87 0.75 0.80 44
accuracy 0.82 174
macro avg 0.82 0.83 0.82 174
weighted avg 0.83 0.82 0.82 174
Confusion matrix (best model)
Predicted →
creative info task adversarial
creative 40 2 3 0
informational 3 37 5 3
task 0 2 33 2
adversarial 8 3 0 33Inference
from sentence_transformers import SentenceTransformer
import joblib
from huggingface_hub import hf_hub_download
embedder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
clf_path = hf_hub_download(repo_id="belrem/llm-prompt-intent-classifier", filename="classifier.joblib")
clf = joblib.load(clf_path)
prompt = "Write a poem about the ocean."
vec = embedder.encode([prompt])
label_id = clf.predict(vec)[0]
labels = ["creative", "informational", "task", "adversarial"]
print(labels[label_id]) # → creativeLimitations
- Adversarial prompts are the hardest class: sophisticated jailbreaks using creative or hypothetical framing may be misclassified as
creativeortask. - Intent is inherently ambiguous — a prompt can be simultaneously creative and a task. The model predicts the dominant intent.
- Dataset skew: adversarial examples from AdvBench may not reflect real-world jailbreak distributions.
