A production-grade open-source model for privacy-focused PII, PHI, and PCI detection with zero-shot entity recognition capabilities.
This model was developed in collaboration between Wordcab and Knowledgator. For enterprise-ready, specialized PII/PHI/PCI models, contact us at info@wordcab.com.
🧠 What is GLiNER?
GLiNER (Generalist and Lightweight Named Entity Recognition) is a bidirectional transformer model that can identify any entity type without predefined categories. Unlike traditional NER models that are limited to specific entity classes, GLiNER allows you to specify exactly what entities you want to extract at runtime.
Key Advantages
Zero-shot recognition: Extract any entity type without retraining
Privacy-first: Process sensitive data locally without API calls
Lightweight: Much faster than large language models for NER tasks
Production-ready: Quantization-aware training with FP16 and UINT8 ONNX models
Comprehensive: 60+ predefined PII categories with custom entity support
How GLiNER Works
Instead of predicting from a fixed set of entity classes, GLiNER takes both text and a list of desired entity types as input, then identifies spans that match those categories:
python
1text ="John Smith called from 415-555-1234 to discuss his account."2entities =["name","phone number","account number"]3# GLiNER finds: "John Smith" → name, "415-555-1234" → phone number
🐍 Python Implementation
The primary GLiNER implementation provides comprehensive PII detection with 60+ entity categories, fine-tuned specifically for privacy and compliance use cases.
Installation
pip install gliner
Quick Start
python
1from gliner import GLiNER
23# Load the model (downloads automatically on first use)4model = GLiNER.from_pretrained("knowledgator/gliner-pii-base-v1.0")56text ="John Smith called from 415-555-1234 to discuss his account number 12345678."7labels =["name","phone number","account number"]89entities = model.predict_entities(text, labels, threshold=0.3)1011for entity in entities:12print(f"{entity['text']} => {entity['label']} (confidence: {entity['score']:.2f})")
Output:
John Smith => name (confidence: 0.95)
415-555-1234 => phone number (confidence: 0.92)
12345678 => account number (confidence: 0.88)
Advanced Usage Examples
Multi-Category Detection
python
1text ="""
2Patient Mary Johnson, DOB 01/15/1980, was discharged on March 10, 2024
3from St. Mary's Hospital. Contact: mary.j@email.com, (555) 123-4567.
4Insurance policy: POL-789456123.
5"""67labels =[8"name","dob","discharge date","organization medical facility",9"email address","phone number","policy number"10]1112entities = model.predict_entities(text, labels, threshold=0.3)1314for entity in entities:15print(f"Found '{entity['text']}' as {entity['label']}")
Batch Processing for High Throughput
python
1documents =[2"Customer John called about his credit card ending in 4532.",3"Sarah's SSN 123-45-6789 needs verification.",4"Email support@company.com for account 987654321 issues."5]67labels =["name","credit card","ssn","email address","account number"]89# Process multiple documents efficiently10results = model.run(documents, labels, threshold=0.3, batch_size=8)1112for doc_idx, entities inenumerate(results):13print(f"\nDocument {doc_idx +1}:")14for entity in entities:15print(f" {entity['text']} => {entity['label']}")
Custom Entity Detection
python
1# GLiNER isn't limited to PII - you can detect any entities2text ="The MacBook Pro with M2 chip costs $1,999 at the Apple Store in Manhattan."3custom_labels =["product","processor","price","store","location"]45entities = model.predict_entities(text, custom_labels, threshold=0.3)
GLiNER excels in privacy-focused applications where traditional cloud-based NER services pose compliance risks.
🎯 Primary Applications
Privacy-First Voice & Transcription
python
1# Automatically redact PII from voice transcriptions2transcription ="Hi, my name is Sarah Johnson and my phone number is 415-555-0123"3pii_labels =["name","phone number","email address","ssn"]45entities = model.predict_entities(transcription, pii_labels)6# Redact or anonymize detected PII before storage
Compliance-Ready Document Processing
python
1# Healthcare: HIPAA-compliant note processing2medical_note ="Patient John Doe, MRN 123456, diagnosed with diabetes..."3phi_labels =["name","medical record number","condition","dob"]45# Finance: PCI-DSS compliant transaction logs6transaction_log ="Card ****4532 charged $299.99 to John Smith"7pci_labels =["credit card","money","name"]89# Legal: Attorney-client privilege protection10legal_doc ="Client Jane Doe vs. Corporation ABC, case #2024-CV-001"11legal_labels =["name","organization","case number"]
Real-Time Data Anonymization
python
1defanonymize_text(text, entity_types):2"""Anonymize PII in real-time"""3 entities = model.predict_entities(text, entity_types)45# Sort by position to replace from end to start6 entities.sort(key=lambda x: x['start'], reverse=True)78 anonymized = text
9for entity in entities:10 placeholder =f"<{entity['label'].upper()}>"11 anonymized = anonymized[:entity['start']]+ placeholder + anonymized[entity['end']:]1213return anonymized
1415original ="John Smith's SSN is 123-45-6789"16anonymized = anonymize_text(original,["name","ssn"])17print(anonymized)# "<NAME>'s SSN is <SSN>"
🌟 Extended Applications
Enhanced Search & Content Understanding
python
1# Extract key entities from user queries for better search2query ="Find restaurants near Stanford University in Palo Alto"3search_entities =["organization","location city","business type"]45# Intelligent document tagging6document ="This quarterly report discusses Microsoft's Azure growth..."7doc_entities =["organization","product","time period"]
1# Process sensitive data entirely on-device2defprocess_locally(user_input):3"""Process PII detection without cloud APIs"""4 pii_types =["name","phone number","email address","ssn","credit card"]56# All processing happens locally - no data leaves device7 detected_pii = model.predict_entities(user_input, pii_types)89if detected_pii:10return"⚠️ Sensitive information detected - proceed with caution"11return"✅ No PII detected - safe to share"
📊 Performance Benchmarks
Accuracy Evaluation
The following benchmarks were run on the synthetic-multi-pii-ner-v1 dataset.
We compare multiple GLiNER-based PII models, including our new Knowledgator GLiNER PII Edge v1.0.
Model Path
Precision
Recall
F1 Score
knowledgator/gliner-pii-edge-v1.0
78.96%
72.34%
75.50%
knowledgator/gliner-pii-small-v1.0
78.99%
74.80%
76.84%
knowledgator/gliner-pii-base-v1.0
79.28%
82.78%
80.99%
knowledgator/gliner-pii-large-v1.0
87.42%
79.4%
83.25%
urchade/gliner_multi_pii-v1
79.19%
74.67%
76.86%
E3-JSI/gliner-multi-pii-domains-v1
78.35%
74.46%
76.36%
gravitee-io/gliner-pii-detection
81.27%
56.76%
66.84%
Key Takeaways
Base Post Model (knowledgator/gliner-pii-base-v1.0) achieves the highest F1 score (80.99%), indicating the strongest overall performance.
Knowledgator Edge Model (knowledgator/gliner-pii-edge-v1.0) is optimized for edge environments, trading a slight decrease in recall for lower latency and footprint.
Gravitee-io Model shows strong precision but lower recall, indicating it is tuned for high confidence but misses more entities.
Comparison with Alternatives
Solution
Speed
Privacy
Accuracy
Flexibility
Cost
GLiNER
⭐⭐⭐⭐
⭐⭐⭐⭐⭐
⭐⭐⭐⭐⭐
⭐⭐⭐⭐
Free
Cloud NER APIs
⭐⭐⭐
⭐⭐⭐
⭐⭐⭐⭐⭐
⭐⭐⭐
$$$
Large Language Models
⭐⭐
⭐⭐
⭐⭐⭐⭐
⭐⭐⭐⭐
$$$$
Traditional NER
⭐⭐⭐⭐⭐
⭐⭐⭐⭐⭐
⭐⭐⭐⭐
⭐
Free
🚀 Alternative Implementations
While Python provides the most comprehensive PII detection capabilities, GLiNER is available across multiple languages for different deployment scenarios.
🦀 Rust Implementation (gline-rs)
Best for: High-performance backend services, microservices
toml
1[dependencies]2"gline-rs"="1"
rust
1usegline_rs::{GLiNER,TextInput,Parameters,RuntimeParameters};23let model =GLiNER::<TokenMode>::new(4Parameters::default(),5RuntimeParameters::default(),6"tokenizer.json",7"model.onnx",8)?;910let input =TextInput::from_str(11&["My name is James Bond."],12&["person"],13)?;1415let output = model.inference(input)?;
Performance: 4x faster than Python on CPU, 37x faster with GPU acceleration.
⚡ C++ Implementation (GLiNER.cpp)
Best for: Embedded systems, mobile apps, edge devices
cpp
1#include"GLiNER/model.hpp"23gliner::Config config{12,512};4gliner::Model model("./model.onnx","./tokenizer.json", config);56std::vector<std::string> texts ={"John works at Microsoft"};7std::vector<std::string> entities ={"person","organization"};89auto output = model.inference(texts, entities);
🌐 JavaScript Implementation (GLiNER.js)
Best for: Web applications, browser-based processing
npm install gliner
javascript
1import{Gliner}from'gliner';23const gliner =newGliner({4tokenizerPath:"onnx-community/gliner_small-v2",5onnxSettings:{6modelPath:"public/model.onnx",7executionProvider:"webgpu",8}9});1011await gliner.initialize();1213const results =await gliner.inference({14texts:["John Smith works at Microsoft"],15entities:["person","organization"],16threshold:0.1,17});
🏗️ Model Architecture & Training
Quantization-Aware Pretraining
GLiNER models use quantization-aware pretraining, which optimizes performance while maintaining accuracy. This allows efficient inference even with quantized models.