模型:

avichr/heBERT_sentiment_analysis

英文

HeBERT:用于极性分析和情感识别的预训练BERT模型

HeBERT是一种希伯来语预训练语言模型。它基于Google的BERT架构,并采用了BERT-Base配置 (Devlin et al. 2018)

HeBERT在以下三个数据集上进行了训练:

  • 希伯来语版本的OSCAR (Ortiz, 2019) :约9.8GB的数据,包括10亿个词和2080万个句子。
  • 希伯来语Wikipedia转储数据集:约650MB的数据,包括6300万个词和380万个句子。
  • 收集了用于本研究的情感用户生成内容(UGC)数据(下面有描述)。我们在情感识别和情感分析的下游任务中对模型进行了评估。
  • 情感UGC数据描述

    我们的用户生成内容(UGC)是从3个主要新闻网站收集的文章评论,时间跨度为2020年1月至2020年8月,数据总大小约为150MB,包括700万个词和35万个句子。我们请众包成员(每个句子3-10个标注员)为8种情感(愤怒、厌恶、期待、恐惧、快乐、悲伤、惊讶和信任)和整体情感/极性标注了4000个句子。为了验证标注,我们使用Krippendorff's alpha寻找每个句子中标注者对情感的一致性。我们保留了得到alpha > 0.7的句子。需要注意的是,虽然我们发现标注者对快乐、信任和厌恶等情感存在普遍一致性,但在某些情感上存在普遍的不一致性,似乎是由于在文本中寻找这些情感的复杂性(例如期待和惊讶)。

    性能

    情感分析
    precision recall f1-score
    natural 0.83 0.56 0.67
    positive 0.96 0.92 0.94
    negative 0.97 0.99 0.98
    accuracy 0.97
    macro avg 0.92 0.82 0.86
    weighted avg 0.96 0.97 0.96

    如何使用

    对于遮挡语言模型(可以微调为任何下游任务)

    from transformers import AutoTokenizer, AutoModel
    tokenizer = AutoTokenizer.from_pretrained("avichr/heBERT")
    model = AutoModel.from_pretrained("avichr/heBERT")
        
    from transformers import pipeline
    fill_mask = pipeline(
        "fill-mask",
        model="avichr/heBERT",
        tokenizer="avichr/heBERT"
    )
    fill_mask("הקורונה לקחה את [MASK] ולנו לא נשאר דבר.")
    

    对于情感分类模型(仅极性):

    from transformers import AutoTokenizer, AutoModel, pipeline
    tokenizer = AutoTokenizer.from_pretrained("avichr/heBERT_sentiment_analysis") #same as 'avichr/heBERT' tokenizer
    model = AutoModel.from_pretrained("avichr/heBERT_sentiment_analysis")
    
    # how to use?
    sentiment_analysis = pipeline(
        "sentiment-analysis",
        model="avichr/heBERT_sentiment_analysis",
        tokenizer="avichr/heBERT_sentiment_analysis",
        return_all_scores = True
    )
    
    >>>  sentiment_analysis('אני מתלבט מה לאכול לארוחת צהריים')	
    [[{'label': 'natural', 'score': 0.9978172183036804},
    {'label': 'positive', 'score': 0.0014792329166084528},
    {'label': 'negative', 'score': 0.0007035882445052266}]]
    
    >>>  sentiment_analysis('קפה זה טעים')
    [[{'label': 'natural', 'score': 0.00047328314394690096},
    {'label': 'possitive', 'score': 0.9994067549705505},
    {'label': 'negetive', 'score': 0.00011996887042187154}]]
    
    >>>  sentiment_analysis('אני לא אוהב את העולם')
    [[{'label': 'natural', 'score': 9.214012970915064e-05}, 
    {'label': 'possitive', 'score': 8.876807987689972e-05}, 
    {'label': 'negetive', 'score': 0.9998190999031067}]]
    

    我们的模型也可在AWS上使用!有关更多信息,请访问 AWS' git

    敬请关注!

    我们仍在努力改进我们的模型,并将随着进展更新此页面。请注意,目前我们只发布了情感分析(极性),情感检测将稍后发布。我们的git: https://github.com/avichaychriqui/HeBERT

    如果您使用了此模型,请引用我们的论文:

    Chriqui, A., & Yahav, I. (2021). HeBERT & HebEMO: a Hebrew BERT Model and a Tool for Polarity Analysis and Emotion Recognition. arXiv preprint arXiv:2102.01909.

    @article{chriqui2021hebert,
      title={HeBERT \\\\\\\\\\\\\\\\& HebEMO: a Hebrew BERT Model and a Tool for Polarity Analysis and Emotion Recognition},
      author={Chriqui, Avihay and Yahav, Inbal},
      journal={arXiv preprint arXiv:2102.01909},
      year={2021}
    }