gliner2-base-v1
antfly inference pull fastino/gliner2-base-v1About GLiNER2
GLiNER2 is a unified multi-task model that performs named entity recognition, zero-shot classification, relation extraction, and structured JSON extraction — all 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.
GLiNER2 is a zero-shot model — you define the entity types, relation types, or classification labels at query time. No fine-tuning required.
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 Case | Description |
|---|---|
| Document Processing | Extract people, organizations, dates from contracts or reports |
| Knowledge Graphs | Build knowledge graphs by extracting entities and their relationships |
| Content Tagging | Classify articles, support tickets, or reviews into custom categories |
| Data Extraction | Pull structured fields from unstructured text (e.g., invoices, resumes) |
Antfly Inference API Usage
Named Entity Recognition
Extract entities with custom labels — no predefined entity types needed:
curl -X POST "http://localhost:8080/ai/v1/recognize" \
-H "Content-Type: application/json" \
-d '{
"model": "gliner2-base-v1",
"texts": ["Steve Jobs founded Apple in Cupertino, California."],
"labels": ["person", "organization", "location"]
}'import requests
response = requests.post(
"http://localhost:8080/ai/v1/recognize",
json={
"model": "gliner2-base-v1",
"texts": ["Steve Jobs founded Apple in Cupertino, California."],
"labels": ["person", "organization", "location"]
}
)
entities = response.json()["entities"]
# [{"text": "Steve Jobs", "label": "person", "score": 0.98}, ...]const response = await fetch("http://localhost:8080/ai/v1/recognize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "gliner2-base-v1",
texts: ["Steve Jobs founded Apple in Cupertino, California."],
labels: ["person", "organization", "location"]
})
});
const { entities } = await response.json();Relation Extraction
Extract relationships between entities as (subject, relation, object) triplets:
curl -X POST "http://localhost:8080/ai/v1/recognize" \
-H "Content-Type: application/json" \
-d '{
"model": "gliner2-base-v1",
"texts": ["Steve Jobs founded Apple in 1976."],
"relation_labels": ["founded by", "located in", "born in"]
}'import requests
response = requests.post(
"http://localhost:8080/ai/v1/recognize",
json={
"model": "gliner2-base-v1",
"texts": ["Steve Jobs founded Apple in 1976."],
"relation_labels": ["founded by", "located in", "born in"]
}
)
relations = response.json()["relations"]
# [[{"head": "Apple", "label": "founded by", "tail": "Steve Jobs", "score": 0.95}]]const response = await fetch("http://localhost:8080/ai/v1/recognize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "gliner2-base-v1",
texts: ["Steve Jobs founded Apple in 1976."],
relation_labels: ["founded by", "located in", "born in"]
})
});
const { relations } = await response.json();Zero-Shot Classification
Classify text into arbitrary categories:
curl -X POST "http://localhost:8080/ai/v1/classify" \
-H "Content-Type: application/json" \
-d '{
"model": "gliner2-base-v1",
"texts": ["Apple reported record quarterly revenue of $124 billion."],
"labels": ["finance", "technology", "sports", "politics"]
}'import requests
response = requests.post(
"http://localhost:8080/ai/v1/classify",
json={
"model": "gliner2-base-v1",
"texts": ["Apple reported record quarterly revenue of $124 billion."],
"labels": ["finance", "technology", "sports", "politics"]
}
)
classifications = response.json()["classifications"]
# [{"label": "finance", "score": 0.92}, {"label": "technology", "score": 0.87}, ...]const response = await fetch("http://localhost:8080/ai/v1/classify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "gliner2-base-v1",
texts: ["Apple reported record quarterly revenue of $124 billion."],
labels: ["finance", "technology", "sports", "politics"]
})
});
const { classifications } = await response.json();JSON Extraction
Extract structured data from text matching a schema:
curl -X POST "http://localhost:8080/ai/v1/extract" \
-H "Content-Type: application/json" \
-d '{
"model": "gliner2-base-v1",
"texts": ["John Smith is a 35-year-old engineer at Google in Mountain View."],
"schema": {
"person": ["name::str", "age::str", "job_title::str", "company::str", "city::str"]
}
}'import requests
response = requests.post(
"http://localhost:8080/ai/v1/extract",
json={
"model": "gliner2-base-v1",
"texts": ["John Smith is a 35-year-old engineer at Google in Mountain View."],
"schema": {
"person": ["name::str", "age::str", "job_title::str", "company::str", "city::str"]
}
}
)
results = response.json()["results"]
# [[{"name": "John Smith", "age": "35", "job_title": "engineer", "company": "Google", "city": "Mountain View"}]]const response = await fetch("http://localhost:8080/ai/v1/extract", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "gliner2-base-v1",
texts: ["John Smith is a 35-year-old engineer at Google in Mountain View."],
schema: {
person: ["name::str", "age::str", "job_title::str", "company::str", "city::str"]
}
})
});
const { results } = await response.json();Supported Tasks
| Task | Endpoint | Description |
|---|---|---|
| NER (default) | /recognize with labels | Extract entities with custom labels |
| Relations | /recognize with relation_labels | Extract (subject, relation, object) triplets |
| Classification | /classify with labels | Zero-shot text classification |
| JSON Extraction | /extract with schema | Extract structured fields from text |
GLiNER2 has a 512 token context limit. For longer documents, split into chunks before processing.
Antfly Configuration
To use GLiNER2 as a recognizer in your Antfly configuration:
recognizer:
provider: antfly
model: gliner2-base-v1
For tables with entity extraction:
tables:
documents:
indexes:
entities:
type: ner
recognizer:
provider: antfly
model: gliner2-base-v1
labels:
- person
- organization
- location
- date
Versions
| Tag | Status |
|---|---|
| latest | Available |
| v1.0.0 | Latest |
Usage
Pull the model
antfly inference pull fastino/gliner2-base-v1Start Antfly Inference
# With Antfly standalone (Antfly Inference enabled by default)
antfly standalone
# Or run Antfly Inference on its own
antfly inferenceUse in configuration
# config.yaml
recognizer:
provider: antfly
model: fastino/gliner2-base-v1Available variants (smaller/faster)
# config.yaml
recognizer:
provider: antfly
model: fastino/gliner2-base-v1-f16