Practical overview
When it fits
Use GLiREL when a text-processing workflow needs to identify relationships between entities using labels that can be specified at inference time.
Who it is for
- NLP developers building information-extraction workflows
- Teams that need to identify task-specific relationships between entities in text
- Python users integrating relation extraction into spaCy
Documented uses
- Classify entity pairs using relation labels chosen for a particular task.
- Constrain candidate relationships by the allowed entity types for each head and tail.
- Add relation extraction to a spaCy text-processing pipeline.
Requirements & limits
- Direct prediction uses tokenized text, candidate labels and entity spans.
- The spaCy example places GLiREL after NER and passes relation-label configuration at inference time.
- The README demonstrates constraints on allowable head and tail entity types.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Set up direct relation prediction
Install GLiREL and prepare a Python workflow that loads a pretrained model for relation prediction.
Before you start
- Python
- The GLiREL package, installed with pip
- spaCy and an English model such as en_core_web_sm, as used in the example
Steps
Install the package with pip install glirel.
Import GLiREL and load the documented pretrained model with GLiREL.from_pretrained.
Use spaCy to tokenize text, then provide the tokens, candidate relation labels and entity spans to predict_relations.
Expected outcome
A Python workflow that returns predicted relations with head and tail entities, labels and scores.
Guide limitations
- The example supplies entity spans directly; it does not document an end-to-end named-entity recognition setup for this direct workflow.
- The README example uses an English spaCy model.
Add GLiREL to a spaCy pipeline
Configure a spaCy pipeline to include GLiREL after the named-entity recognition component.
Before you start
- Python
- GLiREL and spaCy
- A spaCy model with an NER component, such as en_core_web_sm
Steps
Load the spaCy model.
Add the GLiREL component to the pipeline after ner.
Pass text and a glirel_labels configuration through nlp.pipe, then read the relations from the document.
Expected outcome
A spaCy document whose relations can be retrieved from its GLiREL relation data.
Guide limitations
- The README illustrates this with an English pipeline.
- The example configures relation labels and entity-type constraints; it does not specify a universal label set.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 18 October 2026
- Original website title
- jackboyla/GLiREL · Official homepage title · retained in its source language

