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.import { SIEClient } from "@superlinked/sie-sdk";
const client = new SIEClient("http://localhost:8080");
const text = "Tim Cook is the CEO of Apple Inc.";
// Step 1: Extract entities with GLiNERconst nerResult = await client.extract( "urchade/gliner_multi-v2.1", { text }, { labels: ["person", "organization"] });
// Step 2: Pass entities to GLiREL for relation extractionconst result = await client.extract( "jackboyla/glirel-large-v0", { text, metadata: { entities: nerResult.entities } }, { labels: ["works_for", "ceo_of", "founded"] });
for (const relation of result.relations) { console.log(`${relation.head} --${relation.relation}--> ${relation.tail}`);}// Tim Cook --ceo_of--> Apple Inc.
await client.close();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"] });
for (const classification of result.classifications) { console.log(`${classification.label}: ${classification.score.toFixed(2)}`);}// positive: 0.94// neutral: 0.04// negative: 0.02Overflow policy
Section titled “Overflow policy”GLiClass models (gliclass-{small,base,large}-v1.0) have a 512-token fused context; text and the <<LABEL>>...<<SEP>> label prompt share the same budget. When input exceeds that budget, the underlying gliclass library can crash or return corrupted output. Set overflow_policy per request to control how the server handles overflow before it reaches the library.
overflow_policy is gliclass-only today. See the Python SDK and TypeScript SDK references for the typed exception, and the HTTP API for the wire-level option.
| Value | Behavior on overflow |
|---|---|
default (server default) | Input passes through as-is. Not recommended for production; use only to reproduce public benchmarks. |
truncate_text | End of text is truncated to fit; labels are preserved. Raises INPUT_TOO_LONG only if the label prompt alone exceeds the context. |
error | Always raises INPUT_TOO_LONG on overflow. |
from sie_sdk import SIEClientfrom sie_sdk.client.errors import InputTooLongErrorfrom sie_sdk.types import Item
client = SIEClient("http://localhost:8080")
try: result = client.extract( "knowledgator/gliclass-small-v1.0", Item(text=long_review), labels=["positive", "negative", "neutral"], options={"overflow_policy": "truncate_text"}, )except InputTooLongError as e: print(f"Input too long for {e.model}: {e}")import { SIEClient, InputTooLongError } from "@superlinked/sie-sdk";
const client = new SIEClient("http://localhost:8080");
try { const result = await client.extract( "knowledgator/gliclass-small-v1.0", { text: longReview }, { labels: ["positive", "negative", "neutral"], adapterOptions: { overflow_policy: "truncate_text" }, }, );} catch (error) { if (error instanceof InputTooLongError) { console.log(`Input too long for ${error.model}: ${error.message}`); }}Recommended Models
Section titled “Recommended Models”Relation Extraction Models
Section titled “Relation Extraction Models”| Model | Notes |
|---|---|
jackboyla/glirel-large-v0 | Zero-shot relation extraction |
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.
Framework Integrations
Section titled “Framework Integrations”All extraction types (entities, relations, classifications) are also available through framework integrations. See LangChain, LlamaIndex, Haystack, DSPy, and CrewAI for framework-specific examples.
What’s Next
Section titled “What’s Next”- NER & Entity Extraction - named entity recognition
- Vision Tasks - image captioning, object detection, and document understanding
- OCR - convert document images and PDFs to Markdown
- Full model catalog - all supported models