Text Classification
Transformers
ONNX
Safetensors
English
modernbert
prompt-injection
guardrail
security
lora
agent-safety
owasp-llm-top-10
mitre-atlas
Eval Results (legacy)
text-embeddings-inference
Instructions to use dannyliv/agent-guard-modernbert-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dannyliv/agent-guard-modernbert-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="dannyliv/agent-guard-modernbert-base")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("dannyliv/agent-guard-modernbert-base") model = AutoModelForSequenceClassification.from_pretrained("dannyliv/agent-guard-modernbert-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Move V3.2 adapter to adapter/ subfolder so root loads the merged model directly
Browse files
README.md
CHANGED
|
@@ -138,7 +138,17 @@ with torch.no_grad():
|
|
| 138 |
print(f"P(injection) = {p:.3f} flagged={p > 0.5}")
|
| 139 |
```
|
| 140 |
|
| 141 |
-
The merged full model is shipped at the repo root. The V3.2 LoRA adapter is also published
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
Or via the pip-installable SDK:
|
| 144 |
|
|
|
|
| 138 |
print(f"P(injection) = {p:.3f} flagged={p > 0.5}")
|
| 139 |
```
|
| 140 |
|
| 141 |
+
The merged full model is shipped at the repo root, so `from_pretrained` loads V3.2 directly. The V3.2 LoRA adapter is also published in the `adapter/` subfolder for users who want to load it onto the base model with `peft`:
|
| 142 |
+
|
| 143 |
+
```python
|
| 144 |
+
from peft import PeftModel
|
| 145 |
+
base = AutoModelForSequenceClassification.from_pretrained(
|
| 146 |
+
"answerdotai/ModernBERT-base", num_labels=17,
|
| 147 |
+
problem_type="multi_label_classification",
|
| 148 |
+
attn_implementation="eager", reference_compile=False,
|
| 149 |
+
ignore_mismatched_sizes=True)
|
| 150 |
+
m = PeftModel.from_pretrained(base, "dannyliv/agent-guard-modernbert-base", subfolder="adapter")
|
| 151 |
+
```
|
| 152 |
|
| 153 |
Or via the pip-installable SDK:
|
| 154 |
|
adapter_config.json → adapter/adapter_config.json
RENAMED
|
File without changes
|
adapter_model.safetensors → adapter/adapter_model.safetensors
RENAMED
|
File without changes
|