Skip to content

Commit c069e18

Browse files
Merge pull request #529 from HeidiSteen/heidist-release
MRL, subscores, targeted vector filter
2 parents 89aea63 + 49fb398 commit c069e18

11 files changed

+255
-32
lines changed

articles/search/cognitive-search-skill-textsplit.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ ms.date: 10/01/2024
1313

1414
# Text split cognitive skill
1515

16-
The **Text Split** skill breaks text into chunks of text. You can specify whether you want to break the text into sentences or into pages of a particular length. This skill is especially useful if there are maximum text length requirements in other skills downstream, such as embedding skills that pass data chunks to embedding models on Azure OpenAI and other model providers. For more information about this scenario, see [Chunk documents for vector search](vector-search-how-to-chunk-documents.md).
16+
The **Text Split** skill breaks text into chunks of text. You can specify whether you want to break the text into sentences or into pages of a particular length. This skill is useful if there are maximum text length requirements in other skills downstream, such as embedding skills that pass data chunks to embedding models on Azure OpenAI and other model providers. For more information about this scenario, see [Chunk documents for vector search](vector-search-how-to-chunk-documents.md).
17+
18+
Several parameters are version-specific. The skills parameter table notes the API version in which a parameter was introduced so that you know whether a [version upgrade](search-api-migration.md) is required. To use version-specific features such as token chunking in **2024-09-01-preview**, you can use the Azure portal, or target a REST API version, or check an Azure SDK change log to see if it supports the feature.
19+
20+
The Azure portal supports most preview features and can be used to create or update a skillset. For updates to the Text Split skill, edit the skillset JSON definition to add new preview parameters.
1721

1822
> [!NOTE]
1923
> This skill isn't bound to Azure AI services. It's non-billable and has no Azure AI services key requirement.
@@ -23,7 +27,7 @@ Microsoft.Skills.Text.SplitSkill
2327

2428
## Skill Parameters
2529

26-
Parameters are case-sensitive. Some parameters are version-specific. This table notes the API version in which a parameter was introduced so that you know whether a [version upgrade](search-api-migration.md) is required. The Azure portal supports most preview features. For updates to Text Split skill, you can edit the skillset JSON definition to add new preview parameters. Azure SDKs are on a separate release schedule, so you should check their change logs to determine feature availability.
30+
Parameters are case-sensitive.
2731

