快速入門:建立、訓練及發佈您的 QnA Maker 知識庫Quickstart: Create, train, and publish your QnA Maker knowledge base

您可以從自己的內容 (例如常見問題集或產品手冊) 建立 QnA Maker 知識庫 (KB)。You can create a QnA Maker knowledge base (KB) from your own content, such as FAQs or product manuals. 本文包含從簡單的常見問題集網頁建立 QnA Maker 知識庫的範例,以回答問題 QnA Maker。This article includes an example of creating a QnA Maker knowledge base from a simple FAQ webpage, to answer questions QnA Maker.

必要條件Prerequisites

  • 如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶If you don't have an Azure subscription, create a free account before you begin.
  • 在 Azure 入口網站中所建立的 QnA Maker 資源A QnA Maker resource created in the Azure portal. 請記住您在建立資源時選取的 Azure Active Directory 識別碼、訂用帳戶、QnA 資源名稱。Remember your Azure Active Directory ID, Subscription, QnA resource name you selected when you created the resource.

建立第一個 QnA Maker 知識庫Create your first QnA Maker knowledge base

  1. 利用您的 Azure 認證登入 QnAMaker.ai 入口網站。Sign in to the QnAMaker.ai portal with your Azure credentials.

  2. 在 QnA Maker 入口網站中,選取 [建立知識庫]。In the QnA Maker portal, select Create a knowledge base.

  3. 如果您已經有 QnA Maker 資源,請在 [建立] 頁面上略過 [步驟 1]。On the Create page, skip Step 1 if you already have your QnA Maker resource.

    如果您尚未建立資源,則請選取 [建立 QnA 服務]。If you haven't created the resource yet, select Create a QnA service. 系統會將您導向 Azure 入口網站,以在您的訂用帳戶中設定 QnA Maker 服務。You are directed to the Azure portal to set up a QnA Maker service in your subscription. 請記住您在建立資源時選取的 Azure Active Directory 識別碼、訂用帳戶、QnA 資源名稱。Remember your Azure Active Directory ID, Subscription, QnA resource name you selected when you created the resource.

    當您在 Azure 入口網站中建立好資源時,請回到 QnA Maker 入口網站、重新整理瀏覽器頁面,然後繼續 [步驟 2]。When you are done creating the resource in the Azure portal, return to the QnA Maker portal, refresh the browser page, and continue to Step 2.

  4. 在 [步驟 2] 中,選取您的 Active directory、訂用帳戶、服務 (資源),以及在服務中所建立所有知識庫的語言。In Step 2, select your Active directory, subscription, service (resource), and the language for all knowledge bases created in the service.

    選取 QnA Maker 服務知識庫的螢幕擷取畫面

  5. 在 [步驟 3] 中,將知識庫命名為 我的範例 QnA KBIn Step 3, name your knowledge base My Sample QnA KB.

  6. 在 [步驟 4] 中,使用下表進行設定:In Step 4, configure the settings with the following table:

    設定Setting Value
    啟用從 URL、.pdf 或 .docx 檔案進行多回合擷取。Enable multi-turn extraction from URLs, .pdf or .docx files. 已檢查Checked
    多回合預設文字Multi-turn default text 選取和選項Select and option
    + 新增 URL+ Add URL https://www.microsoft.com/en-us/software-download/faq
    閒聊Chit-chat 選取 [Professional]Select Professional
  7. 在 [步驟 5] 中,選取 [建立知識庫]。In Step 5, Select Create your KB.

    擷取程序需要一點時間來讀取文件並找出問題和回答。The extraction process takes a few moments to read the document and identify questions and answers.

    在 QnA Maker 成功建立知識庫之後,[知識庫] 頁面隨即開啟。After QnA Maker successfully creates the knowledge base, the Knowledge base page opens. 您可以在此頁面上編輯知識庫的內容。You can edit the contents of the knowledge base on this page.

新增問答集Add a new question and answer set

  1. 在 QnA Maker 入口網站的 [編輯] 頁面上,從操作工具列中選取 [+新增 QnA 配對]。In the QnA Maker portal, on the Edit page, select + Add QnA pair from the context toolbar.

  2. 新增下列問題:Add the following question:

    How many Azure services are used by a knowledge base?

  3. 新增使用 markdown 設定格式的答案:Add the answer formatted with markdown:

    * Azure QnA Maker service\n* Azure Cognitive Search\n* Azure web app\n* Azure app plan

    以文字型式新增問題與使用 markdown 設定格式的答案。

    markdown 符號 * 用於表示項目符號。The markdown symbol, *, is used for bullet points. \n 用於表示新行。The \n is used for a new line.

    [編輯] 頁面會顯示 markdown。The Edit page shows the markdown. 當您稍後使用 [測試] 面板時,您將會看到 markdown 正確顯示。When you use the Test panel later, you will see the markdown displayed properly.

儲存並定型Save and train

在右上方,選取 [儲存並定型] 來儲存您的編輯內容並將 QnA Maker 定型。In the upper right, select Save and train to save your edits and train QnA Maker. 除非儲存編輯內容,否則不會保留。Edits aren't kept unless they're saved.

