deberta v3 xsmall zeroshot v1.1 all 33
简介
核心亮点
- 无需训练数据,支持自定义标签零样本分类
- 轻量化架构,推理延迟低,适合端侧或低配部署
- 快速验证分类方案,大幅降低数据标注成本
- 适用于内容审核、意图识别等快速迭代场景
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33")
tokenizer = AutoTokenizer.from_pretrained("MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33 config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33')
tokenizer = AutoTokenizer.from_pretrained('MoritzLaurer/deberta-v3-xsmall-zeroshot-v1.1-all-33')
完整文档
---
base_model: microsoft/deberta-v3-xsmall
language:
- en
tags:
- text-classification
- zero-shot-classification
pipeline_tag: zero-shot-classification
library_name: transformers
license: mit
---
deberta-v3-xsmall-zeroshot-v1.1-all-33
This model was fine-tuned using the same pipeline as described in
the model card for MoritzLaurer/deberta-v3-large-zeroshot-v1.1-all-33
and in this paper.
The foundation model is microsoft/deberta-v3-xsmall.
The model only has 22 million backbone parameters and 128 million vocabulary parameters.
The backbone parameters are the main parameters active during inference, providing a significant speedup over larger models.
The model is 142 MB small.
This model was trained to provide a small and highly efficient zeroshot option,
especially for edge devices or in-browser use-cases with transformers.js.
Usage and other details
For usage instructions and other details refer to this model card MoritzLaurer/deberta-v3-large-zeroshot-v1.1-all-33 and this paper.Metrics:
I didn't not do zeroshot evaluation for this model to save time and compute.
The table below shows standard accuracy for all datasets the model was trained on (note that the NLI datasets are binary).
General takeaway: the model is much more efficient than its larger sisters, but it performs less well.
|Datasets|mnli_m|mnli_mm|fevernli|anli_r1|anli_r2|anli_r3|wanli|lingnli|wellformedquery|rottentomatoes|amazonpolarity|imdb|yelpreviews|hatexplain|massive|banking77|emotiondair|emocontext|empathetic|agnews|yahootopics|biasframes_sex|biasframes_offensive|biasframes_intent|financialphrasebank|appreviews|hateoffensive|trueteacher|spam|wikitoxic_toxicaggregated|wikitoxic_obscene|wikitoxic_identityhate|wikitoxic_threat|wikitoxic_insult|manifesto|capsotu|
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|Accuracy|0.925|0.923|0.886|0.732|0.633|0.661|0.814|0.887|0.722|0.872|0.944|0.925|0.967|0.774|0.734|0.627|0.762|0.745|0.465|0.888|0.702|0.94|0.853|0.863|0.914|0.926|0.921|0.635|0.968|0.897|0.918|0.915|0.935|0.9|0.505|0.701|
|Inference text/sec (A10G, batch=128)|1573.0|1630.0|683.0|1282.0|1352.0|1072.0|2325.0|2008.0|4781.0|2743.0|677.0|228.0|238.0|2357.0|5027.0|4323.0|3247.0|3129.0|941.0|1643.0|335.0|1517.0|1452.0|1498.0|2367.0|974.0|2634.0|353.0|2284.0|260.0|252.0|256.0|254.0|259.0|1941.0|2080.0|