Papers
Topics
Authors
Recent
Search
2000 character limit reached

GLiNER2: Unified CPU-Efficient IE System

Updated 13 April 2026
  • GLiNER2 is a unified, CPU-efficient IE system that integrates zero-shot NER, text classification, and hierarchical extraction in a compact 205M-parameter encoder.
  • It employs a bidirectional Transformer with a schema-driven prompting framework to achieve high throughput and low inference latency on standard CPUs.
  • Training leverages a composite dataset combining real-world and synthetic examples, enabling competitive performance and easy deployment via pip and Hugging Face.

GLiNER2 is a unified, CPU-efficient information extraction (IE) system designed to perform named entity recognition (NER), text classification, and arbitrary hierarchical structured data extraction within a single, compact model. Building upon the original GLiNER encoder–prompting paradigm, GLiNER2 broadens the scope of schema-driven, zero-shot IE while maintaining high throughput and minimal hardware requirements. The system exposes a declarative, JSON-style interface that allows joint specification of extraction and classification tasks, executed in a single forward pass (Zaratiana et al., 24 Jul 2025).

1. Architecture and Pretraining

GLiNER2 is implemented as a bidirectional Transformer encoder adopting a “base-plus” configuration: 12 layers, 768 hidden dimensions, 12 attention heads, 2,048 token context, and approximately 205 million parameters. Model initialization leverages a general-purpose pretrained encoder in the style of DeBERTa-v3-base, with key vocabulary extensions for four purpose-specific token types: P, E, C, and L. All special token embeddings are randomly initialized and updated jointly with task-specific layers.

The sole pretraining objective is masked language modeling (MLM):

LMLM=Ex[iMlogP(xixi)]L_{MLM} = - \mathbb{E}_{x}\left[ \sum_{i\in M} \log P(x_i \mid x_{\setminus i}) \right]

No task-specific or domain-adaptive pretraining is introduced beyond MLM. This design preserves generality and compatibility with the schema-driven prompting framework (Zaratiana et al., 24 Jul 2025).

2. Unified Prompting and Multi-Task Schema Interface

All GLiNER2 tasks utilize a shared “prompt ⊕ text” interface. The prompt encodes schema and task specifications, while text is the sequence to be processed. Prompt variants for the primary tasks are as follows:

  • Named Entity Recognition:

