← Back to models

GLiNER2

recognizerLabelsZero-shotRelationsClassificationJSON Extraction

Extract entities, relations, classifications, and structured records from text with labels you choose at request time. This is Antfly's package of Fastino's GLiNER2 base checkpoint.

antfly inference pull antflydb/gliner2-base-v1
By antflydbLicense: apache-2.0Hugging Face source

Technical Specs

Architecture
GLiNER2 / DeBERTa-v3-base
Parameters
208M
English

About GLiNER2#

GLiNER2 is a unified multi-task model that performs named entity recognition, zero-shot classification, relation extraction, and structured JSON extraction from a single model. It uses a DeBERTa-v3-base encoder with the GLiNER2 architecture.

Unlike traditional NER models that are limited to predefined entity types, GLiNER2 accepts arbitrary labels at inference time, making it extremely flexible for diverse extraction tasks.

Capabilities#

  • Named Entity Recognition: Extract entities with custom labels
  • Relation Extraction: Extract (subject, relation, object) triplets from text
  • Zero-Shot Classification: Classify text into arbitrary categories
  • JSON Extraction: Extract structured data matching a schema

Use Cases#

Use CaseDescription
Document ProcessingExtract people, organizations, dates from contracts or reports
Knowledge GraphsBuild knowledge graphs by extracting entities and their relationships
Content TaggingClassify articles, support tickets, or reviews into custom categories
Data ExtractionPull structured fields from unstructured text (e.g., invoices, resumes)

Antfly Inference API Usage#

Pull the model and start Antfly:

antfly inference pull antflydb/gliner2-base-v1

antfly standalone

Every task goes through /ai/v1/extract. Declare entities, relations, classifications, and structures under schema.

Named Entity Recognition#

Extract entities with custom labels. No predefined entity types are needed.

curl -X POST "http://localhost:8080/ai/v1/extract" \
-H "Content-Type: application/json" \
-d '{
"model": "antflydb/gliner2-base-v1",
"inputs": [{"content": "Steve Jobs founded Apple in Cupertino, California."}],
"schema": {"entities": ["person", "organization", "location"]}
}'

Relation Extraction#

Extract relationships between entities as typed edges. Each relation names its source and target entity types:

curl -X POST "http://localhost:8080/ai/v1/extract" \
-H "Content-Type: application/json" \
-d '{
"model": "antflydb/gliner2-base-v1",
"inputs": [{"content": "Steve Jobs founded Apple in 1976."}],
"schema": {
  "entities": ["person", "organization"],
  "relations": [
    {"type": "founded_by", "source": "organization", "target": "person"}
  ]
}
}'

Zero-Shot Classification#

Classify text into arbitrary categories:

curl -X POST "http://localhost:8080/ai/v1/extract" \
-H "Content-Type: application/json" \
-d '{
"model": "antflydb/gliner2-base-v1",
"inputs": [{"content": "Apple reported record quarterly revenue of $124 billion."}],
"schema": {
  "classifications": [
    {"name": "topic", "labels": ["finance", "technology", "sports", "politics"]}
  ]
}
}'

Structured Extraction#

Extract structured records with named fields:

curl -X POST "http://localhost:8080/ai/v1/extract" \
-H "Content-Type: application/json" \
-d '{
"model": "antflydb/gliner2-base-v1",
"inputs": [{"content": "John Smith is a 35-year-old engineer at Google in Mountain View."}],
"schema": {
  "structures": {
    "person": {
      "fields": {"name": "str", "age": "str", "job_title": "str", "company": "str", "city": "str"}
    }
  }
}
}'

Supported Tasks#

TaskSchema fieldDescription
NERentitiesExtract entities with custom labels
RelationsrelationsExtract typed relations between extracted entities
ClassificationclassificationsZero-shot text classification
Structured extractionstructuresExtract records with named fields

Antfly Configuration#

Use GLiNER2 as the extractor in an Antfly configuration:

{
  "provider": "antfly",
  "model": "antflydb/gliner2-base-v1"
}