Academia.eduAcademia.edu

Deep Learning Chatbot using Python

2021, International Journal of Advanced Trends in Computer Science and Engineering

Many organizations are executing Chatbots to address client inquiries and contact clients. As indicated by Mindshare, 63% of shoppers would consider utilizing a chatbot when visiting a business or brand's site. One of the fundamental AI chatbot benefits is that it can convey moment satisfaction. Individuals would much preferably visit online over set aside the effort to call an organization's 800-number.During these difficult Situations it is hard for individuals to go to the stores to purchase something, to emergency clinic for a little clinical test, finding support for an item that you purchased and so forth So these sorts of easier errands, which don't require actual presence, can be supplanted by chatbots. So we will make a chatbot, which when given reasonable purpose documents dependent on a specific item or necessities, can prepare on it utilizing various Layers Neural Networks and make a model. Utilizing this model our chatbot can answer client inquiries.

ISSN 2278-3091 Volume 10, No.3, May - June 2021 Sai Kiran S et al., International Journal of Trends inTrends Computer Science and Engineering, 10(3), Mayand - JuneEngineering 2021, 2019 – 2023 International Journal ofAdvanced Advanced in Computer Science Available Online at http://www.warse.org/IJATCSE/static/pdf/file/ijatcse741032021.pdf https://doi.org/10.30534/ijatcse/2021/751032021 Deep Learning Chatbot using Python 1 Sai Kiran S1 , Srinivas Likhith R2 , P Swarna Latha3 Undergraduate, Vellore Institute of Technology, India, [email protected] 2 Undergraduate, Vellore Institute of Technology, India, [email protected] 3 Associate Professor, Vellore Institute of Technology, India, [email protected] $213 million. The current chatbots which are near, such as Siri, Alexa, Cortana and Google Assistant face challenges in understanding the aims of the client and consequently become hard to manage. In particular, these chatbots can't monitor the specific circumstance and endure in long-going discussions. Another inadequacy of these chatbots is they are planned explicitly for assisting a client for certain particular issues, consequently confining their area. They can't make an intelligent and connected discussion between two individuals on famous points like ongoing news, governmental issues and sports. ABSTRACT Many organizations are executing Chatbots to address client inquiries and contact clients. As indicated by Mindshare, 63% of shoppers would consider utilizing a chatbot when visiting a business or brand's site. One of the fundamental AI chatbot benefits is that it can convey moment satisfaction. Individuals would much preferably visit online over set aside the effort to call an organization's 800-number.During these difficult Situations it is hard for individuals to go to the stores to purchase something, to emergency clinic for a little clinical test, finding support for an item that you purchased and so forth So these sorts of easier errands, which don't require actual presence, can be supplanted by chatbots. So we will make a chatbot, which when given reasonable purpose documents dependent on a specific item or necessities, can prepare on it utilizing various Layers Neural Networks and make a model. Utilizing this model our chatbot can answer client inquiries. In this paper we initially discuss what is Deep learning and find out which model is compatible to train a chatbot and show you a way to create a deep learning based chatbot which can understand the human language and give appropriate responses.and the steps to create the chatbot. 2. LITERATURE SURVEY According to research “Chatbot Utilization for Medical Consultant System” Medical services are essential requirements for human existence despite the fact that they ordinarily have restricted assets. Current advances are used for expanding administration capacity and diminishing the activity cost. Pre-programmed message frameworks or chatbots, which are broadly known in the field of online organizations, can be applied to clinical benefits. Hence, the target of this work is to carry out the medical consultant system administration by utilizing chatbot Technology. It was executed dependent on the data of the side effects and treatment records assembled from the DoctorMe application. The test outcomes show the capacity of the proposed system. Besides, it tends to be utilized as a rule for future improvement and furthermore a rule for future study.[1] Key words : Intents, Layers, Neural networks, Deep learning, Chatbot. 1. INTRODUCTION In this day and age, the way we associate with our advanced gadgets is generally confined in view of what highlights and how much openness every gadget offers. There is an expectation to absorb information related to each new gadget we interface with. Chatbots take care of this issue by connecting with a client utilizing text independently. Chatbots are right now the most effortless way. We have software to be local to people since they have an encounter or conversation with someone. Since chatbots copy a real individual, Artificial Intelligence (AI) strategies are utilized to construct them. One such procedure inside AI is Deep Learning which impersonates the human mind. It discovers patterns from the training data and utilizes the same patterns to process new data. Deep Learning is promising to take care of long standing AI issues like Computer Vision and Natural Language Processing (NLP), with Google putting $4.5 million in Montreal AI Lab notwithstanding a government AI award of According to research “Deep Learning Techniques for Implementation of Chatbots” Different methodologies for the advancement of chatbots and various innovations in the making of chatbots created in light of those endeavors. NLTK is a module in python which is ready to perform Natural Language Processing. It is utilized to take 2019 Sai Kiran S et al., International Journal of Advanced Trends in Computer Science and Engineering, 10(3), May - June 2021, 2019 – 2023 literature, examining more than 70 publications related to chatbots published in the last 5 years. Based on a literature survey, this examination made a comparison from chosen papers according to the strategy adopted. This paper also introduced why current chatbot models fails to take into account while generating responses and how this affects the quality conversation.[6] input in the form of speech and produce responses which people can understand[2] According to research “The Stanford CoreNLP Natural Language Processing Toolkit” the design and utilization of the Stanford CoreNLP toolkit, an extensible pipeline that gives crucial natural language analysis. This toolkit is broadly utilized, both in the exploration NLP group and furthermore among business and government clients of open source NLP innovation. [3] According to the research “Intent DetectionBased Lithuanian Chatbot Created via Automatic DNN Hyper-Parameter Optimization” they handled a purpose recognition issue for the Lithuanian language with the real supervised data. Their main principle of focus is on the upgrade of the Natural Language Understanding (NLU) module, responsible for the comprehension of user's questions. The NLU model is prepared with an appropriately selected word vectorization type and Deep Neural Network (DNN) classifier. During their experiments, they have tentatively investigated fastText and BERT embeddings.[7] According to research “A Rule based Approach to Word Lemmatization” This paper thinks about the consequences of two word lemmatization algorithms, one dependent on if-then principles and the other dependent on ripple down rules enlistment algorithms. It presents the issue of lemmatization of words from Slovene free content and clarifies why the Ripple Down Rules (RDR) approach is very appropriate for the undertaking.[4] According to research “Creating and Evaluating Chatbots as Eligibility Assistants for Clinical Trials: An Active Deep Learning Approach towards User-centered Classification '' they have created a conversation manager, criteria classifier. Using conversation manager users can chat with the chatbot. The criteria classifier module is used to map the criterion into the five predefined categories. criteria classifier processes criteria as vectors of word embeddings. The active learning algorithm, selects the criterion that the model has the least confidence about its category for the human oracle to label. Once the label/class is received from the human oracle, the algorithm propagates the label to the neighboring criteria to increase the number of samples in the training set. The algorithm is also responsible for selecting a validation set from the ones with labels, either annotated by the human oracle or inferred by the model. The convolution neural network is then trained on the training set and tested on the validation set. Based on the confidence of the model’s prediction on the validation set, the active learning algorithm again selects new criteria with low confidence for the human oracle to label. The process repeats until a certain number of iterations is met..[5] According to research “Chatbot Technologies and Challenges” they gave an outline of the innovations that drive chatbots, including Information Extraction and Deep Learning. They have additionally examined the contrasts among conversational and transactional chatbots - the former defined manually on free-form chat logs, while the last are characterized physically to accomplish a particular objective like booking a flight. They have likewise given an outline of commercial tools and platforms that can help in creating and deploying chatbots. At last, they have introduced the limitations and future work difficulties around here.[8] According to research “Accessible conversational user interfaces: considerations for design”a scope of current guidance and flow direction, reports, exploration and writing on open plan for various disability groups, incorporating clients with psychological well-being issues, mental imbalance, medical issue, intellectual incapacities, dyslexia or learning challenges, and tangible, versatility or ability weaknesses. They grouped the components from this assortment of directions that seem applicable to the plan of available CUIs, and cases where direction presents issues which are less decisive, and require further investigation. [9] According to the “A Survey on Chatbot Implementation in Customer Service Industry through Deep Neural Network”, the strategies for creating rules for chatbot have been advanced. strategies for creating chatbots have depended on hand-written rules and templates. With the rise of deep learning these models were quickly replaced by end-to-end neural networks. All the more specifically, Deep Neural Networks is a powerful generative-based model to take care of the conversational response generation problems. This paper led an inside and out review of ongoing to research “Ensemble-based deep reinforcement learning for chatbots” ,trainable chatbots that show familiar and human-like discussions remain a major challenge in artificial According 2020 Sai Kiran S et al., International Journal of Advanced Trends in Computer Science and Engineering, 10(3), May - June 2021, 2019 – 2023 intelligence. Deep Reinforcement Learning (DRL) is promising for tending to this test, however its fruitful application remains an open inquiry. This article portrays a novel ensemble-based methodology applied to esteem based DRL chatbots, which utilize limited activity sets as a type of importance portrayal. In their methodology, while exchange activities are obtained from sentence clustering, the training datasets in our ensemble are obtained from discourse clustering. The latter plan to induce specific agents that figure out how to communicate in a specific style.[10] 3. are a vital point in the field of deep learning in light of the fact that changing a model's loads is the essential route through which deep learning models are prepared. You'll see this by and by later on when we fabricate our first neural networks from scratch. Once a neuron gets its inputs from the previous neurons in the previous layer of the model, it includes each sign increased by its comparing weight and gives them to an initiation function.The actuation work computes the yield as an incentive for the neuron. This yield esteem is then given to the following layer of the neural organization through another synapse. DEEP LEARNING 4. INTENT BASED CHATBOT Deep learning is a part of AI which is totally founded on Artificial neural networks, as neural networks will impersonate the human mind so deep learning is additionally a sort of copy of the human cerebrum. In deep learning, we don't have to explicitly program everything. The idea of deep learning isn't new. It has been around two or three years at this point. It's famous these days in light of the fact that prior we didn't have that much handling power and a ton of information. Over the last 20 years, the processing power has increased dramatically, deep learning and AI came into the light. A chabot is an Artificial Intelligence(AI) based programming that can simulate conversation between clients in Natural language through messaging applications, web-based media platforms, applications and through the phone. There are various kinds of chatbots that are accessible, for example, Rule-based and NLP bots and so on Rule-based chatbots communicate with clients based on preset rules. The user info should coordinate with those pre defined rules to find a solution. NLP chatbots learn dialects along these lines so that kids get familiar with a language. Subsequent to having taken in various models, they can make associations between questions that are asked in an unexpected way. Along these lines, the bot comprehends what the inquiry is about without being absolutely modified for it and a proper answer can be given. In a discussion structure, this is likewise called Conversational artificial intelligence. Figure 1: different layers of Neural Networks 5. Figure 1 depicts the different layers of Neural Networks. Neurons in deep learning models are hubs through which information and calculations stream. Neurons work like this: ● They get at least one info signal. These info signs can emerge out of either the crude informational collection or from neurons situated at a past layer of the neural net. ● They perform certain estimations. ● They convey some yield messages to neurons deeper in the neural net through a neurotransmitter. METHODOLOGY To create an intent based chatbot, we have created a json file, which consists of all the intents. The intent we have created is based on the healthcare system. Intents: In the intent file lists where we’ll store our natural language data. We have our json file as I mentioned earlier which contains the “intents”. It is interchangeable. We can change the intent file anyway we want. We’ll train our chatbot using this intent file so that it can understand the user's intentions and reply accordingly. We have a whole bunch of libraries like nltk (Natural Language Toolkit), which contains a whole bunch of tools for cleaning up text and preparing it for deep learning algorithms, json, which loads json files directly into Python, pickle, which loads pickle files, numpy, which can perform linear algebra operations very efficiently, and keras, which is the deep learning framework we’ll be using. Neurons in a deep learning model are equipped for having synapses that associate with more than one neuron in the former layer. Every synapse has a related weight, which impacts the former neuron's significance in the general neural network.Weights 2021 Sai Kiran S et al., International Journal of Advanced Trends in Computer Science and Engineering, 10(3), May - June 2021, 2019 – 2023 Modules we have used: train_chatbot.py — the code for reading in the natural language data into a training set and using a Keras sequential neural network to create a model chatgui.py — the code for cleaning up the responses based on the predictions from the model and creating a graphical interface for interacting with the chatbot classes.pkl — a list of different types of classes of responses words.pkl — a list of different words that could be used for pattern recognition intents.js on — a bunch of JavaScript objects that lists different tags that correspond to different types of word patterns chatbot_model.h5 — the actual model created by train_chatbot.py and used by chatgui.py. Descent (SGD) optimizer.. Then we have created some methods which will take the user inputs and form an output based on prediction of the deep learning model created.. To converse between users, chatbot needs to have an interface which we developed using the xvfb framework and created a simple user interface of chatbot using python with the help of Tkinter module. 6. ANALYSIS AND TESTING The given figure below is the data flow diagram of our chatbot. One can understand and analyze how and where the data is at a particular moment of time. The figure below shows the workflow of the project. Figure 3: Data flow diagram From Figure 3 we can know where the particular data is at a particular time in our system. So if we look at the flow of data. Firstly the user enters the query in the chat box and clicks on send. After clicking on send the query is imputed to the deep learning model that is previously trained sequential deep learning model. The model gives an intent list as an output then we compare the probabilities of original intent and the output intent. The intent with the higher probability is selected and one response is randomly selected from that tag and is displayed to the user. Figure 2: Flow diagram of proposed methodology For creating our intent-based chatbot, Firstly created an intent file which contains all the patterns of how chatbot will answer user queries. Then we lemmatized the word and extracted words, classes and documents from the intent file using nltk modules. Now we have to create training data using these words, classes and documents. After creating the training data, we have created the neural network model which contains three layers, the first layer will contain 128 neurons and the second layer will contain 64 neurons and the third layer is the output layer. Then, we optimized the neural network model using the Stochastic Gradient We chose boundary value analysis to test our chatbot. We cannot perform automated testing of our prototype using tools because of multiple output situations. We have developed our chatbot based on some intents. An intent file can’t be able to describe all possible scenarios that a user might ask a chatbot to perform. That’s why we need to test it based on boundary values which are extreme possible test cases and see how our chatbot will respond to it.we have tested the conditions of boundary with few valid test cases and some invalid test cases and observed whether we got desired output or not 2022 Sai Kiran S et al., International Journal of Advanced Trends in Computer Science and Engineering, 10(3), May - June 2021, 2019 – 2023 7. RESULTS The result of our chatbot always varies as it is a natural language chatbot that can give the same answer in many different ways. The chatbot always keeps learning as the number of users increase or use it more.The accuracy of the chatbot also increases with the usage of the bot. 8. CONCLUSION In conclusion we have made a chatbot in python that can understand user queries and reply accordingly. In the intent file wetarined our chatbot on, we can add more patterns and improve patterns which will be helpful when replying to the users and improves the accuracy of our chatbot. Deep Learning enabled chatbots are becoming more and more popular because of their applications and problems it can tackle. It can also be very helpful in teaching and has a lot of applications in teaching the visually impaired. 9. FUTURE WORK Our chatbot prototype can not only be used for one purpose. It can be used in many fields based on the intent file used to create a training dataset for the deep learning model to train. A report button can be added in the chatbot which a user can use when he feels the chatbot is not giving him the appropriate answer so that the bot can add the reported data to the intent file and keep learning itself. This drastically improves the performance of the chat bot and it becomes more and more perfect by prolonged usage. 10. ACKNOWLEDGMENT We would like to express our sincere gratitude to our supervisor Prof.Swarnalatha, Senior Lecturer of the Department of Computer Science and Technology, Vellore Institute of Technology University of India. Computer Communication and Informatics (ICCCI) (pp. 1-5). IEEE. 3. Manning, C. D., Surdeanu, M., Bauer, J., Finkel, J. R., Bethard, S., & McClosky, D. (2014, June). The Stanford CoreNLP natural language processing toolkit. In Proceedings of 52nd annual meeting of the association for computational linguistics: system demonstrations (pp. 55-60). 4. Plisson, J., Lavrac, N., & Mladenic, D. (2004, May). A rule based approach to word lemmatization. In Proceedings of IS (Vol. 3, pp. 83-86). 5. Chuan, C. H., & Morgan, S. (2020). Creating and Evaluating Chatbots as Eligibility Assistants for Clinical Trials: An Active Deep Learning Approach towards User-centered Classification. ACM Transactions on Computing for Healthcare, 2(1), 1-19. 6. Nuruzzaman, M., & Hussain, O. K. (2018, October). A survey on chatbot implementation in customer service industry through deep neural networks. In 2018 IEEE 15th International Conference on e-Business Engineering (ICEBE) (pp. 54-61). IEEE. 7. Kapočiūtė-Dzikienė, J. (2020). Intent DetectionBased Lithuanian Chatbot Created via Automatic DNN Hyper-Parameter Optimization. Frontiers in Artificial Intelligence and Applications, 328, 95102. 8. Hristidis, V. (2018, September). Chatbot technologies and challenges. In 2018 First International Conference on Artificial Intelligence for Industries (AI4I) (pp. 126-126). IEEE. 9. Lister, K., Coughlan, T., Iniesto, F., Freear, N., & Devine, P. (2020, April). Accessible conversational user interfaces: considerations for design. In Proceedings of the 17th International Web for All Conference (pp. 1-11). 10. Cuayáhuitl, H., Lee, D., Ryu, S., Cho, Y., Choi, S., Indurthi, S., ... & Kim, J. (2019). Ensemblebased deep reinforcement learning for chatbots. Neurocomputing, 366, 118-130. 11. Ng, C., & Chua, A. (2020). Training of a deep learning algorithm for quadcopter gesture recognition. International Journal of Advanced Trends in Computer Science and Engineering, 9(1), 211. 12. Leong, P. H., Goh, O. S., & Kumar, Y. J. (2020). Deep Learning for Conversational Agent via Context Question Answering Model. International Journal, 9(5). REFERENCES 1. 2. Rosruen, N., & Samanchuen, T. (2018). Chatbot Utilization for Medical Consultant System. 2018 3rd Technology Innovation Management and Engineering Science International Conference (TIMES-iCON), 1-5. Karri, S. P. R., & Kumar, B. S. (2020, January). Deep learning techniques for implementation of chatbots. In 2020 International Conference on 2023