本頁說明 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 引擎簡介」。