Gliner Guard v1
Collection
GLiNER2-based guardrail for PII, content safety classification, prompt attacks detection and more via single forward pass • 2 items • Updated
• 1
Install dependencies (now via our fork, wi'll update installation part after PR to GLiNER2 repo)
pip install "gliner2 @ git+https://github.com/bogdanminko/GLiNER2.git@feature/bi-encoder" torch transformers
Classify Harmful messages and Detect PII via single forward pass
from gliner2 import GLiNER2
model = GLiNER2.from_pretrained("raft-security-lab/gliner-guard-biencoder")
model.config.cache_labels = True
model.compile()
PII_LABELS = ["person", "location", "email", "phone"]
SAFETY_LABELS = ["safe", "unsafe"]
schema = (model.create_schema()
.entities(entity_types=PII_LABELS, threshold=0.4)
.classification(task="safety", labels=SAFETY_LABELS)
)
result = model.extract(
"Send $500 to John Smith at john.smith@gmail.com or I'll leak your photos",
schema=schema
)
output:
{'entities': {'person': ['John Smith'],
'location': [],
'email': ['john.smith@gmail.com'],
'phone': []},
'safety': 'unsafe'}
Base model
jhu-clsp/mmBERT-small