🚀 bert-base-cased在TREC 6类任务上的训练模型
本项目是一个在“trec”数据集上训练的简单基础BERT模型,可用于文本分类任务,在测试集上取得了较高的准确率。
🚀 快速开始
模型描述
这是一个在“trec”数据集上训练的简单基础BERT模型。
预期用途和限制
使用方法
Transformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
from transformers import pipeline
model_name = "aychang/bert-base-cased-trec-coarse"
nlp = pipeline("sentiment-analysis", model=model_name, tokenizer=model_name)
results = nlp(["Where did the queen go?", "Why did the Queen hire 1000 ML Engineers?"])
AdaptNLP
from adaptnlp import EasySequenceClassifier
model_name = "aychang/bert-base-cased-trec-coarse"
texts = ["Where did the queen go?", "Why did the Queen hire 1000 ML Engineers?"]
classifer = EasySequenceClassifier
results = classifier.tag_text(text=texts, model_name_or_path=model_name, mini_batch_size=2)
限制和偏差
这是一个在基准数据集上训练的最小语言模型。
训练数据
TREC https://huggingface.co/datasets/trec
训练过程
包括预处理、使用的硬件、超参数等。
硬件
使用了一块V100。
超参数和训练参数
from transformers import TrainingArguments
training_args = TrainingArguments(
output_dir='./models',
num_train_epochs=2,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
warmup_steps=500,
weight_decay=0.01,
evaluation_strategy="steps",
logging_dir='./logs',
save_steps=3000
)
评估结果
{'epoch': 2.0,
'eval_accuracy': 0.974,
'eval_f1': array([0.98181818, 0.94444444, 1. , 0.99236641, 0.96995708,
0.98159509]),
'eval_loss': 0.138086199760437,
'eval_precision': array([0.98540146, 0.98837209, 1. , 0.98484848, 0.94166667,
0.97560976]),
'eval_recall': array([0.97826087, 0.90425532, 1. , 1. , 1. ,
0.98765432]),
'eval_runtime': 1.6132,
'eval_samples_per_second': 309.943}
📄 许可证
本项目采用MIT许可证。
📋 模型信息
属性 |
详情 |
模型类型 |
基于BERT的文本分类模型 |
训练数据 |
TREC数据集 |