Registry / ai-ml / gliner

gliner

JSON →
library0.2.26pypypi✓ verified 35d ago

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.

ai-mlllm-agents
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
musl
glibc
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}")
Debug
Known footguns
gotchaGLiNER requires `transformers>=4.51.3,<5`. This specific version constraint can lead to conflicts when integrating GLiNER into projects that use other machine learning libraries (e.g., `sentence-transformers`) which might require `transformers>=4.57` (or `transformers 5.x`).
breakingStarting from `v0.2.23`, GLiNER's updated `transformers` dependency (`>=4.57.3`, pulling `transformers 5.x`) breaks deployment on HuggingFace Inference Endpoints due to incompatibility with the `huggingface-inference-toolkit`.
gotchaOlder versions of GLiNER (prior to `0.2.25`) contained bugs that could cause crashes related to `apex.amp` imports if `torch` was not installed with CUDA, or issues with ONNX model loading when a `torch` file was unexpectedly absent.
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.

Agent activity
28 hits · last 30 days
petalbot
5
ahrefsbot
4
dotbot
3
bytedance
2
script
1
googlebot
1
chatgpt-user
1
Resources