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:49text:"The rectangle is red and the background is white."}grounding_chunk_indices:2grounding_chunk_indices:0confidence_scores:0.958192229
confidence_scores:0.992316723
}grounding_supports{segment{start_index:50end_index:120text:"The rectangle appears to be on some type of document editing software."}grounding_chunk_indices:0confidence_scores:0.98374176
}}}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[],[],null,["This page explains each field of the output from Vertex AI RAG Engine.\n\n`retrieveContexts`\n\nThis section describes each field defined in the `retrieveContexts` API and\nuses the fields in sample code.\n\nFields\n\n| **Field name** | **Description** |\n|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `source_uri` | The original source file before it's imported into RAG. If the file is imported from Cloud Storage or Google Drive, `source_uri` is the original file URI in Cloud Storage or Drive. If the file is uploaded, `source_uri` is the file's display name. |\n| `source_display_name` | The file's display name. |\n| `text` | The text chunk that is relevant to the query. |\n| `score` | The similarity or distance between the query and the text chunk. The similarity or distance depends on the `vectorDB` that you choose. For `ragManagedDB`, the score is the `COSINE_DISTANCE`. |\n\nSample output\n\nThis code sample demonstrates the use of the fields to produce sample output. \n\n contexts {\n source_uri: \"gs://sample_folder/hello_world.txt\"\n source_display_name: \"hello_world.txt\"\n text: \"Hello World!\"\n score: 0.60545359030757784\n }\n\n`generateContent`\n\nMost of the fields defined for the `generateContent` API can found in the\n[Response body](/vertex-ai/generative-ai/docs/model-reference/inference#response).\n\nFields\n\nThis section describes each field defined in the `grounding_metadata` part of\nthe `generateContent` API and uses the fields in sample code.\n\n| **Field name** | **Description** |\n|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | The response generated by Gemini. |\n| `grounding_chunks` | The chunks returned by Vertex AI RAG Engine. |\n| `retrieved_context` | A repeated field that can have zero or more chunks used to ground the generated content. |\n| - `uri` | - The `source_uri` specifies where the data is originally stored. |\n| - `title` | - The `source_display_name` is the filename or display name of the original file. |\n| - `text` | - The text chunk is used to ground the Gemini response. |\n| `grounding_supports` | The relationship between the generated content and the grounding chunks. This is a repeated field. Each `grounding_supports` field shows the relationship between one text segment of the generated context and one or more text chunks that are RAG retrieved. |\n| `segment` | The grounded text segment of the generated text. |\n| - `start_index` | - The first index of the grounded text. If the `start_index` is missing, then the `start_index` is `0`. |\n| - `end_index` | - The last index of the grounded text. |\n| - `text` | - The grounded text. |\n| `grounding_chunk_indices` | The chunk that's used to ground the text segment. There can be more than one chunk used to ground the text. The index starts from `0`, which represents the first chunk in the `grounding_chunks` field. The ground is on the entire chunk. The part of the chunk that grounds the response isn't specified. |\n| `confidence_scores` | The score that's used to ground the text on a given chunk. The highest score possible is `1` and the higher the score, the higher the confidence level. Each score matches each `grounding_chunk_indices`. Only the chunks with a confidence score of at least `0.6` are included in the output. |\n\nSample output\n\nThis code sample demonstrates the use of the fields to produce sample output. \n\n candidates {\n content {\n role: \"model\"\n parts {\n text: \"The rectangle is red and the background is white. The rectangle appears to be on some type of document editing software. \\n\"\n }\n }\n grounding_metadata {\n grounding_chunks {\n retrieved_context {\n uri: \"a.txt\"\n title: \"a.txt\"\n 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 .\"\n }\n }\n grounding_chunks {\n retrieved_context {\n uri: \"b.txt\"\n title: \"b.txt\"\n text: \"The video is identical to the last time I described it . It shows a blue rectangle on a white background.\"\n }\n }\n grounding_chunks {\n retrieved_context {\n uri: \"c.txt\"\n title: \"c.txt\"\n 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.\"\n }\n }\n grounding_supports {\n segment {\n end_index: 49\n text: \"The rectangle is red and the background is white.\"\n }\n grounding_chunk_indices: 2\n grounding_chunk_indices: 0\n confidence_scores: 0.958192229\n confidence_scores: 0.992316723\n }\n grounding_supports {\n segment {\n start_index: 50\n end_index: 120\n text: \"The rectangle appears to be on some type of document editing software.\"\n }\n grounding_chunk_indices: 0\n confidence_scores: 0.98374176\n }\n }\n }\n\nWhat's next\n\n- To learn more about RAG context in the API reference, see [Context](/vertex-ai/generative-ai/docs/reference/rest/v1/projects.locations/retrieveContexts).\n- To learn more about RAG, see [Vertex AI RAG Engine overview](/vertex-ai/generative-ai/docs/rag-overview)."]]