Bert 是一种基于 Transformer 双向编码器的架构,通过 MLM(掩码语言建模)目标进行训练。
[bert-base-uncased] 使用 HuggingFace Trainer 在情感数据集上进行了微调,训练参数如下
learning rate 2e-5,
batch size 64,
num_train_epochs=8,from openmind import pipeline
classifier = pipeline("text-classification",model='Changchun_Ascend/bert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)
>>>output=[[{'label': 'sadness', 'score': 0.0005138218402862549}, {'label': 'joy', 'score': 0.9972521662712097}, {'label': 'love', 'score': 0.0007443303475156426}, {'label': 'anger', 'score': 0.000740492541808635}, {'label': 'fear', 'score': 0.0003293847548775375}, {'label': 'surprise', 'score': 0.0004197478701826185}][Twitter-Sentiment-Analysis]。
Colab 笔记本 按照上述笔记本操作,将模型名称从 distilbert 更改为 bert
{
'test_accuracy': 0.9405,
'test_f1': 0.9405920712282673,
'test_loss': 0.15769127011299133,
'test_runtime': 10.5179,
'test_samples_per_second': 190.152,
'test_steps_per_second': 3.042
}