|
--- |
|
license: mit |
|
language: ja |
|
tags: |
|
- luke |
|
- pytorch |
|
- transformers |
|
- commonsenseqa |
|
- commonsense-qa |
|
- CommonsenseQA |
|
- commonsense_qa |
|
- jcommonsenseqa |
|
|
|
--- |
|
|
|
# このモデルはluke-japanese-largeをファインチューニングして、JCommonsenseQA(選択式応答)に用いれるようにしたものです。 |
|
このモデルはluke-japanese-largeを |
|
yahoo japan/JGLUEのJCommonsenseQA( https://github.com/yahoojapan/JGLUE ) |
|
を用いてファインチューニングしたものです。 |
|
|
|
選択式の質問応答タスクに用いることができます。 |
|
|
|
# This model is fine-tuned model for commonsenseqa which is based on luke-japanese-large |
|
|
|
This model is fine-tuned by using yahoo japan JGLUE JCommonsenseQA dataset. |
|
|
|
You could use this model for commonsenseqa tasks. |
|
|
|
# モデルの精度 accuracy of model |
|
モデルの精度は |
|
83.82484361036744 |
|
でした。他の言語モデルと比べても非常に高い値となっています。 |
|
(参考 BERT:72.0、XLM RoBERTa base:68.7) |
|
|
|
# How to use 使い方 |
|
transformers, sentencepieceをinstallして、以下のコードを実行することで、commonsenseqaタスクを解かせることができます。 |
|
please execute this code. |
|
```python |
|
from transformers import AutoTokenizer, AutoModelForMultipleChoice |
|
import torch |
|
import numpy as np |
|
|
|
# modelのロード |
|
tokenizer = AutoTokenizer.from_pretrained('Mizuiro-sakura/luke-large-commonsenseqa-japanese') |
|
model = AutoModelForMultipleChoice.from_pretrained('Mizuiro-sakura/luke-large-commonsenseqa-japanese') |
|
|
|
# 質問と選択肢の代入 |
|
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) |
|
``` |
|
|
|
|
|
# what is Luke? Lukeとは?[1] |
|
LUKE (Language Understanding with Knowledge-based Embeddings) is a new pre-trained contextualized representation of words and entities based on transformer. LUKE treats words and entities in a given text as independent tokens, and outputs contextualized representations of them. LUKE adopts an entity-aware self-attention mechanism that is an extension of the self-attention mechanism of the transformer, and considers the types of tokens (words or entities) when computing attention scores. |
|
|
|
LUKE achieves state-of-the-art results on five popular NLP benchmarks including SQuAD v1.1 (extractive question answering), CoNLL-2003 (named entity recognition), ReCoRD (cloze-style question answering), TACRED (relation classification), and Open Entity (entity typing). luke-japaneseは、単語とエンティティの知識拡張型訓練済み Transformer モデルLUKEの日本語版です。LUKE は単語とエンティティを独立したトークンとして扱い、これらの文脈を考慮した表現を出力します。 |
|
|
|
# Acknowledgments 謝辞 |
|
Lukeの開発者である山田先生とStudio ousiaさんには感謝いたします。 I would like to thank Mr.Yamada @ikuyamada and Studio ousia @StudioOusia. |
|
|
|
# Citation |
|
[1]@inproceedings{yamada2020luke, title={LUKE: Deep Contextualized Entity Representations with Entity-aware Self-attention}, author={Ikuya Yamada and Akari Asai and Hiroyuki Shindo and Hideaki Takeda and Yuji Matsumoto}, booktitle={EMNLP}, year={2020} } |
|
|
|
|
|
|
|
|
|
|
|
|