GithubHelp home page GithubHelp logo

lixiangnlp / seq2seq-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kenkov/seq2seq

0.0 3.0 0.0 51 KB

sequence to sequence neural network model for dialogue system

License: MIT License

Makefile 2.59% Python 97.41%

seq2seq-1'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-1's People

Contributors

kenkov avatar

Watchers

James Cloos avatar Xiang Li avatar  avatar

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.