Giter VIP home page Giter VIP logo

my_chatbot's Introduction

Chatbot_Seq2Seq

基于Github上DeepQA项目进行修改

目录

介绍

该项目基于论文A Neural Conversational Model
利用RNN (seq2seq模型)进行句子预测,基于python和TensorFlow完成。

该项目的预料库使用Cornell Movie Dialogs.已包含在项目文件下。

安装

该程序需要以下依赖:

  • python 3.5+
  • tensorflow (在v1.14.0下完成测试)
  • numpy
  • nltk (用于标记句子的自然语言工具包)
  • tqdm (进度条工具包)
  • CUDA (使用GPU训练,可选)

您可能还需要下载其他数据以使nltk生效。

>>>import nltk
>>>nltk.download()

运行

要训练模型,只需运行 python main.py.训练完成后,可以运行python main.py --test (在save/model/samples_predictions.txt中生成结果)或 main.py—test interactive进行实时提问测试。

要使用TensorBoard可视化计算图形和成本, 只需运行TensorBoard—logdir save/

默认情况下,网络架构是一个标准的编码器/解码器:
具有两个LSTM层(隐藏大小为512)和一个嵌入大小为64的词汇表。网络使用ADAM进行训练。 句子的最大长度设置为10个单词,但是可以增加。

结果

在经过3个小时左右的时间训练后可以得到模型结果:

Q: Hello!
A: Hello.

Q: Hi!
A: Hi.

Q: you are a rebort, right?
A: I'm not.

Q: you are not a rebort?
A: No, i'm not.

Q: How are you?
A: Fine.

Q: What is your name?
A: Bedevere, my liege.

Q: How old are you
A: Fifteen.

Q: Who is John?
A: It's me.

Q: are you John?
A: Yes.

Q: hello,John!
A: Hello.

Q: Can a cat walk ?
A: Sure. why not?

Q: Can a fish walk ?
A: Absolutely not.

Q: Tell me a story
A: I'm sorry.

Q: Once upon a time...
A: Yeah, that's right.

Q: what do you like to talk about ?
A: I do n't know.

Q: You are so nice!
A: I'm not.

Q: See you later.
A: Bye.

以上为回答较为准确的样例,还有一些采用安全回答(如“i don't know. i'm sorry”) 等无意义答案进行回答,更多样例请看文件save/model/samples_predictions.txt

my_chatbot's People

Contributors

cxuxin avatar

Watchers

 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.