Skip to content

[8.x] Add specification for query rules retriever #3090

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 1 commit into from
Nov 5, 2024
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
173 changes: 168 additions & 5 deletions output/schema/schema.json

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

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

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

30 changes: 30 additions & 0 deletions specification/_types/Retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/

import { FieldCollapse } from '@global/search/_types/FieldCollapse'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { QueryVector, QueryVectorBuilder } from '@_types/Knn'
import { float, integer } from '@_types/Numeric'
import { Sort, SortResults } from '@_types/sort'
import { Id } from './common'
import { QueryContainer } from './query_dsl/abstractions'

/**
Expand All @@ -33,6 +35,10 @@ export class RetrieverContainer {
knn?: KnnRetriever
/** A retriever that produces top documents from reciprocal rank fusion (RRF). */
rrf?: RRFRetriever
/** A retriever that reranks the top documents based on a reranking model using the InferenceAPI */
text_similarity_reranker?: TextSimilarityReranker
/** A retriever that replaces the functionality of a rule query. */
rule?: RuleRetriever
}

export class RetrieverBase {
Expand Down Expand Up @@ -78,3 +84,27 @@ export class RRFRetriever extends RetrieverBase {
/** This value determines the size of the individual result sets per query. */
rank_window_size?: integer
}

export class TextSimilarityReranker extends RetrieverBase {
/** The nested retriever which will produce the first-level results, that will later be used for reranking. */
retriever: RetrieverContainer
/** This value determines how many documents we will consider from the nested retriever. */
rank_window_size?: integer
/** Unique identifier of the inference endpoint created using the inference API. */
inference_id?: string
/** The text snippet used as the basis for similarity comparison */
inference_text?: string
/** The document field to be used for text similarity comparisons. This field should contain the text that will be evaluated against the inference_text */
field?: string
}

export class RuleRetriever extends RetrieverBase {
/** The ruleset IDs containing the rules this retriever is evaluating against. */
ruleset_ids: Id[]
/** The match criteria that will determine if a rule in the provided rulesets should be applied. */
match_criteria: UserDefinedValue
/** The retriever whose results rules should be applied to. */
retriever: RetrieverContainer
/** This value determines the size of the individual result set. */
rank_window_size?: integer
}
Loading