beezza commited on
Commit
7a9be32
·
verified ·
1 Parent(s): 8926d2f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -3
README.md CHANGED
@@ -1,3 +1,35 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - ja
5
+ base_model:
6
+ - tohoku-nlp/bert-base-japanese-whole-word-masking
7
+ ---
8
+
9
+ # eBERTの概要
10
+ eBERTは[wrimeデータセット](https://github.com/ids-cv/wrime)に基づく感情予想bertモデルです。<br>
11
+ eBERTは東北大学自然言語処理研究グループ様の[日本語事前学習済みbertモデル](https://huggingface.co/tohoku-nlp/bert-base-japanese-whole-word-masking)を使用しました。
12
+
13
+ # 使用方法
14
+ ```python
15
+ from transformers import BertForSequenceClassification, AutoTokenizer
16
+
17
+ emotions = ['喜び', '悲しみ', '期待', '驚き', '怒り', '恐れ', '嫌悪', '信頼']
18
+
19
+ model = BertForSequenceClassification.from_pretrained("beezza/eBERT")
20
+ tokenizer = AutoTokenizer.from_pretrained("beezza/eBERT")
21
+
22
+ def softmax(x):
23
+ f_x = np.exp(x) / np.sum(np.exp(x))
24
+ return f_x
25
+
26
+ model.eval()
27
+
28
+ tokens = tokenizer("テキスト", truncation=True, return_tensors="pt")
29
+ tokens.to(model.device)
30
+ preds = model(**tokens)
31
+ prob = softmax(preds.logits.cpu().detach().numpy()[0])
32
+ out_dict = {n: p for n, p in zip(emotion_names_jp, prob)}
33
+
34
+ print(out_dict)
35
+ ```