CoolFace
Modelpublic

knowledgator/gliclass-instruct-edge-v1.0

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
6likes483downloads
Model Card

[image]

GLiClass-multitask: Efficient zero-shot and few-shot multi-task model via sequence classification

GLiClass is an efficient zero-shot sequence classification model designed to achieve SoTA performance while being much faster than cross-encoders and LLMs, while preserving strong generalization capabilities.

The model supports text classification with any labels and can be used for the following tasks:

  • Topic Classification
  • Sentiment Analysis
  • Intent Classification
  • Reranking
  • Hallucination Detection
  • Rule-following Verification
  • LLM-safety Classification
  • Natural Language Inference

✨ What's New in V3

  • Hierarchical Labels — Organize labels into groups using dot notation or dictionaries (e.g., sentiment.positive, topic.product).
  • Few-Shot Examples — Provide in-context examples to boost accuracy on your specific task.
  • Label Descriptions — Add natural-language descriptions to labels for more precise classification.
  • Task Prompts — Prepend a custom prompt to guide the model's classification behavior.

See the GLiClass library README for full details on these features.

Installation

bash
pip install gliclass

Quick Start

python
from gliclass import GLiClassModel, ZeroShotClassificationPipeline
from transformers import AutoTokenizer

model = GLiClassModel.from_pretrained("knowledgator/gliclass-instruct-edge-v1.0")
tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-instruct-edge-v1.0")
pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')

Task Examples

1. Topic Classification

python
text = "NASA launched a new Mars rover to search for signs of ancient life."
labels = ["space", "politics", "sports", "technology", "health"]

results = pipeline(text, labels, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])
With hierarchical labels
python
hierarchical_labels = {
    "science": ["space", "biology", "physics"],
    "society": ["politics", "economics", "culture"]
}

results = pipeline(text, hierarchical_labels, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])
# e.g. science.space => 0.95

2. Sentiment Analysis

python
text = "The food was excellent but the service was painfully slow."
labels = ["positive", "negative", "neutral"]

results = pipeline(text, labels, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])
With a task prompt
python
results = pipeline(
    text, labels,
    prompt="Classify the sentiment of this restaurant review:",
    threshold=0.5
)[0]

3. Intent Classification

python
text = "Can you set an alarm for 7am tomorrow?"
labels = ["set_alarm", "play_music", "get_weather", "send_message", "set_reminder"]

results = pipeline(text, labels, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])
With few-shot examples
python
examples = [
    {"text": "Wake me up at 6:30.", "labels": ["set_alarm"]},
    {"text": "Play some jazz.", "labels": ["play_music"]},
]

results = pipeline(text, labels, examples=examples, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])

4. Natural Language Inference

Represent your premise as the text and the hypothesis as a label. The model works best with a single hypothesis at a time.

python
text = "The cat slept on the windowsill all afternoon."
labels = ["The cat was awake and playing outside."]

results = pipeline(text, labels, threshold=0.0)[0]
print(results)
# Low score → contradiction

5. Reranking

Score query–passage relevance by treating passages as texts and the query as the label:

python
query = "How to train a neural network?"
passages = [
    "Backpropagation is the key algorithm for training deep neural networks.",
    "The stock market rallied on strong earnings reports.",
    "Gradient descent optimizes model weights during training.",
]

for passage in passages:
    score = pipeline(passage, [query], threshold=0.0)[0][0]["score"]
    print(f"{score:.3f}  {passage[:60]}")

6. Hallucination Detection

Concatenate context, question, and answer into the text field:

python
text = (
    "Context: The Eiffel Tower was built from 1887 to 1889 and is 330 m tall. "
    "It was the tallest structure until the Chrysler Building in 1930.\n"
    "Question: When was the Eiffel Tower built and how tall is it?\n"
    "Answer: It was built 1887–1889, stands 330 m tall, and was the tallest "
    "structure until the Empire State Building in 1931."
)
labels = ["hallucinated", "correct"]