[P] entities ( [E] e₁ [E] e₂ … [E] e_n ) [[SEP](https://www.emergentmind.com/topics/semantic-entropy-production-sep-metric)] text Each [E] token encodes an entity type eje_j, with span representations hsih_{s_i} computed for candidate spans sis_i. Scoring is via

score(si,ej)=σ(hsihej)\text{score}(s_i, e_j) = \sigma( h_{s_i} \cdot h_{e_j} )

Candidate spans with scores above 0.5 are predicted as entities.

  • Hierarchical Structured Data Extraction:

[P] parent ( [C] a₁ [C] a₂ … [C] a_m ) [SEP] text [P] token is processed with a small MLP to predict the instance count KK (as a classification over integers 0–19). Each field [C] aka_k and each occurrence k=1...Kk=1...K receive a distinct embedding by combining the field and occurrence embeddings. Attribute extraction proceeds as in NER with dot-product/sigmoid matching.

  • Text Classification:

[P] task ( [L] ℓ₁ [L] ℓ₂ … [L] ℓ_k ) [SEP] text [L] tokens specify candidate labels i\ell_i, whose embeddings hih_{\ell_i} are transformed via an MLP to produce logits (eje_j0). Softmax over logits applies for single-label, and independent sigmoid for multi-label settings.

  • Task Composition:

Multiple prompts can be concatenated: [Prompt₁] ⊕ [SEP] ⊕ [Prompt₂] ⊕ … [SEP] ⊕ text, enabling simultaneous multi-task execution within a single run.

3. Training Protocol

GLiNER2 is trained on a composite dataset:

  • Real-world: 135,698 text samples from newswire, Wikipedia, legal documents, PubMed, and arXiv.
  • Synthetic: 118,636 GPT-4o-generated examples targeting business and personal domains.
  • Aggregate: 254,334 annotated examples, with GPT-4o assisting all annotations (NER, hierarchical fields, and classification).

Optimization targets the combined loss:

eje_j1

  • eje_j2: Binary cross-entropy over all span–type scores.
  • eje_j3: Sum of cross-entropy for instance counting (20-way) and binary cross-entropy for each field’s span–field score.
  • eje_j4: Multi-class cross-entropy for single-label tasks (over softmax outputs); binary cross-entropy for multi-label tasks (over sigmoid outputs).

Key hyperparameters include 5 epochs, AdamW optimizer, encoder LR eje_j5, task head LR eje_j6, weight decay 0.01, 1,000 warmup steps, and gradient clipping at 1.0 (Zaratiana et al., 24 Jul 2025).

4. Evaluation and Performance

GLiNER2 exhibits competitive zero-shot performance in both classification and NER tasks, while maintaining low inference latency on standard CPUs. Table summaries:

Zero-Shot Text Classification Accuracy

Dataset GPT-4o GLiClass DeBERTa-v3 GLiNER2
SNIPS 0.97 0.80 0.77 0.83
Banking77 0.78 0.21 0.42 0.70
Amazon Intent 0.72 0.51 0.59 0.53
SST-2 0.94 0.90 0.92 0.86
IMDB 0.95 0.92 0.89 0.87
AG News 0.85 0.68 0.68 0.74
20 Newsgroups 0.68 0.36 0.54 0.49
Average 0.84 0.63 0.69 0.72

CrossNER Zero-Shot F1 (NER)

Domain GPT-4o GLiNER-M GLiNER2
AI 0.547 0.518 0.526
Literature 0.561 0.597 0.564
Music 0.736 0.694 0.632
Politics 0.632 0.686 0.679
Science 0.518 0.581 0.547
Avg 0.599 0.615 0.590

CPU-based Inference Latency (ms)

# Labels GPT-4o DeBERTa GLiClass GLiNER2
5 358 1714 137 130
10 382 3404 131 132
20 425 6758 140 163
50 463 16897 190 208
Speedup 1.00× 0.10× 2.75× 2.62×

These results demonstrate that GLiNER2 matches or exceeds open-source baselines across tasks, operating below 200 ms inference latency on commodity CPUs for up to 50 labels.

5. Deployment, API, and Practical Use

GLiNER2 is distributed via pip (pip install gliner2) and integrates with Hugging Face Transformers. The software exposes a simple API with support for entity, classification, and hierarchical schema extraction. Usage consists of importing and loading a pretrained model, then submitting extraction calls with JSON-style schemas.

Example schema usages:

  • NER: {"entities": ["PERSON","LOCATION"]}
  • Hierarchical Extraction:

eje_j9

  • Classification: {"sentiment": ["positive", "negative", "neutral"]}
  • Mixed Tasks:

hsih_{s_i}0

All extractions within the schema are performed in a single, real-time (≈150 ms) forward pass on CPU. Hardware requirements are minimal, supporting on-premise and privacy-preserving deployments (Zaratiana et al., 24 Jul 2025).

6. Limitations and Future Directions

  • Absence of established zero-shot benchmarks for hierarchical structured extraction; thus, generalization in the wild remains unevaluated for this task type.
  • The current instance count prediction is limited to 19 (via 20-way classification), posing constraints for very large or deeply nested schemas (eje_j7, eje_j8).
  • Domain transfer to highly specialized text types (for example, legal-to-medical) likely requires further adapter-style fine-tuning.
  • Future research avenues include formalizing structured extraction benchmarks, extending count prediction beyond 19, and incorporating relation- and table-extraction under the schema-driven paradigm.

7. Context and Assessment

GLiNER2 unifies multiple IE paradigms—zero-shot NER, flexible classification, and unconstrained hierarchical schema extraction—within a single, efficient, 205 M-parameter encoder. The schema-driven prompting and minimal CPU requirements lower the barrier to deployment in resource-constrained settings. Zero-shot flexibility is retained from GLiNER, and only minimal performance degradation (~1–2 F1 points in NER) is observed relative to dedicated models, even as additional task capabilities are integrated. GLiNER2 represents an advancement in schema-driven IE, enabling joint, interpretable extraction and labeling routines from natural text via an efficient, extensible library (Zaratiana et al., 24 Jul 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to GliNER2.