Instructions to use dcarpintero/pangolin-guard-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dcarpintero/pangolin-guard-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="dcarpintero/pangolin-guard-large")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("dcarpintero/pangolin-guard-large") model = AutoModelForSequenceClassification.from_pretrained("dcarpintero/pangolin-guard-large", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,7 +3,9 @@ library_name: transformers
|
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: answerdotai/ModernBERT-large
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
| 7 |
metrics:
|
| 8 |
- f1
|
| 9 |
- accuracy
|
|
@@ -16,15 +18,15 @@ model-index:
|
|
| 16 |
|
| 17 |
LLM applications face critical security challenges in form of prompt injections and jailbreaks. This can result in models leaking sensitive data or deviating from their intended behavior. Existing safeguard models are not fully open and have limited context windows (e.g., only 512 tokens in LlamaGuard).
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
🤗 [Tech-Blog](https://huggingface.co/blog/dcarpintero/pangolin-fine-tuning-modern-bert) | [GitHub Repo](https://github.com/dcarpintero/pangolin-guard)
|
| 22 |
|
| 23 |
-
## Intended
|
| 24 |
|
| 25 |
-
- Adding a self-hosted, inexpensive
|
| 26 |
|
| 27 |
-
## Evaluation
|
| 28 |
|
| 29 |
Evaluated on unseen data from a subset of specialized benchmarks targeting prompt safety and malicious input detection, while testing over-defense behavior:
|
| 30 |
|
|
@@ -35,9 +37,9 @@ Evaluated on unseen data from a subset of specialized benchmarks targeting promp
|
|
| 35 |
|
| 36 |

|
| 37 |
|
| 38 |
-
## Training
|
| 39 |
|
| 40 |
-
### Training
|
| 41 |
|
| 42 |
The following hyperparameters were used during training:
|
| 43 |
- learning_rate: 5e-05
|
|
@@ -49,7 +51,7 @@ The following hyperparameters were used during training:
|
|
| 49 |
- bf16: True
|
| 50 |
- num_epochs: 2
|
| 51 |
|
| 52 |
-
### Training
|
| 53 |
|
| 54 |
| Training Loss | Epoch | Step | Validation Loss | F1 | Accuracy |
|
| 55 |
|:-------------:|:------:|:----:|:---------------:|:------:|:--------:|
|
|
@@ -74,7 +76,7 @@ The following hyperparameters were used during training:
|
|
| 74 |
| 0.0052 | 1.9792 | 1900 | 0.0225 | 0.9904 | 0.9937 |
|
| 75 |
|
| 76 |
|
| 77 |
-
### Framework
|
| 78 |
|
| 79 |
- Transformers 4.48.3
|
| 80 |
- Pytorch 2.5.1+cu124
|
|
|
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: answerdotai/ModernBERT-large
|
| 5 |
tags:
|
| 6 |
+
- ai-safety
|
| 7 |
+
- safeguards
|
| 8 |
+
- guardrails
|
| 9 |
metrics:
|
| 10 |
- f1
|
| 11 |
- accuracy
|
|
|
|
| 18 |
|
| 19 |
LLM applications face critical security challenges in form of prompt injections and jailbreaks. This can result in models leaking sensitive data or deviating from their intended behavior. Existing safeguard models are not fully open and have limited context windows (e.g., only 512 tokens in LlamaGuard).
|
| 20 |
|
| 21 |
+
**Pangolin Guard** is a ModernBERT (Large), lightweight model that discriminates malicious prompts (i.e. prompt injection attacks).
|
| 22 |
|
| 23 |
🤗 [Tech-Blog](https://huggingface.co/blog/dcarpintero/pangolin-fine-tuning-modern-bert) | [GitHub Repo](https://github.com/dcarpintero/pangolin-guard)
|
| 24 |
|
| 25 |
+
## Intended Use Cases
|
| 26 |
|
| 27 |
+
- Adding a self-hosted, inexpensive defense mechanism against prompt injection attacks to AI agents and conversational interfaces.
|
| 28 |
|
| 29 |
+
## Evaluation Data
|
| 30 |
|
| 31 |
Evaluated on unseen data from a subset of specialized benchmarks targeting prompt safety and malicious input detection, while testing over-defense behavior:
|
| 32 |
|
|
|
|
| 37 |
|
| 38 |

|
| 39 |
|
| 40 |
+
## Training Procedure
|
| 41 |
|
| 42 |
+
### Training Hyperparameters
|
| 43 |
|
| 44 |
The following hyperparameters were used during training:
|
| 45 |
- learning_rate: 5e-05
|
|
|
|
| 51 |
- bf16: True
|
| 52 |
- num_epochs: 2
|
| 53 |
|
| 54 |
+
### Training Results
|
| 55 |
|
| 56 |
| Training Loss | Epoch | Step | Validation Loss | F1 | Accuracy |
|
| 57 |
|:-------------:|:------:|:----:|:---------------:|:------:|:--------:|
|
|
|
|
| 76 |
| 0.0052 | 1.9792 | 1900 | 0.0225 | 0.9904 | 0.9937 |
|
| 77 |
|
| 78 |
|
| 79 |
+
### Framework Versions
|
| 80 |
|
| 81 |
- Transformers 4.48.3
|
| 82 |
- Pytorch 2.5.1+cu124
|