--- license: mit language: - ja base_model: - tohoku-nlp/bert-base-japanese-whole-word-masking --- # eBERTの概要 eBERTは[wrimeデータセット](https://github.com/ids-cv/wrime)に基づく感情予想bertモデルです。
eBERTは東北大学自然言語処理研究グループ様の[日本語事前学習済みbertモデル](https://huggingface.co/tohoku-nlp/bert-base-japanese-whole-word-masking)を使用しました。 # 使用方法 ```python from transformers import BertForSequenceClassification, AutoTokenizer import numpy as np emotions = ['喜び', '悲しみ', '期待', '驚き', '怒り', '恐れ', '嫌悪', '信頼'] model = BertForSequenceClassification.from_pretrained("beezza/eBERT") tokenizer = AutoTokenizer.from_pretrained("beezza/eBERT") def softmax(x): f_x = np.exp(x) / np.sum(np.exp(x)) return f_x model.eval() tokens = tokenizer("テキスト", truncation=True, return_tensors="pt") tokens.to(model.device) preds = model(**tokens) prob = softmax(preds.logits.cpu().detach().numpy()[0]) out_dict = {n: p for n, p in zip(emotions, prob)} print(out_dict) ```