Giter Club home page Giter Club logo

seq2seq-chatbot's Introduction

Seq2Seq Chatbot

This is a 200 lines implementation of Twitter/Cornell-Movie Chatbot, please read the following references before you read the code:

Prerequisites

Model


Training

python3 main.py

Results

Query > happy birthday have a nice day
 > thank you so much
 > thank babe
 > thank bro
 > thanks so much
 > thank babe i appreciate it
Query > donald trump won last nights presidential debate according to snap online polls
 > i dont know what the fuck is that
 > i think he was a racist
 > he is not a racist
 > he is a liar
 > trump needs to be president

seq2seq-chatbot's People

Contributors

arnoldliulj avatar bedna-ku avatar egens avatar luomai avatar pskrunner14 avatar the-black-knight-01 avatar zsdonghao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seq2seq-chatbot's Issues

no validation accuracy ?

validx and validy are not used and there are no calculcations for validation accuracy in the model ?

Using .npz file

I have trained the model on the dataset but I don't know how to get the output using .npz file. Please add instructions to test it as well.

Training is taking too much time

Training on CPU is taking too much time, so do you have any estimate how much time it will take? I have executed this 12 hours ago and now i am on just "Epoch[2/50] step:[600/2852] loss:5.684645 took:9.62770s". Can you please help me to boost this training.

ModuleNotFoundError: No module named 'data.twitter'; 'data' is not a package

I am trying to write code for Chat Box, but encountering the error "ModuleNotFoundError: No module named 'data.twitter'; 'data' is not a package" when trying to execute "from data.twitter import data".

Please suggest , how to resolve the issue?

note: I am working on following environment:
Python is 3.6 V
Tensorflow : 2.0
Tensorlayer: 2.2
python-twitter

hide [TL] message?

When I run the program, there are lots of [TL]*** messages generated. Is there a way to hide these msg? It seems not much online information about this. Thanks in advance!

validX,validY not use?

Hi you! I don't see you use validX,validY data in your code. Could you tell me how to get loss of valid data in your code. Thanks you!

Word2Vec

Hi,

It seems that the example didn't use Word2Vec. I am trying to load pre-trained vectors to represent these words. Do you think it will be helpful to to improve the bot performance? I can't figure out how to do that. Do you have any examples showing the similar procedures?

Thank you in advance!

closed

i say hi, it sometimes says random stuff, sometimes replies hi darling. Can anyone please help me understand what's happening

How can I train with my GPU?

Hello, I'm planning to train this with my GPU to make the training faster. The problem is it only utilizes my CPU. Thank you.

Layer 'model/embedding/seq_embedding' already exists, please choice other 'name' or reuse this layer

Exception: Layer 'model/embedding/seq_embedding' already exists, please choice other 'name' or reuse this layer
Hint : Use different name for different 'Layer' (The name is used to control parameter sharing)
Additional Informations: http://tensorlayer.readthedocs.io/en/latest/modules/layers.html?highlight=clear_layers_name#tensorlayer.layers.clear_layers_name

when i run the code, this problem comes.

python: 3.6
tensorflow-gpu: 1.7.1
tensorlayer: 1.7.4

Python 3.7 is both required and unsupported

After a few hours of debugging, uninstalling, reinstalling, and generally trying to get this code working, I've found the root cause of the problem:

  1. This repository requires TensorFlow 2.0.0+

  2. This repository also requires Python 3.7+

  3. TensorFlow 2.0.0+ only supports Python 3.6 and below.

Can someone provide some guidance on how to get TensorFlow working on a version of Python that isn't supported?

Error: No module named twitter

python main_simple_seq2seq.py
Traceback (most recent call last):
File "main_simple_seq2seq.py", line 18, in
from data.twitter import data
ImportError: No module named twitter

Problem when loading the trained model

Hello, I have a problem when I load my trained model ("model.npz"). It gives me this error:
ValueError: Dimension 0 in both shapes must be equal, but are 6004 and 8004. Shapes are [6004,1024] and [8004,1024]. for 'Assign' (op: 'Assign') with input shapes: [6004,1024], [8004,1024].

Could anyone explain to me a little bit? Or do I need to modify the code?

Many thanks! :)

TensorLayer - initialize global variables Deprecated

When I run the main script this warning message shows up. Any ideas how to rectify this?

[TL] WARNING: From main_simple_seq2seq.py:144: initialize_global_variables (from tensorlayer.layers.utils) is deprecated and will be removed after 2018-09-30. Instructions for updating: This API is deprecated in favor of tf.global_variables_initializer

