Share via


評估及監視生成式 AI 的計量

重要

本文所述的部分功能可能僅適用於預覽版。 此預覽版本沒有服務等級協定,不建議將其用於生產工作負載。 可能不支援特定功能,或可能已經限制功能。 如需詳細資訊,請參閱 Microsoft Azure 預覽版增補使用條款

Azure AI Studio 可讓您評估單一回合或複雜的多回合交談,其中您可以使用特定資料建立生成式 AI 模型 (也稱為檢索增強生成或 RAG)。 您也可以評估一般單回合問題解答情境採用無內容來源的生成式 AI 模型 (非 RAG) 時的表現。 目前,我們支援下列工作類型的內建計量:

問題解答 (單一回合)

在此設定中,使用者會提出個別的問題或提示,並使用生成式 AI 模型來立即產生回應。

測試集格式會遵循下列資料格式:

{"question":"Which tent is the most waterproof?","context":"From our product list, the Alpine Explorer tent is the most waterproof. The Adventure Dining Table has higher weight.","answer":"The Alpine Explorer Tent is the most waterproof.","ground_truth":"The Alpine Explorer Tent has the highest rainfly waterproof rating at 3000m"} 

注意

"context" 和 "ground truth" 欄位是選擇性的,且支援的計量取決於您提供的欄位

交談 (單一回合和多回合)

在此內容中,使用者會透過一系列回合或單一對話來參與交談式互動。 具備擷取機制的生成式 AI 模型會產生回應,且能夠存取並納入外部來源的資訊 (例如文件)。 檢索增強生成 (RAG) 模型會使用外部文件和知識來增強回應的品質和相關性。

測試集格式會遵循下列資料格式:

