BERT零样本分类-英文-base-学术数据集mnli
该模型使用bert-base-uncased在multi_nli数据集(将英文数据集重新翻译得到中文数据集)上面进行了训练得到。
  • 模型资讯
  • 模型资料

零样本分类模型介绍

模型详细介绍及实现原理可参考评测文章:世界那么大,我想去看看——探索ModelScope之零样本分类

Yin等人[1]提出了一种使用预训练的自然语言推理模型来实现零样本分类的方式。
工作原理:将要分类的文本设置为自然语言推理的前提,然后使用每个标签构建一个假设,接着对每个假设进行推理得到文本所属的标签。
该模型可以在不使用下游数据进行训练的情况下,按照指定的标签对文本进行分类。

模型结构

模型描述

该模型使用bert-base-uncased在multi_nli数据集上面进行了自然语言推理任务训练。

如何使用

在ModelScope框架上,通过调用pipeline,提供待分类的文本以及所有可能的标签即可实现文本分类。

代码范例

from modelscope.pipelines import pipeline

classifier = pipeline('zero-shot-classification', 'damo/nlp_bert_zero-shot_english-base')

sentence = 'one day I will see the world'
labels = ['travel', 'cooking', 'dancing']

classifier(sentence, candidate_labels=labels)
# {'labels': ['travel', 'cooking', 'dancing'], 
# 'scores': [0.4974762201309204, 0.2736286520957947, 0.22889523208141327]}

labels = ['travel', 'cooking', 'dancing', 'exploration']
classifier(sentence, candidate_labels=labels, multi_label=True)
# {'labels': ['exploration', 'travel', 'dancing', 'cooking'], 
# 'scores': [0.5681723356246948, 0.49103984236717224, 0.08524788916110992, 0.04436328634619713]}

模型局限性以及可能的偏差

受训练数据的影响,在不同任务上的性能表现可能会有所差异。

数据评估及结果

在multi_nli的验证集上的f1为84.87。

相关论文以及引用信息

@article{yin2019benchmarking,
  title={Benchmarking zero-shot text classification: Datasets, evaluation and entailment approach},
  author={Yin, Wenpeng and Hay, Jamaal and Roth, Dan},
  journal={arXiv preprint arXiv:1909.00161},
  year={2019}
}