GLiNER is a Python library providing a Generalist and Lightweight Model for Named Entity Recognition (NER). It's built on a bidirectional transformer encoder (BERT-like) and can identify any entity type using zero-shot capabilities. It serves as an efficient alternative to traditional NER models and large language models (LLMs) for resource-constrained environments, offering competitive performance on CPUs and consumer hardware. The library currently stands at version 0.2.26 with frequent updates and an active development cadence.
Install & Compatibility
Where this runs
tested against v0.2.26 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ dependency_conflict
✓ 87.78s
py 3.11
✕ dependency_conflict
✓ 83.2s
py 3.12
✕ dependency_conflict
✓ 75.9s
py 3.13
✕ no_wheel
7/8 runs
py 3.9
✕ dependency_conflict
✕ timeout
5086MB installed
● package 5086MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from gliner import GLiNER
This quickstart demonstrates how to load a pre-trained GLiNER model and use it to extract named entities from a given text based on a custom list of labels. The `predict_entities` method returns a list of dictionaries, each containing the extracted text, its predicted label, and a confidence score.
from gliner import GLiNER
# Initialize GLiNER with a pre-trained model
# Available models: "urchade/gliner_base", "urchade/gliner_small-v2.1", "urchade/gliner_medium-v2.1", "urchade/gliner_large-v2.1"
model = GLiNER.from_pretrained("urchade/gliner_medium-v2.1")
text = """Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; 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. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards, a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player."""
# Define the entity labels you want to extract
labels = ["person", "team", "organization", "location", "award", "nationality", "sport", "date"]
# Predict entities
entities = model.predict_entities(text, labels)
# Print the extracted entities
for entity in entities:
print(f"Text: {entity['text']}, Label: {entity['label']}, Score: {entity['score']:.2f}")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.