GLiNER2: Unified Schema-Based Information Extraction and Text Classification#
Extract entities, classify text, parse structured data, and extract relations—all in one efficient model.
GLiNER2 unifies Named Entity Recognition, Text Classification, Structured Data Extraction, and Relation Extraction into a single 205M parameter model. It provides efficient CPU-based inference without requiring complex pipelines or external API dependencies.
from gliner2 import GLiNER2
# Load the model
extractor = GLiNER2.from_pretrained("fastino/gliner2-large-v1")
# Extract entities with descriptions for higher precision
text = "Patient received 400mg ibuprofen for severe headache at 2 PM."
result = extractor.extract_entities(
text,
{
"medication": "Names of drugs, medications, or pharmaceutical substances",
"dosage": "Specific amounts like '400mg', '2 tablets', or '5ml'",
"symptom": "Medical symptoms, conditions, or patient complaints",
"time": "Time references like '2 PM', 'morning', or 'after lunch'"
}
)
print(result)
# Output: {'entities': {'medication': ['ibuprofen'], 'dosage': ['400mg'], 'symptom': ['severe headache'], 'time': ['2 PM']}}
This model can be fine-tuned locally with the gliner2 trainer (see the training guide). To fine-tune or serve it without managing GPUs, the Fastino API offers hosted training and inference, usually faster than training locally.
If you use this model in your research, please cite:
@misc{zaratiana2025gliner2efficientmultitaskinformation,
title={GLiNER2: An Efficient Multi-Task Information Extraction System with Schema-Driven Interface},
author={Urchade Zaratiana and Gil Pasternak and Oliver Boyd and George Hurn-Maloney and Ash Lewis},
year={2025},
eprint={2507.18546},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2507.18546},
}