Instructions to use knowledgator/gliformer-2b-v1.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiFormer
How to use knowledgator/gliformer-2b-v1.5 with GLiFormer:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
GLiFormer 2B v1.5 - the most versatile system one model
![]() |
![]() |
![]() |
What is GLiFormer
GLiFormer is a family of encoder models for information extraction. One shared encoder reads the text together with what to look for, and lightweight task heads produce the outputs: named entities, classes, relations, structured records (including categorical, number and date fields, nested records, and fields calculated from numbers in the text), text edits, and text embeddings. Entity types, class labels, relation types and record schemas are given at inference time, so no retraining is needed for new labels or schemas, and several tasks can run in one pass.
knowledgator/gliformer-2b-v1.5 uses the bidirectional Qwen3.5 encoder (Qwen/Qwen3.5-2B). The checkpoint also carries image classification and object detection heads; the usage examples and results below cover text tasks only.
Size: 2B refers to the backbone (2.21B parameters); with the task heads the checkpoint has 2.65B parameters in total.
Usage
pip install gliformer -U
Or install the GLiFormer framework in a Python 3.10+ environment from the source:
git clone https://github.com/Knowledgator/GLiFormer.git
cd GLiFormer
pip install -e .
The following examples reuse model:
import torch
from gliformer import GLiFormer
model = GLiFormer.from_pretrained(
"knowledgator/gliformer-2b-v1.5",
load_tokenizer=True,
)
model = model.to("cuda" if torch.cuda.is_available() else "cpu").eval()
For a local copy, replace the model ID with the checkpoint directory.
Named entity recognition
entities = model.predict_entities(
"Alice works at Acme in London.",
["person", "organization", "location"],
threshold=0.5,
)
for entity in entities:
print(entity["text"], entity["label"], entity["score"])
Each entity includes text, label, start, end, and score.
Offsets are character positions with an exclusive end.
Pass a list of texts and batch_size=8 for batched extraction.
Text classification
predictions = model.classify(
"The new search feature is fast and easy to use.",
["positive", "negative", "neutral"],
threshold=0.5,
)
print(predictions) # Label dictionaries containing class_name and score.
Named groups are also supported, for example
{"sentiment": ["positive", "negative"], "topic": ["product", "support"]}.
Joint relation extraction
results = model.inference(
"Alice works at Acme.",
joint_relations={
"employment": {
"entities": ["person", "organization"],
"relations": ["works_at"],
}
},
threshold=0.5,
)
for relation in results["joint_relex"][0]:
print(relation["head"]["text"], relation["relation"], relation["tail"]["text"])
Structured extraction
records = model.structure(
"Alice works at Acme.",
{"employee": ["name", "company"]},
)
print(records)
# {'employee': [{'name': 'Alice', 'company': 'Acme'}]}
Fields can be typed. A categorical field ("$type": "class") picks from the given $options instead of
copying text from the input ("$multi": False keeps a single label); date and number fields return
parsed values:
records = model.structure(
"Ticket #4821: Maria Lopez reports that her laptop will not boot after the update. "
"She needs it for a client demo tomorrow. Opened on March 3, 2025.",
{"ticket": {
"customer": {"$type": "text"},
"category": {"$type": "class", "$options": ["hardware", "software", "billing", "account"], "$multi": False},
"priority": {"$type": "class", "$options": ["low", "medium", "high"], "$multi": False},
"opened": {"$type": "date"},
}},
)
print(records)
# {'ticket': [{'customer': 'Maria Lopez', 'category': 'hardware', 'priority': ..., 'opened': datetime.date(2025, 3, 3)}]}
Without "$multi": False, a categorical field returns every option that applies, as a list.
Nested Pydantic schemas support multilevel records:
from pydantic import BaseModel
class Employee(BaseModel):
name: str
role: str
class Department(BaseModel):
name: str
employees: list[Employee]
class Company(BaseModel):
name: str
departments: list[Department]
records = model.structure(
"At Acme, Engineering includes Alice, a software engineer, and Bob, "
"a designer. Sales includes Carol, an account manager.",
{"company": Company},
validate_output=True,
)
print(records)
Calculated fields
A field marked "$calculate": true is computed by a small program over numbers read from the text
(copy, add, subtract, multiply, divide, ...). The optional prompt states the question:
result = model.inference(
"Revenue was $1,200 million in 2023 and $1,000 million in 2022.",
structures={"$root": {"growth": {
"$type": "text",
"$format": "number",
"$description": "Revenue change from 2022 to 2023",
"$calculate": True,
}}},
prompt="By how much did revenue grow from 2022 to 2023?",
decoder_kwargs={"value_spans": True},
)
print(result["structuring"][0]) # {'growth': {'value': ..., 'text': ...}}
print(result["calculation"][0]) # the program, e.g. subtract over the "1,200" and "1,000" spans
Text editing
edited = model.edit_text("She go to school every days.", instruction="fix grammar")
print(edited["text"]) # the corrected text
print(edited["edits"]) # character-level edits against the input
Multiple tasks in one call
results = model.inference(
"Alice joined Acme as a software engineer.",
entities=["person", "organization"],
classes=["business", "sports", "technology"],
structures={"employee": ["name", "company"]},
)
print(results["ner"][0])
print(results["classification"][0])
print(results["structuring"][0])
Text embeddings
import torch.nn.functional as F
embeddings = model.embed_text([
"A scientist works in a laboratory.",
"A researcher conducts an experiment.",
])
print(F.cosine_similarity(embeddings[0:1], embeddings[1:2]).item())
Evaluation results
| Task | Metric | Score |
|---|---|---|
| NER, 26 datasets (up to 500 examples each) | Mean dataset strict entity F1 | 56.80 |
| NER, CrossNER + MIT (7 datasets) | Mean dataset strict entity F1 | 69.09 |
| Classification, 13 datasets | Mean dataset macro-F1 | 78.39 |
| Joint relation extraction, 3 datasets | Mean dataset micro-F1 | 27.58 |
| Multilevel structuring, 500 examples | Order-free, boundary-tolerant JSON F1 | 84.54 |
| Flat multi-record structuring, 300 examples | Order-free, boundary-tolerant JSON F1 | 91.08 |
| Calculation (FinQA / ConvFinQA / TAT-QA), 595 questions | Exact answer | 52.44 |
Dataset means weight datasets equally. NER requires both the entity span and type to match; NER and relation extraction use a 0.5 threshold. Classification macro-F1 averages class F1 scores within each dataset. Structuring compares flattened JSON value paths; "order-free, boundary-tolerant" aligns records without requiring their original order and allows the evaluator's limited boundary repairs; it is not exact JSON match. Most evaluated datasets contributed 30-200 training-split examples (never test examples) to the final fine-tuning data; โ marks datasets with none, whose scores are zero-shot.
Comparison with other models
All three GLiFormer v1.5 checkpoints are listed, with this model in bold. GLiNER, NLI, LLM and GLiFormer v1 numbers are published results from the GLiFormer paper (Tables 3-5); Params are total parameters, NR means not reported. Rows are sorted by average.
CrossNER, strict entity F1. The Perplexity Decider models were run through the OpenRouter Extractions API on the same test examples as the GLiFormer v1.5 rows (CrossNER politics and science: the same 500-example samples), with one list field per entity type and overlapping spans resolved by confidence. Paper baselines use the full test sets. CrossNER literature and music are zero-shot for GLiFormer v1.5 (see โ ).
| Model | Family | Params | AI | Literature | Music | Politics | Science | Avg. |
|---|---|---|---|---|---|---|---|---|
| Gemma-4-31B-IT | LLM | 31.0B | 63.12 | 74.72 | 67.28 | 76.97 | 71.60 | 70.74 |
| GPT-OSS-120B | LLM | 117.0B | 64.72 | 71.36 | 69.00 | 76.55 | 69.58 | 70.24 |
| GPT-5-mini | LLM | NR | 64.99 | 71.10 | 65.68 | 76.72 | 71.33 | 69.97 |
gliformer-2b-v1.5 |
GLiFormer v1.5 | 2.7B | 66.16 | 64.67 | 73.82 | 72.60 | 71.84 | 69.82 |
gliformer-0.4b-v1.5 |
GLiFormer v1.5 | 794M | 60.08 | 66.37 | 76.61 | 70.37 | 68.04 | 68.29 |
| GLiNER Multitask Large v0.5 | GLiNER | 440M | 51.05 | 68.96 | 74.30 | 78.27 | 67.29 | 67.97 |
| NuNER Zero-span | GLiNER | 449M | 60.12 | 64.89 | 69.95 | 72.73 | 66.42 | 66.82 |
gliformer-0.8b-v1.5 |
GLiFormer v1.5 | 1.3B | 62.66 | 63.02 | 69.66 | 66.88 | 69.48 | 66.34 |
| GLiFormer-base | GLiFormer v1 | 264M | 56.38 | 62.60 | 67.65 | 71.36 | 67.51 | 65.10 |
| GLiFormer-large | GLiFormer v1 | 576M | 51.76 | 61.57 | 66.82 | 71.48 | 70.13 | 64.35 |
| Gemma4-12B | LLM | 12.0B | 58.70 | 61.50 | 64.90 | 68.20 | 60.80 | 62.80 |
| Gemma-4-E4B | LLM | 8.0B | 57.90 | 51.40 | 60.80 | 70.30 | 60.50 | 60.20 |
| Qwen3.5 9B | LLM | 9.7B | 48.60 | 48.70 | 55.90 | 62.90 | 58.00 | 54.80 |
| Perplexity: Decider V1.3 | Decision model | NR | 55.21 | 51.57 | 61.12 | 52.28 | 52.35 | 54.50 |
| Perplexity: Decider Flash V1.3 | Decision model | NR | 56.00 | 51.40 | 56.62 | 52.41 | 52.10 | 53.70 |
| Gemma-4-E2B | LLM | 5.1B | 50.30 | 49.00 | 54.70 | 60.00 | 53.00 | 53.40 |
| Qwen3.5-2B | LLM | 2.3B | 20.90 | 23.30 | 28.30 | 28.80 | 30.90 | 26.40 |
| Qwen3.5-0.8B | LLM | 873M | 14.90 | 21.70 | 19.30 | 25.20 | 24.90 | 21.20 |
Text classification, mean macro-F1 over the same 13 datasets.
| Model | Family | Params | Mean macro-F1 |
|---|---|---|---|
| GPT-5-mini | LLM | NR | 79.79 |
| Gemma-4-31B-IT | LLM | 31.0B | 79.69 |
gliformer-2b-v1.5 |
GLiFormer v1.5 | 2.7B | 78.39 |
| Gemma4-12B | LLM | 12.0B | 77.80 |
| GPT-OSS-120B | LLM | 117.0B | 77.76 |
gliformer-0.4b-v1.5 |
GLiFormer v1.5 | 794M | 76.02 |
gliformer-0.8b-v1.5 |
GLiFormer v1.5 | 1.3B | 75.24 |
| GLiFormer-large | GLiFormer v1 | 576M | 75.03 |
| Gemma-4-E4B | LLM | 8.0B | 74.10 |
| GLiFormer-base | GLiFormer v1 | 264M | 72.36 |
| Qwen3.5 9B | LLM | 9.7B | 71.40 |
| Gemma-4-E2B | LLM | 5.1B | 70.80 |
| BGE-M3 zero-shot v2.0 | NLI | 568M | 58.33 |
| Qwen3.5-2B | LLM | 2.3B | 57.30 |
| mDeBERTa-v3-base MNLI/XNLI | NLI | 279M | 51.93 |
| Qwen3.5-0.8B | LLM | 873M | 45.20 |
Relation extraction, micro-F1. Averages cover only the three datasets evaluated here (the paper also reports CoNLL04). Baseline sample sizes and protocols follow their sources and may differ from the 500-document runs below, so treat this table as indicative. โ uses gold entities.
| Model | Entities | DocRED | CrossRE | FewRel | Avg. |
|---|---|---|---|---|---|
gliformer-0.4b-v1.5 |
predicted | 25.50 | 20.48 | 56.76 | 34.25 |
| Qwen3.5 9B | prompted | 11.60 | 3.80 | 71.60 | 29.00 |
gliformer-2b-v1.5 |
predicted | 17.70 | 23.01 | 42.03 | 27.58 |
gliformer-0.8b-v1.5 |
predicted | 16.74 | 17.85 | 36.08 | 23.56 |
| GLiNER-Relex | predicted | 31.30 | 18.10 | 12.50 | 20.63 |
| Gemma-4-31B-IT | prompted | 17.96 | 9.84 | 30.18 | 19.33 |
| GPT-OSS-120B | prompted | 17.77 | 10.99 | 28.79 | 19.18 |
| Qwen3.5-2B | prompted | 1.20 | 0.70 | 53.50 | 18.47 |
| GLiFormer-large | predicted | 12.78 | 12.61 | 24.08 | 16.49 |
| Qwen3.5-0.8B | prompted | 0.10 | 0.60 | 47.20 | 15.97 |
| GPT-5-mini | prompted | 18.60 | 12.40 | 15.00 | 15.33 |
| GLiFormer-base | predicted | 10.00 | 10.00 | 23.49 | 14.50 |
| Gemma4-12B | prompted | 14.00 | 7.90 | 15.50 | 12.47 |
| Gemma-4-E4B | prompted | 11.60 | 6.10 | 13.70 | 10.47 |
| GLiREL โ | gold | 2.40 | 1.40 | 24.00 | 9.27 |
| Gemma-4-E2B | prompted | 2.90 | 3.50 | 9.60 | 5.33 |
Named entity recognition
| Dataset | Examples | Precision | Recall | F1 |
|---|---|---|---|---|
| ACE 2004 | 500 | 45.70 | 32.53 | 38.01 |
| ACE 2005 | 500 | 46.15 | 33.86 | 39.07 |
| AnatEM | 500 | 42.76 | 53.25 | 47.43 |
| bc2gm | 500 | 44.98 | 61.01 | 51.78 |
| bc4chemd | 500 | 41.76 | 63.37 | 50.35 |
| bc5cdr | 500 | 66.81 | 74.27 | 70.34 |
| Broad Tweet Corpus | 500 | 54.35 | 74.93 | 63.00 |
| CoNLL 2003 | 500 | 67.07 | 75.80 | 71.16 |
| CrossNER_AI | 431 | 70.58 | 62.25 | 66.16 |
| CrossNER_literature โ | 416 | 66.87 | 62.62 | 64.67 |
| CrossNER_music โ | 465 | 74.62 | 73.04 | 73.82 |
| CrossNER_politics | 500 | 73.58 | 71.66 | 72.60 |
| CrossNER_science | 500 | 76.70 | 67.55 | 71.84 |
| FabNER | 500 | 33.60 | 25.06 | 28.71 |
| FindVehicle | 500 | 47.29 | 51.33 | 49.23 |
| GENIA_NER | 500 | 48.81 | 64.91 | 55.72 |
| HarveyNER | 500 | 16.55 | 51.61 | 25.07 |
| mit-movie | 500 | 73.37 | 71.25 | 72.29 |
| mit-restaurant โ | 500 | 67.07 | 58.06 | 62.24 |
| MultiNERD | 500 | 60.77 | 89.23 | 72.30 |
| ncbi | 500 | 47.38 | 60.67 | 53.21 |
| Ontonotes | 500 | 41.18 | 48.13 | 44.38 |
| PolyglotNER | 500 | 34.34 | 72.89 | 46.69 |
| TweetNER7 | 500 | 49.68 | 51.26 | 50.46 |
| WikiANN en | 500 | 59.01 | 62.59 | 60.75 |
| WikiNeural | 500 | 66.75 | 86.85 | 75.48 |
Text classification
| Dataset | Examples | Accuracy | Macro-F1 | Weighted F1 |
|---|---|---|---|---|
| SetFit/CR | 376 | 92.02 | 91.44 | 92.06 |
| SetFit/sst2 | 1,821 | 93.41 | 93.41 | 93.41 |
| SetFit/sst5 | 2,210 | 53.44 | 52.86 | 53.55 |
| stanfordnlp/imdb | 25,000 | 95.32 | 95.32 | 95.32 |
| SetFit/20_newsgroups โ | 7,532 | 57.98 | 58.55 | 59.77 |
| SetFit/enron_spam | 2,000 | 95.35 | 95.35 | 95.35 |
| AmazonScience/massive | 2,974 | 79.96 | 77.41 | 80.56 |
| PolyAI/banking77 | 3,080 | 78.57 | 78.05 | 78.05 |
| mteb/financial_phrasebank | 1,129 | 96.63 | 96.32 | 96.64 |
| SetFit/ag_news โ | 7,600 | 88.39 | 88.35 | 88.35 |
| dair-ai/emotion | 2,000 | 66.85 | 53.03 | 65.04 |
| MoritzLaurer/cap_sotu โ | 23,040 | 54.11 | 50.21 | 54.76 |
| cornell-movie-review-data/rotten_tomatoes | 1,066 | 88.84 | 88.82 | 88.82 |
Micro-F1 equals accuracy in these single-label runs. cap_sotu has no test split; its train split is scored.
Joint relation extraction
Runs use predicted entities, 500 documents per dataset (DocRED dev, CrossRE test, FewRel validation). Gold counts are relation instances, not documents.
| Dataset | Gold relations | Precision | Recall | Micro-F1 | Macro-F1 |
|---|---|---|---|---|---|
| DocRED | 5,924 | 20.66 | 15.48 | 17.70 | 8.89 |
| CrossRE | 1,920 | 23.83 | 22.24 | 23.01 | 17.36 |
| FewRel | 500 | 76.32 | 29.00 | 42.03 | 37.67 |
Structured extraction
| Set | Strict JSON F1 | Order-free JSON F1 | Order-free, boundary-tolerant F1 | Structure F1 |
|---|---|---|---|---|
| Multilevel, 500 examples | 72.59 | 82.01 | 84.54 | 88.16 |
| Flat multi-record, 300 examples | 82.13 | 90.42 | 91.08 | 94.30 |
Multilevel set by gold JSON depth:
| Gold JSON depth | Examples | Order-free, boundary-tolerant F1 |
|---|---|---|
| 2 | 300 | 91.40 |
| 3 | 67 | 82.01 |
| 4 | 67 | 72.75 |
| 5 | 66 | 67.84 |
Calculation
Financial question answering over tables and text: a 595-question sample of the FinQA, ConvFinQA and TAT-QA test splits. "Exact" requires the computed value to match the gold answer; "program exact" requires the predicted operation sequence to match.
| Subset | Questions | Exact | Within 1% | Program exact |
|---|---|---|---|---|
| All | 595 | 52.44 | 69.24 | 76.47 |
| FinQA | 187 | 56.15 | 65.78 | 74.33 |
| ConvFinQA | 240 | 53.75 | 68.33 | 74.17 |
| TAT-QA | 168 | 46.43 | 74.40 | 82.14 |
| Answer copied from text | 133 | 65.41 | 88.72 | 84.21 |
| Answer computed | 462 | 48.70 | 63.64 | 74.24 |
Citation
If you use this model, please cite the GLiFormer paper (knowledgator.com/research/gliformer):
@misc{stepanov2026gliformer,
title = {GLiFormer: A Generalist Multitask Transformer Encoder},
author = {Stepanov, Ihor and Shtopko, Mykhailo and Vodianytskyi, Dmytro and Lukashov, Oleksandr and Yaroshenko, Mykyta},
year = {2026},
month = sep,
publisher = {Knowledgator},
url = {https://www.knowledgator.com/research/gliformer}
}
- Downloads last month
- -



