本頁說明 Vertex AI RAG 引擎輸出內容的每個欄位。
retrieveContexts
本節將說明 retrieveContexts
API 中定義的每個欄位,並在程式碼範例中使用這些欄位。
欄位
欄位名稱 | 說明 |
---|---|
source_uri |
匯入 RAG 前的原始來源檔案。如果檔案是從 Cloud Storage 或 Google 雲端硬碟匯入,source_uri 是 Cloud Storage 或雲端硬碟中的原始檔案 URI。如果檔案已上傳,source_uri 是檔案的顯示名稱。 |
source_display_name |
檔案的顯示名稱。 |
text |
與查詢相關的文字區塊。 |
score |
查詢和文字區塊之間的相似度或距離。
相似度或距離取決於您選擇的 vectorDB 。如果是 ragManagedDB ,則分數為 COSINE_DISTANCE 。 |
輸出範例
這個程式碼範例示範如何使用這些欄位產生範例輸出內容。
contexts {
source_uri: "gs://sample_folder/hello_world.txt"
source_display_name: "hello_world.txt"
text: "Hello World!"
score: 0.60545359030757784
}
generateContent
為 generateContent
API 定義的大多數欄位都位於回應主體中。
欄位
本節將說明 generateContent
API 的 grounding_metadata
部分定義的每個欄位,並在範例程式碼中使用這些欄位。
欄位名稱 | 說明 |
---|---|
text |
Gemini 生成的回覆。 |
grounding_chunks |
Vertex AI RAG 引擎傳回的區塊。 |
retrieved_context |
重複欄位,可包含零或多個用於生成內容的區塊。 |
|
|
|
|
|
|
grounding_supports |
生成內容與基礎塊之間的關係。這是重複欄位。每個 grounding_supports 欄位都會顯示生成的內容中某個文字片段,與 RAG 擷取的某個或多個文字塊之間的關係。 |
segment |
生成文字中經過驗證的文字片段。 |
|
|
|
|
|
|
grounding_chunk_indices |
用來錨定文字區隔的區塊。可用於根據文字內容提供資訊的區塊不只一個。索引從 0 開始,代表 grounding_chunks 欄位中的第一個區塊。整個區塊都是地面。未指定做為回覆依據的區塊部分。 |
confidence_scores |
用於將文字錨定在特定區塊的分數。最高分為 1 ,分數越高,代表信心程度越高。每個分數都會對應至每個 grounding_chunk_indices 。輸出內容只會包含信心分數至少為 0.6 的區塊。 |
輸出範例
這個程式碼範例示範如何使用這些欄位產生範例輸出內容。
candidates {
content {
role: "model"
parts {
text: "The rectangle is red and the background is white. The rectangle appears to be on some type of document editing software. \n"
}
}
grounding_metadata {
grounding_chunks {
retrieved_context {
uri: "a.txt"
title: "a.txt"
text: "Okay , I see a red rectangle on a white background . It looks like it\'s on some sort of document editing software. It has those small squares and circles around it, indicating that it\'s a selected object ."
}
}
grounding_chunks {
retrieved_context {
uri: "b.txt"
title: "b.txt"
text: "The video is identical to the last time I described it . It shows a blue rectangle on a white background."
}
}
grounding_chunks {
retrieved_context {
uri: "c.txt"
title: "c.txt"
text: "Okay , I remember the rectangle was blue in the past session . Now it is red.\n The red rectangle is still there . It \' s still in the same position on the white background, with the same handles around it. Nothing new is visible since last time.\n You \' re welcome . The red rectangle is still the only thing visible."
}
}
grounding_supports {
segment {
end_index: 49
text: "The rectangle is red and the background is white."
}
grounding_chunk_indices: 2
grounding_chunk_indices: 0
confidence_scores: 0.958192229
confidence_scores: 0.992316723
}
grounding_supports {
segment {
start_index: 50
end_index: 120
text: "The rectangle appears to be on some type of document editing software."
}
grounding_chunk_indices: 0
confidence_scores: 0.98374176
}
}
}
後續步驟
- 如要進一步瞭解 API 參考資料中的 RAG 情境,請參閱「情境」。
- 如要進一步瞭解 RAG,請參閱 Vertex AI RAG 引擎總覽。