dariofinardi commited on
Commit
d5d1efd
·
verified ·
1 Parent(s): d25b41a

Point at gliner2-rs, which now holds this engine as a crate

Browse files

The 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.

Files changed (1) hide show
  1. README.md +20 -5
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-guardrails-PII-Multi-onnx](https://github.com/dariofinardi/gliner2-guardrails-PII-Multi-onnx)**
53
- > The crate that consumes these files, along with the exporter that produced them
54
- > and the script that verifies them against PyTorch.
 
 
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 gliner2_guardrails::{SchemaTask, SpanConfig, SpanEngine};
 
137
 
138
- gliner2_guardrails::init("my-app");
139
 
140
  let mut engine = SpanEngine::new(SpanConfig::new("GLiNER2-Guardrails-PII-Multi-onnx"))?;
141
  let tasks = vec![SchemaTask::Entities(vec![
@@ -148,6 +151,18 @@ for e in engine.extract("Mario Rossi, mario.rossi@example.com, Cupertino.", &tas
148
  }
149
  ```
150
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  The engine picks the architecture and the best precision for the platform on its
152
  own. Byte offsets index the original text, so extracted spans keep their
153
  original casing — which matters when you are redacting a document rather than
 
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-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