Illustration of what GLiNER does: Small zero-shot model that pulls any entity types out of text, CPU-friendly
AI-generated illustration

urchade /

GLiNER

Small zero-shot model that pulls any entity types out of text, CPU-friendly

Named entity recognition (NER) means finding things like people, dates, organizations and places in text. Classic NER models only know the labels they were trained on. GLiNER lets you pass in the labels you want at prediction time, such as person or credit card number, and returns the matching spans.

You load a pretrained model from Hugging Face, give it text and a list of labels, and call predict_entities. The models are small enough to run on a CPU. The README says they compete with larger LLMs like ChatGPT and UniNER on NER, and it offers torch.compile, FP16 and INT8 quantization, and ONNX export for speed.

Besides the original uni-encoder design, the repo has a bi-encoder for very large label sets, a joint entity and relation extraction model, a decoder variant that generates entity types, and a streaming model for incremental NER. You can fine-tune them on your own data, and a Ray Serve layer handles production serving.

What it does

  • Zero-shot entity extraction

    You choose the entity labels at prediction time. No labeled data or retraining is needed to try a new type.

  • Several architectures

    Uni-encoder, bi-encoder for large label sets, RelEx for entities plus relations, a decoder variant, and a streaming span model.

  • Small, fast inference

    Runs on CPU and consumer hardware. Options include torch.compile, FP16 and INT8 quantization, and ONNX export.

  • Fine-tuning

    Train on your own JSON dataset with a script or train_model(). Example notebooks cover Colab fine-tuning and synthetic data generation.

  • Ray Serve serving layer

    Adds dynamic batching, memory-aware batch sizing, multi-GPU replicas and an HTTP API for production use.

What you could build

  • Redact personal data such as emails, passports and card numbers from documents using the PII models.
  • Build a knowledge graph by extracting entities and relations together in one pass.
  • Tag large document collections against hundreds of entity types with the bi-encoder.
  • Fine-tune an entity extractor for biomedical, legal or financial text with a small labeled set.
  • Parse search queries into structured entities to improve search and RAG pipelines.

Get started

Install the package, then load a pretrained model with GLiNER.from_pretrained and call predict_entities with your text and a list of labels. The Colab notebook and Hugging Face Space linked in the README let you try it first.

pip install gliner

Commands are copied from the project's README. Read it on GitHub for the full setup.

More in Models & local AI

    ↑↓ to move, Enter to open, Esc to close