I tried replacing it with tf.global_variables_initializer but the script crashed with the following message:

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value model/seq2seq/encode/rnn/multi_rnn_cell/cell_2/basic_lstm_cell/kernel [[Node: model/seq2seq/encode/rnn/multi_rnn_cell/cell_2/basic_lstm_cell/kernel/read = Identity[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](model/seq2seq/encode/rnn/multi_rnn_cell/cell_2/basic_lstm_cell/kernel)]] [[Node: seq_loss_with_mask/_51 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_2513_seq_loss_with_mask", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Can't import data

ModuleNotFoundError Traceback (most recent call last)
in ()
8
9 ###============= prepare data
---> 10 from data.twitter import data
11 metadata, idx_q, idx_a = data.load_data(PATH='data/twitter/') # Twitter
12 # from data.cornell_corpus import data

ModuleNotFoundError: No module named 'data.twitter'

how to train my own data

How any I chane the dataset . Can I take the dataset of mine rather then twitter data & corpus movie data
if yes then how?

Been having this issue on both Windows and Linux..

I posted this under a work account so I closed the issue and logged in with my personal.

The issue I get is this:

python3 main.py

Traceback (most recent call last):
File "main.py", line 11, in
from tensorlayer.models.seq2seq import Seq2seq
ImportError: No module named 'tensorlayer.models.seq2seq'

No module named 'tensorlayer.models.seq2seq'

Can someone share with me how to resolve this error? Thanks.

Traceback (most recent call last):
File "D:\ChatBot\seq2seq-chatbot-master\main.py", line 11, in
from tensorlayer.models.seq2seq import Seq2seq
ModuleNotFoundError: No module named 'tensorlayer.models.seq2seq'

No module named twitter

File "main_simple_seq2seq.py", line 18, in
from data.twitter import data
ImportError: No module named twitter

Did I miss some files?
Can you please help me?Many thanks^ o^

question about seq2seq

Dear Dr.pskrunner

Hello, i am a follower of your github. i have a question that whether the copy mechanism (copy_decoder)is available in pskrunner14/pytorch-seq2seq or not?

Because i want to learn that code.

Thank you, very much.

Best wishes

Tianlin Zhang

tensorflow server signature

I am trying to serve the model over tensorflow serving and I have created the below signature. But it doesnt seem to work. Please help me @pskrunner14

encode_seqs = tf.placeholder(dtype=tf.int64, shape=[batch_size, None], name="encode_seqs")
decode_seqs = tf.placeholder(dtype=tf.int64, shape=[batch_size, None], name="decode_seqs")

Inference Data Placeholders

encode_seqs2 = tf.placeholder(dtype=tf.int64, shape=[1, None], name="encode_seqs")
decode_seqs2 = tf.placeholder(dtype=tf.int64, shape=[1, None], name="decode_seqs")

export_path_base = './export_base/'
export_path = os.path.join(
tf.compat.as_bytes(export_path_base),
tf.compat.as_bytes(str(1)))
print('Exporting trained model to', export_path)
builder = tf.saved_model.builder.SavedModelBuilder(export_path)

    classification_inputs = tf.saved_model.utils.build_tensor_info(
        encode_seqs)
    classification_outputs_classes = tf.saved_model.utils.build_tensor_info(
        decode_seqs)
    #classification_outputs_scores = tf.saved_model.utils.build_tensor_info(loss)

    classification_signature = (
        tf.saved_model.signature_def_utils.build_signature_def(
            inputs={
                tf.saved_model.signature_constants.CLASSIFY_INPUTS:
                    classification_inputs
            },
            outputs={
                tf.saved_model.signature_constants.CLASSIFY_OUTPUT_CLASSES:
                    classification_outputs_classes,
                #tf.saved_model.signature_constants.CLASSIFY_OUTPUT_SCORES:
                    #classification_outputs_scores
            },
            method_name=tf.saved_model.signature_constants.CLASSIFY_METHOD_NAME))

    tensor_info_x = tf.saved_model.utils.build_tensor_info(encode_seqs2)
    tensor_info_y = tf.saved_model.utils.build_tensor_info(decode_seqs2)

    prediction_signature = (
        tf.saved_model.signature_def_utils.build_signature_def(
            inputs={'issue': tensor_info_x},
            outputs={'solution': tensor_info_y},
            method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME))

    builder.add_meta_graph_and_variables(
        sess, [tf.saved_model.tag_constants.SERVING],
        signature_def_map={
            'predict_solution':
                prediction_signature,
            tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
                classification_signature,
        },
        main_op=tf.tables_initializer(),
        strip_default_attrs=True)

    builder.save()

    print('Done exporting!')

I have the below signature,

C:\Users\d074437\PycharmProjects\seq2seq>saved_model_cli show --dir ./export_base/1 --all

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['predict_solution']:
The given SavedModel SignatureDef contains the following input(s):
inputs['issue'] tensor_info:
dtype: DT_INT64
shape: (1, -1)
name: encode_seqs_1:0
The given SavedModel SignatureDef contains the following output(s):
outputs['solution'] tensor_info:
dtype: DT_INT64
shape: (1, -1)
name: decode_seqs_1:0
Method name is: tensorflow/serving/predict

signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_INT64
shape: (32, -1)
name: encode_seqs:0
The given SavedModel SignatureDef contains the following output(s):
outputs['classes'] tensor_info:
dtype: DT_INT64
shape: (32, -1)
name: decode_seqs:0
Method name is: tensorflow/serving/classify

But when I try to run it, I get an error as below

C:\Users\d074437\PycharmProjects\seq2seq>saved_model_cli run --dir ./export_base --tag_set serve --signature_def predict_solution --inputs='this is the text'
usage: saved_model_cli [-h] [-v] {show,run,scan} ...
saved_model_cli: error: unrecognized arguments: is the text'

Load n.npz failed!

i have this error: Load n.npz failed!
May I know why it is like this?

Using the Chatbot

Hi there,

I trained the data for a few days and now the samples are returning good results to the predefined "Happy Birthday" and "Trump" requests.

Great job by you. Thanks so far.

Do you already have a small python program for using the chatbot? If I write a message, the chatbot should return a single answer.

Thanks
Chris

Undefined names can raise NameError at runtime

flake8 testing of https://github.com/zsdonghao/seq2seq-chatbot on Python 2.7.13

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./tensorlayer/layers.py:5976:49: F821 undefined name 'single_cell'
            cell = tf.contrib.rnn.MultiRNNCell([single_cell] * num_layers)
                                                ^

./tensorlayer/layers.py:5978:49: F821 undefined name 'single_cell'
            cell = tf.nn.rnn_cell.MultiRNNCell([single_cell] * num_layers)
                                                ^

./tensorlayer/prepro.py:1007:8: F821 undefined name 'is_random'
    if is_random:
       ^

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.