From beda885134fe78a63db9d5f2a60dcb7ae6be866c Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Mon, 20 Jan 2025 17:05:02 +0100 Subject: [PATCH 1/3] Add rescore_vector to knn query and knn section --- output/schema/schema.json | 54 ++++++++++++++++++++++++++++++++++--- output/typescript/types.ts | 6 +++++ specification/_types/Knn.ts | 9 +++++++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index e964109a02..1fec430d5c 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -47774,9 +47774,21 @@ "namespace": "_types" } } + }, + { + "description": "Apply oversampling and rescoring to quantized vectors", + "name": "rescore_vector", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "RescoreVector", + "namespace": "_types" + } + } } ], - "specLocation": "_types/Knn.ts#L54-L72" + "specLocation": "_types/Knn.ts#L61-L81" }, { "kind": "interface", @@ -47997,9 +48009,21 @@ "namespace": "_global.search._types" } } + }, + { + "description": "Apply oversampling and rescoring to quantized vectors", + "name": "rescore_vector", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "RescoreVector", + "namespace": "_types" + } + } } ], - "specLocation": "_types/Knn.ts#L30-L52" + "specLocation": "_types/Knn.ts#L35-L59" }, { "kind": "interface", @@ -49313,7 +49337,7 @@ } } ], - "specLocation": "_types/Knn.ts#L74-L77", + "specLocation": "_types/Knn.ts#L83-L86", "variants": { "kind": "container" } @@ -49705,6 +49729,28 @@ ], "specLocation": "_types/Stats.ts#L247-L253" }, + { + "kind": "interface", + "name": { + "name": "RescoreVector", + "namespace": "_types" + }, + "properties": [ + { + "description": "Applies the specified oversample factor to k on the approximate kNN search", + "name": "oversample", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "float", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/Knn.ts#L30-L33" + }, { "kind": "enum", "members": [ @@ -51899,7 +51945,7 @@ } } ], - "specLocation": "_types/Knn.ts#L79-L82" + "specLocation": "_types/Knn.ts#L88-L91" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index fb5d902c3c..b40e8b4636 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2500,6 +2500,7 @@ export interface KnnQuery extends QueryDslQueryBase { k?: integer filter?: QueryDslQueryContainer | QueryDslQueryContainer[] similarity?: float + rescore_vector?: RescoreVector } export interface KnnRetriever extends RetrieverBase { @@ -2521,6 +2522,7 @@ export interface KnnSearch { filter?: QueryDslQueryContainer | QueryDslQueryContainer[] similarity?: float inner_hits?: SearchInnerHits + rescore_vector?: RescoreVector } export interface LatLonGeoLocation { @@ -2701,6 +2703,10 @@ export interface RequestCacheStats { miss_count: long } +export interface RescoreVector { + oversample: float +} + export type Result = 'created' | 'updated' | 'deleted' | 'not_found' | 'noop' export interface Retries { diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 0735fb45bd..a2bc539889 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -27,6 +27,11 @@ export type QueryVector = float[] /* KnnSearch (used in kNN search) and KnnQuery (ued in kNN queries) are close * but different enough to require different classes */ +export interface RescoreVector { + /** Applies the specified oversample factor to k on the approximate kNN search */ + oversample: float +} + export interface KnnSearch { /** The name of the vector field to search against */ field: Field @@ -49,6 +54,8 @@ export interface KnnSearch { * @doc_id knn-inner-hits */ inner_hits?: InnerHits + /** Apply oversampling and rescoring to quantized vectors */ + rescore_vector?: RescoreVector } /** @@ -69,6 +76,8 @@ export interface KnnQuery extends QueryBase { filter?: QueryContainer | QueryContainer[] /** The minimum similarity for a vector to be considered a match */ similarity?: float + /** Apply oversampling and rescoring to quantized vectors */ + rescore_vector?: RescoreVector } /** @variants container */ From 6f149b28f8c284aa2e63a8022e36f0ae099f3f79 Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Mon, 20 Jan 2025 17:12:51 +0100 Subject: [PATCH 2/3] Add rescore_vector to knn retriever --- output/schema/schema.json | 20 ++++++++++++++++---- output/typescript/types.ts | 1 + specification/_types/Retriever.ts | 4 +++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index 1fec430d5c..7e16779108 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -47874,9 +47874,21 @@ "namespace": "_types" } } + }, + { + "description": "Apply oversampling and rescoring to quantized vectors", + "name": "rescore_vector", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "RescoreVector", + "namespace": "_types" + } + } } ], - "specLocation": "_types/Retriever.ts#L64-L77" + "specLocation": "_types/Retriever.ts#L64-L79" }, { "kind": "interface", @@ -49395,7 +49407,7 @@ } } ], - "specLocation": "_types/Retriever.ts#L79-L86" + "specLocation": "_types/Retriever.ts#L81-L88" }, { "kind": "interface", @@ -50049,7 +50061,7 @@ } } ], - "specLocation": "_types/Retriever.ts#L101-L110" + "specLocation": "_types/Retriever.ts#L103-L112" }, { "kind": "type_alias", @@ -52021,7 +52033,7 @@ } } ], - "specLocation": "_types/Retriever.ts#L88-L99" + "specLocation": "_types/Retriever.ts#L90-L101" }, { "kind": "enum", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index b40e8b4636..fbb7f81362 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2510,6 +2510,7 @@ export interface KnnRetriever extends RetrieverBase { k: integer num_candidates: integer similarity?: float + rescore_vector?: RescoreVector } export interface KnnSearch { diff --git a/specification/_types/Retriever.ts b/specification/_types/Retriever.ts index 636f9413fb..1835bfd191 100644 --- a/specification/_types/Retriever.ts +++ b/specification/_types/Retriever.ts @@ -19,7 +19,7 @@ import { FieldCollapse } from '@global/search/_types/FieldCollapse' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' -import { QueryVector, QueryVectorBuilder } from '@_types/Knn' +import {QueryVector, QueryVectorBuilder, RescoreVector} from '@_types/Knn' import { float, integer } from '@_types/Numeric' import { Sort, SortResults } from '@_types/sort' import { Id } from './common' @@ -74,6 +74,8 @@ export class KnnRetriever extends RetrieverBase { num_candidates: integer /** The minimum similarity required for a document to be considered a match. */ similarity?: float + /** Apply oversampling and rescoring to quantized vectors */ + rescore_vector?: RescoreVector } export class RRFRetriever extends RetrieverBase { From 8ba4854bf42659591ba21f6f74dd000c65e6fc7a Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Mon, 20 Jan 2025 17:22:03 +0100 Subject: [PATCH 3/3] Style fix --- specification/_types/Retriever.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/_types/Retriever.ts b/specification/_types/Retriever.ts index 1835bfd191..73bf634231 100644 --- a/specification/_types/Retriever.ts +++ b/specification/_types/Retriever.ts @@ -19,7 +19,7 @@ import { FieldCollapse } from '@global/search/_types/FieldCollapse' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' -import {QueryVector, QueryVectorBuilder, RescoreVector} from '@_types/Knn' +import { QueryVector, QueryVectorBuilder, RescoreVector } from '@_types/Knn' import { float, integer } from '@_types/Numeric' import { Sort, SortResults } from '@_types/sort' import { Id } from './common'