Giter Club home page Giter Club logo

chatbot-pytorch's Introduction

Pytorch Implementation of Japanese Chatbot

Description

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 .

Difference

  • 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).

Contents

  • settings.py - Extract environment variables to use tweepy
  • collect_replies.py - Obtain dialogue data
  • preprocess.py - Preprocess of dialogue data obtained
  • model.py - Encoder and Decoder with Attention
  • global_config.py - Common variables and functions
  • train.py - Script to train
  • loader.py - Function to load and save model
  • load_saved_model.py - Load latest saved model and talk with him

Machine

  • Ubuntu 16.04
  • GeForce GTX 1070
  • Memory 16GB
  • CPU Corei5

Requirements

  • Anaconda3-4.2.0 (Python 3.5)
  • pytorch
  • tweepy
  • python-dotenv
  • MeCab

Install

Please reference: http://pytorch.org/

$ conda install pytorch torchvision -c soumith

How to use?

  1. Registration to the Twitter API(https://apps.twitter.com).

  2. 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=...
  1. Collect dialogue data. If you think enough data (10MB~) gathered, do Ctrl-C.
$ python collect_replies.py   
  1. Move collected data to data directory.
$ mv source.txt target.txt data/
  1. Let's train conversational model.
$ python train.py   
  1. Let's talk with him!
$ python load_saved_model.py

Results

result

Reference

Author

[wataruhashimoto52] https://github.com/wataruhashimoto52

Contribute

Welcome submit PR and pull request!

Contact

If you find an issue or have some questions, please contact Wataru Hashimoto.

  • (at)TinyDrone on Twitter
  • w.hashimoto (at) outlook.com

chatbot-pytorch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

airob rikuei

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.