GLiNER (Entity Extraction)
Zero-shot named entity recognition service. Extract entities from text without training, using any custom labels.
Port: 8093
Model: urchade/gliner_multi-v2.1
What it Does
GLiNER extracts named entities from text with zero-shot capability:
- Zero-shot NER - Define custom entity types at runtime
- Multilingual - Works across multiple languages
- Flexible labels - No predefined entity types required
Use cases:
- Extract people, organizations, locations from documents
- Find custom entities (products, dates, amounts)
- Build knowledge graphs from unstructured text
API Endpoints
Extract Entities
Endpoint: POST /predict
curl -X POST "http://gliner-server:8093/predict" \
-H "Content-Type: application/json" \
-d '{
"text": "Apple Inc. was founded by Steve Jobs in Cupertino, California.",
"labels": ["person", "organization", "location"],
"threshold": 0.5
}'Request:
| Parameter | Type | Description |
|---|---|---|
text | string | Text to analyze |
labels | array | Entity types to extract |
threshold | number | Confidence threshold (0-1, default: 0.5) |
Response:
{
"entities": [
{"text": "Apple Inc.", "label": "organization", "score": 0.95, "start": 0, "end": 10},
{"text": "Steve Jobs", "label": "person", "score": 0.92, "start": 27, "end": 37},
{"text": "Cupertino, California", "label": "location", "score": 0.88, "start": 41, "end": 62}
]
}Preload Model
Force model loading (useful during startup):
curl -X POST "http://gliner-server:8093/preload"Health Check
curl http://gliner-server:8093/healthUsage Example
import requests
text = """
The merger between Microsoft and Activision Blizzard was approved
by the FTC on October 13, 2023. The deal was worth $68.7 billion.
"""
response = requests.post(
"http://gliner-server:8093/predict",
json={
"text": text,
"labels": ["company", "organization", "date", "money"],
"threshold": 0.4
}
)
for entity in response.json()["entities"]:
print(f"{entity['label']}: {entity['text']} ({entity['score']:.2f})")Output:
company: Microsoft (0.91)
company: Activision Blizzard (0.88)
organization: FTC (0.85)
date: October 13, 2023 (0.92)
money: $68.7 billion (0.89)Configuration
| Variable | Default | Description |
|---|---|---|
GLINER_MODEL | urchade/gliner_multi-v2.1 | Model name |
GLINER_THRESHOLD | 0.5 | Default confidence threshold |
GLINER_LABELS | - | Default labels (comma-separated) |
GLINER_DEVICE | auto | cuda:0, mps, cpu |
GLINER_MAX_CHARS | - | Truncate long inputs |
Tips
- Lower threshold (0.3-0.4) for recall, higher (0.6-0.8) for precision
- Specific labels work better than generic ones
- Batch processing - Send multiple texts for efficiency