• Stars
    star
    780
  • Rank 58,299 (Top 2 %)
  • Language
    Lua
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neural conversational model in Torch

Neural Conversational Model in Torch

This is an attempt at implementing Sequence to Sequence Learning with Neural Networks (seq2seq) and reproducing the results in A Neural Conversational Model (aka the Google chatbot).

The Google chatbot paper became famous after cleverly answering a few philosophical questions, such as:

Human: What is the purpose of living?
Machine: To live forever.

How it works

The model is based on two LSTM layers. One for encoding the input sentence into a "thought vector", and another for decoding that vector into a response. This model is called Sequence-to-sequence or seq2seq.

seq2seq
Source: http://googleresearch.blogspot.ca/2015/11/computer-respond-to-this-email.html

In this experiment, we train the seq2seq model with movie dialogs from the Cornell Movie-Dialogs Corpus. The lines are shortened to the first sentence.

Sample conversation

Here's a sample conversation after training for 20 epoch with 50000 examples, using the following command:

th train.lua --cuda --dataset 50000 --hiddenSize 1000

(Took 3 days to train on my GeForce GTX 780M.)

For OpenCL, use --opencl instead of --cuda. To train on CPU, don't provide any of those two.

WARNING: I can no longer reproduce those results. The cause seems to be a change in one of dependencies. But I'm currently working on a new implementation based on harvardnlp/seq2seq-attn.

me: Hello?
bot: Hi.

me: How are you?
bot: I'm fine.

me: What's your name?
bot: It's hard to describe.

me: How so?
bot: I'm not sure.

me: What color is the sky?
bot: It's blue.

me: What is your job?
bot: It's not that i'm a fucking werewolf!

me: What is the purpose of life?
bot: A gift.

me: Are you intelligent?
bot: Yes, well...

me: Are you a machine?
bot: That's a lie.

me: Are you human?
bot: No, i'm not.

me: What are you?
bot: I'm not sure.

me: Do you plan on taking over the world?
bot: No, i don't.

Phew! That was close. Good thing I didn't train it on the full dataset. Please experiment responsibly.

(Disclaimer: nonsensical responses have been removed.)

Installing

  1. Install Torch.

  2. Install the following additional Lua libs:

    luarocks install nn
    luarocks install rnn
    luarocks install penlight

    To train with CUDA install the latest CUDA drivers, toolkit and run:

    luarocks install cutorch
    luarocks install cunn

    To train with opencl install the lastest Opencl torch lib:

    luarocks install cltorch
    luarocks install clnn
  3. Download the Cornell Movie-Dialogs Corpus and extract all the files into data/cornell_movie_dialogs.

Training

th train.lua [-h / options]

The model will be saved to data/model.t7 after each epoch if it has improved (error decreased).

Options (some, not all)

  • --opencl use opencl for computation (requires torch-cl)
  • --cuda use cuda for computation
  • --gpu [index] use the nth GPU for computation (eg. on a 2015 MacBook --gpu 0 results in the Intel GPU being used while --gpu 1 uses the far more powerful AMD GPU)
  • -- dataset [size] control the size of the dataset
  • --maxEpoch [amount] specify the number of epochs to run

Testing

To load the model and have a conversation:

th eval.lua

License

MIT License

Copyright (c) 2016 Marc-Andre Cournoyer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

thin

A very fast & simple Ruby web server
Ruby
2,235
star
2

tinyrb

A tiny subset of Ruby with a Lua'esc VM
C
459
star
3

pusher

The Rack App that pushes (aka Rack::Comet)
Ruby
172
star
4

min

The Min language
Java
102
star
5

tube

The internet is a series of tubes. This is one of them.
Ruby
78
star
6

rbv8

A Ruby VM running on Google V8 super VM.
C++
65
star
7

tinyjs

A subset of JavaScript implemented in JavaScript
JavaScript
59
star
8

orange

Yummy & juicy compiler
Ruby
56
star
9

invisible

The invisible framework
CSS
51
star
10

thin-turbo

New and ultra-turbo-crazy-fast backend for Thin
C
47
star
11

thin_async

A nice wrapper to send response body asynchronously with Thin
Ruby
39
star
12

utterance_parser

Extract intent and entities from natural language utterances
Ruby
36
star
13

ruby_http_parser

Ruby bindings to Ryan Dahl's http-parser
C
34
star
14

talker.rb

A real-time Talker Ruby client.
Ruby
26
star
15

fast_output_buffer

A faster output buffer for ActionView.
C
23
star
16

nn.rb

A toy Neural Network in Ruby
Ruby
22
star
17

mysql_s3_backup

A simple backup script for Mysql and S3 with incremental backups.
Ruby
21
star
18

nanodb

an ultra tiny db
16
star
19

rack-sandbox

Run multiple framework / rack app / wathever inside the same VM
Ruby
15
star
20

scout

The campfire bot we use at Standout Jobs
Ruby
10
star
21

llvmruby

LLVM bindings for Ruby
Ruby
8
star
22

confoo

My Confoo.ca presentation: How to kick assess with asynchronous processing
Ruby
6
star
23

sc

If static site generators were vegies, this one would be a pickle.
Ruby
6
star
24

node-syscalls

Node wrapper to some UNIX syscalls. Used during http://truthabouteventloops.com/.
C++
5
star
25

peg

fork of peg/leg
C
5
star
26

mtlrb-jan12

Montreal.rb January 2012 presentation on creating an homoiconic programming language in < 150 LOC.
Ruby
4
star
27

node-cusec

node.js CUSEC 2010 presentation stuff
JavaScript
4
star
28

Ruby-Supreme.tmbundle

A TextMate bundle I use w/ my Ruby stuff. Full of magic.
4
star
29

macournoyer.github.com

ze github pages of mine
3
star
30

meshu

MeshU presentation
Ruby
3
star
31

sequencer

Online sequencer
JavaScript
3
star
32

mor7

My Montreal on Rails 7 presentation of Thin
Ruby
3
star
33

waq

"How a Web server works" presentation for Web à Québec (in french)
Ruby
2
star
34

gh-contest

Ruby
2
star
35

iolounge

My personal casual comforting place to play w/ Io
2
star