Create a QnA Maker knowledge base | Microsoft qna maker tutorial
In this tutorial, you learn how to:
- Create a knowledge base in the QnA Maker portal
- Review, save, and train the knowledge base
- Publish the knowledge base
- Use Curl to query the knowledge base
Prerequisites
This tutorial requires an existing QnA Maker service.
Create a knowledge base
- Sign in to the QnA Maker portal.
- Select Create a knowledge base from the top menu.
- Skip the first step because you will use your existing QnA Maker service.
- In the next step, select your existing settings:
Setting Purpose Microsoft Azure Directory Id Your Microsoft Azure Directory Id is associated with the account you use to sign into the Azure portal and the QnA Maker portal. Azure Subscription name Your billing account you created the QnA Maker resource in. Azure QnA Service Your existing QnA Maker resource. - In the next step, Enter your knowledge base name,
My Tutorial kb
. - In the next step, populate your kb with the following settings:
Setting name Setting value Purpose URL https://docs.microsoft.com/
azure/cognitive-services/
qnamaker/faqs
The contents of the FAQ at that URL are formatted with a question followed by an answer. QnA Maker can interpret this format to extract questions and the associated answers. File not used in this tutorial This uploads files for questions and answers. Chit-chat personality The friend This gives a friendly and casual personality to common questions and answers. You can edit these questions and answers later. - Select Create your KB to finish the creation process.
Review KB, save, and train
- Review the questions and answers. The first page is questions and answers from the URL.
- Select the last page of questions and answers from the bottom of the table. The page shows questions and answers from the Chit-chat personality.
- From the toolbar above the list of questions and answers, select the metadata icon. This shows the metadata tags for each question and answer. The Chit-chat questions have the editorial: chit-chat metadata already set. This metadata is returned to the client application along with the selected answer. The client application, such as a chat bot, can use this filtered metadata to determine additional processing or interactions with the user.
- Select Save and train in the top menu bar.
Publish to get KB endpoints
Select the Publish button from the top menu. Once you are on the publish page, select Publish, next to the Cancel button.
After the KB is published, the endpoint is displayed
Use curl to query for an FAQ answer
- Select the Curl tab.
- Copy the text of the Curl tab and execute in a Curl-enabled terminal or command-line. The authorization header’s value includes the text
Endpoint
with a trailing space then the key. - Replace
with
How large can my KB be?
. This is close to the question,How large a knowledge base can I create?
, but not exactly the same. QnA Maker applies natural language processing to determine that the two questions are the same. - Execute the CURL command and receive the JSON response including the score and answer.
TXT
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 581 100 543 100 38 418 29 0:00:01 0:00:01 --:--:-- 447{ "answers": [ { "questions": [ "How large a knowledge base can I create?" ], "answer": "The size of the knowledge base depends on the SKU of Azure search you choose when creating the QnA Maker service. Read [here](https://docs.microsoft.com/azure/cognitive-services/qnamaker/tutorials/choosing-capacity-qnamaker-deployment)for more details.", "score": 42.81, "id": 2, "source": "https://docs.microsoft.com/azure/cognitive-services/qnamaker/faqs", "metadata": [] } ]}
QnA Maker is somewhat confident with the score of 42.81%.
Use curl to query for a Chit-chat answer
- In the Curl-enabled terminal, replace
How large can my KB be?
with an bot conversation-ending statement from the user, such asThank you
. - Execute the CURL command and receive the JSON response including the score and answer.
TXT
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 525 100 501 100 24 525 25 --:--:-- --:--:-- --:--:-- 550{ "answers": [ { "questions": [ "Thank you", "Thanks", "Thnx", "Kthx", "I appreciate it", "Thank you so much", "I thank you", "My sincere thank" ], "answer": "You're very welcome.", "score": 100.0, "id": 109, "source": "qna_chitchat_the_friend.tsv", "metadata": [ { "name": "editorial", "value": "chitchat" } ] } ]}
Because the question of
Thank you
exactly matched a Chit-chat question, QnA Maker is completely confident with the score of 100. QnA Maker also returned all the related questions as well as the metadata property containing the Chit-chat metadata tag information.
Use curl to query for the default answer
Any question that QnA Maker is not confident in an answer receives the default answer. This answer is configured in the Azure portal.
- In the Curl-enabled terminal, replace
Thank you
withx
. - Execute the CURL command and receive the JSON response including the score and answer.
TXT
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 186 100 170 100 16 272 25 --:--:-- --:--:-- --:--:-- 297{ "answers": [ { "questions": [], "answer": "No good match found in KB.", "score": 0.0, "id": -1, "metadata": [] } ]}
QnA Maker returned a score of 0 which means no confidence but it also returned the default answer.
Next Part: Create a QnA Bot