Making Sandwichman's Tale by Machine Learning ver4

The 4th to make Sandwichman's Tale by deep learning! !! !! !! !! !! !! !! !! !! !! !!

I'm in charge of 14 natural language processing Advent Calendar 2019 (sorry for being late for a day !!!) https://qiita.com/advent-calendar/2019/nlp

I want to automatically make a control like Sandwichman, and I want to sell this to a comedy office for 4000 trillion yen. And I want to meet Sandwichman!

This time I implemented HRED with pytorch!

Past try

Ver3 >> https://qiita.com/yoyoyo_/items/e03a1a5f99762352c95f Ver2 >> https://qiita.com/yoyoyo_/items/f30c538234e62dbaa081 Ver1 >> https://qiita.com/yoyoyo_/items/105879c386be1d8b0782

HRED

The original paper is A Hierarchical Recurrent Encoder-Decoder For Generative Context-Aware Query Suggestion https://arxiv.org/abs/1507.02221 (2015)

In 3 lines

--HRED is an abbreviation for Hierarchical Recurrent Encoder Decoder. ――Simply put, it automatically generates conversations while drawing on the flow of conversations. seq2 An evolution of seq. ――By inserting an RNN that memorizes past conversation responses, it develops into a "conversation" instead of a question-and-answer.

model

seq2 Compare seq and HRED. HRED has added Hierarchical RNN (abbreviated as HRNN) to seq2seq. HRNN is an RNN for memorizing the flow of past conversations, and Decoder generates a response considering past conversations by initializing the internal state of HRNN.

If you use this, can you make a good control? That is this attempt! !!

seq2seq HRED
seq2seq.png HRED.png

algorithm

The order is to repeat steps 1-5. The number of repetitions is called the number of sessions, and it seems that it was set to 5 times in the paper.

  1. Learn Encoder with one sentence
  2. Input the output of Encoder to HRNN
  3. Set the internal state of HRNN to the initial state of the internal state of Decoder
  4. Learn Decoder
  5. Set the output of Decoder to the input of Encoder and go to 1.

code

I also put it on deep learning knocks!

https://github.com/yoyoyo-yo/DeepLearningMugenKnock/tree/master/Question_nlp#q-hred

I actually tried it

The first "A: Hello, I'm Sandwichman" is what I typed It's not a word, but are you trying to understand the context?

A:Hi, I ’m Sandwichman.
B:What? ". Ten you. Hmm. .. Hmm you. .. Ten you. hand. ?? To. hand? ". ?? Hmm. hand? I'm sorry, you. hand. hand. hand. Teyo you. hand? Ten. Teten. hand. hand. Ten. hand? Tente. hand? .. Ten. hand. Ten. hand? .. Ten. hand? Ten
A:That's you. What? hand. ?? But? It's like Gaden. What? hand. It's good. What? Hmm. hand? .. so. Hmm. .. hand? .. .. Ten. hand. .. Hmm. Ten. hand. Hmm. .. Ten. hand? .. hand. .. hand. ?? so. What? That's right. .. .. Yo. .. .. Hmm. Yode. hand
B:But it is. "
A:.. hand? ".
B: 。
A: 。
B:is not it.
A:.. hand. hand. you. hand. hand. hand. What! ". ".
B:There isn't.
A:Ha ".
B:Ha "also. ".
A:"Hateta"
B:"Hahata".
A:Hamoyo ". "Deta"
B:Goodbye you.
A:, ".
B: 。
A:Is it? ".
B:Is it? "
A:Hamoyo "
B: 。
A:"
B:How is it?
A:Is it? .. .. hand? ". .. hand. .. ?? .. .. I'm sorry. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
B:Mona ". .. hand. .. you. .. .. .. .. .. Hmm. .. ". .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
A:, ".
B:Ha "also.
A:Is "even".
B: 。
A: 。
B:is".
A:Ha "
B:Ha "also. What?
A:Hahamo. "? "
B:Ha ".
A:Ha "
B:"Hateta".
A:Is
B:Ha "
A:"Hata".
B:Hamoyo ".
A:It is. "
B:Good morning "
A:I was happy. "
B:Hamoyotetan "
A:Hamoyo you. You came out. "
B:Hayo "
A:Hello.
B:Naha.
A:It is. "
B:It is. "
A:.. You are! "
B:Ha ".
A:What is it?
B:". .. hand. you. .. What? .. .. .. .. ". .. hand. .. ?? ". .. .. .. .. .. .. .. .. .. .. Isn't it? .. I wonder. .. .. .. .. .. .. .. .. .. .. .. .. .. .. hand. .. .. .. .. It is. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
A:Is it? "
B:What is it? " ?? ". .. hand. .. you. .. Hmm. hand. .. Hmm. .. ". hand. .. ". What?
A:Absent".
B:Ha "
A:Ha ".
B:"
A:.. That's it. "
B:Ha "also.
A:"Hateta"
B:Hamoyo. Also". "Tate ni".
A:Ha "
B:Hamoyo. To "
A:What was it? ".
B:What is it? hand"

To summarize in 3 lines

--I tried to make a sandwich man's control with HRED that incorporated Hierarchical RNN that acquires past conversation information into seq2seq. ――It's not a human language, but is it a response? --Next, try VHRED

When Sandwichman is completely done, do you think that all the code so far will be put together and put out to Git and others?

Recommended Posts

Making Sandwichman's Tale by Machine Learning ver4
4 [/] Four Arithmetic by Machine Learning
Machine learning summary by Python beginners
Machine learning
[Failure] Find Maki Horikita by machine learning
Four arithmetic operations by machine learning 6 [Commercial]
Python & Machine Learning Study Memo ④: Machine Learning by Backpropagation
Judgment of igneous rock by machine learning ②
Try to forecast power demand by machine learning
Predicting House Prices (Machine Learning: Second Half) ver1.1
Classify machine learning related information by topic model
Analysis of shared space usage by machine learning
Stock price forecast by machine learning Numerai Signals
[Translation] scikit-learn 0.18 Tutorial Introduction of machine learning by scikit-learn
Reasonable price estimation of Mercari by machine learning
[Memo] Machine learning
Classification of guitar images by machine learning Part 2
Machine learning classification
A story about data analysis by machine learning
Machine Learning sample
Python learning memo for machine learning by Chainer from Chapter 2
Python learning memo for machine learning by Chainer Chapters 1 and 2
Time series data prediction by AutoML (automatic machine learning)
Machine learning tutorial summary
About machine learning overfitting
Machine learning ⑤ AdaBoost Summary
Machine Learning: Supervised --AdaBoost
Machine learning logistic regression
Machine learning support vector machine
Machine Sommelier by Keras-
Studying Machine Learning ~ matplotlib ~
Machine learning linear regression
Machine learning course memo
Machine learning library dlib
Machine learning (TensorFlow) + Lotto 6
Somehow learn machine learning
Machine learning library Shogun
Machine learning rabbit challenge
Introduction to machine learning
Machine Learning: k-Nearest Neighbors
What is machine learning?
Collect machine learning data by scraping from bio-based public databases
"Learn while making! Development deep learning by PyTorch" on Colaboratory.
Predict the presence or absence of infidelity by machine learning
Python learning memo for machine learning by Chainer Chapter 7 Regression analysis
Distinguish t + pazolite songs by machine learning (NNC challenge development)
Stock price forecast by machine learning Let's get started Numerai