meta-boy / mapleChan

ChatBot Based on Cake-Chat, built in Python (serverside) and Tkinter ( client-side GUI )

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ramrao Adik Institute of Technology

(Department of Computer Engineering)

** **

Mini Project Report

On

Chatbot using CakeChat and Tkinter (GUI)

** **** Subject-: Open Source Technology Lab**

Presented By


Roll No. Batch-Sr. No. Name
18CE8004 C3/5 Anurag Patil
18CE7009 C3/13 Amankumar Singh
18CE8019 C3/10 Pratik Murari

INTRODUCTION

Open-source software (OSS) is a type of computer software in which source code is released under a license in which the copyright holder grants users the rights to study, change, and distribute the software to anyone and for any purpose. Open-source software may be developed in a collaborative public manner. Open-source software is a prominent example of open collaboration.

Open-source software development can bring in diverse perspectives beyond those of a single company. A 2008 report by the Standish Group stated that the adoption of open-source software models has resulted in savings of about $60 billion (£48 billion) per year for consumers.

Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.

Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python is often described as a "batteries included" language due to its comprehensive standard library

TECHNOLOGES / LIBRARIES / CONCEPTS:

  1. Libraries:
  2. Flask==1.1.1
  3. numpy==1.16.0
  4. Theano==1.0.4
  5. https://github.com/Lasagne/Lasagne/archive/master.zip
  6. unicodecsv==0.14.1
  7. requests==2.18.4
  8. nltk==3.2.5
  9. scipy==0.19.1
  10. scikit-learn==0.19.1
  11. tensorboard-logger==0.0.4
  12. telepot==12.4
  13. gensim==1.0.1
  14. six==1.14.0
  15. Concepts:
  16. Natural Language Processing
  17. Native GUI desigining

IMPLEMENTATION:

An already existing Emotional Generative Dialog System called CakeChat ( https://github.com/lukalabs/cakechat )was used in the making of this project. The system was written in Python 2.7, hence it was ported over to Python 3.6 to fit according to the college syllabus.

CakeChat is a dialog system that is able to express emotions in a text conversation. It is written in Theano and Lasagne. It uses end-to-end trained embeddings of 5 different emotions to generate responses conditioned by a given emotion.

Network Architecture and Features:

  • ●●** Model:**

    • Hierarchical Recurrent Encoder-Decoder (HRED) architecture for handling deep dialog context[7]
    • Multilayer RNN with GRU cells. First layer of the utterance-level encoder is always bidirectional.
    • Thought vector is fed into decoder on each decoding step.
    • Decoder can be conditioned on any string label. For example: emotion label or id of a person talking.
  • ●●** Word embedding layer:**

    • May be initialized using w2v model trained on your own corpus.
    • Embedding layer may either stay fixed of be fine-tuned along with all other weights of the network.
  • ●●** Decoding:**

    • 4 different response generation algorithms: "sampling", "beamsearch", "sampling-reranking" and "beamsearch-reranking". Reranking of the generated candidates is performed according to the log-likelihood or MMI-criteria[3]. See configuration settings description for details.
  • ●●** Metrics:**

    • Perplexity
    • n-gram distinct metrics adjusted to the samples size[3].
    • Lexical similarity between samples of the model and some fixed dataset. Lexical similarity is a cosine distance between TF-IDF vector of responses generated by the model and tokens in the dataset.
    • Ranking metrics: mean average precision and mean recall@k.[8]

PROCEDURE

Training the model:

  1. Put your training text corpus to data/corpora_processed/. Each line of the corpus file should be a JSON object containing a list of dialog messages sorted in chronological order. Code is fully language-agnostic — you can use any unicode texts in datasets. Refer to our dummy corpus to see the input format data/corpora_processed/train_processed_dialogs.txt.
  2. The following datasets are used for validation and early stopping:
  3. data/corpora_processed/val_processed_dialogs.txt(dummy example) - for the context sensitive dataset
  4. data/quality/context_free_validation_set.txt - for the context-free validation dataset
  5. data/quality/context_free_questions.txt - is used for generating responses for logging and computing distinct-metrics
  6. data/quality/context_free_test_set.txt - is used for computing metrics of the trained model, e.g. ranking metrics
  7. Set up training parameters in cakechat/config.py. See configuration settings description for more details.
  8. Run python tools/prepare_index_files.py to build the index files with tokens and conditions from the training corpus.
  9. Run python tools/train.py. Don't forget to set USE_GPU=<GPU_ID> environment variable (with GPU_ID as from nvidia-smi) if you want to use GPU. Use SLICE_TRAINSET=N to train the model on a subset of the first N samples of your training data to speed up preprocessing for debugging.
  10. You can also set IS_DEV=1 to enable the "development mode". It uses a reduced number of model parameters (decreased hidden layer dimensions, input and output sizes of token sequences, etc.), performs verbose logging and disables Theano graph optimizations. Use this mode for debugging.
  11. Weights of your model will be saved in data/nn_models/

Running the system:

Installing the dependencies:

python -m pip install -r requirements.txt

Run a server that processes HTTP-requests with given input messages (contexts) and returns response messages of the model:

python bin/cakechat_server.py

Run the client

python bin/cakechat_client.py

RESULTS

Fully functional chatbot client that provides human-like interaction in the sense of communication.

CONCLUSION

Thus we successfully created a chatbot with GUI completely using Python. The tools provided by this open-sourced language were very powerful thus it allowed us to achieve this level of complexity.

REFERENCES

CREDITS

CakeChat is developed and maintained by the Replika team: Michael Khalman, Nikita Smetanin, Artem Sobolev, Nicolas Ivanov, Artem Rodichev and Denis Fedorenko. Demo by Oleg Akbarov, Alexander Kuznetsov and Vladimir Chernosvitov.

About

ChatBot Based on Cake-Chat, built in Python (serverside) and Tkinter ( client-side GUI )

License:MIT License


Languages

Language:Python 98.7%Language:Dart 0.5%Language:HTML 0.4%Language:Kotlin 0.2%Language:Swift 0.2%Language:Objective-C 0.0%