{"messages":[{"role":"user","content":"How can I check the status of my online order?"},{"content":"Hi Sarah Lee! To check the status of your online order for previous purchases such as the TrailMaster X4 Tent or the CozyNights Sleeping Bag, please refer to your email for order confirmation and tracking information. If you need further assistance, feel free to contact our customer support at support@contosotrek.com or give us a call at 1-800-555-1234.
","role":"assistant","context":{"citations":[{"id":"cHJvZHVjdF9pbmZvXzYubWQz","title":"Information about product item_number: 6","content":"# Information about product item_number: 6\n\nIt's essential to check local regulations before using the EcoFire Camping Stove, as some areas may have restrictions on open fires or require a specific type of stove.\n\n30) How do I clean and maintain the EcoFire Camping Stove?\n   To clean the EcoFire Camping Stove, allow it to cool completely, then wipe away any ash or debris with a brush or cloth. Store the stove in a dry place when not in use."}]}}]}

支援的計量

如同評估大型語言模型的方法所述,測量方法分為手動和自動化兩種。 自動化測量適用於大規模測量,擁有更大的涵蓋範圍,可提供更全面的結果。 在系統、使用方式和降低風險方式發展時,此方法也很適合持續測量來監視任何迴歸。

針對生成式 AI 應用程式的自動化測量,我們支援兩種主要方法:

  • 傳統機器學習計量
  • AI 輔助計量

AI 輔助的計量會利用 GPT-4 等語言模型來評估 AI 生成的輸出,特別是在預期答案因缺乏已定義根據事實而無法使用的情況下。 傳統的機器學習計量 (例如 F1 分數) 可測量 AI 產生的回應與預期答案之間的精確度和召回率。

我們的 AI 輔助計量會評估產生 AI 應用程式的安全性和生成品質。 這些計量分為兩個不同的類別:

  • 風險和安全性計量:

    這些計量著重於識別潛在的內容與安全性風險,並確保所產生內容的安全性。

    其中包含:

    • 仇恨和不公平的內容不良率
    • 性內容不良率
    • 暴力內容不良率
    • 自我傷害相關內容不良率
    • 越獄不良率
  • 生成品質計量:

    這些計量會評估所產生內容的整體品質和連貫性。

    其中包含:

    • 連貫性
    • 流暢度
    • 根據性
    • 相關性
    • 擷取分數
    • 相似性

我們針對上述工作類型支援下列 AI 輔助計量:

工作類型 僅限問題和生成答案 (不需要上下文或基本事實) 問題和生成答案 + 上下文 問題和生成答案 + 上下文 + 基本事實
問題解答 - 風險和安全性計量 (所有 AI 輔助):仇恨和不公平的內容不良率、性內容不良率、暴力內容不良率、自我傷害相關內容不良率,以及越獄不良率
- 生成品質計量 (所有 AI 輔助):連貫性、流暢性
先前的資料行計量
+
生成品質計量 (所有 AI 輔助):
- 根據性
- 相關性
先前的資料行計量
+
生成品質計量:
相似性 (AI 輔助)
F1 分數 (傳統 ML 計量)
交談 - 風險和安全性計量 (所有 AI 輔助):仇恨和不公平的內容不良率、性內容不良率、暴力內容不良率、自我傷害相關內容不良率,以及越獄不良率
- 生成品質計量 (所有 AI 輔助):連貫性、流暢性
先前的資料行計量
+
生成品質計量 (所有 AI 輔助):
- 根據性
- 擷取分數
N/A

注意

雖然我們有為您提供一組完整的內建計量,能夠輕鬆且高效地評估您生成式 AI 應用程式的品質和安全性,但最佳做法是根據您的特定工作類型對其進行調整和自訂。 此外,我們可讓您引進全新的計量,藉此從全新角度測量應用程式,並確保符合您的獨特目標。

風險和安全性計量

風險和安全性計量會利用我們先前大型語言模型專案 (例如 GitHub Copilot 和 Bing) 中取得的見解。 這可確保評估針對風險和安全性嚴重性分數所產生之回應的完整方法。 這些計量是透過我們的安全評估服務所產生,該服務採用了一組 LLM。 每個模型都負責評估回應中可能出現的特定風險 (例如性內容、暴力內容等)。 這些模型會提供風險定義和嚴重性規模,並據以標註生成的對話。 目前,我們會計算以下風險和安全性計量的「不良率」。 針對每個計量,服務會測量是否偵測到這些類型的內容,以及偵測到的嚴重性層級。 這四種類型各有三個嚴重性層級 (非常低、低、中、高)。 使用者指定容錯閾值,而我們的服務所產生的不良率,會對應至每個閾值層級及以上產生的執行個體數目。

內容類型:

  • 仇恨和不公平的內容
  • 性內容
  • 暴力內容
  • 自我傷害相關內容

除了上述類型的內容外,我們也支援在評估的比較檢視中使用「越獄不良率」,此計量會測量模型回應中越獄的流行程度。 越獄是指模型回應略過其限制時。 當 LLM 偏離預定的任務或主題時,也會發生越獄。

您可以在自己的資料或測試資料集上,測量這些風險和安全性計量。 然後,您可以在此模擬測試資料集上進行評估,以輸出具有內容風險嚴重性層級 (非常低、低、中或高) 的已標註測試資料集,並在 Azure AI 中查看結果,從而為您提供整個測試資料集的總體不良率,以及每個內容風險標籤和推理的執行個體檢視。

不同於資料表中的其他計量,LLM 無法以附註可靠地測量越獄漏洞。 不過,越獄漏洞可以透過比較兩個不同的自動化資料集來測量 (1) 內容風險資料集與(2) 第一回合越獄注入的內容風險資料集。 然後,使用者藉由比較兩個資料集內容風險不良率來評估越獄弱點。

注意

AI 輔助的風險和安全性計量是由 Azure AI Studio 安全評估後端服務裝載,僅適用於下列區域:美國東部 2、法國中部、英國南部、瑞典中部。

可用的區域具有下列容量:

區域 TPM
瑞典中部 450k
法國中部 380k
英國南部 280k
美國東部 2 80k

仇恨和不公平的內容定義和嚴重性規模

警告

內容風險定義和嚴重性規模包含可能令某些使用者感到不舒服的描述。

性內容定義和嚴重性規模

警告

內容風險定義和嚴重性規模包含可能令某些使用者感到不舒服的描述。

暴力內容定義和嚴重性規模

警告

內容風險定義和嚴重性規模包含可能令某些使用者感到不舒服的描述。

警告

內容風險定義和嚴重性規模包含可能令某些使用者感到不舒服的描述。

生成品質計量

生成品質計量可用來評估生成式 AI 應用程式所產生的內容整體品質。 以下是這些計量含義的詳細說明:

AI 輔助:根據性

針對根據性,我們提供兩個版本:

  • 透過整合至 Azure AI Studio 安全評估,利用 Azure AI 內容安全服務 (AACS) 進行根據性偵測。 使用者不需要部署,後端服務將提供模型供您輸出分數和推理。 目前支援下列區域:美國東部 2 和瑞典中部。
  • 使用自身模型只輸出分數的提示型根據性。 目前所有區域都支援。

AACS 型根據性

分數特性 分數詳細資料
分數範圍 1-5,其中 1 是無根據,5 是具根據
此計量為何? 測量模型產生的答案與來源資料中的資訊 (例如,RAG 問答中擷取的文件或用於摘要的文件) 的資訊一致程度,並輸出特定生成句子無根據的推理。
如何運作? 根據性偵測會利用 Azure AI 內容安全服務自訂語言模型微調為自然語言處理工作,稱為自然語言推斷 (NLI),其會將宣告評估為來源文件所牽涉或不需要的宣告。 
使用時機? 若您需要確認 AI 所產生回應與所提供的內容一致且經過驗證,請使用根據性計量。 對於注重事實正確性和內容正確性的應用程式而言,這一點至關重要,例如資訊擷取、問答和內容摘要等。 此計量可確保 AI 產生的答案有充分參考內容。
需要哪些輸入? 問題、內容、生成的答案

提示型根據性

分數特性 分數詳細資料
分數範圍 1-5,其中 1 是無根據,5 是具根據
此計量為何? 測量模型產生的答案與來源資料資訊 (使用者定義內容) 的相符程度。
如何運作? 根據性量值會評估 AI 所產生答案主張與來源內容之間的對應程度,並確定這些主張經過內容證實。 即使 LLM 的回應實際為正確,如果無法針對提供的來源 (例如您的輸入來源或資料庫) 進行驗證,則同樣會被視為缺乏根據。
使用時機? 若您需要確認 AI 所產生回應與所提供的內容一致且經過驗證,請使用根據性計量。 對於注重事實正確性和內容正確性的應用程式而言,這一點至關重要,例如資訊擷取、問答和內容摘要等。 此計量可確保 AI 產生的答案有充分參考內容。
需要哪些輸入? 問題、內容、生成的答案

大型語言模型判斷用來評分此計量的內建提示:

You will be presented with a CONTEXT and an ANSWER about that CONTEXT. You need to decide whether the ANSWER is entailed by the CONTEXT by choosing one of the following rating: 

1. 5: The ANSWER follows logically from the information contained in the CONTEXT. 

2. 1: The ANSWER is logically false from the information contained in the CONTEXT. 

3. an integer score between 1 and 5 and if such integer score does not exist,  

use 1: It is not possible to determine whether the ANSWER is true or false without further information. 

Read the passage of information thoroughly and select the correct answer from the three answer labels. 

Read the CONTEXT thoroughly to ensure you know what the CONTEXT entails.  

Note the ANSWER is generated by a computer system, it can contain certain symbols, which should not be a negative factor in the evaluation. 

AI 輔助:相關性

分數特性 分數詳細資料
分數範圍 整數 [1-5]:其中 1 為不佳,5 為良好
此計量為何? 測量模型所產生回應與指定問題相關和直接相關的程度。
如何運作? 相關性量值會評估答案擷取內容重點的能力。 高相關性分數表示 AI 系統對輸入的了解程度,以及產生一致且情境適當輸出的能力。 相反地,低相關性分數表示產生的回應可能偏離主題、缺乏脈絡或不足以滿足使用者所需的查詢。
使用時機? 若要評估 AI 系統在理解輸入並產生情境適當回應的效能時,請使用相關性計量。
需要哪些輸入? 問題、內容、生成的答案

大型語言模型判斷用來評分此計量的內建提示 (針對回答資料格式):

Relevance measures how well the answer addresses the main aspects of the question, based on the context. Consider whether all and only the important aspects are contained in the answer when evaluating relevance. Given the context and question, score the relevance of the answer between one to five stars using the following rating scale: 

One star: the answer completely lacks relevance 

Two stars: the answer mostly lacks relevance 

Three stars: the answer is partially relevant 

Four stars: the answer is mostly relevant 

Five stars: the answer has perfect relevance 

This rating value should always be an integer between 1 and 5. So the rating produced should be 1 or 2 or 3 or 4 or 5. 

大型語言模型判斷用來評分此計量的內建提示 (針對交談資料格式) (無可用的根據性事實):

You will be provided a question, a conversation history, fetched documents related to the question and a response to the question in the {DOMAIN} domain. Your task is to evaluate the quality of the provided response by following the steps below:  
 
- Understand the context of the question based on the conversation history.  
 
- Generate a reference answer that is only based on the conversation history, question, and fetched documents. Don't generate the reference answer based on your own knowledge.  
 
- You need to rate the provided response according to the reference answer if it's available on a scale of 1 (poor) to 5 (excellent), based on the below criteria:  
 
5 - Ideal: The provided response includes all information necessary to answer the question based on the reference answer and conversation history. Please be strict about giving a 5 score.  
 
4 - Mostly Relevant: The provided response is mostly relevant, although it might be a little too narrow or too broad based on the reference answer and conversation history.  
 
3 - Somewhat Relevant: The provided response might be partly helpful but might be hard to read or contain other irrelevant content based on the reference answer and conversation history.  
 
2 - Barely Relevant: The provided response is barely relevant, perhaps shown as a last resort based on the reference answer and conversation history.  
 
1 - Completely Irrelevant: The provided response should never be used for answering this question based on the reference answer and conversation history.  
 
- You need to rate the provided response to be 5, if the reference answer can not be generated since no relevant documents were retrieved.  
 
- You need to first provide a scoring reason for the evaluation according to the above criteria, and then provide a score for the quality of the provided response.  
 
- You need to translate the provided response into English if it's in another language. 

- Your final response must include both the reference answer and the evaluation result. The evaluation result should be written in English.  

大型語言模型判斷用來評分此計量的內建提示 (針對交談資料格式) (具可用的根據性事實):


Your task is to score the relevance between a generated answer and the question based on the ground truth answer in the range between 1 and 5, and please also provide the scoring reason.  
 
Your primary focus should be on determining whether the generated answer contains sufficient information to address the given question according to the ground truth answer.   
 
If the generated answer fails to provide enough relevant information or contains excessive extraneous information, then you should reduce the score accordingly.  
 
If the generated answer contradicts the ground truth answer, it will receive a low score of 1-2.   
 
For example, for question "Is the sky blue?", the ground truth answer is "Yes, the sky is blue." and the generated answer is "No, the sky is not blue.".   
 
In this example, the generated answer contradicts the ground truth answer by stating that the sky is not blue, when in fact it is blue.   
 
This inconsistency would result in a low score of 1-2, and the reason for the low score would reflect the contradiction between the generated answer and the ground truth answer.  
 
Please provide a clear reason for the low score, explaining how the generated answer contradicts the ground truth answer.  
 
Labeling standards are as following:  
 
5 - ideal, should include all information to answer the question comparing to the ground truth answer, and the generated answer is consistent with the ground truth answer  
 
4 - mostly relevant, although it might be a little too narrow or too broad comparing to the ground truth answer, and the generated answer is consistent with the ground truth answer  
 
3 - somewhat relevant, might be partly helpful but might be hard to read or contain other irrelevant content comparing to the ground truth answer, and the generated answer is consistent with the ground truth answer  
 
2 - barely relevant, perhaps shown as a last resort comparing to the ground truth answer, and the generated answer contradicts with the ground truth answer  
 
1 - completely irrelevant, should never be used for answering this question comparing to the ground truth answer, and the generated answer contradicts with the ground truth answer  

AI 輔助:連貫性

分數特性 分數詳細資料
分數範圍 整數 [1-5]:其中 1 為不佳,5 為良好
此計量為何? 測量語言模型以順暢流動、自然閱讀,以及類似人類語言的方式產生輸出的能力。
如何運作? 連貫性量值會評估語言模型在回應中產生語意自然、流暢且類似真人言語文字的能力。
使用時機? 評估模型產生的回應在真實世界應用程式中的可讀性以及對使用者的友善程度。
需要哪些輸入? 問題、產生的答案

大型語言模型判斷用來評分此計量的內建提示:

Coherence of an answer is measured by how well all the sentences fit together and sound naturally as a whole. Consider the overall quality of the answer when evaluating coherence. Given the question and answer, score the coherence of answer between one to five stars using the following rating scale: 

One star: the answer completely lacks coherence 

Two stars: the answer mostly lacks coherence 

Three stars: the answer is partially coherent 

Four stars: the answer is mostly coherent 

Five stars: the answer has perfect coherency 

This rating value should always be an integer between 1 and 5. So the rating produced should be 1 or 2 or 3 or 4 or 5. 

AI 輔助:流暢度

分數特性 分數詳細資料
分數範圍 整數 [1-5]:其中 1 為不佳,5 為良好
此計量為何? 測量生成式 AI 預測答案的文法熟練度。
如何運作? 流暢度量值會評估產生的文字符合文法規則、語法結構和運用適當詞彙,從而產生語言上正確回應的程度。
使用時機? 此量值適用於評估 AI 所產生文字的語言正確性,確保在所產生的回應遵循適當的文法規則、語法結構和詞彙使用方式。
需要哪些輸入? 問題、產生的答案

大型語言模型判斷用來評分此計量的內建提示:

Fluency measures the quality of individual sentences in the answer, and whether they are well-written and grammatically correct. Consider the quality of individual sentences when evaluating fluency. Given the question and answer, score the fluency of the answer between one to five stars using the following rating scale: 

One star: the answer completely lacks fluency 

Two stars: the answer mostly lacks fluency 

Three stars: the answer is partially fluent 

Four stars: the answer is mostly fluent 

Five stars: the answer has perfect fluency 

This rating value should always be an integer between 1 and 5. So the rating produced should be 1 or 2 or 3 or 4 or 5. 

AI 輔助:擷取分數

分數特性 分數詳細資料
分數範圍 浮點數 [1-5]:其中 1 是不佳,5 是良好
此計量為何? 測量模型所擷取文件與指定問題相關和直接相關的程度。
如何運作? 擷取分數會測量所擷取文件與使用者問題 (摘要自整個交談歷程記錄) 的品質和相關性。 步驟:步驟 1:將使用者查詢依照意圖細分,從使用者查詢擷取意圖,例如「Azure Linux VM 和 Azure Windows VM 的價格為何?」 -> 意圖會是 [「Azure Linux VM 的定價為何?」、「Azure Windows VM 的定價為何?」]。 步驟 2:針對使用者查詢的每個意圖,要求模型評估意圖本身或意圖答案是否存在,或是否可從擷取的文件推斷。 答案可為「否」或「是,文件 [doc1]、[doc2]...」。 「是」表示所擷取的文件與意圖或意圖的答案有關聯性,反之亦然。 步驟 3:計算開頭為「是」的有答案意圖分數。 在此情況下,所有意圖都具有相同的重要性。 步驟 4:最後,將分數進行平方以懲罰錯誤。
使用時機? 若要確保所擷取的文件與回答使用者的問題高度相關時,請使用擷取分數。 此分數有助於確保所擷取內容的品質和適當性。
需要哪些輸入? 問題、內容、生成的答案

大型語言模型判斷用來評分此計量的內建提示:

A chat history between user and bot is shown below 

A list of documents is shown below in json format, and each document has one unique id.  

These listed documents are used as contex to answer the given question. 

The task is to score the relevance between the documents and the potential answer to the given question in the range of 1 to 5.  

1 means none of the documents is relevant to the question at all. 5 means either one of the document or combination of a few documents is ideal for answering the given question. 

Think through step by step: 

- Summarize each given document first 

- Determine the underlying intent of the given question, when the question is ambiguous, refer to the given chat history  

- Measure how suitable each document to the given question, list the document id and the corresponding relevance score.  

- Summarize the overall relevance of given list of documents to the given question after # Overall Reason, note that the answer to the question can soley from single document or a combination of multiple documents.  

- Finally, output "# Result" followed by a score from 1 to 5.  

  

# Question 

{{ query }} 

# Chat History 

{{ history }} 

# Documents 

---BEGIN RETRIEVED DOCUMENTS--- 

{{ FullBody }} 

---END RETRIEVED DOCUMENTS--- 

AI 輔助:GPT 相似度

分數特性 分數詳細資料
分數範圍 整數 [1-5]:其中 1 為不佳,5 為良好
此計量為何? 測量來源資料 (有根據事實) 句子與 AI 模型所產生回應之間的相似度。
如何運作? GPT 相似度量值會評估有根據事實句子 (或文件) 與 AI 模型所產生預測之間的相似度。 此計算需要為有根據事實和模型預測建立句子層級的嵌入,這種高維度向量表示法可擷取句子的語意和內容。
使用時機? 此量值適用於客觀評估 AI 模型的效能,特別是在可存取有根據事實回應的文字生成工作中。 GPT 相似度可讓您評估所產生文字語意與所需內容的相符程度,藉此協助量測模型的品質和精確度。
需要哪些輸入? 問題、有根據事實答案、產生的答案

大型語言模型判斷用來評分此計量的內建提示:

GPT-Similarity, as a metric, measures the similarity between the predicted answer and the correct answer. If the information and content in the predicted answer is similar or equivalent to the correct answer, then the value of the Equivalence metric should be high, else it should be low. Given the question, correct answer, and predicted answer, determine the value of Equivalence metric using the following rating scale: 

One star: the predicted answer is not at all similar to the correct answer 

Two stars: the predicted answer is mostly not similar to the correct answer 

Three stars: the predicted answer is somewhat similar to the correct answer 

Four stars: the predicted answer is mostly similar to the correct answer 

Five stars: the predicted answer is completely similar to the correct answer 

This rating value should always be an integer between 1 and 5. So the rating produced should be 1 or 2 or 3 or 4 or 5. 

傳統機器學習:F1 分數

分數特性 分數詳細資料
分數範圍 浮點數 [0-1]
此計量為何? 測量模型生成內容與有根據事實回答之間共用字數的比例。
如何運作? F1 分數會計算模型生成內容與有根據事實之間共用字數的比例。 比例計算是將所產生回應的每個字組與有根據事實答案的字組進行比較。 生成內容與事實之間的共用字數是 F1 分數的基礎:精確度是共用字數佔生成內容中總字數的比例,而記憶度是共用字數佔有根據事實總字數的比例。
使用時機? 當您想要結合模型回應記憶度和精確度的單一全面性計量時,請使用 F1 分數。 此分數可在回應擷取準確資訊方面,提供模型的效能平衡評估。
需要哪些輸入? 問題、有根據事實答案、產生的答案

下一步