注意
已弃用:如需更长上下文和更高准确率,请使用 deberta-small-long-nli。
这是基于 [DeBERTa-v3-base],在 [tasksource 数据集] 的 600 多个任务上通过多任务学习进行微调的模型。 此检查点在许多任务上具有出色的零样本验证性能(例如在 WNLI 上达到 70%),可用于:
import argparse
import torch
from openmind import pipeline, is_torch_npu_available
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name_or_path",
default=None,
type=str,
help="Path to model",
required=False,
)
args = parser.parse_args()
return args
if __name__=="__main__":
args = parse_args()
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
#推理
classifier = pipeline(
task="zero-shot-classification",
model=args.model_name_or_path,
device=device
)
text = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
print(classifier(text, candidate_labels))该模型的NLI训练数据包含[label-nli],这是一个专门为提升此类零样本分类而构建的NLI数据集。
import argparse
import torch
from openmind import pipeline, is_torch_npu_available
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name_or_path",
default=None,
type=str,
help="Path to model",
required=False,
)
args = parser.parse_args()
return args
if __name__=="__main__":
args = parse_args()
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
#推理
pipe = pipeline('text-classification', model=args.model_name_or_path, device=device)
print(pipe([dict(text='there is a cat',text_pair='there is a black cat')]))根据 IBM 模型回收评估,该模型在所有采用 microsoft/deberta-v3-base 架构的模型中排名第一。 https://ibm.github.io/model-recycling/
该模型在 600 个任务上进行了 20 万步的训练,批处理大小为 384,峰值学习率为 2e-5。训练在 Nvidia A30 24GB GPU 上进行,耗时 15 天。 这是顶部带有 MNLI 分类器的共享模型。每个任务都有特定的 CLS 嵌入,该嵌入有 10% 的概率被丢弃,以方便在没有它的情况下使用模型。所有多项选择模型都使用相同的分类层。对于分类任务,如果模型的标签匹配,则共享权重。
https://github.com/sileod/tasksource/
https://github.com/sileod/tasknet/
训练代码:https://colab.research.google.com/drive/1iB4Oxl9_B5W3ZDzXoWJN-olUbqLBxgQS?usp=sharing
更多详细信息请参见此文章:
@article{sileo2023tasksource,
title={tasksource: Structured Dataset Preprocessing Annotations for Frictionless Extreme Multi-Task Learning and Evaluation},
author={Sileo, Damien},
url= {https://arxiv.org/abs/2301.05948},
journal={arXiv preprint arXiv:2301.05948},
year={2023}
}