共用方式為


Azure AI 搜尋中的多向量欄位支援

備註

這項功能目前處於公開預覽狀態。 此預覽版在沒有服務等級協議的情況下提供,不建議用於生產工作負載。 可能不支援特定功能,或可能已經限制功能。 如需詳細資訊,請參閱 Microsoft Azure 預覽版增補使用條款

Azure AI 搜尋中的多重向量欄位支援功能可讓您在單一檔欄位中索引多個子向量。 這項功能對於多模式數據或長格式檔等使用案例而言非常有價值,其中以單一向量表示內容會導致遺失重要詳細數據。

局限性

  • 複雜欄位內的巢狀區塊不支援語意排名器。 因此,語意排名器不支援多向量欄位中的巢狀向量。

瞭解多向量場支援

傳統上,向量類型,例如 Collection(Edm.Single) 只能在最上層欄位中使用。 透過引進多向量欄位支援,您現在可以在複雜集合的巢狀欄位中使用向量類型,有效地允許多個向量與單一檔產生關聯。

單一檔最多可以包含 100 個向量,並跨所有複雜的集合字段。 向量欄位的巢狀結構僅支援一層深度。

具有多向量欄位的索引定義

這項功能不需要新的索引屬性。 以下是範例索引定義:

{
  "name": "multivector-index",
  "fields": [
    {
      "name": "id",
      "type": "Edm.String",
      "key": true,
      "searchable": true
    },
    {
      "name": "title",
      "type": "Edm.String",
      "searchable": true
    },
    {
      "name": "description",
      "type": "Edm.String",
      "searchable": true
    },
    {
      "name": "descriptionEmbedding",
      "type": "Collection(Edm.Single)",
      "dimensions": 3,
      "searchable": true,
      "retrievable": true,
      "vectorSearchProfile": "hnsw"
    },
    {
      "name": "scenes",
      "type": "Collection(Edm.ComplexType)",
      "fields": [
        {
          "name": "embedding",
          "type": "Collection(Edm.Single)",
          "dimensions": 3,
          "searchable": true,
          "retrievable": true,
          "vectorSearchProfile": "hnsw"
        },
        {
          "name": "timestamp",
          "type": "Edm.Int32",
          "retrievable": true
        },
        {
          "name": "description",
          "type": "Edm.String",
          "searchable": true,
          "retrievable": true
        },
        {
          "name": "framePath",
          "type": "Edm.String",
          "retrievable": true
        }
      ]
    }
  ]
}

樣本內嵌文件

以下範例文件說明如何在實務中使用多向量欄位:

{
  "id": "123",
  "title": "Non-Existent Movie",
  "description": "A fictional movie for demonstration purposes.",
  "descriptionEmbedding": [1, 2, 3],
  "releaseDate": "2025-08-01",
  "scenes": [
    {
      "embedding": [4, 5, 6],
      "timestamp": 120,
      "description": "A character is introduced.",
      "framePath": "nonexistentmovie\\scenes\\scene120.png"
    },
    {
      "embedding": [7, 8, 9],
      "timestamp": 2400,
      "description": "The climax of the movie.",
      "framePath": "nonexistentmovie\\scenes\\scene2400.png"
    }
  ]
}

在此範例中,場景字段是包含多個向量的複雜集合(內嵌字段),以及其他相關聯的數據。 每個向量都代表電影中的場景,可用來在其他電影中尋找類似的場景,以及其他潛在的使用案例。

使用多向量欄位支援的查詢

多向量字段支援功能引進了 Azure AI 搜尋服務中查詢機制的一些變更。 不過,主要查詢程式大致相同。 先前, vectorQueries 只能以定義為最上層索引欄位的向量欄位為目標。 透過這項功能,我們會放寬這項限制,並允許 vectorQueries 以巢狀於複雜類型集合內的字段為目標(最高一層深)。 此外,有新的查詢時間參數可供使用: perDocumentVectorLimit

  • perDocumentVectorLimit 設定為 1 可確保每份文件最多只有一個向量相符,保證結果來自不同的文件。
  • 將設定 perDocumentVectorLimit0 (無限制) 可讓來自相同檔的多個相關向量進行比對。
{
  "vectorQueries": [
    {
      "kind": "text",
      "text": "whales swimming",
      "K": 50,
      "fields": "scenes/embedding",
      "perDocumentVectorLimit": 0
    }
  ],
  "select": "title, scenes/timestamp, scenes/framePath"
}

在單一欄位中對多個向量進行排名

當多個向量與單一文件相關聯時,Azure AI 搜尋會使用其中的最大分數進行排名。 系統會使用最相關的向量來評分每份檔,以防止較不相關的檔稀釋。

擷取集合中的相關元素

$select 參數中包含複雜類型的集合時,只會傳回符合向量查詢的元素。 這適用於擷取相關聯的元數據,例如時間戳、文字描述或影像路徑。

備註

若要減少承載大小,請避免在 參數中包含 $select 向量值本身。 如果不需要,請考慮完全省略向量儲存。

偵錯多向量查詢 (預覽版)

當檔包含多個內嵌向量時,例如文字和影像內嵌在不同的子字段時,系統會在所有元素之間使用最高的向量分數來排名檔。

若要偵錯每個向量的貢獻方式,請使用 innerHits 偵錯模式 (在最新預覽版 REST API 中提供)。

POST /indexes/my-index/docs/search?api-version=2025-11-01-preview
{
  "vectorQueries": [
    {
      "kind": "vector",
      "field": "keyframes.imageEmbedding",
      "kNearestNeighborsCount": 5,
      "vector": [ /* query vector */ ]
    }
  ],
  "debug": "innerHits"
}

範例回應圖形

"@search.documentDebugInfo": {
  "innerHits": {
    "keyframes": [
      {
        "ordinal": 0,
        "vectors": [
          {
            "imageEmbedding": {
              "searchScore": 0.958,
              "vectorSimilarity": 0.956
            },
            "textEmbedding": {
              "searchScore": 0.958,
              "vectorSimilarity": 0.956
            }
          }
        ]
      },
      {
        "ordinal": 1,
        "vectors": [
          {
            "imageEmbedding": null,
            "textEmbedding": {
              "searchScore": 0.872,
              "vectorSimilarity": 0.869
            }
          }
        ]
      }
    ]
  }
}

欄位描述

領域 說明
ordinal 集合內元素的零基索引。
vectors 元素中包含的每個可搜尋向量欄位對應一個項目。
searchScore 該欄位的最終分數 (在經過任何重新評分和加權之後)。
vectorSimilarity 距離函數傳回的原始相似度。

備註

innerHits 目前只報告向量欄位。

與 debug=vector 的關聯性

以下是有關此屬性的一些事實:

  • 現有的 debug=vector 開關會維持不變。

  • 與多向量欄位搭配使用時, @search.documentDebugInfo.vector.subscore 會顯示用來排名父檔的分數上限,但不會顯示每個元素的詳細數據。

  • 使用 innerHits 來深入了解個別元素如何參與分數。