測試知識庫Test the knowledge base

  1. 在 QnA Maker 入口網站的右上方,選取 [測試] 來測試您所做的變更是否已生效。In the QnA Maker portal, in the upper right, select Test to test that the changes you made took effect.

  2. 在文字方塊中輸入範例使用者查詢。Enter an example user query in the textbox.

    I want to know the difference between 32 bit and 64 bit Windows

    在文字方塊中輸入範例使用者查詢。

  3. 選取 [檢查],更詳細地檢查回應。Select Inspect to examine the response in more detail. 測試視窗是用來測試您對知識庫所做的變更,然後加以發佈。The test window is used to test your changes to the knowledge base before publishing your knowledge base.

  4. 再次選取 [測試] 以關閉 [測試] 面板。Select Test again to close the Test panel.

發佈知識庫Publish the knowledge base

當您發佈知識庫時,您知識庫的內容會從 test 索引移到 Azure 搜尋服務中的 prod 索引。When you publish a knowledge base, the contents of your knowledge base move from the test index to a prod index in Azure search.

移動您的知識庫內容的螢幕擷取畫面

  1. 在 QnA Maker 入口網站中,選取 [發佈]。In the QnA Maker portal, select Publish. 若要接著確認,請選取頁面上的 [發佈]。Then to confirm, select Publish on the page.

    QnA Maker 服務現在已成功發佈。The QnA Maker service is now successfully published. 您可以在您的應用程式或 Bot 程式碼中使用此端點。You can use the endpoint in your application or bot code.

    發佈成功的螢幕擷取畫面

建立 BotCreate a bot

發佈之後,您可以從 [發佈] 頁面建立 Bot:After publishing, you can create a bot from the Publish page:

  • 您可以快速建立數個 Bot,讓全部 Bot 指向相同知識庫中個別 Bot 適用的不同區域或定價方案。You can create several bots quickly, all pointing to the same knowledge base for different regions or pricing plans for the individual bots.
  • 如果您想讓知識庫只有一個 Bot,可使用 在 Azure 入口網站中檢視 Bot 連結,來檢視您目前的 Bot 清單。If you want only one bot for the knowledge base, use the View all your bots on the Azure portal link to view a list of your current bots.

當您變更知識庫並重新發佈時,不需要對 Bot 採取進一步的動作。When you make changes to the knowledge base and republish, you don't need to take further action with the bot. 其已設定為與知識庫搭配使用,而且會與知識庫未來的所有變更搭配運作。It's already configured to work with the knowledge base, and works with all future changes to the knowledge base. 每次發佈知識庫後,與之連線的所有 Bot 就會自動更新。Every time you publish a knowledge base, all the bots connected to it are automatically updated.

  1. 在 QnA Maker 入口網站的 [發佈] 頁面上,選取 [建立 Bot]。In the QnA Maker portal, on the Publish page, select Create bot. 只有在發佈知識庫後,此按鈕才會出現。This button appears only after you've published the knowledge base.

    建立 Bot 的螢幕擷取畫面

  2. Azure 入口網站會在新的瀏覽器索引標籤中開啟,其中會包含 Azure Bot 服務的建立頁面。A new browser tab opens for the Azure portal, with the Azure Bot Service's creation page. 設定 Azure Bot 服務。Configure the Azure bot service. Bot 與 QnA Maker 可共用 Web 應用程式服務方案,但不能共用 Web 應用程式。The bot and QnA Maker can share the web app service plan, but can't share the web app. 這表示 Bot 的 應用程式名稱 必須與 QnA Maker 服務的應用程式名稱不同。This means the app name for the bot must be different from the app name for the QnA Maker service.

    • 建議事項Do
      • 變更 Bot 控制代碼 - 如果不是唯一的。Change bot handle - if it is not unique.
      • 選取 SDK 語言。Select SDK Language. 建立 Bot 後,您可以將程式碼下載至您的本機開發環境,並繼續進行開發程序。Once the bot is created, you can download the code to your local development environment and continue the development process.
    • 禁止事項Don't
      • 建立 Bot 時,請勿在 Azure 入口網站中變更下列設定。change the following settings in the Azure portal when creating the bot. 這些是為您現有知識庫預先填入的內容:They are pre-populated for your existing knowledge base:
        • QnA 驗證金鑰QnA Auth Key
        • App Service 方案和位置App service plan and location
  3. 建立 Bot 之後,請開啟 [Bot 服務] 資源。After the bot is created, open the Bot service resource.

  4. 在 [Bot 管理] 下,選取 [在網路聊天中測試]。Under Bot Management, select Test in Web Chat.

  5. 在 [輸入您的訊息] 聊天提示中,輸入:At the chat prompt of Type your message, enter:

    Azure services?

    聊天 Bot 會使用來自您知識庫的答案來回應。The chat bot responds with an answer from your knowledge base.

    在測試網頁聊天中輸入使用者查詢。

您完成了哪些工作?What did you accomplish?

您已建立新的知識庫、將公用 URL 新增至知識庫、新增自己的 QnA 配對、定型、測試及發佈知識庫。You created a new knowledge base, added a public URL to the knowledge base, added your own QnA pair, trained, tested, and published the knowledge base.

在發佈知識庫之後,您已建立 Bot 並測試 Bot。After publishing the knowledge base, you created a bot, and tested the bot.

這一切都是在幾分鐘內完成,而不需要撰寫任何程式碼或清除內容。This was all accomplished in a few minutes without having to write any code or clean the content.

清除資源Clean up resources

如果您不想繼續進行下一個快速入門,請刪除 Azure 入口網站中的 QnA Maker 和 Bot Framework 資源。If you are not continuing to the next quickstart, delete the QnA Maker and Bot framework resources in the Azure portal.

後續步驟Next steps

其他資訊:For more information: