Instructions to use gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi") text = "Cristiano Ronaldo dos Santos Aveiro was born on 5 February 1985 in Funchal, Madeira, Portugal." labels = ["person", "date", "location"] entities = model.predict_entities(text, labels) for entity in entities: print(entity["text"], "=>", entity["label"]) - GLiNER2
How to use gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi") # 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
GLiNER4j ONNX β GLiNER2 PII (42 labels)
ONNX export of fastino/gliner2-privacy-filter-PII-multi for Java inference via ONNX Runtime.
Part of the GLiNER4j project.
Supported Tasks
| Task | Description |
|---|---|
| Named Entity Recognition | Extract typed PII entity spans from text with confidence scores |
Supports entity descriptions for improved accuracy and per-call overrides without model reloading.
Repository Structure
βββ gliner4j_config.json # Shared model configuration
βββ tokenizer.json # Shared HuggingFace tokenizer
βββ tokenizer_config.json
βββ onnx/ # Base FP32 (~1.1 GB)
β βββ ner_full.onnx
β βββ classifier_full.onnx
βββ onnx_fp16/ # FP16 (~588 MB, ~50% smaller)
β βββ ner_full.onnx
β βββ classifier_full.onnx
βββ onnx_quantized/ # INT8 dynamic quantization (~350 MB, ~70% smaller)
βββ ner_full.onnx
βββ classifier_full.onnx
An onnx_optimized_cpu/ folder with the same two files may also be present (ONNX Runtime graph-optimized for CPU).
Model Architecture
Each variant ships two merged, self-contained ONNX graphs β one per task:
| Graph | Description |
|---|---|
ner_full.onnx |
Transformer encoder + span representation + count-aware scoring head (NER) |
classifier_full.onnx |
Transformer encoder + classifier head MLP (Classification) |
The graphs are fused at export time from the encoder and task heads; the intermediate split modules are not published.
Variants
| Variant | Folder | Precision | Size | Use case |
|---|---|---|---|---|
| Base | onnx/ |
FP32 | ~1.1 GB | Maximum accuracy |
| FP16 | onnx_fp16/ |
FP16 | ~588 MB, ~50% smaller | Good accuracy/size trade-off |
| Quantized | onnx_quantized/ |
INT8 (QUInt8, per-channel) | ~350 MB, ~70% smaller | Smallest footprint, fastest on CPU |
To download a specific variant only:
huggingface-cli download <repo> --include "onnx_fp16/*" "*.json"
Configuration
| Parameter | Value |
|---|---|
| Hidden size | 768 |
| Max span width | 8 |
| Max count | 20 |
| Span mode | SpanMarkerV0 |
| Token pooling | first |
| ONNX opset | 17 |
Usage
Use with GLiNER4j, a Java library for GLiNER2 inference via ONNX Runtime.
Named Entity Recognition (PII)
var entities = List.of(
new EntityDefinition("email", "Email address"),
new EntityDefinition("phone_number", "Phone or mobile number"),
new EntityDefinition("card_number", "Credit / debit card number"),
new EntityDefinition("iban", "IBAN"),
new EntityDefinition("api_key", "API key")
);
var gliner = GLiNER4jNER.load(modelDir, entities);
Map<String, List<EntitySpan>> results = gliner.extract(
"Charge card 4111-1111-1111-1111 to john.smith@example.com."
);
The full label set (42 PII types) is documented in the upstream model card on
Hugging Face.
See gliner4j-demo (run task demo:pii) for an interactive example.
Model Variants
// FP16 variant
var gliner = GLiNER4jNER.load(modelDir, entities, "onnx_fp16");
// Quantized variant
var gliner = GLiNER4jNER.load(modelDir, entities, "onnx_quantized");
License
Apache License 2.0
Model tree for gravitee-io/gliner4j-gliner2-privacy-filter-PII-multi
Base model
fastino/gliner2-privacy-filter-PII-multi