Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Embedding-based classifiers can detect prompt injection attacks

About

Large Language Models (LLMs) are seeing significant adoption in every type of organization due to their exceptional generative capabilities. However, LLMs are found to be vulnerable to various adversarial attacks, particularly prompt injection attacks, which trick them into producing harmful or inappropriate content. Adversaries execute such attacks by crafting malicious prompts to deceive the LLMs. In this paper, we propose a novel approach based on embedding-based Machine Learning (ML) classifiers to protect LLM-based applications against this severe threat. We leverage three commonly used embedding models to generate embeddings of malicious and benign prompts and utilize ML classifiers to predict whether an input prompt is malicious. Out of several traditional ML methods, we achieve the best performance with classifiers built using Random Forest and XGBoost. Our classifiers outperform state-of-the-art prompt injection classifiers available in open-source implementations, which use encoder-only neural networks.

Md. Ahsan Ayub, Subhabrata Majumdar• 2024

Related benchmarks

TaskDatasetResultRank
Harmfulness DetectionAegis
Macro F188.11
25
Harmful prompt detectionXSTest
F1 Score95.04
20
Harmful prompt detectionSimpST
F1 Score100
17
Harmful prompt detectionWGMix
F1 Score88.09
17
Harmful prompt detectionWJB
F1 Score96.84
17
Harmful prompt detectionOpenAI
F1 Score75.69
17
Harmful prompt detectionCombined Average
F1 Score (Combined Average)87.06
17
Harmful prompt detectionTChat
F1 Score68.9
17
Harmful prompt detectionHarmB
F1 Score96.98
17
Input ModerationHarmful safety datasets Average
Average F1 Score (Input Moderation)87.54
9
Showing 10 of 11 rows

Other info

Follow for update