GithubHelp home page GithubHelp logo

seq2seq's Introduction

seq2seq

Seq2seq is a Python library for modeling dialogue/conversational model with neural network.

This software implements seqence to sequence (seq2seq) neural network models with the aim to create dialogue systems.

Install

This software depends on chainer and gensim. You must install them first.

$ pip3 install chainer==1.6.1
$ pip3 install gensim==0.12.4

It is also recommended to install cuda to use GPU. It is optional, but using GPU improves performance.

$ pacman -S cuda  # for ArchLinux

Usage

You must learn a model to use seq2seq first with you own corpus. It is easy to use your own corpus in this module. The following description uses test corpus included in this software to show you how to apply learning scripts to the corpus.

corpus_test directory has a test corpus conv.txt. corpus should be the folllowing format.

original_ sentence<TAB>reply_sentence

A sentence in the second column is reply to a sentence in the first column. These sentences should be separated by TAB.

Each sentence should be divided into tokens such as words or characters. You can utilize corpus_test/Makefile to split sentences into words and characters.

$ cd corpus_test
$ make char

Makefile splits conv.txt to sent.char.txt and conv.char.txt. sent.char.txt has all texts in conv.txt splitted by characters. conv.char.txt has all conversations in conv.txt splitted by characters.

Makefile can also split conv.txt to sent.word.txt and conv.word.txt by using make word. When you use this, you should specify TOKENIZER in Makefile first. The default is mecab -Owakati. sent.word.txt has all texts in conv.txt splitted by words. conv.word.txt has all conversations in conv.txt splitted by words.

This section uses conv.sent.txt and sent.sent.txt to descrive usage, but you can also use conv.word.txt and sent.word.txt instead.

After preparing a corpus, you can learn your model which predicts a reply sentence from a input sentence based on the corpus. There are a configuration file test.ini which has parameters to learn a model from the test corpus.

Use train.py to learn your model.

$ python train.py test.ini -tlstm

Specify -g0 if you use GPU.

$ python train.py test.ini -tlstm

After finishing training, use test.py for talking with the model.

$ python test.py test.ini -tlstm <./corpus_test/sent.char.txt

Use -g option to use GPU.

# enable GPU to use -g option
$ python train.py test.ini -g0 -tlstm
$ python test.py test.ini -g0 -tlstm

There is Makefile for convenient.

# train the model
$ make train
# test the model
# make test

Model description

  • Word Embedding initializer: word2vec or random between [0, 1]
  • Layers : embedding layer -> 2 hidden layers -> output layer -> Softmax
  • Units/activation functions: LSTM or ReLU with dropout option
  • Optimizer: ADAM with clipping

seq2seq's People

Contributors

kenkov avatar

Stargazers

IMLHF avatar Shuyan Huang avatar Andrii Melekhovskiy avatar Lee Nelson avatar Eric Mayberry avatar  avatar  avatar  avatar Keisuke Shirai avatar zhucanxiang avatar Alonso avatar Ben Lai avatar  avatar Seong Hoon Jung avatar Winnerineast Lee avatar  avatar himkt avatar Yi Tay avatar Bruno Cabral avatar Joe avatar Zhongyang Li avatar Ruo Zhang avatar Jim Huang avatar yuanke avatar  avatar roys avatar Kelvin Ngan avatar Chang-Hong Hsu avatar li avatar  avatar Andherson Maeda avatar Meno avatar odanado avatar JourneyLiu avatar sile avatar André Betz avatar Tadas Šubonis avatar Aldiantoro Nugroho avatar  avatar IKEGAMI Yukino avatar NOKUBI Takatsugu avatar hassaku avatar shi3z avatar Emilio Monti avatar kai avatar

Watchers

James Cloos avatar Emilio Monti avatar NOKUBI Takatsugu avatar sile avatar Tonya avatar

seq2seq's Issues

Error when running

Hi, I ran the code following the readme and ran into this error.

Traceback (most recent call last):
File "train.py", line 7, in
from seq2seq import train_encoder_decoder
File "/Users/username/seq2seq/seq2seq.py", line 21
dictionary: corpora.Dictionary,
^
SyntaxError: invalid syntax

May I know how to fix it?

Thanks!

ImportError: No module named 'typing'

rzai@rzai00:/prj/seq2seq$ CUDA_VISIBLE_DEVICES=1 python3 train.py test.ini -tlstm
Using gpu device 0: GeForce GTX 1080 (CNMeM is disabled, cuDNN 5005)
Traceback (most recent call last):
File "train.py", line 7, in
from seq2seq import train_encoder_decoder
File "/home/rzai/prj/seq2seq/seq2seq.py", line 10, in
from typing import List
ImportError: No module named 'typing'
rzai@rzai00:
/prj/seq2seq$

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.