このモデルはLuke-japanese-large-liteをファインチューニングしたものです。
このモデルは8つの感情(喜び、悲しみ、期待、驚き、怒り、恐れ、嫌悪、信頼)の内、どの感情が文章に含まれているのか分析することができます。
このモデルはwrimeデータセット(
https://huggingface.co/datasets/shunk031/wrime
)を用いて学習を行いました。
This model is based on Luke-japanese-large-lite
This model is fine-tuned model which besed on studio-ousia/Luke-japanese-large-lite.
This could be able to analyze which emotions (joy or sadness or anticipation or surprise or anger or fear or disdust or trust ) are included.
This model was fine-tuned by using wrime dataset.
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 は単語とエンティティを独立したトークンとして扱い、これらの文脈を考慮した表現を出力します。
how to use 使い方
ステップ1:pythonとpytorch, sentencepieceのインストールとtransformersのアップデート(バージョンが古すぎるとLukeTokenizerが入っていないため)
update transformers and install sentencepiece, python and pytorch
ステップ2:下記のコードを実行する
Please execute this code
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, LukeConfig
2import torch
3tokenizer = AutoTokenizer.from_pretrained("Mizuiro-sakura/luke-japanese-large-sentiment-analysis-wrime")
4config = LukeConfig.from_pretrained('Mizuiro-sakura/luke-japanese-large-sentiment-analysis-wrime', output_hidden_states=True)
5model = AutoModelForSequenceClassification.from_pretrained('Mizuiro-sakura/luke-japanese-large-sentiment-analysis-wrime', config=config)
6
7text='すごく楽しかった。また行きたい。'
8
9max_seq_length=512
10token=tokenizer(text,
11 truncation=True,
12 max_length=max_seq_length,
13 padding="max_length")
14output=model(torch.tensor(token['input_ids']).unsqueeze(0), torch.tensor(token['attention_mask']).unsqueeze(0))
15max_index=torch.argmax(torch.tensor(output.logits))
16
17if max_index==0:
18 print('joy、うれしい')
19elif max_index==1:
20 print('sadness、悲しい')
21elif max_index==2:
22 print('anticipation、期待')
23elif max_index==3:
24 print('surprise、驚き')
25elif max_index==4:
26 print('anger、怒り')
27elif max_index==5:
28 print('fear、恐れ')
29elif max_index==6:
30 print('disgust、嫌悪')
31elif max_index==7:
32 print('trust、信頼')
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}
}