results = pipeline(text, labels, threshold=0.0)[0]
for r in results:
    print(r["label"], "=>", r["score"])
# "hallucinated" should score higher (Empire State Building & 1931 are wrong)

7. Rule-following Verification

Include the domain and rules as part of the text:

python
text = (
    "Domain: e-commerce product reviews\n"
    "Rule: No promotion of illegal activity.\n"
    "Text: The software is okay, but search for 'productname_patch_v2.zip' "
    "to unlock all features for free."
)
labels = ["follows_guidelines", "violates_guidelines"]

results = pipeline(text, labels, threshold=0.0)[0]
for r in results:
    print(r["label"], "=>", r["score"])

8. LLM-safety Classification

python
text = "I'm looking for a good Italian restaurant near downtown Chicago, budget ~$50/person."
labels = [
    "benign request",
    "prompt injection",
    "system prompt extraction",
    "jailbreak attempt",
    "harmful content request",
    "social engineering",
    "data exfiltration",
]

results = pipeline(text, labels, threshold=0.5)[0]
for r in results:
    print(r["label"], "=>", r["score"])

Benchmarks

F1 scores on zero-shot text classification (no fine-tuning on these datasets):

GLiClass-V1 Multitask:

Dataset[large‑v1.0](https://huggingface.co/knowledgator/gliclass-instruct-large-v1.0)[base‑v1.0](https://huggingface.co/knowledgator/gliclass-instruct-base-v1.0)[edge‑v1.0](https://huggingface.co/knowledgator/gliclass-instruct-edge-v1.0)
CR0.90660.89220.7933
sst20.91540.91980.7577
sst50.33870.22660.2163
20_newsgroups0.55770.51890.2555
spam0.97900.93800.7609
financial_phrasebank0.82890.52170.3905
imdb0.93970.93640.8159
ag_news0.75210.69780.6043
emotion0.44730.44540.2941
cap_sotu0.43270.45790.2380
rotten_tomatoes0.84910.84580.5455
massive0.58240.47570.2090
banking0.69870.60720.4635
snips0.85090.65150.5461
AVERAGE0.71990.65250.4922

GLiClass-V3:

Dataset[large‑v3.0](https://huggingface.co/knowledgator/gliclass-large-v3.0)[base‑v3.0](https://huggingface.co/knowledgator/gliclass-base-v3.0)[modern‑large‑v3.0](https://huggingface.co/knowledgator/gliclass-modern-large-v3.0)[modern‑base‑v3.0](https://huggingface.co/knowledgator/gliclass-modern-base-v3.0)[edge‑v3.0](https://huggingface.co/knowledgator/gliclass-edge-v3.0)
CR0.93980.91270.89520.89020.8215
sst20.91920.89590.93300.89590.8199
sst50.46060.33760.46190.27560.2823
20_newsgroups0.59580.47590.39050.34330.2217
spam0.75840.67600.58130.63980.5623
financial_phrasebank0.90000.89710.59290.42000.5004
imdb0.93660.92510.94020.91580.8485
ag_news0.71810.72790.72690.66630.6645
emotion0.45060.44470.45170.42540.3851
cap_sotu0.45890.46140.40720.36250.2583
rotten_tomatoes0.84110.79430.76640.70700.7024
massive0.56490.50400.39050.34420.2414
banking0.55740.46980.36830.35610.0272
snips0.96920.94740.77070.56630.5257
AVERAGE0.71930.67640.61970.55770.4900

Citation

bibtex
@misc{stepanov2025gliclassgeneralistlightweightmodel,
      title={GLiClass: Generalist Lightweight Model for Sequence Classification Tasks}, 
      author={Ihor Stepanov and Mykhailo Shtopko and Dmytro Vodianytskyi and Oleksandr Lukashov and Alexander Yavorskyi and Mykyta Yaroshenko},
      year={2025},
      eprint={2508.07662},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2508.07662}, 
}
knowledgator/gliclass-instruct-edge-v1.0 · CoolFace