Token Classification
GLiNER2
ONNX
Rust
onnxruntime
pii
ner
privacy
redaction
safety
moderation
guardrails
information-extraction
span-extraction
jailbreak-detection
toxicity-classification
Instructions to use jugaadsrl/GLiNER2-Guardrails-PII-Multi-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use jugaadsrl/GLiNER2-Guardrails-PII-Multi-onnx with GLiNER2:
from gliner2 import GLiNER2 model = GLiNER2.from_pretrained("jugaadsrl/GLiNER2-Guardrails-PII-Multi-onnx") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - Notebooks
- Google Colab
- Kaggle
Point at gliner2-rs, which now holds this engine as a crate
Browse filesThe repository this card linked to has been folded into gliner2-rs as crates/gliner2-guardrails and is being archived; the link would have become a dead end. Updates the snippet for the workspace layout and adds the moderation helpers, including the decoding rule that never returns an empty list.
README.md
CHANGED
|
@@ -49,9 +49,11 @@ datasets:
|
|
| 49 |
ONNX build of [`fastino/GLiNER2-Guardrails-PII-Multi`](https://huggingface.co/fastino/GLiNER2-Guardrails-PII-Multi),
|
| 50 |
for running the model **without Python** at inference time.
|
| 51 |
|
| 52 |
-
> **Rust engine: [github.com/dariofinardi/gliner2-
|
| 53 |
-
>
|
| 54 |
-
>
|
|
|
|
|
|
|
| 55 |
|
| 56 |
Converted and published by [Jugaad s.r.l.](https://edito-pdf.com), which uses it in
|
| 57 |
production inside **Edito** and **Omissis** for GDPR-native document
|
|
@@ -133,9 +135,10 @@ tokenizer.json 15.3 MB
|
|
| 133 |
## Usage
|
| 134 |
|
| 135 |
```rust
|
| 136 |
-
use
|
|
|
|
| 137 |
|
| 138 |
-
|
| 139 |
|
| 140 |
let mut engine = SpanEngine::new(SpanConfig::new("GLiNER2-Guardrails-PII-Multi-onnx"))?;
|
| 141 |
let tasks = vec,
|
| 50 |
for running the model **without Python** at inference time.
|
| 51 |
|
| 52 |
+
> **Rust engine: [github.com/dariofinardi/gliner2-rs](https://github.com/dariofinardi/gliner2-rs)**
|
| 53 |
+
> A Cargo workspace holding the engine, the exporter that produced these files and
|
| 54 |
+
> the suite that verifies them against PyTorch. Use the `gliner2-guardrails`
|
| 55 |
+
> crate for this checkpoint: it carries the moderation label sets with the
|
| 56 |
+
> per-task thresholds the model expects.
|
| 57 |
|
| 58 |
Converted and published by [Jugaad s.r.l.](https://edito-pdf.com), which uses it in
|
| 59 |
production inside **Edito** and **Omissis** for GDPR-native document
|
|
|
|
| 135 |
## Usage
|
| 136 |
|
| 137 |
```rust
|
| 138 |
+
use gliner2_core::{SchemaTask, SpanConfig, SpanEngine};
|
| 139 |
+
use gliner2_guardrails::{Task, prompt_moderation_schema, verdict};
|
| 140 |
|
| 141 |
+
gliner2_core::init("my-app");
|
| 142 |
|
| 143 |
let mut engine = SpanEngine::new(SpanConfig::new("GLiNER2-Guardrails-PII-Multi-onnx"))?;
|
| 144 |
let tasks = vec![SchemaTask::Entities(vec![
|
|
|
|
| 151 |
}
|
| 152 |
```
|
| 153 |
|
| 154 |
+
For the guardrails side, `prompt_moderation_schema()` builds the three
|
| 155 |
+
prompt-side tasks with the thresholds and single/multi-label settings this
|
| 156 |
+
checkpoint was trained with, and `verdict()` applies gliner2's decoding rule —
|
| 157 |
+
which never returns an empty list, falling back to the top-scoring label when
|
| 158 |
+
nothing clears the threshold:
|
| 159 |
+
|
| 160 |
+
```rust
|
| 161 |
+
let out = engine.extract(prompt, &prompt_moderation_schema())?;
|
| 162 |
+
println!("{:?}", verdict(&out, Task::PromptSafety));
|
| 163 |
+
println!("{:?}", verdict(&out, Task::JailbreakDetection));
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
The engine picks the architecture and the best precision for the platform on its
|
| 167 |
own. Byte offsets index the original text, so extracted spans keep their
|
| 168 |
original casing — which matters when you are redacting a document rather than
|