Downloads · 30 days
72
6% of all-time downloads
Mizuiro-sakura/bert-large-japanese-v2-finetuned-commonsenseQA
bert-large-japanese-v2-finetuned-commonsenseQA is a multiple choice model from Mizuiro-sakura. Use it for the multiple choice task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
このモデルはcl-tohoku/bert-large-japanese-v2をyahoo japan/JGLUEのJCommonsenseQA( https://github.com/yahoojapan/JGLUE ) を用いてファインチューニングしたものです。 This model is fine-tuned by using JGLUE/JCommonsenseQA dataset.
Downloads · 30 days
72
6% of all-time downloads
All-time downloads
1.1K
Public
Repo size
2.7 GB
Likes
0
Public
Click a slice to open those files.
.bin1.3 GB · 100%
From the Hugging Face model README
このモデルはcl-tohoku/bert-large-japanese-v2をyahoo japan/JGLUEのJCommonsenseQA( https://github.com/yahoojapan/JGLUE ) を用いてファインチューニングしたものです。
This model is fine-tuned by using JGLUE/JCommonsenseQA dataset.
You could use this model for CommonsenseQA tasks.
transformersおよびpytorch, fugashi, unidic_liteをインストールしてください。
pip install transformers, pytorch, fugashi, unidic_lite
以下のコードを実行することで、CommonsenseQAタスクを解かせることができます。 please execute this code.
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)
0.888715
(参考 BERT : 72.0, XLM RoBERTa base : 68.7, LUKE : 80.0)