NLP: 日本語で質問に答える, transformers, pytorch ver. 2

Last Updated on July 6, 2021 by shibatau

サンプル文でより適切な答えを得るようにいろいろ試し、末尾のGoogle Colaboratoryで公開しました。

I.何をする?

 

次に紹介されているスクリプトで日本語の応答を実行しました。半角スペースで文節を分けると結果がよいようです。

 

Question Answering with Pretrained Transformers Using PyTorch

 

II.サンプル

 

context = "彼は テレビと新聞が 嫌いです。しかし、彼は Youtube を見ます。彼は 23歳で 四日市に 住んでいます。"
question = "彼は 何を 嫌いですか?"
result = question_answering(question=question, context=context)
print("Answer:", result['answer'])
print("Score:", result['score'])

 

>Answer: Youtube
>>Score: 0.967326819896698

 

III.Contextと質問を工夫

 

より適切な答えをえるには、どのようなcontext、質問文がよいか試しています。

Google Colaboratoryに公開しました。

 

https://colab.research.google.com/drive/1XE_sifSm7sj9AGEzvKJm4pYykGdPVwEw?usp=sharing

 

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.