本页介绍了 Vertex AI RAG Engine 输出的各个字段。
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 Engine 返回的块。 |
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 Engine 概览。