Mizuiro-sakura commited on
Commit
913edbf
1 Parent(s): 90ea9ad

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md CHANGED
@@ -1,3 +1,75 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language: ja
4
+ library_name: transformers
5
+ tags:
6
+ - pytorch
7
+ - bert
8
+ - commonsenseqa
9
+ - commonsense_qa
10
+ - commonsense-qa
11
+ - CommonsenseQA
12
+ datasets:
13
+ - wikipedia
14
+ - cc100
15
+ - oscar
16
+ metrics:
17
+ - accuracy
18
+
19
  ---
20
+
21
+ # このモデルはcl-tohoku/bert-large-japanese-v2をファインチューニングしてCommonsenseQA(選択式の質問)に用いれるようにしたものです。
22
+ このモデルはcl-tohoku/bert-large-japanese-v2をyahoo japan/JGLUEのJCommonsenseQA( https://github.com/yahoojapan/JGLUE ) を用いてファインチューニングしたものです。
23
+ # This model is fine-tuned model for CommonsenseQA which is based on cl-tohoku/bert-large-japanese-v2
24
+ This model is fine-tuned by using JGLUE/JCommonsenseQA dataset.
25
+
26
+ You could use this model for CommonsenseQA tasks.
27
+
28
+ # How to use 使い方
29
+ transformersおよびpytorch, fugashi, unidic_liteをインストールしてください。
30
+
31
+ pip install transformers, pytorch, fugashi, unidic_lite
32
+
33
+ 以下のコードを実行することで、CommonsenseQAタスクを解かせることができます。 please execute this code.
34
+ ```python
35
+ from transformers import AutoTokenizer, AutoModelForMultipleChoice
36
+ import torch
37
+ import numpy as np
38
+
39
+ # modelのロード
40
+ tokenizer = AutoTokenizer.from_pretrained('Mizuiro-sakura/bert-large-japanese-v2-finetuned-commonsenseQA')
41
+ model = AutoModelForMultipleChoice.from_pretrained('Mizuiro-sakura/bert-large-japanese-v2-finetuned-commonsenseQA')
42
+
43
+ # 質問と選択肢の代入
44
+ question = '電子機器で使用される最も主要な電子回路基板の事をなんと言う?'
45
+ choice1 = '掲示板'
46
+ choice2 = 'パソコン'
47
+ choice3 = 'マザーボード'
48
+ choice4 = 'ハードディスク'
49
+ choice5 = 'まな板'
50
+
51
+ # トークン化(エンコーディング・形態素解析)する
52
+ token = tokenizer([question,question,question,question,question],[choice1,choice2,choice3,choice4,choice5],return_tensors='pt',padding=True)
53
+ leng=len(token['input_ids'][0])
54
+
55
+ # modelに入力するための下準備
56
+ X1 = np.empty(shape=(1, 5, leng))
57
+ X2 = np.empty(shape=(1, 5, leng))
58
+ X1[0, :, :] = token['input_ids']
59
+ X2[0, :, :] = token['attention_mask']
60
+
61
+ # modelにトークンを入力する
62
+ results = model(torch.tensor(X1).to(torch.int64),torch.tensor(X2).to(torch.int64))
63
+
64
+ # 最も高い値のインデックスを取得する
65
+ max_result=torch.argmax(results.logits)
66
+ print(max_result)
67
+ ```
68
+ # モデルの精度 accuracy of model
69
+ 0.888715
70
+ (参考 BERT : 72.0, XLM RoBERTa base : 68.7, LUKE : 80.0)
71
+
72
+
73
+
74
+
75
+