Agent Retrieval (舊稱 向量搜尋 2.0) 提供 VertexRanker,用於語意重新排名,由 Ranking API 提供技術支援。
代理式檢索功能會使用倒數排名融合 (RRF) 擷取及融合候選結果,接著 VertexRanker 會使用專屬語意模型,根據自然語言查詢重新評分合併的候選結果。這能提升前 k 個結果的關聯性,尤其是單純搜尋會遺漏細微差異的查詢。重新排名作業會在伺服器端進行,並呼叫 BatchSearchDataObjects。不需要額外的用戶端連線或額外的來回。
VertexRanker
VertexRanker 已設為 BatchSearchDataObjectsRequest 物件 combine.ranker 欄位的重新排名器。您必須設定主要排序器 (僅支援 RRF)。重新排序器會在 RRF 融合步驟後執行,並將輸出內容替換為語意重新評分的清單。
下表列出排序器設定欄位。
| 欄位 | 必填 | 說明 |
|---|---|---|
combine.ranker.rrf.weights |
是 | 基礎搜尋結果 RRF 融合的權重。 |
combine.ranker.vertex_ranker.model |
是 | 排名模型名稱。支援的值:semantic-ranker-fast@latest、semantic-ranker-default@latest、semantic-ranker-fast-004、semantic-ranker-default-004。如要瞭解各項模型,請參閱「Ranking API 模型」。 |
combine.ranker.vertex_ranker.top_n |
是 | 從融合清單傳送至排序器的候選項目數量上限。有效值介於 1 到 1000 之間。 |
combine.ranker.vertex_ranker.text_record_spec.query |
是 | 排名器用來為記錄評分的自然語言查詢。 |
combine.ranker.vertex_ranker.text_record_spec.title_template |
是 | 範本字串 (例如 {title}) 會指定如何擷取 (建構) 各記錄的標題。使用點路徑指定資料欄位。 |
combine.ranker.vertex_ranker.text_record_spec.content_template |
是 | 範本字串 (例如 {body.text}) 會指定如何擷取 (建構) 每筆記錄的主要內容。使用點路徑指定資料欄位。 |
combine.top_k |
選用 | 重新排序後要傳回的最終結果數量。這個值必須小於或等於 vertex_ranker.top_n,且小於或等於 1000。 |
以下範例說明要求的主體。
{
"searches": [
{ "semantic_search": { "search_text": "running shoes", "search_field": "embedding", "task_type": "RETRIEVAL_QUERY", "top_k": 50 } },
{ "text_search": { "search_text": "running shoes", "data_field_names": ["title"], "top_k": 50 } }
],
"combine": {
"top_k": 10,
"ranker": {
"rrf": { "weights": [1.0, 1.0] },
"vertex_ranker": {
"model": "semantic-ranker-fast@latest",
"top_n": 50,
"text_record_spec": {
"query": "running shoes",
"title_template": "{title}",
"content_template": "{body.text}"
}
}
}
}
}
範本會使用點路徑指向資料物件資料欄位,例如 {title} 或 {nested.field}。這些欄位必須存在於集合結構定義中,否則要求會在驗證期間遭到拒絕。如果資料物件缺少提供的欄位,伺服器會以透明方式從儲存空間重新擷取完整記錄,以便填入範本。
配額和價格資訊
Agent Retrieval 的 VertexRanker 採用免費方案配額,並依用量計費。每項專案每 30 天可獲得免費的排名用量配額。用量未超出此額度時,不需支付任何費用。如果用量超過這個額度,則會按照標準 Ranking API 定價向用戶專案收費。
下表列出配額值。
| 項目 | 值 |
|---|---|
| 免費方案配額 | 每項消費者專案每 30 天 80,000 個排名單位。 |
| 超額用量 | 按照消費者專案的標準 Ranking API 定價計費。 |
| 每次重新排名呼叫的記錄數量上限 | 1000 (top_n 必須介於 [1, 1000] 和 top_k <= top_n 之間)。 |
達到免費方案配額後,要求不會失敗。80,000 個排名單元的配額用完後,後續的 VertexRanker 用量仍會繼續計費,並以超額用量計費。配額會在首次使用後 30 天重設。
排名單元的計算方式是根據傳送至排名器的記錄數量,以及標題和內容範本的大小,並採用與獨立 Ranking API 相同的計算方式。如需完整詳細資料,請參閱「Ranking API 定價」。
您必須先在用戶專案啟用 Discovery Engine,才能使用 VertexRanker。詳情請參閱「失敗條件」。
失敗處理和警告
VertexRanker 會盡可能重新排序。如果排名呼叫失敗,BatchSearchDataObjects RPC 仍會成功,並傳回 RRF 融合結果,並截斷至 top_k。失敗情形會回報在回應的 search_response_metadata.warnings 欄位中。系統會保留 Ranking API 的完整狀態碼。非預期狀態的警告代碼為 UNAVAILABLE,警告訊息為:"Reranking is temporarily unavailable. Returning fused (RRF) results without
semantic reranking."
失敗條件
在下列情況下,整個 BatchSearchDataObjects RPC 會失敗,並顯示 FAILED_PRECONDITION (不會備用 RRF)。
- 未啟用 Discovery Engine API:Ranking API 會傳回
FAILED_PRECONDITION,並顯示Discovery Engine API is not enabled for the consumer project /<N/>. Please enable the API and try again."訊息。 修正方式:在用戶專案啟用 Discovery Engine API。
客戶必須為消費者專案啟用 Discovery Engine,才能重新排名。
下表列出警告代碼、產生警告的一般原因,以及說明警告的訊息。
| 警告代碼 | 常見原因 | 警告訊息 |
|---|---|---|
RESOURCE_EXHAUSTED |
超過用戶專案的 Ranking API 配額。注意:超過 80,000 個排名單元的配額不會導致這項警告,而是會收取超額費用。 | <Quota exceeded message>; RankService.Rank call failed for consumer project <N> with request query: <query> and <model>: semantic-ranker-fast@latest number of records: <N> |
DEADLINE_EXCEEDED |
Ranker.Rank 未在要求期限內完成。 |
<deadline-exceeded message from Ranker.Rank>; RankService.Rank call failed for consumer project <N> with request query: <query> and <model>: semantic-ranker-fast@latest number of records: <N> |
UNAVAILABLE |
Ranker.Rank 傳回 UNAVAILABLE,或傳回非保留代碼 (例如 INTERNAL),該代碼會收合為 UNAVAILABLE。 |
如果基礎代碼為 UNAVAILABLE:"RankService.Rank call failed for consumer project...其他情況: "Reranking is temporarily unavailable. Returning fused (RRF) results without semantic reranking." |
FAILED_PRECONDITION |
Ranking API 傳回的任何 FAILED_PRECONDITION。 |
RankService.Rank call failed for consumer project <N> with request query: <query> and <model>: semantic-ranker-fast@latest number of records: <N> |
CANCELLED |
呼叫端在重新排名完成前取消了 BatchSearchDataObjects RPC。 |
<cancellation message from the cancelled RankService.Rank RPC>; RankService.Rank call failed for consumer project <N> with request query: <query> and <model>: semantic-ranker-fast@latest number of records: <N> |