本页面介绍了 Vertex AI RAG 引擎输出中的字段。输出包含以下主要部分: 以下示例展示了 为 以下示例展示了
retrieveContexts
:包含从源数据中检索到的文本块的相关信息。generateContent
:包含生成的回答和元数据,这些元数据显示了回答如何基于检索到的文本块。retrieveContexts
retrieveContexts
响应包含以下字段。字段
字段名称
说明
source_uri
原始源文件的 URI。
source_display_name
文件的显示名称。
text
与查询相关的文本块。
score
表示查询与文本块之间相似程度的分数。所用指标取决于您选择的
vectorDB
。对于 ragManagedDB
,得分是 COSINE_DISTANCE
。示例输出
retrieveContexts
响应的格式:contexts {
source_uri: "gs://sample_folder/hello_world.txt"
source_display_name: "hello_world.txt"
text: "Hello World!"
score: 0.60545359030757784
}
generateContent
generateContent
API 定义的大部分字段都可以在响应正文中找到。字段
grounding_metadata
对象包含以下字段:
text
:由 Gemini 生成的回答。grounding_chunks
:Vertex AI RAG Engine 返回的与查询相关的文本块列表。每个块对象包含以下字段:
retrieved_context
:一个对象,包含用于确定生成内容的基础的文本块。它包含以下字段:
uri
:原始数据的 source_uri
。title
:原始文件的 source_display_name
。text
:用于为 Gemini 回答提供依据的文本块。grounding_supports
:一个列表,用于描述生成的回答的各个部分与依据块之间的关系。每个条目都包含以下字段:
segment
:一个对象,用于描述生成回答中基于源数据的片段。它包含以下字段:
start_index
:已根据事实依据的文本段的起始字符索引。如果省略此字段,则索引为 0
。end_index
:已根据事实依据确定的文本段的结束字符索引。text
:接地段的文本。grounding_chunk_indices
:一个索引列表,用于指向 grounding_chunks
中用于锚定文本段的块。索引从 0
开始。一个片段可以由多个块提供依据。confidence_scores
:置信度分数列表。每个得分都表示文本段与 grounding_chunk_indices
中相应块的关联程度。最高分为 1.0
。仅包含置信度得分不低于 0.6
的块。示例输出
generateContent
响应的格式,重点是 grounding_metadata
: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
}
}
}
后续步骤
Vertex AI RAG Engine 的检索和生成输出
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-19。