(Department of Computer Engineering)
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:
- Libraries:
- Flask==1.1.1
- numpy==1.16.0
- Theano==1.0.4
- https://github.com/Lasagne/Lasagne/archive/master.zip
- unicodecsv==0.14.1
- requests==2.18.4
- nltk==3.2.5
- scipy==0.19.1
- scikit-learn==0.19.1
- tensorboard-logger==0.0.4
- telepot==12.4
- gensim==1.0.1
- six==1.14.0
- Concepts:
- Natural Language Processing
- 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:
- 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.
- The following datasets are used for validation and early stopping:
- data/corpora_processed/val_processed_dialogs.txt(dummy example) - for the context sensitive dataset
- data/quality/context_free_validation_set.txt - for the context-free validation dataset
- data/quality/context_free_questions.txt - is used for generating responses for logging and computing distinct-metrics
- data/quality/context_free_test_set.txt - is used for computing metrics of the trained model, e.g. ranking metrics
- Set up training parameters in cakechat/config.py. See configuration settings description for more details.
- Run python tools/prepare_index_files.py to build the index files with tokens and conditions from the training corpus.
- 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.
- 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.
- 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
- A Neural Conversational Model ( https://arxiv.org/pdf/1506.05869.pdf )
- How NOT To Evaluate Your Dialogue System ( https://arxiv.org/pdf/1603.08023.pdf )
- A Diversity-Promoting Objective Function for Neural Conversation Models ( https://arxiv.org/pdf/1510.03055.pdf )
- Emotional Chatting Machine: Emotional Conversation Generation with Internal and External Memory ( https://arxiv.org/pdf/1704.01074.pdf )
- A Persona-Based Neural Conversation Model ( https://arxiv.org/pdf/1603.06155.pdf )
- Topic Aware Neural Response Generation ( https://arxiv.org/pdf/1606.08340v2.pdf )
- A Hierarchical Recurrent Encoder-Decoder For Generative Context-Aware Query Suggestion ( https://arxiv.org/pdf/1507.02221.pdf )
- Quantitative Evaluation of User Simulation Techniques for Spoken Dialogue Systems ( http://mi.eng.cam.ac.uk/~sjy/papers/scgy05.pdf )
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.