Relations & Classification
GLiREL and GLiClass models extract relationships and classify text with zero-shot label support.
Relation Extraction
Section titled “Relation Extraction”GLiREL models extract relationships between entities. Relation types are passed via the labels parameter. Entities must be pre-extracted (e.g. with GLiNER) and passed in item.metadata:
from sie_sdk import SIEClientfrom sie_sdk.types import Item
client = SIEClient("http://localhost:8080")
text = "Tim Cook is the CEO of Apple Inc."
# Step 1: Extract entities with GLiNERner_result = client.extract( "urchade/gliner_multi-v2.1", Item(text=text), labels=["person", "organization"])
# Step 2: Pass entities to GLiREL for relation extractionresult = client.extract( "jackboyla/glirel-large-v0", Item(text=text, metadata={"entities": ner_result["entities"]}), labels=["works_for", "ceo_of", "founded"])
for relation in result["relations"]: print(f"{relation['head']} --{relation['relation']}--> {relation['tail']}")# Tim Cook --ceo_of--> Apple Inc.// The TypeScript SDK does not yet support relation extraction.// Use the Python SDK or the HTTP API directly:
const text = "Tim Cook is the CEO of Apple Inc.";
// Step 1: Extract entities with GLiNERconst nerResponse = await fetch("http://localhost:8080/v1/extract/urchade/gliner_multi-v2.1", { method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" }, body: JSON.stringify({ items: [{ text }], params: { labels: ["person", "organization"] }, }),});const nerData = await nerResponse.json();
// Step 2: Pass entities to GLiREL for relation extractionconst response = await fetch("http://localhost:8080/v1/extract/jackboyla/glirel-large-v0", { method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" }, body: JSON.stringify({ items: [{ text, metadata: { entities: nerData.items[0].entities } }], params: { labels: ["works_for", "ceo_of", "founded"] }, }),});
const data = await response.json();for (const relation of data.items[0].relations) { console.log(`${relation.head} --${relation.relation}--> ${relation.tail}`);}// Tim Cook --ceo_of--> Apple Inc.Relation Fields
Section titled “Relation Fields”| Field | Type | Description |
|---|---|---|
head | str | Source entity |
tail | str | Target entity |
relation | str | Relation type |
score | float | Confidence score |
Text Classification
Section titled “Text Classification”GLiClass models classify text into categories:
result = client.extract( "knowledgator/gliclass-base-v1.0", Item(text="I absolutely loved this movie! The acting was superb."), labels=["positive", "negative", "neutral"])
for classification in result["classifications"]: print(f"{classification['label']}: {classification['score']:.2f}")# positive: 0.94# neutral: 0.04# negative: 0.02const result = await client.extract( "knowledgator/gliclass-base-v1.0", { text: "I absolutely loved this movie! The acting was superb." }, { labels: ["positive", "negative", "neutral"] });
// Classification results are returned as entities with label scoresfor (const entity of result.entities) { console.log(`${entity.label}: ${entity.score.toFixed(2)}`);}// positive: 0.94// neutral: 0.04// negative: 0.02Recommended Models
Section titled “Recommended Models”NER Models
Section titled “NER Models”| Model | Languages | Notes |
|---|---|---|
urchade/gliner_multi-v2.1 | Multilingual | General-purpose NER |
urchade/gliner_large-v2.1 | English | Larger model (459M params) |
numind/NuNER_Zero | English | Zero-shot NER |
urchade/gliner_multi_pii-v1 | Multilingual | PII detection |
Classification Models
Section titled “Classification Models”| Model | Notes |
|---|---|
knowledgator/gliclass-base-v1.0 | Zero-shot classification |
knowledgator/gliclass-small-v1.0 | Faster, smaller |
See Full model catalog for the complete list.
What’s Next
Section titled “What’s Next”- NER & Entity Extraction — named entity recognition
- Vision Tasks — image captioning, OCR, and document understanding
- Full model catalog — all supported models