A package for detecting prompt injections in text using Open-Source LLMs.
Project description
Pytector
Pytector is a Python package designed to detect prompt injection in text inputs using state-of-the-art machine learning models from the transformers library.
Disclaimer
Pytector is still a prototype and cannot provide 100% protection against prompt injection attacks!
Features
- Detect prompt injections with pre-trained models.
- Support for multiple models including DeBERTa, DistilBERT, and ONNX versions.
- Easy-to-use interface with customizable threshold settings.
Installation
pip install pytector
Install Pytector directly from the source code:
git clone https://github.com/MaxMLang/pytector.git
cd pytector
pip install .
Usage
To use Pytector, you can import the PromptInjectionDetector class and create an instance with a pre-defined model or a custom model URL.
import pytector
# Initialize the detector with a pre-defined model
detector = pytector.PromptInjectionDetector(model_name_or_url="deberta")
# Check if a prompt is a potential injection
is_injection, probability = detector.detect_injection("Your suspicious prompt here")
print(f"Is injection: {is_injection}, Probability: {probability}")
Documentation
For full documentation, visit the docs directory.
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytector-0.0.9.tar.gz.
File metadata
- Download URL: pytector-0.0.9.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81a9f8dfc64ac7ade0570c91e24f903b3a1a26fa066c13fcef27f2b39cb1633
|
|
| MD5 |
dffc8d1cb676d0108008112e455505ca
|
|
| BLAKE2b-256 |
36f20b0f18480b177d5a72fd637f48b445a3b53bde2bf823485367b0522e8002
|
File details
Details for the file pytector-0.0.9-py3-none-any.whl.
File metadata
- Download URL: pytector-0.0.9-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c90d99d10aa5fdea1196f107a337fe371c4ad11740d5c044321a2531c470a093
|
|
| MD5 |
e9fb7b68fce84d442640436ef5ffb146
|
|
| BLAKE2b-256 |
f11eb0141e10ce0cb21ee6b2866031c76e8d4b700ff86d753980633bc49a0a8d
|