.qna 檔案格式
適用于: SDK v4
注意
Azure AI QnA Maker 將于 2025 年 3 月 31 日淘汰。 從 2022 年 10 月起,您將無法建立新的 QnA Maker 資源或知識庫。 較新版的問題和解答功能現在隨附於 Azure AI 語言。
自訂問題解答是 Azure AI 語言的一項功能,是 QnA Maker 服務的更新版本。 如需 Bot Framework SDK 中問答支援的詳細資訊,請參閱 自然語言理解 。
.qna 檔案包含適用于 QnAmaker.ai 概念的 Markdown 類似文字定義。 本文涵蓋透過 .qna 檔案格式表示的各種概念。
新增批註
使用 > 來建立批註。 以下為範例:
> This is a comment and will be ignored
問答組
.qna 檔案和剖析器支援問答定義。
以下是基本問答定義的語法:
# ? Question
[list of question variations]
```
Answer
```
以下是問答定義的範例:
> # QnA Definitions
### ? who is the ceo?
```
You can change the default message if you use the QnAMakerDialog.
For details, see [Azure AI Bot Service documentation](/articles/adaptive-dialog/adaptive-dialog-prebuilt-actions.md).
```
### ? How do I programmatically update my KB?
```
You can use our REST apis to manage your KB.
\#1. See here for details: https://westus.dev.cognitive.microsoft.com/docs/services/58994a073d9e04097c7ba6fe/operations/58994a073d9e041ad42d9baa
```
請注意, markdown
的 answer
型別識別碼是選擇性的。
多個問題
只要將變化新增至問題,即可將多個問題新增至相同的答案。
### ? Aren't you feeling happy today?
- Feeling cheerful?
```markdown
I'm quite happy, thank you.
```
QnAMaker 篩選器
QnA Maker 中的篩選是簡單的索引鍵/值組,可用來縮小搜尋結果範圍、提升答案和儲存內容。
使用下列語法來新增篩選:
***Filters:***
- name = value
- name = value
以下是如何使用篩選的範例:
### ? Where can I get coffee?
- I need coffee
**Filters:**
- location = seattle
```markdown
You can get coffee in our Seattle store at 1 pike place, Seattle, WA
```
### ? Where can I get coffee?
- I need coffee
**Filters:**
- location = portland
```markdown
You can get coffee in our Portland store at 52 marine drive, Portland, OR
```
QnA Maker PDF 檔案擷取
QnA Maker 也支援在 KB 建立期間內嵌 PDF 檔案。 您可以使用 URL 參考配置,將 QnA Maker 的檔案新增至內嵌。 如果 URI 的內容類型不是文字或 HTML,剖析器會將它新增至 QnA Maker 內嵌的檔案集合。
[SurfaceManual.pdf](https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf)
外部參考
.qna 檔案支援外部參考,並使用 Markdown 連結語法。
參考另一個 .qna 檔案
使用 [link name](<.qna file name>)
參考另一個 .qna 檔案。 參考可以是包含 .qna 檔案的絕對路徑或相對路徑。
包含 .qna 檔案的資料夾參考
透過下列方式支援使用其他 .qna 檔案參考資料夾:
[link name](<.qna file path>/*)
:在指定的絕對或相對路徑下尋找 .qna 檔案。[link name](<.qna file path>/**)
:以遞迴方式尋找指定之絕對路徑或相對路徑下的 .qna 檔案,包括子資料夾。
參考 URL
透過 參考 QnAMaker 在 KB 建立 [link name](<URL>)
期間內嵌的 URL。
來自特定檔案的參考
您也可以將參考新增至意圖區段下特定檔案中定義的語句,或新增為 QnA 配對。
[link name](<.lu file path>#<INTENT-NAME>)
:尋找 .lu 檔案中 INTENT-NAME > 底下 < 找到的所有語句,並將其新增至指定參考的問題清單。[link name](<.lu file path>#*utterances*)
:尋找 .lu 檔案中的所有語句,並將其新增至指定參考的問題清單。[link name](<.qna file path>#?)
:從 .qna 檔案中定義的所有 QnA 配對中尋找問題,並將其新增至指定此參考的語句清單。[link name](<.qna folder>/*#?)
:從指定資料夾中的所有 .qna 檔案中尋找所有問題,並將其新增至指定此參考的語句清單。
以下是上述參考的範例:
> QnA URL reference
[QnaURL](/azure/ai-services/qnamaker/)
> Include all content in ./kb1.qna
[KB1](./kb1.qna)
> Look for all .qna files under a path
[ChitChat](./chitchat/*)
> Recursively look for .qna files under a path including subfolders.
[ChitChat](../chitchat/resources/**)
模型描述
您可以在 .qna 檔案中包含 LUIS 應用程式或 QnA Maker KB 的組態資訊,以協助引導剖析器正確處理 LU 內容。
注意
Language Understanding (LUIS) 將于 2025 年 10 月 1 日淘汰。 從 2023 年 4 月 1 日起,您將無法建立新的 LUIS 資源。 新版的語言理解現在已提供作為 Azure AI 語言的一部分。
對話式語言理解(CLU)是 Azure AI 語言的一項功能,是 LUIS 的更新版本。 如需 Bot Framework SDK 中語言理解支援的詳細資訊,請參閱 自然語言理解 。
以下說明如何新增正在唱 > 的組態資訊!# :
> !# @<property> = <value>
> !# @<scope>-<property> = <value>
> !# @<scope>-<property> = <semicolon-delimited-key-value-pairs>
請注意,透過 CLI 引數明確傳入的任何資訊都會覆寫 .qna 檔案中的資訊。
> Parser instruction - this is optional; unless specified, the parser will default to the latest version.
> !# @version = 1.0
> QnA Maker KB description
> !# @kb.name = my qna maker kb name
> Source for a specific QnA pair
> !# @qna.pair.source = <source value>
多轉內容
使用 Markdown 連結標記法,多重轉內容會以 .qna 格式表示。 使用下列方式指定連結:
- [display text](#<ID or question>)
您可以選擇性地針對僅針對問題提供內容相關的任何提示加入 context-only
。 閱讀將 現有問答組新增為後續提示 的章節,以深入瞭解如何使用 context
。
- [tell me a joke](#?joke) `context-only`
後續提示
開發人員有兩個選項可用來建立後續提示:直接使用問題作為後續提示,或將明確識別碼指派給 QnA 配對。
直接使用問題
第一組具有連結文字作為 question
的 QnA 配對將會新增為提示。 如果您需要更明確的控制,請改用 識別碼 。
當您直接使用問題時,請使用 Markdown 慣例,並以連字號取代空格(例如,使用 #?when-is-the-portland-store-open
而非 #?when is the portland store open
)。 剖析器會盡最大努力尋找連結。
# ?store hours
```
Most our stores are open M-F 9AM-10PM.
```
**Prompts:**
- [Seattle store](#?seattle)
- [Portland store](#?when-is-the-portland-store-open)
# ?seattle
```
The Seattle store is open M-F 9AM-10PM.
```
# ?when is the portland store open
- portland store hours
```
The Portland store is open 24/7.
```
提示
在大部分的 Markdown 轉譯器中,連結實際上不會轉譯為可選取的連結。
將明確識別碼指派給 QnA 配對
為每個提示指派一個號碼的識別碼。 您可以在下列範例中看到每個商店的提示已指派不同的數值。
# ?store hours
```
Most our stores are open M-F 9AM-10PM.
```
**Prompts:**
- [Seattle store](#1)
- [Portland store](#2)
<a id = "1"></a>
# ?seattle
```
The Seattle store is open M-F 9AM-10PM.
```
<a id = "2"></a>
# ?when is the portland store open
- portland store hours
```
The Portland store is open 24/7.
```
其他資源
- 如需 .lu 檔案格式的相關資訊,請參閱 .lu 檔案格式。