Skip to content

Add rescore_vector to knn query, knn section and knn retriever #3553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions specification/_types/Knn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

/**
Expand All @@ -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 */
Expand Down
4 changes: 3 additions & 1 deletion specification/_types/Retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down
Loading