knowledgator/gliformer-large-v1

Model

GLiFormer Large v1

113

13 commits

1 linked in READMEs

updated Sep 18, 2026

See the code
deberta
document-understanding
feature-extraction
gliformer
named-entity-recognition
pytorch
relation-extraction
structured-extraction
text-classification
token-classification

README

GLiFormer Large v1

One encoder for PDF layout processing, entity recognition, classification, relation extraction, structured records, and text embeddings.

GLiFormer supported tasks

knowledgator/gliformer-large-v1 is the 575.6M-parameter large release of GLiFormer. It accepts task labels and extraction schemas at inference time, with task heads sharing a DeBERTa encoder. The layout-aware architecture supports text and document-layout inputs; the usage examples and quality results below focus on text tasks.

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 .

Optional CUDA attention kernels are available with pip install -e ".[flash]". CPU inference uses eager attention. The following examples reuse model:

import torch
from gliformer import GLiFormer

model = GLiFormer.from_pretrained(
    "knowledgator/gliformer-large-v1",
    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

Specify the entity types at inference time:

text = "Alice works at Acme in London."
entities = model.predict_entities(
    text,
    ["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

Supply entity and relation labels together to use this checkpoint's joint relation head:

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"])

inference returns a dictionary of task outputs, each containing one result per input text. The separate predict_relations convenience method requires an open relation head; use joint_relations for this model.

Structured extraction

Extract records directly into a Python dictionary:

records = model.structure(
    "Alice works at Acme.",
    {"employee": ["name", "company"]},
)
print(records)
# {'employee': [{'name': 'Alice', 'company': 'Acme'}]}

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)

The decoder assembles source-grounded fields and parent–child relationships into nested records. Predictions depend on the schema, input, and thresholds; Pydantic validation checks the output schema, not factual correctness.

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(embeddings.shape)  # torch.Size([2, 1024])
print(F.cosine_similarity(embeddings[0:1], embeddings[1:2]).item())

Reported evaluation results

TaskMetricScore
NER, 26 datasets / 131,156 examplesMean dataset strict entity F150.91
CrossNER, 5 domains / 2,505 examplesMean domain strict entity F164.35
Classification, 13 datasets / 79,828 examplesMean dataset macro-F175.03
Multilevel structuring, 500 examplesOrder-free, boundary-tolerant JSON F191.10

Dataset means weight datasets equally. NER requires both the entity span and type to match. Classification macro-F1 averages class F1 scores within each dataset. Structuring compares flattened JSON value paths after aligning records without requiring their original order and allowing the evaluator's limited boundary repairs; it is not exact JSON match. The manuscript corrects the structuring evaluation size to 500; historical notes contain obsolete bucket counts totaling 300.

Named entity recognition

DatasetExamplesPrecisionRecallF1
ACE 200481251.6729.0037.15
ACE 20051,06044.8822.4229.90
AnatEM3,83026.1831.7428.70
bc2gm5,00045.4651.5348.30
bc4chemd26,36440.7467.5850.84
bc5cdr4,79761.9272.0566.60
Broad Tweet Corpus2,00055.5570.9962.33
CoNLL 20033,45358.9672.8265.16
CrossNER_AI43151.6951.8351.76
CrossNER_literature41663.1160.1061.57
CrossNER_music46567.4866.1766.82
CrossNER_politics65070.4672.5271.48
CrossNER_science54371.6368.6970.13
FabNER2,06427.1718.4721.99
FindVehicle20,77742.1151.2146.21
GENIA_NER1,85448.4257.2352.46
HarveyNER1,3039.9522.5413.81
mit-movie2,44263.1052.9857.60
mit-restaurant1,52038.8830.2534.03
MultiNERD10,00054.9691.9168.79
ncbi94047.6364.0554.63
Ontonotes8,26228.2042.1833.80
PolyglotNER10,00035.5270.8547.31
TweetNER757643.4648.6245.90
WikiANN en10,00054.8557.7456.26
WikiNeural11,59773.9387.5380.16

Text classification

DatasetExamplesAccuracyMacro-F1Weighted F1
SetFit/CR37691.2290.4591.20
SetFit/sst21,82192.9792.9792.97
SetFit/sst52,21044.3440.3343.39
stanfordnlp/imdb25,00093.9493.9393.93
SetFit/20_newsgroups7,53257.9457.1858.70
SetFit/enron_spam2,00097.9597.9597.95
AmazonScience/massive2,97471.3269.9871.93
PolyAI/banking773,08070.9770.5570.55
mteb/financial_phrasebank1,12997.2596.7797.24
SetFit/ag_news7,60082.0781.5381.53
dair-ai/emotion2,00054.7548.0755.59
MoritzLaurer/cap_sotu23,04051.7449.0051.15
cornell-movie-review-data/rotten_tomatoes1,06686.6886.6886.68

Micro-F1 equals accuracy in these single-label runs. Reported prediction coverage is 97.15% for 20 Newsgroups and 100% for the other datasets. Summary scores retain the original reports' precision; means of the rounded rows can differ by 0.01.

Joint relation extraction

These runs use predicted entities. Gold counts are relation instances, not documents. Base and large were evaluated on different-sized subsets, so their relation scores are not a controlled comparison on identical examples.

DatasetGold relationsPrecisionRecallMicro-F1Macro-F1
DocRED6,00329.908.1312.783.64
CrossRE1,92622.768.7212.6111.72
FewRel50021.8626.8024.0821.40
CoNLL04 zero-shot67738.4733.5335.8335.32

CoNLL04 zero-shot typed F1, which also checks endpoint entity types, is 34.73%.

Multilevel structuring

Gold JSON depthOrder-free, boundary-tolerant F1
389.94
495.11
591.69
6+92.80

Evaluation provenance and reproduction

You can find more information on the evaluation methodology here: https://www.knowledgator.com/research

Evaluation entry points are in gliformer_eval. For example, after preparing the CrossNER files, run from the framework repository:

python gliformer_eval/eval_ner.py \
  --model knowledgator/gliformer-large-v1 \
  --data data/NER \
  --datasets CrossNER_AI CrossNER_literature CrossNER_music CrossNER_politics CrossNER_science \
  --output eval_results/gliformer_large_v1_ner.json

Each dataset directory must contain labels.json and test.json. The other task entry points are eval_classification.py, eval_relex.py, and eval_structuring.py; use --help for data paths and inference settings. Reproduction requires matching the original data subsets, schema labels, thresholds, and decoding settings.

Training and intended use

The checkpoint uses the backbone listed above with supervised task heads for information extraction, classification, structuring, and embeddings. See the manuscript for the documented multitask training mixtures. Full checkpoint-specific training provenance is not recorded in the saved evaluation reports.

Use this model for extracting labeled mentions, candidate classes, relations, and structured records from text, and for producing text similarity vectors. The available results cover English tasks. Quality on other languages, document-layout inputs, and embedding benchmarks is not established by the tables above.

Limitations

  • Labels, schema wording, domain, input length, and thresholds affect predictions.
  • Extraction can omit information, choose incorrect spans, or attach records to the wrong parent.
  • Reported NER transfer groups do not establish that every evaluated domain was absent from training.
  • Fixed record anchors and the configured span width constrain extraction capacity.
  • This checkpoint has no dedicated vision, audio, or open relation head.

Contributors

Ihor

13 commits

knowledgator/gliformer-large-v1

Model

GLiFormer Large v1

113

13 commits

1 linked in READMEs

updated Sep 18, 2026

See the code
deberta
document-understanding
feature-extraction
gliformer
named-entity-recognition
pytorch
relation-extraction
structured-extraction
text-classification
token-classification

README

GLiFormer Large v1

One encoder for PDF layout processing, entity recognition, classification, relation extraction, structured records, and text embeddings.

GLiFormer supported tasks

knowledgator/gliformer-large-v1 is the 575.6M-parameter large release of GLiFormer. It accepts task labels and extraction schemas at inference time, with task heads sharing a DeBERTa encoder. The layout-aware architecture supports text and document-layout inputs; the usage examples and quality results below focus on text tasks.

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 .

Optional CUDA attention kernels are available with pip install -e ".[flash]". CPU inference uses eager attention. The following examples reuse model:

import torch
from gliformer import GLiFormer

model = GLiFormer.from_pretrained(
    "knowledgator/gliformer-large-v1",
    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

Specify the entity types at inference time:

text = "Alice works at Acme in London."
entities = model.predict_entities(
    text,
    ["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

Supply entity and relation labels together to use this checkpoint's joint relation head:

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"])

inference returns a dictionary of task outputs, each containing one result per input text. The separate predict_relations convenience method requires an open relation head; use joint_relations for this model.

Structured extraction

Extract records directly into a Python dictionary:

records = model.structure(
    "Alice works at Acme.",
    {"employee": ["name", "company"]},
)
print(records)
# {'employee': [{'name': 'Alice', 'company': 'Acme'}]}

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)

The decoder assembles source-grounded fields and parent–child relationships into nested records. Predictions depend on the schema, input, and thresholds; Pydantic validation checks the output schema, not factual correctness.

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(embeddings.shape)  # torch.Size([2, 1024])
print(F.cosine_similarity(embeddings[0:1], embeddings[1:2]).item())

Reported evaluation results

TaskMetricScore
NER, 26 datasets / 131,156 examplesMean dataset strict entity F150.91
CrossNER, 5 domains / 2,505 examplesMean domain strict entity F164.35
Classification, 13 datasets / 79,828 examplesMean dataset macro-F175.03
Multilevel structuring, 500 examplesOrder-free, boundary-tolerant JSON F191.10

Dataset means weight datasets equally. NER requires both the entity span and type to match. Classification macro-F1 averages class F1 scores within each dataset. Structuring compares flattened JSON value paths after aligning records without requiring their original order and allowing the evaluator's limited boundary repairs; it is not exact JSON match. The manuscript corrects the structuring evaluation size to 500; historical notes contain obsolete bucket counts totaling 300.

Named entity recognition

DatasetExamplesPrecisionRecallF1
ACE 200481251.6729.0037.15
ACE 20051,06044.8822.4229.90
AnatEM3,83026.1831.7428.70
bc2gm5,00045.4651.5348.30
bc4chemd26,36440.7467.5850.84
bc5cdr4,79761.9272.0566.60
Broad Tweet Corpus2,00055.5570.9962.33
CoNLL 20033,45358.9672.8265.16
CrossNER_AI43151.6951.8351.76
CrossNER_literature41663.1160.1061.57
CrossNER_music46567.4866.1766.82
CrossNER_politics65070.4672.5271.48
CrossNER_science54371.6368.6970.13
FabNER2,06427.1718.4721.99
FindVehicle20,77742.1151.2146.21
GENIA_NER1,85448.4257.2352.46
HarveyNER1,3039.9522.5413.81
mit-movie2,44263.1052.9857.60
mit-restaurant1,52038.8830.2534.03
MultiNERD10,00054.9691.9168.79
ncbi94047.6364.0554.63
Ontonotes8,26228.2042.1833.80
PolyglotNER10,00035.5270.8547.31
TweetNER757643.4648.6245.90
WikiANN en10,00054.8557.7456.26
WikiNeural11,59773.9387.5380.16

Text classification

DatasetExamplesAccuracyMacro-F1Weighted F1
SetFit/CR37691.2290.4591.20
SetFit/sst21,82192.9792.9792.97
SetFit/sst52,21044.3440.3343.39
stanfordnlp/imdb25,00093.9493.9393.93
SetFit/20_newsgroups7,53257.9457.1858.70
SetFit/enron_spam2,00097.9597.9597.95
AmazonScience/massive2,97471.3269.9871.93
PolyAI/banking773,08070.9770.5570.55
mteb/financial_phrasebank1,12997.2596.7797.24
SetFit/ag_news7,60082.0781.5381.53
dair-ai/emotion2,00054.7548.0755.59
MoritzLaurer/cap_sotu23,04051.7449.0051.15
cornell-movie-review-data/rotten_tomatoes1,06686.6886.6886.68

Micro-F1 equals accuracy in these single-label runs. Reported prediction coverage is 97.15% for 20 Newsgroups and 100% for the other datasets. Summary scores retain the original reports' precision; means of the rounded rows can differ by 0.01.

Joint relation extraction

These runs use predicted entities. Gold counts are relation instances, not documents. Base and large were evaluated on different-sized subsets, so their relation scores are not a controlled comparison on identical examples.

DatasetGold relationsPrecisionRecallMicro-F1Macro-F1
DocRED6,00329.908.1312.783.64
CrossRE1,92622.768.7212.6111.72
FewRel50021.8626.8024.0821.40
CoNLL04 zero-shot67738.4733.5335.8335.32

CoNLL04 zero-shot typed F1, which also checks endpoint entity types, is 34.73%.

Multilevel structuring

Gold JSON depthOrder-free, boundary-tolerant F1
389.94
495.11
591.69
6+92.80

Evaluation provenance and reproduction

You can find more information on the evaluation methodology here: https://www.knowledgator.com/research

Evaluation entry points are in gliformer_eval. For example, after preparing the CrossNER files, run from the framework repository:

python gliformer_eval/eval_ner.py \
  --model knowledgator/gliformer-large-v1 \
  --data data/NER \
  --datasets CrossNER_AI CrossNER_literature CrossNER_music CrossNER_politics CrossNER_science \
  --output eval_results/gliformer_large_v1_ner.json

Each dataset directory must contain labels.json and test.json. The other task entry points are eval_classification.py, eval_relex.py, and eval_structuring.py; use --help for data paths and inference settings. Reproduction requires matching the original data subsets, schema labels, thresholds, and decoding settings.

Training and intended use

The checkpoint uses the backbone listed above with supervised task heads for information extraction, classification, structuring, and embeddings. See the manuscript for the documented multitask training mixtures. Full checkpoint-specific training provenance is not recorded in the saved evaluation reports.

Use this model for extracting labeled mentions, candidate classes, relations, and structured records from text, and for producing text similarity vectors. The available results cover English tasks. Quality on other languages, document-layout inputs, and embedding benchmarks is not established by the tables above.

Limitations

  • Labels, schema wording, domain, input length, and thresholds affect predictions.
  • Extraction can omit information, choose incorrect spans, or attach records to the wrong parent.
  • Reported NER transfer groups do not establish that every evaluated domain was absent from training.
  • Fixed record anchors and the configured span width constrain extraction capacity.
  • This checkpoint has no dedicated vision, audio, or open relation head.

Contributors

Ihor

13 commits