GLiNER2: Compact Multi-Task Extraction
- GLiNER2 is a compact multi-task information extraction framework that unifies named entity recognition, text classification, and structured data extraction via a prompt-based, schema-driven interface.
- It employs a 12-layer bidirectional transformer with modular task-specific heads, enabling zero-shot, parallel inference and competitive performance on benchmarks.
- The framework achieves efficient CPU deployment with low memory usage while delivering strong F1 scores in PII extraction and other structured extraction tasks.
GLiNER2 is a compact, multi-task information extraction framework designed to unify named entity recognition (NER), text classification, and structured data extraction under a schema-driven interface, all within an efficient transformer-based architecture. It is engineered for CPU-efficient, on-premises deployment, balancing competitive performance with reduced resource requirements compared to LLMs. GLiNER2's versatility is achieved through a unified prompt-based input format and modular heads for span extraction, classification, and hierarchical schema parsing. The architecture enables single-pass, parallel inference and supports arbitrary combinations of extraction tasks via user-specified schemas. The GLiNER2 framework has further been adapted for specialized tasks, notably in the form of GLiNER2-PII, a multilingual model dedicated to fine-grained personally identifiable information (PII) extraction, combining synthetic multilingual data generation with high-recall schema-driven span extraction (Zaratiana et al., 24 Jul 2025, Zaratiana et al., 11 May 2026).
1. Model Architecture and Schema-Driven Design
GLiNER2 employs a bidirectional transformer encoder backbone, typically with ∼12 layers, hidden size of 768, and a total parameter count of 205–300 million depending on the task-specific configuration. The model introduces special learned tokens for prompt metadata ([P]), entity types ([E]), attribute fields ([C]), classification labels ([L]), and prompt delimiters ([SEP]). All information extraction tasks are expressed as concatenated prompts and input sequences, allowing the model to process various tasks within the same forward pass (Zaratiana et al., 24 Jul 2025).
Task-specific heads are structured as follows:
- Named Entity Recognition: For each candidate span (up to a fixed length), span vectors are constructed from encoder endpoint representations and scored against entity-type embeddings using a dot-product mechanism.
- Text Classification: Each classification label ([L]) is embedded within the prompt and projected to a logit via a small MLP.
- Hierarchical Structured Extraction: Nested field extraction leverages [C] tokens and an occurrence-ID embedding to score each possible field instance across predicted structure counts.
- PII-Focused Adaptations (GLiNER2-PII): Incorporates a schema-conditioned span extractor with a specialized classification head for 42 fine-grained PII entity types, plus nested annotation handling (Zaratiana et al., 11 May 2026).
All task heads share the encoder backbone, enabling mixed-task inference in a single forward pass. Task configuration is exposed via a Python API where users define extraction schemas as dicts or natural-language descriptions, which are compiled into model-consumable prompts.
2. Training Regimen and Data Construction
The pretraining and fine-tuning pipeline for GLiNER2 leverages both real-world and synthetic datasets:
- GLiNER2 Pretraining: Utilizes a corpus of 254,334 examples, combining 135,698 real-world annotations sourced from news, Wikipedia, PubMed, legal, and scientific texts (GPT-4o plus manual QA), and 118,636 synthetic examples diversified across domains (dialog, e-commerce, health, etc.) with full NER, classification, and structure annotations (Zaratiana et al., 24 Jul 2025).
- PII Extraction (GLiNER2-PII): Trained on a synthetic, constraint-driven multilingual corpus of 4,910 annotated texts spanning English, French, Spanish, German, Italian, Portuguese, and Dutch. The generation pipeline systematically samples label sets, domains, formats, languages, and annotation nesting, ensuring diverse and realistic coverage without privacy risk (Zaratiana et al., 11 May 2026).
A multi-task learning objective combines losses for all heads, with negative sampling for NER and span-classification tasks to manage computational cost. AdamW is the optimizer, typically with learning rates 1e–5 to 5e–5, batch size 16–32, and standard weight decay and gradient clipping. For GLiNER2-PII, cross-entropy loss is computed over span-label pairs, with additional negative span sampling per batch.
3. Information Extraction Task Coverage
GLiNER2 supports a unified interface for:
- Zero-Shot Named Entity Recognition: Schema-driven, prompt-conditioned NER; span-level prediction per user-specified entity types.
- Text and Multi-Label Classification: Prompt-defined label spaces; supports binary/multi-class and multi-label settings.
- Hierarchical Structured Extraction: Supports extraction of structured records (e.g., products with fields), predicting both structure count and per-field spans in a single pass.
- Personally Identifiable Information Extraction (GLiNER2-PII): Fine-tuned for 42 categorized PII spans, supporting nested entities and multilingual generalization.
A summary of supported tasks and features:
| Task Type | Supported by GLiNER2 | Supported by GLiNER2-PII |
|---|---|---|
| NER | Yes | Yes (Fine-grained PII) |
| Classification | Yes | No |
| Structure | Yes | No |
| Multilingual | No | Yes |
| Nested Spans | Partial | Yes (Explicit) |
The schema-driven interface (API) abstracts prompt construction for all supported tasks, enabling dynamic adaptation to new labels or nested schemas.
4. Evaluation and Empirical Performance
GLiNER2 demonstrates competitive performance on standard benchmarks, approaching or matching LLMs while maintaining a substantially smaller resource footprint.
- Text Classification (Zero-Shot, 7 Benchmarks): Mean accuracy 0.72 for GLiNER2 (vs. DeBERTa-v3 0.69, GLiClass 0.63, GPT-4o >0.84).
- NER (Zero-Shot, CrossNER): Average F1 0.590 (comparable to GPT-4o at 0.599; best-in-class on Politics and Literature domains) (Zaratiana et al., 24 Jul 2025).
- PII Span Extraction (SPY Benchmark): GLiNER2-PII achieves the highest average F1 (0.471) among five compared systems, with especially high recall on both legal (0.722) and medical (0.681) queries. Competing baselines include OpenAI Privacy Filter and various GLiNER-based PII models, which trade recall for higher precision or vice versa (Zaratiana et al., 11 May 2026).
A selection of span-level metrics for PII extraction (SPY benchmark):
| Model | Precision (Legal) | Recall (Legal) | F1 (Legal) | Precision (Medical) | Recall (Medical) | F1 (Medical) | Avg F1 |
|---|---|---|---|---|---|---|---|
| GLiNER2-PII | 0.354 | 0.722 | 0.475 | 0.355 | 0.681 | 0.467 | 0.471 |
| OpenAI Privacy Filter | 0.25–0.27 | 0.64–0.67 | 0.373 | — | — | — | — |
| urchade / gliner_multi_pii-v1 | 0.48–0.52 | 0.31–0.31 | 0.384 | — | — | — | — |
| NVIDIA GLiNER-PII, knowledgator / gliner-pii-base | — | — | 0.368–0.391 | — | — | — | — |
The recall advantage is particularly relevant for PII redaction, where missing sensitive spans incurs higher risk than false positives.
5. Multilingual Generalization and Synthetic Data
GLiNER2-PII is trained exclusively on synthetic data generated across seven languages using a constraint-driven pipeline based on the Pioneer Agent framework. For each example, both label selection (to ensure distributional variety and annotation nesting) and diversity dimensions (document type, register, locale) are tightly controlled. Documents span support tickets, CRM notes, invoices, KYC forms, medical records, and more.
Although GLiNER2-PII is evaluated primarily on English-only benchmarks, held-out experiments on French and Spanish queries yield recall >0.65 with only a minor absolute drop in precision (~0.05). This suggests effective transfer from synthetic multilingual corpora to real non-English settings, despite the absence of real PII data in the training set (Zaratiana et al., 11 May 2026).
6. Deployment, Efficiency, and Extensibility
GLiNER2 is optimized for CPU deployment and fast inference:
- Model Size: ∼205–300M parameters.
- Latency: 130–210 ms per classification call (GLiNER2); GLiNER2-PII achieves 50–200 ms per medium-length document on 8–16 core CPU sockets.
- Memory: Runs in 4–6 GB RAM (GLiNER2); a 16 GB RAM instance can concurrently serve multiple GLiNER2-PII extraction requests via batching (Zaratiana et al., 24 Jul 2025, Zaratiana et al., 11 May 2026).
- Precision Calibration: Confidence thresholds may be tuned per-label to trade off recall and precision, and downstream filtering can be applied.
- Extensibility: The schema-driven architecture supports extension to new entity types (including domain- or locale-specific identifiers) by fine-tuning on targeted synthetic or annotated corpora.
- API Integration: GLiNER2 and GLiNER2-PII are distributed as open-source packages through Hugging Face and PyPI, offering a zero-dependency Python API and extract_entities function signature (Zaratiana et al., 11 May 2026).
7. Limitations and Future Directions
Current limitations include:
- Benchmark Coverage: Formal multilingual and hierarchical extraction benchmarks are lacking; further evaluations are required to quantify non-English and deep schema extraction performance.
- Instance Modeling: Structured extraction is limited to a fixed number (0–19) of structure instances; scalability for higher-frequency schemas may be improved by more flexible modeling.
- Relation Extraction: General relation extraction beyond parent-child schemas is not directly addressed; extensions may follow GLiREL-style architectures.
- Context Length: For documents exceeding the 2048-token context window, performance may degrade; sliding-window or hierarchical encoding strategies are suggested for future work.
- Pretraining Data: GLiNER2 base covers only English in the initial release; multilingual extensions are planned and realized in GLiNER2-PII for PII extraction.
A plausible implication is that schema-conditioned span extraction via compact transformers, coupled with large-scale synthetic data, provides a compelling approach for multilingual, fine-grained extraction tasks under deployment and privacy constraints. The modular architecture and schema-driven interface position GLiNER2 and derivatives as foundational tools for real-world, on-premises information extraction (Zaratiana et al., 24 Jul 2025, Zaratiana et al., 11 May 2026).