Skip to content
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

[ML] add rerank to _inference #2479

Merged
merged 4 commits into from
Apr 3, 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
32 changes: 31 additions & 1 deletion output/openapi/elasticsearch-serverless-openapi.json

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

82 changes: 79 additions & 3 deletions output/schema/schema.json

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

10 changes: 9 additions & 1 deletion output/typescript/types.ts

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

12 changes: 12 additions & 0 deletions specification/inference/_types/Results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ export class CompletionResult {
result: string
}

/**
* The rerank result object representing a single ranked document
* id: the original index of the document in the request
* score: the score of the document relative to the query
* text: Optional, the text of the document, if requested
*/
export class RankedDocument {
id: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented in elastic/elasticsearch#106378 that we might want to rename this field.

score: string
text?: string
}
/**
* InferenceResult is an aggregation of mutually exclusive variants
* @variants container
Expand All @@ -72,4 +83,5 @@ export class InferenceResult {
text_embedding?: Array<TextEmbeddingResult>
sparse_embedding?: Array<SparseEmbeddingResult>
completion?: Array<CompletionResult>
rerank?: Array<RankedDocument>
}
4 changes: 3 additions & 1 deletion specification/inference/_types/TaskType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
*/
export enum TaskType {
sparse_embedding,
text_embedding
text_embedding,
rerank,
completion
}
5 changes: 5 additions & 0 deletions specification/inference/inference/InferenceRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export interface Request extends RequestBase {
inference_id: Id
}
body: {
/**
* Query input, required for rerank task.
* Not required for other tasks.
*/
query?: string
/**
* Text input to the model.
* Either a string or an array of strings.
Expand Down
Loading