2832
| Parameter name | Version | Description |
2933
|--------------------|-------------|-------------|
@@ -32,8 +36,8 @@ Parameters are case-sensitive. Some parameters are version-specific. This table
3236
| `defaultLanguageCode` | All versions | (optional) One of the following language codes: `am, bs, cs, da, de, en, es, et, fr, he, hi, hr, hu, fi, id, is, it, ja, ko, lv, no, nl, pl, pt-PT, pt-BR, ru, sk, sl, sr, sv, tr, ur, zh-Hans`. Default is English (en). A few things to consider: <ul><li>Providing a language code is useful to avoid cutting a word in half for nonwhitespace languages such as Chinese, Japanese, and Korean.</li><li>If you don't know the language in advance (for example, if you're using the [LanguageDetectionSkill](cognitive-search-skill-language-detection.md) to detect language), we recommend the `en` default. </li></ul> |
3337
| `pageOverlapLength` | [2024-07-01](/rest/api/searchservice/skillsets/create-or-update) | Only applies if `textSplitMode` is set to `pages`. Each page starts with this number of characters or tokens from the end of the previous page. If this parameter is set to 0, there's no overlapping text on successive pages. This [example](#example-for-chunking-and-vectorization) includes the parameter. |
3438
| `maximumPagesToTake` | [2024-07-01](/rest/api/searchservice/skillsets/create-or-update) | Only applies if `textSplitMode` is set to `pages`. Number of pages to return. The default is 0, which means to return all pages. You should set this value if only a subset of pages are needed. This [example](#example-for-chunking-and-vectorization) includes the parameter.|
35-
| `unit` | [2024-09-01-preview](/rest/api/searchservice/skillsets/create-or-update?view=rest-searchservice-2024-09-01-preview&preserve-view=true) | Only applies if `textSplitMode` is set to `pages`. Specifies whether to chunk by `characters` (default) or `azureOpenAITokens`. Setting the unit affects `maximumPageLength` and `pageOverlapLength`. |
36-
| `azureOpenAITokenizerParameters` | [2024-09-01-preview](/rest/api/searchservice/skillsets/create-or-update?view=rest-searchservice-2024-09-01-preview&preserve-view=true) | An object providing extra parameters for the `azureOpenAITokens` unit. <br><br>`encoderModelName` is a designated tokenizer used for converting text into tokens, essential for natural language processing (NLP) tasks. Different models use different tokenizers. Valid values include cl100k_base (default) used by GPT-35-Turbo and GPT-4. Other valid values are r50k_base, p50k_base, and p50k_edit. The skill implements the tiktoken library by way of [SharpToken](https://www.nuget.org/packages/SharpToken) and `Microsoft.ML.Tokenizers` but doesn't support every encoder. For example, there's currently no support for o200k_base encoding used by GPT-4o. <br><br>`allowedSpecialTokens` defines a collection of special tokens that are permitted within the tokenization process. Special tokens are string that you want to treat uniquely, ensuring they aren't split during tokenization. For example ["[START"], "[END]"].|
39+
| `unit` | [2024-09-01-preview](/rest/api/searchservice/skillsets/create-or-update?view=rest-searchservice-2024-09-01-preview&preserve-view=true) | **New**. Only applies if `textSplitMode` is set to `pages`. Specifies whether to chunk by `characters` (default) or `azureOpenAITokens`. Setting the unit affects `maximumPageLength` and `pageOverlapLength`. |
40+
| `azureOpenAITokenizerParameters` | [2024-09-01-preview](/rest/api/searchservice/skillsets/create-or-update?view=rest-searchservice-2024-09-01-preview&preserve-view=true) | **New**. An object providing extra parameters for the `azureOpenAITokens` unit. <br><br>`encoderModelName` is a designated tokenizer used for converting text into tokens, essential for natural language processing (NLP) tasks. Different models use different tokenizers. Valid values include cl100k_base (default) used by GPT-35-Turbo and GPT-4. Other valid values are r50k_base, p50k_base, and p50k_edit. The skill implements the tiktoken library by way of [SharpToken](https://www.nuget.org/packages/SharpToken) and `Microsoft.ML.Tokenizers` but doesn't support every encoder. For example, there's currently no support for o200k_base encoding used by GPT-4o. <br><br>`allowedSpecialTokens` defines a collection of special tokens that are permitted within the tokenization process. Special tokens are string that you want to treat uniquely, ensuring they aren't split during tokenization. For example ["[START"], "[END]"].|
3741

3842
## Skill Inputs
3943

articles/search/hybrid-search-how-to-query.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ ms.date: 10/01/2024
1919
In this article, learn how to:
2020

2121
+ Set up a basic request
22-
+ Add filters
22+
+ Formulate hybrid queries with more parameters and filters
2323
+ Improve relevance using semantic ranking or vector weights
2424
+ Optimize query behaviors by controlling text and vector inputs
2525

26-
To improve relevance in a hybrid query, use these parameters:
26+
> [!NOTE]
27+
> New in [**2024-09-01-preview**](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true) is the ability to target filters to just the vector subqueries in a hybrid request. This gives you more precision over how filters are applied. For more information, see [scope filters to vector subqueries](#hybrid-search-with-filters-scoped-to-vector-subqueries-preview) in this article.
28+
29+
<!-- To improve relevance in a hybrid query, use these parameters:
2730
2831
+ [vector.queries.weight](vector-search-how-to-query.md#vector-weighting) lets you set the relative weight of the vector query. This feature is particularly useful in complex queries where two or more distinct result sets need to be combined, as is the case for hybrid search. This feature is generally available.
2932
3033
+ [hybridsearch.maxTextRecallSize and countAndFacetMode (preview)](#set-maxtextrecallsize-and-countandfacetmode-preview) give you more control over text inputs into a hybrid query. This feature requires a preview API version.
31-
34+
-->
3235
## Prerequisites
3336

3437
+ A search index containing `searchable` vector and nonvector fields. We recommend the [Import and vectorize data wizard](search-import-data-portal.md) to create an index quickly. Otherwise, see [Create an index](search-how-to-create-search-index.md) and [Add vector fields to a search index](vector-search-how-to-create-index.md).
@@ -177,6 +180,50 @@ api-key: {{admin-api-key}}
177180

178181
+ When you postfilter query results, the number of results might be less than top-n.
179182

183+
## Hybrid search with filters scoped to vector subqueries (preview)
184+
185+
Using [**2024-09-01-preview**](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true), you can override a global filter on the search request by applying a secondary filter that targets just the vector subqueries in a hybrid request.
186+
187+
This feature provides fine-grained control by ensuring that filters only influence the vector search results, leaving keyword-based search results unaffected.
188+
189+
The targeted filter fully overrides the global filter, including any filters used for [security trimming](search-security-trimming-for-azure-search.md) or geospatial search. In cases where global filters are required, such as security trimming, you must explicitly include these filters in both the top-level filter and in each vector-level filter to ensure security and other constraints are consistently enforced.
190+
191+
To apply targeted vector filters:
192+
193+
+ Use the [latest preview Search Documents REST API](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true#request-body) or an Azure SDK beta package that provides the feature.
194+
195+
+ Modify a query request, adding a new `vectorQueries.filterOverride` parameter set to an [OData filter expression](search-query-odata-filter.md).
196+
197+
Here's an example of hybrid query that adds a filter override. The global filter "Rating gt 3" is replaced at run time by the filterOvrride.
198+
199+
```http
200+
POST https://{{search-service-name}}.search.windows.net/indexes/{{index-name}}/docs/search?api-version=2024-09-01=preview
201+
202+
{
203+
"vectorQueries": [
204+
{
205+
"vector": [
206+
-0.009154141,
207+
0.018708462,
208+
. . .
209+
-0.02178128,
210+
-0.00086512347
211+
],
212+
"fields": "DescriptionVector",
213+
"kind": "vector",
214+
"exhaustive": true,
215+
"filterOverride": "Address/City eq 'Seattle'",
216+
"k": 10
217+
}
218+
],
219+
"search": "historic hotel walk to restaurants and shopping",
220+
"select": "HotelName, Description, Address/City, Rating",
221+
"filter": "Rating gt 3"
222+
"debug": "vector",
223+
"top": 10
224+
}
225+
```
226+
180227
## Semantic hybrid search
181228

182229
Assuming that you [enabled semantic ranker](semantic-how-to-enable-disable.md) and your index definition includes a [semantic configuration](semantic-how-to-query-request.md), you can formulate a query that includes vector search and keyword search, with semantic ranking over the merged result set. Optionally, you can add captions and answers.

articles/search/hybrid-search-ranking.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Reciprocal Rank Fusion (RRF) is an algorithm that evaluates the search scores fr
1818

1919
RRF is based on the concept of *reciprocal rank*, which is the inverse of the rank of the first relevant document in a list of search results. The goal of the technique is to take into account the position of the items in the original rankings, and give higher importance to items that are ranked higher in multiple lists. This can help improve the overall quality and reliability of the final ranking, making it more useful for the task of fusing multiple ordered search results.
2020

21+
> [!NOTE]
22+
> New in [**2024-09-01-preview**](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true) is the ability to deconstruct an RRF-ranked search score into its component subscores. This gives you transparency into all-up score composition. For more information, see [unpack search scores (preview)](#unpack-a-search-score-into-subscores-preview) in this article.
23+
2124
## How RRF ranking works
2225

2326
RRF works by taking the search results from multiple methods, assigning a reciprocal rank score to each document in the results, and then combining the scores to create a new ranking. The concept is that documents appearing in the top positions across multiple search methods are likely to be more relevant and should be ranked higher in the combined result.
@@ -57,9 +60,62 @@ The following chart identifies the scoring property returned on each match, algo
5760

5861
Semantic ranking occurs after RRF merging of results. Its score (`@search.rerankerScore`) is always reported separately in the query response. Semantic ranker can rerank full text and hybrid search results, assuming those results include fields having semantically rich content. It can rerank pure vector queries if the search documents include text fields that contain semantically relevant content.
5962

63+
## Unpack a search score into subscores (preview)
64+
65+
Using [**2024-09-01-preview**](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true), you can deconstruct a search score to view its subscores.
66+
67+
For vector queries, this information can help you determine an appropriate value for [vector weighting](vector-search-how-to-query.md#vector-weighting) or [setting minimum thresholds](vector-search-how-to-query.md#set-thresholds-to-exclude-low-scoring-results-preview).
68+
69+
To get subscores:
70+
71+
+ Use the [latest preview Search Documents REST API](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-09-01-preview&preserve-view=true#request-body) or an Azure SDK beta package that provides the feature.
72+
73+
+ Modify a query request, adding a new `debug` parameter set to either `vector`, `semantic` if using semantic ranker, or `all`.
74+
75+
Here's an example of hybrid query that returns subscores in debug mode:
76+
77+
```http
78+
POST https://{{search-service-name}}.search.windows.net/indexes/{{index-name}}/docs/search?api-version=2024-09-01=preview
79+
80+
{
81+
"vectorQueries": [
82+
{
83+
"vector": [
84+
-0.009154141,
85+
0.018708462,
86+
. . .
87+
-0.02178128,
88+
-0.00086512347
89+
],
90+
"fields": "DescriptionVector",
91+
"kind": "vector",
92+
"exhaustive": true,
93+
"k": 10
94+
},
95+
{
96+
"vector": [
97+
-0.009154141,
98+
0.018708462,
99+
. . .
100+
-0.02178128,
101+
-0.00086512347
102+
],
103+
"fields": "DescriptionVector",
104+
"kind": "vector",
105+
"exhaustive": true,
106+
"k": 10
107+
}
108+
],
109+
"search": "historic hotel walk to restaurants and shopping",
110+
"select": "HotelName, Description, Address/City",
111+
"debug": "vector",
112+
"top": 10
113+
}
114+
```
115+
60116
## Weighted scores
61117

62-
Using 2024-07-01 and newer preview API versions, you can [weight vector queries](vector-search-how-to-query.md#vector-weighting) to increase or decrease their importance in a hybrid query.
118+
Using [**2024-07-01**](/rest/api/searchservice/documents/search-post) and newer preview API versions, you can [weight vector queries](vector-search-how-to-query.md#vector-weighting) to increase or decrease their importance in a hybrid query.
63119

64120
Recall that when computing RRF for a certain document, the search engine looks at the rank of that document for each result set where it shows up. Assume a document shows up in three separate search results, where the results are from two vector queries and one text BM25-ranked query. The position of the document varies in each result.
65121

@@ -69,9 +125,9 @@ Recall that when computing RRF for a certain document, the search engine looks a
69125
| vector results two | position 5 | 0.81514114 | 2.0 | 1.63028228 |
70126
| BM25 results | position 10 | 0.8577363 | NA | 0.8577363 |
71127

72-
The document's position in each result set corresponds to an initial score, which are added up to create the final RRF score for that document.
128+
The document's position in each result set corresponds to an initial score, which is added up to create the final RRF score for that document.
73129

74-
If you add vector weighting, the initial scores are subect to a weighting multiplier that increases or decreases the score. The default is 1.0, which means no weighting and the initial score is used as-is in RRF scoring. However, if you add a weight of 0.5, the score is reduced and that result becomes less important in the combined ranking. Conversely, if you add a weight of 2.0, the score becomes a larger factor in the overall RRF score.
130+
If you add vector weighting, the initial scores are subject to a weighting multiplier that increases or decreases the score. The default is 1.0, which means no weighting and the initial score is used as-is in RRF scoring. However, if you add a weight of 0.5, the score is reduced and that result becomes less important in the combined ranking. Conversely, if you add a weight of 2.0, the score becomes a larger factor in the overall RRF score.
75131

76132
In this example, the @search.score (weighted) values are passed to the RRF ranking model.
77133

@@ -87,9 +143,9 @@ For more information, see [How to work with search results](search-pagination-pa
87143

88144
## Diagram of a search scoring workflow
89145

90-
The following diagram illustrates a hybrid query that invokes keyword and vector search, with boosting through scoring profiles, and semantic ranking.
146+
The following diagram illustrates a hybrid query that invokes keyword and vector search, with [boosting through scoring profiles](index-add-scoring-profiles.md#how-search-scoring-works-in-azure-ai-search), and semantic ranking.
91147

92-
:::image type="content" source="media/hybrid-search/search-scoring-flow.png" alt-text="Diagram of prefilters." border="true" lightbox="media/hybrid-search/search-scoring-flow.png":::
148+
:::image type="content" source="media/scoring-profiles/scoring-over-ranked-results.png" alt-text="Diagram of prefilters." border="true" lightbox="media/scoring-profiles/scoring-over-ranked-results.png":::
93149

94150
A query that generates the previous workflow might look like this:
95151

0 commit comments

Comments
 (0)