Sponsored by
Vmake Labs Video Enhancer
-Vmake Labs Video Enhancer uses AI to improve video quality, restore details, reduce blur, and upscale videos to 8K.
🔗 GLiNER-relex: Generalist and Lightweight Model for Joint Zero-Shot NER and Relation Extraction
GLiNER-relex is a unified model for
zero-shot Named Entity Recognition (NER)
and
Relation Extraction (RE)
that performs both tasks simultaneously in a single forward pass. Built on the GLiNER architecture, it extends the span-based approach to jointly identify entities and extract relationships between them.
✨ Key Features
Joint Extraction
: Simultaneously extracts entities and relations in one forward pass
Zero-Shot
: No fine-tuning required - specify entity types and relation types at inference time
Efficient
: Single encoder architecture processes both tasks together
Flexible
: Supports custom entity and relation schemas per inference call
Production-Ready
: ONNX export support for deployment
📦 Installation
First, install the GLiNER library:
pip install gliner -U
🚀 Quick Start
Basic Usage
from gliner import GLiNER
# Load the model
model = GLiNER.from_pretrained("knowledgator/gliner-relex-large-v0.5")
# Define your entity types and relation types
entity_labels = ["location", "person", "date", "structure"]
relation_labels = ["located in", "designed by", "completed in"]
# Input text
text = "The Eiffel Tower, located in Paris, France, was designed by engineer Gustave Eiffel and completed in 1889."# Run inference - returns both entities and relations
entities, relations = model.inference(
texts=[text],
labels=entity_labels,
relations=relation_labels,
threshold=0.5,
adjacency_threshold=0.55,
relation_threshold=0.8,
return_relations=True
)
# Print entitiesprint("Entities:")
for entity in entities[0]:
print(f" {entity['text']} -> {entity['label']} (score: {entity['score']:.3f})")
# Print relationsprint("\nRelations:")
for relation in relations[0]:
head = relation['head']['text']
tail = relation['tail']['text']
rel_type = relation['relation']
score = relation['score']
print(f" {head} --[{rel_type}]--> {tail} (score: {score:.3f})")
texts = [
"Elon Musk founded SpaceX in Hawthorne, California.",
"Microsoft, led by Satya Nadella, acquired GitHub in 2018.",
"The Louvre Museum in Paris houses the Mona Lisa."
]
entity_labels = ["person", "organization", "location", "artwork"]
relation_labels = ["founder of", "CEO of", "located in", "acquired", "houses"]
entities, relations = model.inference(
texts=texts,
labels=entity_labels,
relations=relation_labels,
threshold=0.5,
relation_threshold=0.5,
batch_size=8,
return_relations=True
)
for i, (text_entities, text_relations) inenumerate(zip(entities, relations)):
print(f"\nText {i + 1}:")
print(f" Entities: {[e['text'] for e in text_entities]}")
print(f" Relations: {[(r['head']['text'], r['relation'], r['tail']['text']) for r in text_relations]}")
Entity-Only Extraction
If you only need entities without relations:
entities = model.inference(
texts=[text],
labels=entity_labels,
relations=[], # Empty list for relations
threshold=0.5,
return_relations=False# Skip relation extraction
)
⚙️ Advanced Configuration
Adjusting Thresholds
You can fine-tune extraction sensitivity with separate thresholds:
We recommend lowering the
threshold
(entity extraction threshold) and keeping it in the range of 0.3–0.5. For
adjacency_threshold
, the model provides good results in the 0.5–0.65 range. For
relation_threshold
, use larger values like 0.7–0.9. Feel free to adjust all of these values based on your project requirements.
📊 Output Format
Entity Format
{
"start": int, # Start character position"end": int, # End character position "text": str, # Entity text span"label": str, # Entity type"score": float# Confidence score (0-1)
}
gliner-relex-large-v0.5 huggingface.co is an AI model on huggingface.co that provides gliner-relex-large-v0.5's model effect (), which can be used instantly with this knowledgator gliner-relex-large-v0.5 model. huggingface.co supports a free trial of the gliner-relex-large-v0.5 model, and also provides paid use of the gliner-relex-large-v0.5. Support call gliner-relex-large-v0.5 model through api, including Node.js, Python, http.
gliner-relex-large-v0.5 huggingface.co is an online trial and call api platform, which integrates gliner-relex-large-v0.5's modeling effects, including api services, and provides a free online trial of gliner-relex-large-v0.5, you can try gliner-relex-large-v0.5 online for free by clicking the link below.
knowledgator gliner-relex-large-v0.5 online free url in huggingface.co:
gliner-relex-large-v0.5 is an open source model from GitHub that offers a free installation service, and any user can find gliner-relex-large-v0.5 on GitHub to install. At the same time, huggingface.co provides the effect of gliner-relex-large-v0.5 install, users can directly use gliner-relex-large-v0.5 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
gliner-relex-large-v0.5 install url in huggingface.co: