🚀 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",
}