🚀 Transformers - ModernBERT-base模型
ModernBERT-base模型是一个经过多任务微调的模型,在自然语言推理(NLI)任务上表现出色,可用于零样本分类、情感分析等多种自然语言处理任务。
🚀 快速开始
环境准备
确保你已经安装了transformers
库。如果尚未安装,可以使用以下命令进行安装:
pip install transformers
模型使用
[ZS] 零样本分类管道
from transformers import pipeline
classifier = pipeline("zero-shot-classification",model="tasksource/ModernBERT-base-nli")
text = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
classifier(text, candidate_labels)
此模型的NLI训练数据包含 label-nli,这是一个专门为提升此类零样本分类能力而构建的NLI数据集。
[NLI] 自然语言推理管道
from transformers import pipeline
pipe = pipeline("text-classification",model="tasksource/ModernBERT-base-nli")
pipe([dict(text='there is a cat',
text_pair='there is a black cat')])
进一步微调的骨干模型
此检查点比基础版本具有更强的推理和细粒度能力,可用于进一步的微调。
✨ 主要特性
- 多任务微调:在多个NLI任务上进行了微调,包括MNLI、ANLI、SICK等。
- 出色的推理能力:在推理任务上表现出色,优于llama 3.1 8B Instruct在ANLI和FOLIO上的表现。
- 长上下文推理:能够处理长上下文的推理任务。
- 零样本分类:可以进行新标签的零样本分类。
📦 安装指南
使用pip
安装transformers
库:
pip install transformers
💻 使用示例
基础用法
零样本分类
from transformers import pipeline
classifier = pipeline("zero-shot-classification",model="tasksource/ModernBERT-base-nli")
text = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
classifier(text, candidate_labels)
自然语言推理
from transformers import pipeline
pipe = pipeline("text-classification",model="tasksource/ModernBERT-base-nli")
pipe([dict(text='there is a cat',
text_pair='there is a black cat')])
📚 详细文档
模型信息
属性 |
详情 |
库名称 |
transformers |
基础模型 |
answerdotai/ModernBERT-base |
许可证 |
apache-2.0 |
语言 |
en |
任务类型 |
零样本分类 |
训练数据集 |
nyu-mll/glue、facebook/anli等 |
标签 |
instruct、natural-language-inference、nli、mnli等 |
模型测试准确率
测试名称 |
测试准确率 |
glue/mnli |
0.87 |
glue/qnli |
0.93 |
glue/rte |
0.85 |
... |
... |
模型训练信息
该模型在Nvidia A30 GPU上训练了200k步。
📄 许可证
本模型使用apache-2.0
许可证。
📚 引用
如果你使用了此模型,请引用以下论文:
@inproceedings{sileo-2024-tasksource,
title = "tasksource: A Large Collection of {NLP} tasks with a Structured Dataset Preprocessing Framework",
author = "Sileo, Damien",
booktitle = "Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)",
month = may,
year = "2024",
address = "Torino, Italia",
publisher = "ELRA and ICCL",
url = "https://aclanthology.org/2024.lrec-main.1361",
pages = "15655--15684",
}