Gliclass Edge V3.0
GLiClass是一款高效的零樣本分類器,性能與交叉編碼器相當但計算效率更高,適用於多任務場景。
下載量 105
發布時間 : 7/20/2025
模型介紹
內容詳情
替代品
模型概述
通用輕量級序列分類模型,支持零樣本分類、主題分類、情感分析及RAG管道重排,通過LoRA適配器微調保留知識。
模型特點
高效零樣本分類
單次前向傳播完成分類,計算效率優於交叉編碼器
多任務適配
支持主題分類、情感分析及RAG重排等多種任務
邏輯推理能力
在邏輯任務上訓練以增強推理能力
知識保留微調
使用LoRA適配器避免破壞預訓練知識
模型能力
文本分類
自然語言推理
情感分析
零樣本學習
多標籤分類
使用案例
內容分類
新聞主題分類
對新聞文本進行多標籤主題分類
在20_news_groups數據集F1達0.5958
情感分析
產品評論情感分析
分析用戶評論的情感傾向
在sst2數據集F1達0.9192
RAG增強
檢索結果重排序
作為RAG管道的重排組件
🚀 GLiClass:用於序列分類的通用輕量級模型
GLiClass是一款高效的零樣本分類器,靈感源自GLiNER。它在性能上與交叉編碼器相當,但計算效率更高,因為分類只需一次前向傳播。該模型可用於主題分類
、情感分析
,還能作為RAG
管道中的重排器。此外,模型在邏輯任務上進行訓練以誘導推理能力,並使用LoRA適配器進行微調,避免破壞先前學習的知識。
🚀 快速開始
安裝GLiClass庫
pip install gliclass
pip install -U transformers>=4.48.0
初始化模型和管道
from gliclass import GLiClassModel, ZeroShotClassificationPipeline
from transformers import AutoTokenizer
model = GLiClassModel.from_pretrained("knowledgator/gliclass-edge-v3.0")
tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-edge-v3.0", add_prefix_space=True)
pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')
text = "One day I will see the world!"
labels = ["travel", "dreams", "sport", "science", "politics"]
results = pipeline(text, labels, threshold=0.5)[0] #because we have one text
for result in results:
print(result["label"], "=>", result["score"])
NLI任務使用示例
若要將其用於NLI類型的任務,建議將前提表示為文本,假設表示為標籤。可以輸入多個假設,但模型在單個假設輸入時效果最佳。
# 初始化模型和多標籤管道
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)
✨ 主要特性
- 高效零樣本分類:受GLiNER工作啟發,在單次前向傳播中完成分類,性能與交叉編碼器相當,但計算效率更高。
- 多任務應用:可用於
主題分類
、情感分析
,還能作為RAG
管道中的重排器。 - 邏輯推理誘導:在邏輯任務上進行訓練,以誘導推理能力。
- 知識保留微調:使用LoRA適配器進行微調,避免破壞先前學習的知識。
📦 安裝指南
pip install gliclass
pip install -U transformers>=4.48.0
💻 使用示例
基礎用法
from gliclass import GLiClassModel, ZeroShotClassificationPipeline
from transformers import AutoTokenizer
model = GLiClassModel.from_pretrained("knowledgator/gliclass-edge-v3.0")
tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-edge-v3.0", add_prefix_space=True)
pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')
text = "One day I will see the world!"
labels = ["travel", "dreams", "sport", "science", "politics"]
results = pipeline(text, labels, threshold=0.5)[0] #because we have one text
for result in results:
print(result["label"], "=>", result["score"])
高級用法
# 用於NLI類型任務的示例
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)
📚 詳細文檔
模型信息
屬性 | 詳情 |
---|---|
模型類型 | 用於序列分類的通用輕量級模型 |
訓練數據集 | BioMike/formal-logic-reasoning-gliclass-2k、knowledgator/gliclass-v3-logic-dataset、tau/commonsense_qa |
評估指標 | F1 |
標籤 | 文本分類、自然語言推理、情感分析 |
管道標籤 | 文本分類 |
LoRA參數
gliclass‑modern‑base‑v3.0 | gliclass‑modern‑large‑v3.0 | gliclass‑base‑v3.0 | gliclass‑large‑v3.0 | |
---|---|---|---|---|
LoRa r | 512 | 768 | 384 | 384 |
LoRa α | 1024 | 1536 | 768 | 768 |
focal loss α | 0.7 | 0.7 | 0.7 | 0.7 |
目標模塊 | "Wqkv", "Wo", "Wi", "linear_1", "linear_2" | "Wqkv", "Wo", "Wi", "linear_1", "linear_2" | "query_proj", "key_proj", "value_proj", "dense", "linear_1", "linear_2", mlp.0", "mlp.2", "mlp.4" | "query_proj", "key_proj", "value_proj", "dense", "linear_1", "linear_2", mlp.0", "mlp.2", "mlp.4" |
GLiClass-V3模型
模型名稱 | 大小 | 參數數量 | 平均基準分數 | 平均推理速度 (batch size = 1, a6000, 示例/秒) |
---|---|---|---|---|
gliclass‑edge‑v3.0 | 131 MB | 32.7M | 0.4873 | 97.29 |
gliclass‑modern‑base‑v3.0 | 606 MB | 151M | 0.5571 | 54.46 |
gliclass‑modern‑large‑v3.0 | 1.6 GB | 399M | 0.6082 | 43.80 |
gliclass‑base‑v3.0 | 746 MB | 187M | 0.6556 | 51.61 |
gliclass‑large‑v3.0 | 1.75 GB | 439M | 0.7001 | 25.22 |
基準測試
以下是幾個文本分類數據集上的F1分數。所有測試模型均未在這些數據集上進行微調,而是在零樣本設置下進行測試。
GLiClass-V3模型
數據集 | gliclass‑large‑v3.0 | gliclass‑base‑v3.0 | gliclass‑modern‑large‑v3.0 | gliclass‑modern‑base‑v3.0 | gliclass‑edge‑v3.0 |
---|---|---|---|---|---|
CR | 0.9398 | 0.9127 | 0.8952 | 0.8902 | 0.8215 |
sst2 | 0.9192 | 0.8959 | 0.9330 | 0.8959 | 0.8199 |
sst5 | 0.4606 | 0.3376 | 0.4619 | 0.2756 | 0.2823 |
20_news_groups | 0.5958 | 0.4759 | 0.3905 | 0.3433 | 0.2217 |
spam | 0.7584 | 0.6760 | 0.5813 | 0.6398 | 0.5623 |
financial_phrasebank | 0.9000 | 0.8971 | 0.5929 | 0.4200 | 0.5004 |
imdb | 0.9366 | 0.9251 | 0.9402 | 0.9158 | 0.8485 |
ag_news | 0.7181 | 0.7279 | 0.7269 | 0.6663 | 0.6645 |
emotion | 0.4506 | 0.4447 | 0.4517 | 0.4254 | 0.3851 |
cap_sotu | 0.4589 | 0.4614 | 0.4072 | 0.3625 | 0.2583 |
rotten_tomatoes | 0.8411 | 0.7943 | 0.7664 | 0.7070 | 0.7024 |
massive | 0.5649 | 0.5040 | 0.3905 | 0.3442 | 0.2414 |
banking | 0.5574 | 0.4698 | 0.3683 | 0.3561 | 0.0272 |
AVERAGE | 0.7001 | 0.6556 | 0.6082 | 0.5571 | 0.4873 |
先前的GLiClass模型
數據集 | gliclass‑large‑v1.0‑lw | gliclass‑base‑v1.0‑lw | gliclass‑modern‑large‑v2.0 | gliclass‑modern‑base‑v2.0 |
---|---|---|---|---|
CR | 0.9226 | 0.9097 | 0.9154 | 0.8977 |
sst2 | 0.9247 | 0.8987 | 0.9308 | 0.8524 |
sst5 | 0.2891 | 0.3779 | 0.2152 | 0.2346 |
20_news_groups | 0.4083 | 0.3953 | 0.3813 | 0.3857 |
spam | 0.3642 | 0.5126 | 0.6603 | 0.4608 |
financial_phrasebank | 0.9044 | 0.8880 | 0.3152 | 0.3465 |
imdb | 0.9429 | 0.9351 | 0.9449 | 0.9188 |
ag_news | 0.7559 | 0.6985 | 0.6999 | 0.6836 |
emotion | 0.3951 | 0.3516 | 0.4341 | 0.3926 |
cap_sotu | 0.4749 | 0.4643 | 0.4095 | 0.3588 |
rotten_tomatoes | 0.8807 | 0.8429 | 0.7386 | 0.6066 |
massive | 0.5606 | 0.4635 | 0.2394 | 0.3458 |
banking | 0.3317 | 0.4396 | 0.1355 | 0.2907 |
AVERAGE | 0.6273 | 0.6291 | 0.5400 | 0.5211 |
交叉編碼器
數據集 | deberta‑v3‑large‑zeroshot‑v2.0 | deberta‑v3‑base‑zeroshot‑v2.0 | roberta‑large‑zeroshot‑v2.0‑c | comprehend_it‑base |
---|---|---|---|---|
CR | 0.9134 | 0.9051 | 0.9141 | 0.8936 |
sst2 | 0.9272 | 0.9176 | 0.8573 | 0.9006 |
sst5 | 0.3861 | 0.3848 | 0.4159 | 0.4140 |
enron_spam | 0.5970 | 0.4640 | 0.5040 | 0.3637 |
financial_phrasebank | 0.5820 | 0.6690 | 0.4550 | 0.4695 |
imdb | 0.9180 | 0.8990 | 0.9040 | 0.4644 |
ag_news | 0.7710 | 0.7420 | 0.7450 | 0.6016 |
emotion | 0.4840 | 0.4950 | 0.4860 | 0.4165 |
cap_sotu | 0.5020 | 0.4770 | 0.5230 | 0.3823 |
rotten_tomatoes | 0.8680 | 0.8600 | 0.8410 | 0.4728 |
massive | 0.5180 | 0.5200 | 0.5200 | 0.3314 |
banking77 | 0.5670 | 0.4460 | 0.2900 | 0.4972 |
AVERAGE | 0.6695 | 0.6483 | 0.6213 | 0.5173 |
推理速度
每個模型在a6000 GPU上對文本長度為64、256和512個標記,以及標籤數量為1、2、4、8、16、32、64和128的示例進行了測試。然後,對不同文本長度的分數進行了平均。
模型名稱 / 每秒樣本數 / m個標籤 | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 平均 |
---|---|---|---|---|---|---|---|---|---|
gliclass‑edge‑v3.0 | 103.81 | 101.01 | 103.50 | 103.50 | 98.36 | 96.77 | 88.76 | 82.64 | 97.29 |
gliclass‑modern‑base‑v3.0 | 56.00 | 55.46 | 54.95 | 55.66 | 54.73 | 54.95 | 53.48 | 50.34 | 54.46 |
gliclass‑modern‑large‑v3.0 | 46.30 | 46.82 | 46.66 | 46.30 | 43.93 | 44.73 | 42.77 | 32.89 | 43.80 |
gliclass‑base‑v3.0 | 49.42 | 50.25 | 40.05 | 57.69 | 57.14 | 56.39 | 55.97 | 45.94 | 51.61 |
gliclass‑large‑v3.0 | 19.05 | 26.86 | 23.64 | 29.27 | 29.04 | 28.79 | 27.55 | 17.60 | 25.22 |
deberta‑v3‑base‑zeroshot‑v2.0 | 24.55 | 30.40 | 15.38 | 7.62 | 3.77 | 1.87 | 0.94 | 0.47 | 10.63 |
deberta‑v3‑large‑zeroshot‑v2.0 | 16.82 | 15.82 | 7.93 | 3.98 | 1.99 | 0.99 | 0.49 | 0.25 | 6.03 |
roberta‑large‑zeroshot‑v2.0‑c | 50.42 | 39.27 | 19.95 | 9.95 | 5.01 | 2.48 | 1.25 | 0.64 | 16.12 |
comprehend_it‑base | 21.79 | 27.32 | 13.60 | 7.58 | 3.80 | 1.90 | 0.97 | 0.49 | 9.72 |
📄 許可證
本項目採用Apache-2.0許可證。
Gliclass Edge V3.0
Apache-2.0
GLiClass是一款高效的零樣本分類器,性能與交叉編碼器相當但計算效率更高,適用於多任務場景。
文本分類
Safetensors 其他
G
knowledgator
105
4
Gliclass X Base
Apache-2.0
GLiClass 是一個高效的零樣本分類器,性能與交叉編碼器相當但計算效率更高,支持多語言文本分類任務。
文本分類
Safetensors
G
knowledgator
181
4
Gliclass Modern Base V3.0
Apache-2.0
GLiClass 是一款高效的零樣本分類器,受 GLiNER 啟發,能在單次前向傳播中完成分類任務,兼具交叉編碼器性能和更高計算效率。
文本分類
Safetensors 其他
G
knowledgator
105
2
Langcache Crossencoder V1 Ms Marco MiniLM L12 V2
Apache-2.0
基於Transformer架構的CrossEncoder模型,在Quora問題對數據集上微調,用於計算文本對得分,適用於語義相似度和語義搜索任務。
文本分類 英語
L
aditeyabaral-redis
281
0
Langcache Crossencoder V1 Ms Marco MiniLM L6 V2
Apache-2.0
這是一個基於Cross Encoder架構的模型,專門用於文本對分類任務,在Quora問題對數據集上微調而來,適用於語義相似性判斷和語義搜索場景。
文本分類 英語
L
aditeyabaral-redis
338
0
Roberta Base Emotion
Apache-2.0
基於RoBERTa架構的情感分析模型,在Twitter情感數據集上微調,用於文本情感分類。
文本分類 英語
R
bhadresh-savani
703
5
Koelectra Fine Tunning Emotion
MIT
基於KoELECTRA微調的韓語情感分類模型,能識別憤怒、幸福、焦慮、尷尬、悲傷和心痛六種情感。
文本分類
Transformers 韓語

