Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
This is a (quality of life) QoL feature I have proactively built into our upcoming RC, on the client side. We currently have no utilities that empower customers to customize their
/rerank
results downstream of the API, which I'm anticipating will cause friction with heavy users of/rerank
.Solution
Reranking results by recency is a super popular, common, and useful feature for all of our clients to have. This PR can serve as the POC for this feature's integration into our other clients.
Overview
/rerank
endpoint and gets results backUse cases
Toggles available to the user (passed in via
options
):decay
true/falsedecayWeight
(default 0.5): The magnitude of the decay's impact on document scores.decayThreshold
(default 30 days): Time period (in days) after which the decay starts significantly affecting. If a document is within the threshold, the decay will scale based on how old the document is. If it is older than the threshold, the document is treated as fully decayed (normalized decay of 1).Future toggles
It'd be ideal in the future to allow the user to choose between common recency decay functions other than
additive
, e.g.multiplicative
,exponential
, andlog
.User requirements
The user must pass in documents that contain a
timestamp
field that is a stringified timestamp, to the millisecond, e.g. "2010-08-10 00:03:21"Type of Change
Test Plan
New integration and unit tests pass.
Still need to do:
/rerank
docstring of how to pass inoptions
containing recency stuffFurther reading: