Mizuiro-sakura's picture
Update README.md
8dc8560
---
license: mit
language: ja
library_name: transformers
tags:
- pytorch
- bert
- commonsenseqa
- commonsense_qa
- commonsense-qa
- CommonsenseQA
datasets:
- wikipedia
- cc100
- oscar
metrics:
- accuracy
---
# このモデルはcl-tohoku/bert-large-japanese-v2をファインチューニングしてCommonsenseQA(選択式の質問)に用いれるようにしたものです。
このモデルはcl-tohoku/bert-large-japanese-v2をyahoo japan/JGLUEのJCommonsenseQA( https://github.com/yahoojapan/JGLUE ) を用いてファインチューニングしたものです。
# This model is fine-tuned model for CommonsenseQA which is based on cl-tohoku/bert-large-japanese-v2
This model is fine-tuned by using JGLUE/JCommonsenseQA dataset.
You could use this model for CommonsenseQA tasks.
# How to use 使い方
transformersおよびpytorch, fugashi, unidic_liteをインストールしてください。
pip install transformers, pytorch, fugashi, unidic_lite
以下のコードを実行することで、CommonsenseQAタスクを解かせることができます。 please execute this code.
```python
from transformers import AutoTokenizer, AutoModelForMultipleChoice
import torch
import numpy as np
# modelのロード
tokenizer = AutoTokenizer.from_pretrained('Mizuiro-sakura/bert-large-japanese-v2-finetuned-commonsenseQA')
model = AutoModelForMultipleChoice.from_pretrained('Mizuiro-sakura/bert-large-japanese-v2-finetuned-commonsenseQA')
# 質問と選択肢の代入
question = '電子機器で使用される最も主要な電子回路基板の事をなんと言う?'
choice1 = '掲示板'
choice2 = 'パソコン'
choice3 = 'マザーボード'
choice4 = 'ハードディスク'
choice5 = 'まな板'
# トークン化(エンコーディング・形態素解析)する
token = tokenizer([question,question,question,question,question],[choice1,choice2,choice3,choice4,choice5],return_tensors='pt',padding=True)
leng=len(token['input_ids'][0])
# modelに入力するための下準備
X1 = np.empty(shape=(1, 5, leng))
X2 = np.empty(shape=(1, 5, leng))
X1[0, :, :] = token['input_ids']
X2[0, :, :] = token['attention_mask']
# modelにトークンを入力する
results = model(torch.tensor(X1).to(torch.int64),torch.tensor(X2).to(torch.int64))
# 最も高い値のインデックスを取得する
max_result=torch.argmax(results.logits)
print(max_result+1)
```
# モデルの精度 accuracy of model
0.888715
(参考 BERT : 72.0, XLM RoBERTa base : 68.7, LUKE : 80.0)