{"id":118,"date":"2018-03-27T13:23:00","date_gmt":"2018-03-27T13:23:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2018\/03\/27\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot\/"},"modified":"2020-11-05T14:16:18","modified_gmt":"2020-11-05T13:16:18","slug":"bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot\/","title":{"rendered":"Bot Framework Tutorial 5: How to Train a Question and Answer(QnA) Bot"},"content":{"rendered":"<p>This Bot Framework tutorial follows from the Tutorial 4 where we create a Question and Answer Bot. In this tutorial, we would focus on improving the functionality\u00a0 of our the question and answer bot so that it can give more intelligent answers to questions.<\/p>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<p>Today we would focus on Create a chat robot that would answer any question about Computer Programming and we would do this together<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t1\">Examine the Base Questions<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t2\">Add Your own questions<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t3\">Create a QnaServer in qnamaker.ai<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t4\">Test the Service<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t5\">Train Your Service<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t6\">Quiz for You<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t7\">Publish and Test\u00a0 The Service<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t8\">Create a New Question and Answer Bot in Azure<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot#t9\">Final Notes and Next Steps<\/a><\/li>\n<\/ol>\n<p><ins style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7041870931346451\" data-ad-slot=\"4209786523\"><\/ins><br \/>\n<b><\/b><\/p>\n<h3 id=\"t1\">1. Examine the Base Questions List<\/h3>\n<p>For this tutorial, we would start with a basic list of computer programming questions. You can view these questions from <a href=\"https:\/\/kindsonthegenius.com\/blog\/computer-programming-questions-and-answers-java-c-c-php-python-javascript-visual-basic-c-html\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/4.bp.blogspot.com\/-58MVOjLl9g0\/Wroup_t9IJI\/AAAAAAAABnw\/1enxMbIxk84UJHYu4DUJqLaE8aqsPZhcgCLcBGAs\/s1600\/List%2Bof%2BQuestions.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/4.bp.blogspot.com\/-58MVOjLl9g0\/Wroup_t9IJI\/AAAAAAAABnw\/1enxMbIxk84UJHYu4DUJqLaE8aqsPZhcgCLcBGAs\/s640\/List%2Bof%2BQuestions.jpg\" width=\"604\" height=\"640\" border=\"0\" data-original-height=\"864\" data-original-width=\"820\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 1:<\/b> Base Questions List<\/div>\n<p>&nbsp;<\/p>\n<p>Figure 1 shows the base qustions list that would serve as our starting point<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t2\">2. Add Your own questions<\/h3>\n<p>You can add more questions to this list. Just leave the question in the comment box under the list. You could also leave the question in the comment box under this tutorial.<\/p>\n<p>If you have the answer to the question you could provide it along with the question, if not, then we would provide the answer and add it to the list in a short time.<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/1.bp.blogspot.com\/-qTiV1Y2_Od4\/WrowiyGLkuI\/AAAAAAAABn8\/8CuR-KrTlts_dYMeKxm0mzLyk87fnd7gQCLcBGAs\/s1600\/Comment%2Bbox%2Bto%2Bleave%2Ba%2Bquestion.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/1.bp.blogspot.com\/-qTiV1Y2_Od4\/WrowiyGLkuI\/AAAAAAAABn8\/8CuR-KrTlts_dYMeKxm0mzLyk87fnd7gQCLcBGAs\/s640\/Comment%2Bbox%2Bto%2Bleave%2Ba%2Bquestion.jpg\" width=\"640\" height=\"378\" border=\"0\" data-original-height=\"666\" data-original-width=\"1124\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 2:<\/b> Add Your Question here<\/div>\n<p>&nbsp;<\/p>\n<p>If would like to have access to the Programming Questions and Answers page, then mention that in the comment box, as well as your email. After verifying that the request is authentic, then we would provide you with a link to edit the questions and answers list and add your own questions.<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t3\">3. Create a QnaServer in qnamaker.ai<\/h3>\n<p><b>Step 1:<\/b> Visit qnaMaker.ai<br \/>\n<b>Step 2:<\/b> Click on Create New Service<br \/>\n<b>Step 3<\/b>: Enter the name of the Service (eg. Programming-Questions-Service)<\/p>\n<p>Now you need to enter the url of the knowledgebase. The knowledgebase is simply the list of question and answers we already have.<\/p>\n<p>&nbsp;<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/1.bp.blogspot.com\/-ZS6MGYSvItE\/WrozBzF4DOI\/AAAAAAAABoI\/6xLXtCTd8U0yCGBt70GqGEbT1KIlapdeACLcBGAs\/s1600\/Create%2BNew%2BQna%2BService.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/1.bp.blogspot.com\/-ZS6MGYSvItE\/WrozBzF4DOI\/AAAAAAAABoI\/6xLXtCTd8U0yCGBt70GqGEbT1KIlapdeACLcBGAs\/s640\/Create%2BNew%2BQna%2BService.jpg\" width=\"640\" height=\"470\" border=\"0\" data-original-height=\"882\" data-original-width=\"1197\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 3:<\/b> Create new Qna Service<\/div>\n<p>&nbsp;<\/p>\n<p><b>Step 4: <\/b>Enter the url of our programming questions and answers page:\u00a0<a href=\"https:\/\/kindsonthegenius.com\/blog\/computer-programming-questions-and-answers-java-c-c-php-python-javascript-visual-basic-c-html\/\">http:\/\/kindsonthegenius.blogspot.hu\/2018\/03\/computer-programming-questions-and.html<\/a><br \/>\nCopy and paste the url in the box<\/p>\n<p><b>Step 5:<\/b> Scroll down the page and click on the create button<br \/>\nAfter some seconds, the knowledgebase is created as shown in Figure 4.<\/p>\n<p>Notice that the\u00a0 system recognizes which text is a questions and which is the answer to the question. Also, any image is the file or text that is not question and answers are ignored.<br \/>\nIsn&#8217;t this amazing!<\/p>\n<p><ins style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7041870931346451\" data-ad-slot=\"4209786523\"><\/ins><br \/>\n<b><\/b><\/p>\n<h3 id=\"t4\">4. Test Your Service<\/h3>\n<p>To test our service:<br \/>\n<b>Step 1:<\/b> Click on the Test menu by the left<br \/>\nThe testing page is displayed as shown in Figure 4<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/4.bp.blogspot.com\/-SjCphIzaghQ\/Wro2Ij9q7EI\/AAAAAAAABoU\/Ub6aFnsPegAqQYkgeFXeOFIKb4lIBO1vgCLcBGAs\/s1600\/Testing%2BPage.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/4.bp.blogspot.com\/-SjCphIzaghQ\/Wro2Ij9q7EI\/AAAAAAAABoU\/Ub6aFnsPegAqQYkgeFXeOFIKb4lIBO1vgCLcBGAs\/s640\/Testing%2BPage.jpg\" width=\"640\" height=\"458\" border=\"0\" data-original-height=\"799\" data-original-width=\"1113\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 4:<\/b> Testing Page<\/div>\n<p>&nbsp;<\/p>\n<p><b>Step 2:<\/b> Enter some of the questions we have in the list and observe the response.<br \/>\nYou would observe that it gives the correct response.<br \/>\nLet&#8217;s now move to the training section so we see how we can improve performance<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t5\">5. Train Your Service<\/h3>\n<p>However, you entered the questions exactly as it is because you already have the list of question. But a user trying to ask questions about computer programming may ask questions in a different way or with different wordings.<\/p>\n<p>For example, the three questions should produce the same answer(at least for a simple bot):<\/p>\n<ul>\n<li>Can you tell me about JVM?<\/li>\n<li>What is Java Virtual Machine?<\/li>\n<li>What does JVM stand for?<\/li>\n<\/ul>\n<p><b>Step 1: <\/b>Try to enter this three questions and what do you observe? Give answer in the comment box below.<\/p>\n<div><b>Step 2:<\/b> Now Enter What is Java Virtual Machine.<\/div>\n<div>You will observe that it give us the wrong answer \ud83d\ude03<\/div>\n<p>Training would help us fix this.<\/p>\n<p><b>Step 3:<\/b> Now enter What is JVM, so that is gives the right answer.<br \/>\nWe want it to give us the same answer when we enter What is Java Virtual Machine<\/p>\n<p><b>Step 4:<\/b> By the right hand side, in the text box under &#8216;provide multiple alternative phrasing to the question to broaden the knowledge base&#8217;, enter What is Java Virtual Machine<br \/>\n<b>Step 5:<\/b> Click Add (the\u00a0+ sign)<br \/>\nNotice that the question is added as a second question for this particular answer as shown in Figure 5<\/p>\n<p>&nbsp;<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/2.bp.blogspot.com\/-SKEo5KONvDM\/Wro6WYQDncI\/AAAAAAAABog\/wJ4p3oGJ2QMzkRgySthXttNFbHOkx2LugCLcBGAs\/s1600\/Providing%2BAlternative%2Bquestion.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/2.bp.blogspot.com\/-SKEo5KONvDM\/Wro6WYQDncI\/AAAAAAAABog\/wJ4p3oGJ2QMzkRgySthXttNFbHOkx2LugCLcBGAs\/s640\/Providing%2BAlternative%2Bquestion.jpg\" width=\"640\" height=\"275\" border=\"0\" data-original-height=\"632\" data-original-width=\"1465\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 5:<\/b> Training the Qna Service<\/div>\n<p>&nbsp;<\/p>\n<p><b>Step 6:<\/b> Click on Save and Retrain<br \/>\n<b>Step 7:<\/b> Now, Enter the question again, What is Java Virtual Machine<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #990000;\">What do you observe?<\/span><br \/>\nNotice now that it gives the right answer<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t6\">6. Quiz for you<\/h3>\n<p>Train the Service the give the same answer for the following quesion\u00c9<\/p>\n<p>What are some Languages in Programming?<br \/>\nMention some programming languages?<br \/>\nGive examples of programming languages?<\/p>\n<p>Also take some time to train the service to handle other variations of the other questions in the list. Remember to click on Save and Retrain when you are done with the training.<\/p>\n<p><ins style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7041870931346451\" data-ad-slot=\"4209786523\"><\/ins><br \/>\n<b><\/b><\/p>\n<h3 id=\"t7\">7. Publish and Test\u00a0 The Service<\/h3>\n<p>After you are done with the training:<br \/>\n<b>Step 1<\/b>: Click on Publish. A review page is displayed<br \/>\n<b>Step 2<\/b>: Click on Publish again to publish the service<\/p>\n<p>&nbsp;<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/2.bp.blogspot.com\/-F4Lr3E27Kj0\/Wro9GEybaZI\/AAAAAAAABos\/lSCiolyP4G8UqzEgpRBNjEEnIvbYx-u7wCLcBGAs\/s1600\/Publish-Successful%2Bpage.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/2.bp.blogspot.com\/-F4Lr3E27Kj0\/Wro9GEybaZI\/AAAAAAAABos\/lSCiolyP4G8UqzEgpRBNjEEnIvbYx-u7wCLcBGAs\/s320\/Publish-Successful%2Bpage.jpg\" width=\"519\" height=\"310\" border=\"0\" data-original-height=\"652\" data-original-width=\"1095\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><b>Figure 6<\/b>: Publish Success page<\/div>\n<p>&nbsp;<\/p>\n<p>Now, you can see Success page.<br \/>\nIn this page you will find the KnowledgebaseId and the Subcription Key.<\/p>\n<p><b>Step 3:<\/b> Copy and save this output, because you will need it in the nex tutorial.<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t8\">8. Create a New Question and Answer Bot in Azure<\/h3>\n<p>You will need to do this by yourself.<br \/>\nSee <a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-4-creating-a-question-and-answerqna-bot\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Create a Question and Answer Bot<\/a><br \/>\nGive the bot a name like ProgrammingBot or ProgrammingAssistant or ProgrammingTutor<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t9\">9. Final Notes and Next Steps<\/h3>\n<p>Now we have a working qna Service and we have a question and answer bot. This is interesting because in the next tutorial we would examine how allow users to use this bot for free.<\/p>\n<p>You know, the public could make use of your bot and it would even apear that they are chatting with someone<br \/>\nIn the next tutorial, we would examing Channels and also\u00a0 add Skype channel to this bot so that it can connect with and chat with real users<\/p>\n<p>For now I would like to thank you for the time spent learning. Do leave a question or observation if you have any.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Bot Framework tutorial follows from the Tutorial 4 where we create a Question and Answer Bot. In this tutorial, we would focus on improving &hellip; <\/p>\n","protected":false},"author":2,"featured_media":704,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[195],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/118"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":13,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":1764,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/118\/revisions\/1764"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media\/704"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}