本頁說明如何使用 Vertex AI Search 剖析及分塊處理文件。
您可以設定剖析或分塊設定,以便:
指定 Vertex AI Search 解析內容的方式。將非結構化內容上傳至 Vertex AI Search 時,可以指定剖析方式。Vertex AI Search 提供數位剖析器、PDF 專用的 OCR 剖析器,以及版面配置剖析器。您也可以自備已剖析的文件。如果文件含有豐富的內容和結構元素 (例如章節、段落、表格、圖片和清單),建議使用版面配置剖析器,從文件中擷取這些元素,以供搜尋和生成回覆。
請參閱「透過剖析功能提升內容偵測準確度」。
將 Vertex AI Search 用於檢索增強生成 (RAG)。 使用上傳至 Vertex AI Search 應用程式的相關資料,提升 LLM 的輸出內容品質。如要這麼做,請開啟文件分塊功能,將資料編列為索引塊,提升關聯性並降低 LLM 的運算負載。您也會開啟版面配置剖析器,偵測標題和清單等文件元素,改善文件分塊方式。
如要瞭解如何將文件分塊以供 RAG 使用,以及如何在搜尋要求中傳回分塊,請參閱「將文件分塊以供 RAG 使用」。
剖析文件
您可以透過下列方式控制內容剖析:
指定剖析器類型。您可以根據檔案類型指定要套用的剖析類型:
- 數位剖析器。除非指定其他剖析器類型,否則所有檔案類型預設都會啟用數位剖析器。如果資料存放區未指定其他預設剖析器,或指定的剖析器不支援所擷取文件的檔案類型,數位剖析器就會處理擷取的文件。
- PDF 的 OCR 剖析。如果打算上傳掃描的 PDF 或含有圖片文字的 PDF,可以開啟 OCR 剖析器,提升 PDF 索引品質。請參閱本文的「PDF 的 OCR 剖析器」一節。
- 版面配置剖析器。如果您打算將 Vertex AI Search 用於 RAG,請為 HTML、PDF 或 DOCX 檔案啟用版面配置剖析器。如要瞭解這個剖析器及如何啟用,請參閱「為 RAG 建立文件區塊」。
使用自行剖析的文件。(僅限允許清單中的使用者搶先體驗) 如果您已剖析非結構化文件,可以將預先剖析的內容匯入 Vertex AI Search。請參閱「自備已剖析的文件」。
剖析器適用情形比較
下表列出各剖析器支援的文件類型,並顯示各剖析器可偵測及剖析的元素。
檔案類型 | 數位剖析器 | OCR 剖析器 | 版面配置剖析器 |
---|---|---|---|
HTML | 偵測段落元素 | 不適用 | 偵測段落、表格、圖片、清單、標題和標題元素 |
偵測段落 (數位文字) 元素 | 偵測段落元素 | 偵測段落、表格、圖片、標題和標題元素 | |
DOCX (預先發布版) | 偵測段落元素 | 不適用 | 偵測段落、表格、圖片、清單、標題、標題元素 |
PPTX (預先發布版) | 偵測段落元素 | 不適用 | 偵測段落、表格、圖片、清單、標題、標題元素 |
TXT | 偵測段落元素 | 不適用 | 不適用 |
XLSX (預覽) | 偵測段落元素 | 不適用 | 偵測段落、表格、標題、章節標題元素 |
數位剖析器
數位剖析器會從文件中擷取機器可讀取的文字。這項功能會偵測文字區塊,但不會偵測表格、清單和標題等文件元素。
如果您在建立資料儲存庫時未指定其他剖析器做為預設剖析器,或是指定的剖析器不支援上傳的檔案類型,系統就會使用數位剖析器做為預設剖析器。
PDF 的 OCR 剖析器
如果 PDF 無法搜尋 (例如掃描的 PDF 或內含圖片的 PDF,如資訊圖表),建議您在建立資料存放區時開啟光學字元辨識 (OCR) 處理功能。這可讓 Vertex AI Search 擷取段落元素。
如果您有可搜尋的 PDF 或其他數位格式,且內容大多是機器可讀取的文字,通常不需要使用 OCR 剖析器。不過,如果 PDF 包含無法搜尋的文字 (例如掃描文字或資訊圖表) 和機器可解讀的文字,您可以在指定 OCR 剖析器時,將 useNativeText
欄位設為 true。在這種情況下,系統會將機器可讀取的文字與 OCR 剖析輸出內容合併,以提升文字擷取品質。
如果自訂搜尋應用程式使用非結構化資料儲存庫,即可使用 OCR 處理功能。
OCR 處理器可以剖析 PDF 檔案的前 500 頁。超過 500 頁上限的網頁不會處理。
版面配置剖析器
Vertex AI Search 可透過版面配置剖析功能,偵測 PDF 和 HTML 的版面配置。DOCX 檔案支援功能為預先發布版。Vertex AI Search 接著會識別文字區塊、表格、清單等內容元素,以及標題和標題等結構元素,並使用這些元素定義文件的組織和階層。
您可以為所有檔案類型開啟版面配置剖析功能,也可以指定要為哪些檔案類型開啟這項功能。版面配置剖析器會偵測段落、表格、清單等內容元素,以及標題、標題、頁首、註腳等結構元素。
只有在對 RAG 使用文件分塊功能時,才能使用版面配置剖析器。開啟文件分塊功能後,Vertex AI Search 會在擷取文件時將文件分成多個區塊,並以區塊形式傳回文件。偵測文件版面配置可進行內容感知分塊,並提升與文件元素相關的搜尋和答案生成作業。如要進一步瞭解如何將文件分塊,以用於 RAG,請參閱「將文件分塊,以用於 RAG」。
圖片註解 (預先發布版功能)
如果啟用圖片註解,系統在來源文件中偵測到圖片時,會將圖片的說明 (註解) 和圖片本身指派給一個區塊。註解會決定是否要在搜尋結果中傳回區塊。如果系統生成答案,註解可做為答案的來源。
版面配置剖析器可偵測下列圖片類型:BMP、GIF、JPEG、PNG 和 TIFF。
表格註解
如果啟用表格註解功能,系統在來源文件中偵測到表格時,會將表格說明 (註解) 和表格本身指派給一個區塊。註解會決定是否要在搜尋結果中傳回區塊。如果系統生成答案,註解可做為答案的來源。
排除 HTML 內容
使用 HTML 文件的版面配置剖析器時,您可以排除特定部分的 HTML 內容,避免系統處理這些內容。如要提升搜尋應用程式和 RAG 應用程式的資料品質,可以排除樣板或區段,例如導覽選單、頁首、頁尾或側欄。
為此,layoutParsingConfig
提供下列欄位:
excludeHtmlElements
:要排除的 HTML 標記清單。 系統會排除這些標記內的內容。excludeHtmlClasses
:要排除的 HTML 類別屬性清單。含有這些類別屬性的 HTML 元素及其內容都會遭到排除。excludeHtmlIds
:要排除的 HTML 元素 ID 屬性清單。系統會排除具有這些 ID 屬性的 HTML 元素及其內容。
指定預設剖析器
建立資料儲存庫時,加入 documentProcessingConfig
物件,即可為該資料儲存庫指定預設剖析器。如果未加入 documentProcessingConfig.defaultParsingConfig
,系統會使用數位剖析器。如果指定的剖析器不適用於檔案類型,系統也會使用數位剖析器。
REST
如要指定預設剖析器,請按照下列步驟操作:
使用 API 建立搜尋資料儲存庫時,請在資料儲存庫建立要求中加入
documentProcessingConfig.defaultParsingConfig
。您可以指定 OCR 剖析器、版面配置剖析器或數位剖析器:如要指定 PDF 的 OCR 剖析器,請按照下列步驟操作:
"documentProcessingConfig": { "defaultParsingConfig": { "ocrParsingConfig": { "useNativeText": "NATIVE_TEXT_BOOLEAN" } } }
NATIVE_TEXT_BOOLEAN
為選填欄位。只有在擷取 PDF 時才需要設定。如果設為true
,系統會為 OCR 剖析器啟用機器可讀文字處理功能。預設值為false
。
如要指定版面配置剖析器,請按照下列步驟操作:
"documentProcessingConfig": { "defaultParsingConfig": { "layoutParsingConfig": {} } }
如要指定數位剖析器,請按照下列步驟操作:
"documentProcessingConfig": { "defaultParsingConfig": { "digitalParsingConfig": {} } }
控制台
透過控制台建立搜尋資料儲存庫時,可以指定預設剖析器。
範例
以下範例會在建立資料儲存區時指定 OCR 剖析器為預設剖析器。由於 OCR 剖析器僅適用於 PDF 檔案,因此系統會使用 OCR 剖析器處理所有擷取的 PDF 檔案,並使用數位剖析器處理其他檔案類型。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: exampleproject" \
"https://discoveryengine.googleapis.com/v1/projects/exampleproject/locations/global/collections/default_collection/dataStores?dataStoreId=datastore123" \
-d '{
"displayName": "exampledatastore",
"industryVertical": "GENERIC",
"solutionTypes": ["SOLUTION_TYPE_SEARCH"],
"contentConfig": "CONTENT_REQUIRED",
"documentProcessingConfig": {
"defaultParsingConfig": {
"ocrParsingConfig": {
"useNativeText": "false"
}
}
}
}'
指定檔案類型的剖析器覆寫
您可以指定特定檔案類型 (PDF、HTML 或 DOCX) 應由預設剖析器以外的剖析器剖析。如要這麼做,請在資料儲存庫建立要求中加入 documentProcessingConfig
欄位,並指定覆寫剖析器。如果未指定預設剖析器,系統會預設使用數位剖析器。
REST
如要指定檔案類型專屬的剖析器覆寫,請按照下列步驟操作:
使用 API 建立搜尋資料儲存庫時,請在資料儲存庫建立要求中加入
documentProcessingConfig.defaultParsingConfig
。您可以為
pdf
、html
或docx
指定剖析器:"documentProcessingConfig": { "parsingConfigOverrides": { "FILE_TYPE": { PARSING_CONFIG }, } }
更改下列內容:
FILE_TYPE
:可接受的值為pdf
、html
和docx
。PARSING_CONFIG
:指定要套用至檔案類型的剖析器設定。您可以指定 OCR 剖析器、版面配置剖析器或數位剖析器:如要指定 PDF 的 OCR 剖析器,請按照下列步驟操作:
"ocrParsingConfig": { "useNativeText": "NATIVE_TEXT_BOOLEAN" }
NATIVE_TEXT_BOOLEAN
:選用。只有在擷取 PDF 時才需要設定。如果設為true
,系統會為 OCR 剖析器啟用機器可讀文字處理功能。預設值為false
。
如要指定版面配置剖析器,請按照下列步驟操作:
"layoutParsingConfig": {}
如要指定數位剖析器,請按照下列步驟操作:
"documentProcessingConfig": { "defaultParsingConfig": { "digitalParsingConfig": {} } }
控制台
透過控制台建立搜尋資料儲存庫時,您可以為特定檔案類型指定剖析器覆寫。
範例
以下範例會在建立資料儲存區時指定,PDF 檔案應由 OCR 剖析器處理,HTML 檔案則應由版面配置剖析器處理。在這種情況下,數位剖析器會處理 PDF 和 HTML 檔案以外的任何檔案。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: exampleproject" \
"https://discoveryengine.googleapis.com/v1/projects/exampleproject/locations/global/collections/default_collection/dataStores?dataStoreId=datastore123" \
-d '{
"displayName": "exampledatastore",
"industryVertical": "GENERIC",
"solutionTypes": ["SOLUTION_TYPE_SEARCH"],
"contentConfig": "CONTENT_REQUIRED",
"documentProcessingConfig": {
"parsingConfigOverrides": {
"pdf": {
"ocrParsingConfig": {
"useNativeText": "false"
},
},
"html": {
"layoutParsingConfig": {}
}
}
}
}'
編輯現有資料儲存庫的文件剖析設定
如果已有資料儲存庫,可以變更預設剖析器,並新增檔案格式例外狀況。不過,更新後的剖析器設定只會套用至匯入資料存放區的新文件。資料儲存庫中已有的文件不會使用新設定重新剖析。
如要變更資料儲存庫的文件剖析設定,請按照下列步驟操作:
前往 Google Cloud 控制台的「AI Applications」頁面。
在導覽選單中,按一下「資料儲存庫」。
在「名稱」欄中,點選要編輯的資料儲存庫。
在「處理設定」分頁中,編輯「文件剖析」設定。
「文件分塊」設定無法變更。如果資料儲存庫未啟用文件分塊功能,就無法選擇版面配置剖析器。
按一下「提交」。
設定版面配置剖析器,排除 HTML 內容
您可以指定 documentProcessingConfig.defaultParsingConfig.layoutParsingConfig
中的 excludeHtmlElements
、excludeHtmlClasses
或 excludeHtmlIds
,排除 HTML 內容。
REST
如要排除特定 HTML 內容,避免版面配置剖析器處理,請按照下列步驟操作:
使用 API 建立搜尋資料儲存庫時,請在資料儲存庫建立要求中加入
documentProcessingConfig.defaultParsingConfig.layoutParsingConfig
。如要排除特定 HTML 標記類型,請使用:
"documentProcessingConfig": { "defaultParsingConfig": { "layoutParsingConfig": { "excludeHtmlElements": ["HTML_TAG_1","HTML_TAG_2","HTML_TAG_N"] } } }
將 HTML_TAG 變數換成代碼名稱,例如
nav
和footer
。如要排除特定 HTML 元素類別屬性,請使用:
"documentProcessingConfig": { "defaultParsingConfig": { "layoutParsingConfig": { "excludeHtmlClasses": ["HTML_CLASS_1","HTML_CLASS_2","HTML_CLASS_N"] } } }
將 HTML_CLASS 變數替換為類別屬性,例如
overlay
和screenreader
。如要排除特定 HTML 元素 ID 屬性,請使用:
"documentProcessingConfig": { "defaultParsingConfig": { "layoutParsingConfig": { "excludeHtmlIds": ["HTML_ID_1","HTML_ID_2","HTML_ID_N"] } } }
將 HTML_ID 變數替換為 ID 屬性,例如
cookie-banner
。
範例
這個範例指定當版面配置剖析器處理 HTML 檔案時,剖析器會略過下列項目:
HTML 元素標記:
header
、footer
、nav
和aside
overlays
和screenreader
類型的 HTML 元素類別屬性屬性 ID 為
cookie-banner
的任何元素
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: exampleproject" \
"https://discoveryengine.googleapis.com/v1/projects/exampleproject/locations/global/collections/default_collection/dataStores?dataStoreId=datastore123" \
-d '{
"displayName": "exampledatastore",
"industryVertical": "GENERIC",
"solutionTypes": ["SOLUTION_TYPE_SEARCH"],
"contentConfig": "CONTENT_REQUIRED",
"documentProcessingConfig": {
"defaultParsingConfig": {
"layoutParsingConfig": {
"excludeHtmlElements": ["header", "footer", "nav", "aside"],
"excludeHtmlClasses": ["overlays", "screenreader"],
"excludeHtmlIds": ["cookie-banner"]
}
}
}
}'
以 JSON 格式取得已剖析的文件
呼叫 getProcessedDocument
方法並指定 PARSED_DOCUMENT
做為處理後的文件類型,即可取得 JSON 格式的剖析文件。如果您需要將剖析的文件上傳至其他位置,或是決定使用「自備剖析文件」功能將剖析的文件重新匯入 AI 應用程式,以 JSON 格式取得剖析的文件會很有幫助。
REST
如要以 JSON 格式取得已剖析的文件,請按照下列步驟操作:
呼叫
getProcessedDocument
方法:curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents/DOCUMENT_ID:getProcessedDocument?processed_document_type=PARSED_DOCUMENT"
更改下列內容:
PROJECT_ID
:專案 ID。DATA_STORE_ID
:資料儲存庫的 ID。DOCUMENT_ID
:要取得的文件 ID。
帶入自行剖析的文件
您可以將預先剖析的非結構化文件匯入 Vertex AI Search 資料儲存庫。舉例來說,您可以自行剖析 PDF,然後匯入剖析結果,而非匯入原始 PDF 文件。這樣一來,您就能以結構化方式匯入文件,確保搜尋和答案生成功能可取得文件版面配置和元素資訊。
剖析後的非結構化文件會以 JSON 格式表示,其中會使用一連串的文字、表格和清單區塊描述非結構化文件。匯入剖析完的非結構化文件資料時,請使用與匯入其他類型非結構化文件 (例如 PDF) 相同的方式匯入 JSON 檔案。開啟這項功能後,只要上傳的 JSON 檔案採用 application/json
MIME 類型或 .JSON 副檔名,系統就會將其視為已剖析的文件。
如要啟用這項功能及瞭解如何使用,請與 Google 帳戶團隊聯絡。
將文件分塊,供 RAG 使用
根據預設,Vertex AI Search 會針對文件檢索進行最佳化,也就是搜尋應用程式會在每次搜尋結果中傳回 PDF 或網頁等文件。
如果自訂搜尋應用程式使用非結構化資料儲存庫,即可使用文件分塊功能。
您可以改為針對 RAG 最佳化 Vertex AI Search,主要用途是使用自訂資料增強 LLM 輸出內容。開啟文件分塊功能後,Vertex AI Search 會將文件分成多個區塊。在搜尋結果中,搜尋應用程式可以傳回相關資料區塊,而非完整文件。使用資料塊進行 RAG 可提高 LLM 回覆的關聯性,並減少 LLM 的運算負載。
如要將 Vertex AI Search 用於 RAG,請按照下列步驟操作:
限制
分塊功能有以下限制:
- 建立資料儲存庫後,就無法開啟或關閉文件分塊。
- 如果資料儲存庫已啟用文件分塊功能,您可以要求搜尋文件,而非分塊。不過,如果資料儲存庫已啟用文件分塊功能,就不適合用來傳回文件。系統會將區塊匯總為文件,然後傳回文件。
- 文件分塊功能啟用後,公開測試版支援搜尋摘要和後續追問搜尋功能,但正式版不支援。
文件分塊選項
本節說明您指定的選項,可開啟文件分塊功能。
建立資料儲存庫時,請開啟下列選項,讓 Vertex AI Search 將文件編入索引。
可辨識版面的文件分塊。如要開啟這項選項,請在資料儲存庫建立要求中加入
documentProcessingConfig
欄位,並指定ChunkingConfig.LayoutBasedChunkingConfig
。開啟「以版面配置為準的文件分塊」後,Vertex AI Search 會偵測文件版面配置,並在分塊時納入考量。這有助於提升語意連貫性,並減少內容中的雜訊,進而改善檢索和 LLM 生成作業。同一區塊中的所有文字都來自相同的版面配置實體,例如標題、副標題和清單。
版面配置剖析。如要啟用這個選項,請在建立資料儲存庫時指定
ParsingConfig.LayoutParsingConfig
。版面配置剖析器會偵測 PDF、HTML 和 DOCX 檔案的版面配置。這項功能會識別文字區塊、表格、清單、標題和標題等元素,並使用這些元素定義文件的結構和階層。
如要進一步瞭解版面配置剖析,請參閱「版面配置剖析」。
開啟文件分塊功能
如要啟用文件分塊功能,請在資料儲存庫建立要求中加入 documentProcessingConfig
物件,並啟用可辨識版面的文件分塊和版面剖析功能。
REST
如要開啟文件分塊功能,請按照下列步驟操作:
使用 API 建立搜尋資料儲存庫時,請在資料儲存庫建立要求中加入
documentProcessingConfig.chunkingConfig
物件。"documentProcessingConfig": { "chunkingConfig": { "layoutBasedChunkingConfig": { "chunkSize": CHUNK_SIZE_LIMIT, "includeAncestorHeadings": HEADINGS_BOOLEAN, } }, "defaultParsingConfig": { "layoutParsingConfig": {} } }
更改下列內容:
CHUNK_SIZE_LIMIT
:選用。每個區塊的權杖大小上限。預設值為 500。支援的值為 100 到 500 (含)。HEADINGS_BOOLEAN
:選用。決定是否要在每個區塊中加入標題。預設值為false
。在文件中間的分塊中附加標題和各層級的標題,有助於避免在擷取和排序分塊時遺失脈絡。
控制台
透過控制台建立搜尋資料儲存庫時,可以開啟文件分塊功能。
自備區塊 (預先發布版,僅限許可清單使用者)
如果您已將自有文件分塊,可以將這些文件上傳至 Vertex AI Search,不必開啟文件分塊選項。
自備區塊是預先發布版功能,僅限允許清單中的使用者使用。如要使用這項功能,請與 Google 帳戶團隊聯絡。
列出文件的區塊
如要列出特定文件的所有區塊,請呼叫 Chunks.list
方法。
REST
如要列出文件的區塊,請按照下列步驟操作:
呼叫
Chunks.list
方法:curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents/DOCUMENT_ID/chunks"
更改下列內容:
PROJECT_ID
:專案 ID。DATA_STORE_ID
:資料儲存庫的 ID。DOCUMENT_ID
:要列出區塊的文件 ID。
從已處理的文件取得 JSON 格式的區塊
如要以 JSON 格式取得特定文件的所有區塊,請呼叫 getProcessedDocument
方法。如果需要將區塊上傳至其他位置,或是決定使用「自備區塊」功能將區塊重新匯入 AI 應用程式,以 JSON 格式取得區塊會很有幫助。
REST
如要取得文件的 JSON 區塊,請按照下列步驟操作:
呼叫
getProcessedDocument
方法:curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents/DOCUMENT_ID:getProcessedDocument?processed_document_type=CHUNKED_DOCUMENT"
更改下列內容:
PROJECT_ID
:專案 ID。DATA_STORE_ID
:資料儲存庫的 ID。DOCUMENT_ID
:要從中取得區塊的文件 ID。
取得特定區塊
如要取得特定區塊,請呼叫 Chunks.get
方法。
REST
如要取得特定區塊,請按照下列步驟操作:
呼叫
Chunks.get
方法:curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents/DOCUMENT_ID/chunks/CHUNK_ID"
更改下列內容:
PROJECT_ID
:專案 ID。DATA_STORE_ID
:資料儲存庫的 ID。DOCUMENT_ID
:區塊所屬文件的 ID。CHUNK_ID
:要傳回的區塊 ID。
在搜尋要求中傳回區塊
確認資料已正確分塊後,Vertex AI Search 就能在搜尋結果中傳回分塊資料。
回應會傳回與搜尋查詢相關的區塊。此外,你也可以選擇傳回來源文件中相關區塊前後的相鄰區塊。相鄰的區塊可提供背景資訊並提高準確度。
REST
如要取得分塊資料:
發出搜尋要求時,請將
ContentSearchSpec.SearchResultMode
指定為chunks
。contentSearchSpec": { "searchResultMode": "RESULT_MODE", "chunkSpec": { "numPreviousChunks": NUMBER_OF_PREVIOUS_CHUNKS, "numNextChunks": NUMBER_OF_NEXT_CHUNKS } }
RESULT_MODE
:決定搜尋結果是以完整文件還是以區塊形式傳回。如要取得區塊,資料儲存庫必須開啟文件分塊功能。可接受的值為documents
和chunks
。如果資料儲存區已啟用文件分塊功能,預設值為chunks
。NUMBER_OF_PREVIOUS_CHUNKS
:要傳回的區塊數量,這些區塊緊接在相關區塊之前。允許的最大值為 5。NUMBER_OF_NEXT_CHUNKS
:要傳回的區塊數量,這些區塊會緊接在相關區塊之後。允許的最大值為 5。
範例
以下搜尋查詢要求範例會將 SearchResultMode
設為 chunks
,要求一個前一個區塊和一個下一個區塊,並使用 pageSize
將結果數量限制為單一相關區塊。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: exampleproject" \
"https://discoveryengine.googleapis.com/v1/projects/exampleproject/locations/global/collections/default_collection/dataStores/datastore123/servingConfigs/default_search:search" \
-d '{
"query": "animal",
"pageSize": 1,
"contentSearchSpec": {
"searchResultMode": "CHUNKS",
"chunkSpec": {
"numPreviousChunks": 1,
"numNextChunks": 1
}
}
}'
以下範例顯示範例查詢傳回的回應。回應包含相關分塊、前一個和下一個分塊、原始文件的中繼資料,以及每個分塊的衍生來源文件頁面範圍。
回應
{ "results": [ { "chunk": { "name": "projects/961309680810/locations/global/collections/default_collection/dataStores/allie-pdf-adjacent-chunks_1711394998841/branches/0/documents/0d8619f429d7f20b3575b14cd0ad0813/chunks/c17", "id": "c17", "content": "\n# ESS10: Stakeholder Engagement and Information Disclosure\nReaders should also refer to ESS10 and its guidance notes, plus the template available for a stakeholder engagement plan. More detail on stakeholder engagement in projects with risks related to animal health is contained in section 4 below. The type of stakeholders (men and women) that can be engaged by the Borrower as part of the project's environmental and social assessment and project design and implementation are diverse and vary based on the type of intervention. The stakeholders can include: Pastoralists, farmers, herders, women's groups, women farmers, community members, fishermen, youths, etc. Cooperatives members, farmer groups, women's livestock associations, water user associations, community councils, slaughterhouse workers, traders, etc. Veterinarians, para-veterinary professionals, animal health workers, community animal health workers, faculties and students in veterinary colleges, etc. 8 \n# 4. Good Practice in Animal Health Risk Assessment and Management\n\n# Approach\nRisk assessment provides the transparent, adequate and objective evaluation needed by interested parties to make decisions on health-related risks associated with project activities involving live animals. As the ESF requires, it is conducted throughout the project cycle, to provide or indicate likelihood and impact of a given hazard, identify factors that shape the risk, and find proportionate and appropriate management options. The level of risk may be reduced by mitigation measures, such as infrastructure (e.g., diagnostic laboratories, border control posts, quarantine stations), codes of practice (e.g., good animal husbandry practices, on-farm biosecurity, quarantine, vaccination), policies and regulations (e.g., rules for importing live animals, ban on growth hormones and promotors, feed standards, distance required between farms, vaccination), institutional capacity (e.g., veterinary services, surveillance and monitoring), changes in individual behavior (e.g., hygiene, hand washing, care for animals). Annex 2 provides examples of mitigation practices. This list is not an exhaustive one but a compendium of most practiced interventions and activities. The cited measures should take into account social, economic, as well as cultural, gender and occupational aspects, and other factors that may affect the acceptability of mitigation practices by project beneficiaries and other stakeholders. Risk assessment is reviewed and updated through the project cycle (for example to take into account increased trade and travel connectivity between rural and urban settings and how this may affect risks of disease occurrence and/or outbreak). Projects monitor changes in risks (likelihood and impact) b by using data, triggers or indicators. ", "documentMetadata": { "uri": "gs://table_eval_set/pdf/worldbank/AnimalHealthGoodPracticeNote.pdf", "title": "AnimalHealthGoodPracticeNote" }, "pageSpan": { "pageStart": 14, "pageEnd": 15 }, "chunkMetadata": { "previousChunks": [ { "name": "projects/961309680810/locations/global/collections/default_collection/dataStores/allie-pdf-adjacent-chunks_1711394998841/branches/0/documents/0d8619f429d7f20b3575b14cd0ad0813/chunks/c16", "id": "c16", "content": "\n# ESS6: Biodiversity Conservation and Sustainable Management of Living Natural Resources\nThe risks associated with livestock interventions under ESS6 include animal welfare (in relation to housing, transport, and slaughter); diffusion of pathogens from domestic animals to wildlife, with risks for endemic species and biodiversity (e.g., sheep and goat plague in Mongolia affecting the saiga, an endemic species of wild antelope); the introduction of new breeds with potential risk of introducing exotic or new diseases; and the release of new species that are not endemic with competitive advantage, potentially putting endemic species at risk of extinction. Animal welfare relates to how an animal is coping with the conditions in which it lives. An animal is in a good state of welfare if it is healthy, comfortable, well nourished, safe, able to express innate behavior, 7 Good Practice Note - Animal Health and related risks and is not suffering from unpleasant states such as pain, fear or distress. Good animal welfare requires appropriate animal care, disease prevention and veterinary treatment; appropriate shelter, management and nutrition; humane handling, slaughter or culling. The OIE provides standards for animal welfare on farms, during transport and at the time of slaughter, for their welfare and for purposes of disease control, in its Terrestrial and Aquatic Codes. The 2014 IFC Good Practice Note: Improving Animal Welfare in Livestock Operations is another example of practical guidance provided to development practitioners for implementation in investments and operations. Pastoralists rely heavily on livestock as a source of food, income and social status. Emergency projects to restock the herds of pastoralists affected by drought, disease or other natural disaster should pay particular attention to animal welfare (in terms of transport, access to water, feed, and animal health) to avoid potential disease transmission and ensure humane treatment of animals. Restocking also entails assessing the assets of pastoralists and their ability to maintain livestock in good conditions (access to pasture and water, social relationship, technical knowledge, etc.). Pastoralist communities also need to be engaged by the project to determine the type of animals and breed and the minimum herd size to be considered for restocking. \n# Box 5. Safeguarding the welfare of animals and related risks in project activities\nIn Haiti, the RESEPAG project (Relaunching Agriculture: Strengthening Agriculture Public Services) financed housing for goats and provided technical recommendations for improving their welfare, which is critical to avoid the respiratory infections, including pneumonia, that are serious diseases for goats. To prevent these diseases, requires optimal sanitation and air quality in herd housing. This involves ensuring that buildings have adequate ventilation and dust levels are reduced to minimize the opportunity for infection. Good nutrition, water and minerals are also needed to support the goats' immune function. The project paid particular attention to: (i) housing design to ensure good ventilation; (ii) locating housing close to water sources and away from human habitation and noisy areas; (iii) providing mineral blocks for micronutrients; (iv) ensuring availability of drinking water and clean food troughs. ", "documentMetadata": { "uri": "gs://table_eval_set/pdf/worldbank/AnimalHealthGoodPracticeNote.pdf", "title": "AnimalHealthGoodPracticeNote" }, "pageSpan": { "pageStart": 13, "pageEnd": 14 } } ], "nextChunks": [ { "name": "projects/961309680810/locations/global/collections/default_collection/dataStores/allie-pdf-adjacent-chunks_1711394998841/branches/0/documents/0d8619f429d7f20b3575b14cd0ad0813/chunks/c18", "id": "c18", "content": "\n# Scoping of risks\nEarly scoping of risks related to animal health informs decisions to initiate more comprehensive risk assessment according to the type of livestock interventions and activities. It can be based on the following considerations: • • • • Type of livestock interventions supported by the project (such as expansion of feed resources, improvement of animal genetics, construction/upgrading and management of post-farm-gate facilities, etc. – see also Annex 2); Geographic scope and scale of the livestock interventions; Human and animal populations that are likely to be affected (farmers, women, children, domestic animals, wildlife, etc.); and Changes in the project or project context (such as emerging disease outbreak, extreme weather or climatic conditions) that would require a re-assessment of risk levels, mitigation measures and their likely effect on risk reduction. Scenario planning can also help to identify project-specific vulnerabilities, country-wide or locally, and help shape pragmatic analyses that address single or multiple hazards. In this process, some populations may be identified as having disproportionate exposure or vulnerability to certain risks because of occupation, gender, age, cultural or religious affiliation, socio-economic or health status. For example, women and children may be the main caretakers of livestock in the case of 9 Good Practice Note - Animal Health and related risks household farming, which puts them into close contact with animals and animal products. In farms and slaughterhouses, workers and veterinarians are particularly exposed, as they may be in direct contact with sick animals (see Box 2 for an illustration). Fragility, conflict, and violence (FCV) can exacerbate risk, in terms of likelihood and impact. Migrants new to a geographic area may be immunologically naïve to endemic zoonotic diseases or they may inadvertently introduce exotic diseases; and refugees or internally displaced populations may have high population density with limited infrastructure, leaving them vulnerable to disease exposure. Factors such as lack of access to sanitation, hygiene, housing, and health and veterinary services may also affect disease prevalence, contributing to perpetuation of poverty in some populations. Risk assessment should identify populations at risk and prioritize vulnerable populations and circumstances where risks may be increased. It should be noted that activities that seem minor can still have major consequences. See Box 6 for an example illustrating how such small interventions in a project may have large-scale consequences. It highlights the need for risk assessment, even for simple livestock interventions and activities, and how this can help during the project cycle (from concept to implementation). ", "documentMetadata": { "uri": "gs://table_eval_set/pdf/worldbank/AnimalHealthGoodPracticeNote.pdf", "title": "AnimalHealthGoodPracticeNote" }, "pageSpan": { "pageStart": 15, "pageEnd": 16 } } ] } } } ], "totalSize": 61, "attributionToken": "jwHwjgoMCICPjbAGEISp2J0BEiQ2NjAzMmZhYS0wMDAwLTJjYzEtYWQxYS1hYzNlYjE0Mzc2MTQiB0dFTkVSSUMqUMLwnhXb7Ygtq8SKLa3Eii3d7Ygtj_enIqOAlyLm7Ygtt7eMLduPmiKN96cijr6dFcXL8xfdj5oi9-yILdSynRWCspoi-eyILYCymiLk7Ygt", "nextPageToken": "ANxYzNzQTMiV2MjFWLhFDZh1SMjNmMtADMwATL5EmZyMDM2YDJaMQv3yagQYAsciPgIwgExEgC", "guidedSearchResult": {}, "summary": {} }