GLiNER
Generalist and Lightweight Model for Named Entity Recognition (Extract any entity types from texts)
What is GLiNER?
Generalist and Lightweight Model for Named Entity Recognition (Extract any entity types from texts)
Overview of GLiNER
What it is
GLiNER is a framework for training and deploying small Named Entity Recognition (NER) models with zero-shot capabilities. It supports incremental streaming NER, joint entity and relation extraction, and multi-task token classification. The models are fine-tunable, optimized to run on CPUs and consumer hardware, and have performance competitive with larger models like ChatGPT and UniNER.
Key features
- Zero-shot NER: extract any entity type without labeled data or task-specific training.
- Runs on CPU and edge devices: supports FP16 and INT8 quantization, torch.compile, and ONNX export.
- Scalable to millions of labels via bi-encoder architecture that pre-computes label embeddings.
- Joint entity and relation extraction (RelEx architecture) for building knowledge graphs in a single pass.
- PII detection: state-of-the-art multilingual models covering major entity types across 100+ languages.
- Fine-tuning in minutes: few-shot learning on small datasets with competitive results.
- Serving layer with dynamic batching and HTTP API based on Ray Serve for production workloads.
Use cases
- Compliance and PII redaction: detect and mask 40+ types of personal data across documents and data pipelines.
- Knowledge graph construction: jointly extract entities and relations to power Graph RAG, semantic search, and analytics.
- Large-scale entity extraction: use the bi-encoder to tag millions of documents against hundreds or thousands of entity types.
- Domain-specific NER: fine-tune on biomedical, legal, financial, or any specialized corpus with minimal labeled data.
- Multi-lingual information extraction: extract structured data from 100+ languages with a single model.
- Search and retrieval augmentation: parse queries into structured entities to improve search relevance and RAG pipelines.
Getting started
Installation: bash pip install gliner Or with uv (faster): bash uv pip install gliner For serving support: bash uv pip install gliner[serve] Basic usage: python from gliner import GLiNER model = GLiNER.from_pretrained('gliner-community/gliner_small-v2.5') text = '''Cristiano Ronaldo dos Santos Aveiro (born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team.''' labels = ['person', 'date', 'organization', 'location'] entities = model.predict_entities(text, labels, threshold=0.5) for entity in entities: print(entity['text'], '=>', entity['label'])
License and pricing
Licensed under Apache-2.0. Open source.
Based on the project's public README and repository metadata.