--- license: mit language: ja tags: - luke - pytorch - transformers - jnli - natural-language-inference - NaturalLanguageInference --- # このモデルはluke-japanese-baseをファインチューニングして、JNLI(文章の関係性判別)に用いれるようにしたものです。 このモデルはluke-japanese-baseを yahoo japan/JGLUEのJNLI( https://github.com/yahoojapan/JGLUE ) を用いてファインチューニングしたものです。 文章の関係性(矛盾 contradiction, 中立 neutral, 含意 entailment)を計算するタスクに用いることができます。 # This model is fine-tuned model for JNLI which is based on luke-japanese-base This model is fine-tuned by using yahoo japan JGLUE JNLI dataset. You could use this model for calculating natural language inference. # モデルの精度 accuracy of model モデルの精度(正答率)は 0.8976992604765818 # How to use 使い方 transformers, sentencepieceをinstallして、以下のコードを実行することで、JNLI(文章の関係性判別)タスクを解かせることができます。 please execute this code. ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch tokenizer=AutoTokenizer.from_pretrained('Mizuiro-sakura/luke-japanese-base-finetuned-jnli') model=AutoModelForSequenceClassification.from_pretrained('Mizuiro-sakura/luke-japanese-base-finetuned-jnli') token=tokenizer.encode('時計がついている場所にパブリックマーケットセンターとかかれた看板が設置されています。', '屋根の上に看板があり時計もついています。') result=model(torch.tensor(token).unsqueeze(0)) max_index=torch.argmax(result.logits) if max_index==0: print('contradiction') elif max_index==1: print('neutral') elif max_index==2: print('entailment') ``` # 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} }