K
Jinuuuu
441
1
The Teacher V 2
這是一個用於零樣本分類任務的transformers模型,可在無需大量標註數據的情況下對文本進行分類。
文本分類
Transformers

T
shiviklabs
172
0
Gender Prediction Model From Text
MIT
該模型基於DeBERTa-v3-large構建,能夠根據英文文本內容預測匿名發言者或作者的性別。
文本分類
Transformers 英語

G
fc63
106
1
Qwen3 Reranker 0.6B W4A16 G128
Apache-2.0
Qwen3-Reranker-0.6B的GPTQ量化版本,顯存使用優化且精度損失小
文本分類
Transformers

Q
boboliu
151
1
精選推薦AI模型
Qwen2.5 VL 7B Abliterated Caption It I1 GGUF
Apache-2.0
Qwen2.5-VL-7B-Abliterated-Caption-it的量化版本,支持多語言圖像描述任務。
圖像生成文本
Transformers 支持多種語言

Q
mradermacher
167
1
Nunchaku Flux.1 Dev Colossus
其他
Colossus Project Flux 的 Nunchaku 量化版本,旨在根據文本提示生成高質量圖像。該模型在優化推理效率的同時,將性能損失降至最低。
圖像生成 英語
N
nunchaku-tech
235
3
Qwen2.5 VL 7B Abliterated Caption It GGUF
Apache-2.0
這是一個基於Qwen2.5-VL-7B模型的靜態量化版本,專注於圖像描述生成任務,支持多種語言。
圖像生成文本
Transformers 支持多種語言

Q
mradermacher
133
1
Olmocr 7B 0725 FP8
Apache-2.0
olmOCR-7B-0725-FP8是基於Qwen2.5-VL-7B-Instruct模型,使用olmOCR-mix-0225數據集微調後量化為FP8版本的文檔OCR模型。
圖像生成文本
Transformers 英語

O
allenai
881
3
Lucy 128k GGUF
Apache-2.0
Lucy-128k是基於Qwen3-1.7B開發的專注於代理式網絡搜索和輕量級瀏覽的模型,在移動設備上也能高效運行。
大型語言模型
Transformers 英語

L
Mungert
263
2