This is a sequence-to-sequence conversational model with attention mechanism implemented by Pytorch. This model is optimized for Japanese. You may replace existing tokenizer with for your language. This implementation is based on official Pytorch Tutorials http://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html .
-
Addition of scripts (
collect_replies.py
&settings.py
) to collect dialogue data -
Change of preprocess scheme accompanying it
-
You can load saved latest model and talk with him (
load_saved_model.py
).
settings.py
- Extract environment variables to use tweepycollect_replies.py
- Obtain dialogue datapreprocess.py
- Preprocess of dialogue data obtainedmodel.py
- Encoder and Decoder with Attentionglobal_config.py
- Common variables and functionstrain.py
- Script to trainloader.py
- Function to load and save modelload_saved_model.py
- Load latest saved model and talk with him
- Ubuntu 16.04
- GeForce GTX 1070
- Memory 16GB
- CPU Corei5
- Anaconda3-4.2.0 (Python 3.5)
- pytorch
- tweepy
- python-dotenv
- MeCab
Please reference: http://pytorch.org/
$ conda install pytorch torchvision -c soumith
-
Registration to the Twitter API(https://apps.twitter.com).
-
Extraction of consumer key, consumer secret key, access token key and access token secret key. Then, please make
.env
file and write consumerkey, consumer secret key, access token key and access token secret key.
$ vi .env
CONSUMER_KEY=...
CONSUMER_SECRET=...
ACCESS_TOKEN=...
ACCESS_TOKEN_SECRET=...
- Collect dialogue data. If you think enough data (10MB~) gathered, do Ctrl-C.
$ python collect_replies.py
- Move collected data to data directory.
$ mv source.txt target.txt data/
- Let's train conversational model.
$ python train.py
- Let's talk with him!
$ python load_saved_model.py
- https://arxiv.org/abs/1506.05869
- http://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html
- https://github.com/jinfagang/pytorch_chatbot
[wataruhashimoto52] https://github.com/wataruhashimoto52
Welcome submit PR and pull request!
If you find an issue or have some questions, please contact Wataru Hashimoto.
- (at)TinyDrone on Twitter
- w.hashimoto (at) outlook.com