Skip to main content

Multitask Models

Overview​

Multitask models handle several natural language processing tasks with a shared encoder. Knowledgator provides GLiFormer checkpoints with dedicated task heads and GLiNER multitask models with task-specific pipelines.

GLiFormer Models​

GLiFormer accepts labels and extraction schemas at inference time. Both v1 checkpoints support entity recognition, text classification, joint relation extraction, multilevel structured records, and text embeddings.

ModelParametersEncoder layersEmbedding dimensionConfigured max_len
GLiFormer Base v1264.2M1276816,384
GLiFormer Large v1575.6M2410248,192

Both checkpoints use the gliformer-layout model type and include NER, classification, joint relations, multilevel structuring, and embedding heads. Both configure a maximum span width of 12 words and 100 structuring record anchors.

Text and schema prompts share the encoder budget. max_len is a configuration setting, not a measured guarantee of quality for inputs of that length. The reported evaluations cover English text.

import torch
from gliformer import GLiFormer

model = GLiFormer.from_pretrained(
"knowledgator/gliformer-base-v1",
load_tokenizer=True,
)
model = model.to("cuda" if torch.cuda.is_available() else "cpu").eval()

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

See Installation, Usage, and Pretrained Models for setup, nested schemas, checkpoint details, and reported metrics.

GLiNER Multitask Models​

Supported Tasks​

GLiNER multitask models support the following tasks:

  • Classification: Categorize text into predefined classes for tasks like sentiment analysis, topic classification, or content categorization
  • Question-Answering: Extract answers to natural language questions from given text passages
  • Relation Extraction: Identify and extract relationships between entities in text
  • Open Information Extraction: Extract structured information from text using custom prompts and label definitions
  • Summarization: Generate concise summaries of longer text passages

Benefits​

  • Efficiency: Use a single model for multiple tasks instead of managing separate models
  • Consistency: Shared representations ensure consistent understanding across different tasks
  • Flexibility: Easily switch between tasks without loading different models
  • Resource-Friendly: Reduced memory footprint and deployment complexity

Multitask Models​

Name▼Encoder▼Size (GB)▼Zero-Shot F1 Score▼
gliner-multitask-v1.0deberta-v2-xlarge3.640.6325
gliner-multitask-large-v0.5deberta-v3-large1.760.6276
gliner-llama-multitask-1B-v1.0Llama-encoder-1.0B4.240.6153

Classification​

from gliner import GLiNER
from gliner.multitask import GLiNERClassifier

model_id = 'knowledgator/gliner-multitask-v1.0'
model = GLiNER.from_pretrained(model_id)
classifier = GLiNERClassifier(model=model)
text = "SpaceX successfully launched a new rocket into orbit."
labels = ['science', 'technology', 'business', 'sports']
predictions = classifier(text, classes=labels, multi_label=False)
print(predictions)
Expected Output
[[{'label': 'technology', 'score': 0.3839840292930603}]]

Question-Answering​

from gliner import GLiNER
from gliner.multitask import GLiNERQuestionAnswerer

model_id = 'knowledgator/gliner-multitask-v1.0'
model = GLiNER.from_pretrained(model_id)
answerer = GLiNERQuestionAnswerer(model=model)
text = "SpaceX successfully launched a new rocket into orbit."
question = 'Which company launched a new rocket?'
predictions = answerer(text, questions=question)
print(predictions)
Expected Output
[[{'answer': 'SpaceX', 'score': 0.998126208782196}]]

Relation Extraction​

from gliner import GLiNER
from gliner.multitask import GLiNERRelationExtractor

model_id = 'knowledgator/gliner-multitask-v1.0'
model = GLiNER.from_pretrained(model_id)
relation_extractor = GLiNERRelationExtractor(model=model)
text = "Elon Musk founded SpaceX in 2002 to reduce space transportation costs."
relations = ['founded', 'owns', 'works for']
entities = ['person', 'company', 'year']
predictions = relation_extractor(text, entities=entities, relations=relations)
print(predictions)
Expected Output
[[{'source': 'Elon Musk', 'relation': 'founded', 'target': 'SpaceX', 'score': 0.9583475589752197}]]

Open Information Extraction​

from gliner import GLiNER
from gliner.multitask import GLiNEROpenExtractor

model_id = 'knowledgator/gliner-multitask-v1.0'
model = GLiNER.from_pretrained(model_id)
extractor = GLiNEROpenExtractor(model=model, prompt="Extract all companies related to space technologies")
text = "Elon Musk founded SpaceX in 2002 to reduce space transportation costs. Also Elon is founder of Tesla, NeuroLink and many other companies."
labels = ['company']
predictions = extractor(text, labels=labels)
print(predictions)
Expected Output
[[{'start': 72, 'end': 78, 'text': 'SpaceX', 'label': 'company', 'score': 0.9622299075126648}, {'start': 149, 'end': 154, 'text': 'Tesla', 'label': 'company', 'score': 0.9357912540435791}, {'start': 156, 'end': 165, 'text': 'NeuroLink', 'label': 'company', 'score': 0.9122058749198914}]]

Summarization​

from gliner import GLiNER
from gliner.multitask import GLiNERSummarizer

model_id = 'knowledgator/gliner-multitask-v1.0'
model = GLiNER.from_pretrained(model_id)
summarizer = GLiNERSummarizer(model=model)
text = "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975 to develop and sell BASIC interpreters for the Altair 8800. During his career at Microsoft, Gates held the positions of chairman, chief executive officer, president and chief software architect, while also being the largest individual shareholder until May 2014."
summary = summarizer(text, threshold=0.1)
print(summary)
Expected Output
['Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975 to develop and sell BASIC interpreters for the Altair 8800. During his career at Microsoft, Gates held the positions of chairman, chief executive officer, president and chief software architect, while also being the largest individual shareholder until May 2014.']

More details on usage​