Skip to main content

Ensemble Prompt Injection Detection

Project description

PromptForest - Fast and Reliable Injection Detector Ensemble

PromptForest is a prompt injection detector ensemble focused on real-world latency and reliability.

We rely on an ensemble of small, accurate prompt detection models using a voting system to generate accurate detections.

By comparing predictions across multiple models, the system can flag prompts where models disagree, helping to reduce the risk of false negatives.

This discrepancy score enables downstream workflows such as:

  • Human-in-the-loop review for high-risk or ambiguous prompts
  • Adaptive throttling or alerting in production systems
  • Continuous monitoring and model improvement

Statistics

PromptForest was evaluated against the SOTA model Qualifire Sentinel model (v2).

Metric PromptForest Sentinel v2
Accuracy 0.802 0.982
Avg Confidence on Wrong Answers 0.643 0.858
Expected Calibration Error (ECE) 0.060 0.202
Approximate Model Size ~250M params 600M params

Key Insights

  • Calibrated uncertainty: PromptForest is less confident on wrong predictions than Sentinel, resulting in a much lower ECE.

  • Parameter efficiency: Achieves competitive reliability with <50% of the parameters.

  • Interpretability: Confidence scores can be used to flag uncertain predictions for human review.

Interpretation: While Sentinel has higher raw accuracy, PromptForest provides better-calibrated confidence. For systems where overconfidence on wrong answers is risky, PromptForest can reduce the chance of critical errors despite being smaller and faster.

Supported Models

Provider Model Name
Meta Llama Prompt Guard 86M (Built with Llama)
ProtectAI DebertaV3 Prompt Injection Finetune
Vijil Vijil Dome Prompt Injection Detection
Appleroll PromptForest-XGBoost

Performance

E2E Request Latency
Average Case: 100ms
Worst Case: 200ms

Accuracy
Preliminary results indicate ensemble performance is at least as good as any individual model. Extensive benchmarking is ongoing.

Quick Start

To use PromptForest, simply install the pip package and serve it at a port of your choice. It should automatically start downloading the default model ensemble.

Gated models are downloaded through our own ensemble github respository and are released in accordance to their terms and conditions.

pip install promptforest
promptforest serve --port 8000 

Disclaimer & Limitations

PromptForest uses a combination of open-source and third-party machine learning models, including models and weights released by other organizations under their respective licenses (e.g. Meta LLaMA Prompt Guard and other public prompt-injection detectors). All third-party components remain the property of their original authors and are used in accordance with their licenses.

PromptForest is not a standalone security solution and should not be relied upon as the sole defense mechanism for protecting production systems. Prompt injection detection is an inherently adversarial and evolving problem, and no automated system can guarantee complete protection.

This project has not yet been extensively validated against real-world, large-scale, or targeted prompt-injection attacks. Results may vary depending on deployment context, model configuration, and threat model.

PromptForest is intended to be used as one layer in a defense-in-depth strategy, alongside input validation, output filtering, access control, sandboxing, monitoring, and human oversight.

License

This project is licensed under Apache 2.0. Third-party models and weights are redistributed under their original licenses (see THIRD_PARTY_LICENSES folder for details). Users must comply with these licenses.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptforest-0.5.0a0.tar.gz (653.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptforest-0.5.0a0-py3-none-any.whl (677.0 kB view details)

Uploaded Python 3

File details

Details for the file promptforest-0.5.0a0.tar.gz.

File metadata

  • Download URL: promptforest-0.5.0a0.tar.gz
  • Upload date:
  • Size: 653.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for promptforest-0.5.0a0.tar.gz
Algorithm Hash digest
SHA256 5b19cb9c51b50f84fb1de7af35e0620acce274832f0c977b6d422420806795cc
MD5 62a65bcd9899283b1e97337d08c5e152
BLAKE2b-256 41935bd06d08c34350bc8c401d6828850b0586f5c68f15a45d39fc50477776fc

See more details on using hashes here.

File details

Details for the file promptforest-0.5.0a0-py3-none-any.whl.

File metadata

  • Download URL: promptforest-0.5.0a0-py3-none-any.whl
  • Upload date:
  • Size: 677.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for promptforest-0.5.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 e253dc34a7852d2f0a22252fa713046eeed0e8a471a8c7005a3976bcda0759e5
MD5 8726c668f200650bd4433251a83d1856
BLAKE2b-256 ba2e3d3f163275dc3c8c61c8682a90c96cb9dc037a65c98e641c1e77c765cb4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page