made example for explainable

This commit is contained in:
Evgeniya Sukhodolskaya
2025-08-20 13:36:01 +02:00
committed by Jenny
parent 13ed6b91b7
commit 7a60d47283
4 changed files with 13 additions and 13 deletions
@@ -1 +1 @@
This code snippet applies exponential decay to boost the relevance of search results based on a datetime field in the payload. Items closer in time to a specified `target` datetime receive higher scores, with relevance decreasing exponentially and reaching a specified 0.1 `midpoint` of relevance after a defined time `scale` period of 1 week.
This code snippet applies exponential decay to boost the relevance of search results based on a datetime field called "upload_time" in the payload (which can be when a point was uploaded to Qdrant). Items closer in time to a specified `target`, so, in our case, the current datetime, which means "fresher" results, receive higher scores. Relevance score is decreasing exponentially with "upload_time" getting further away from `target` time, reaching a 0.5 `midpoint` of relevance after a defined `scale` period of 1 day.
@@ -12,13 +12,13 @@ POST /collections/{collection_name}/points/query
{
"exp_decay": {
"x": {
"datetime_key": "upload_time" // payload key
"datetime_key": "update_time" // payload key
},
"target": {
"datetime": "2025-08-04T00:00:00Z" // target time, for example, time of the search
"datetime": "YYYY-MM-DDT00:00:00Z" // current datetime
},
"scale": 86400, // 1 week in seconds
"midpoint": 0.1 // 0.1 output with deviation on `scale` (1 week) from `target`
"scale": 86400, // 1 day in seconds
"midpoint": 0.5 // if item's "update_time" is more than 1 day apart from current datetime, relevance score is less than 0.5
}
}
]
@@ -18,10 +18,10 @@ time_boosted = client.query_points(
datetime_key="upload_time" # payload key
),
target=models.DatetimeExpression(
datetime="2025-08-04T00:00:00Z" # target time, for example, time of the search
datetime="YYYY-MM-DDT00:00:00Z" # current datetime
),
scale=86400, # 1 week in seconds
midpoint=0.1 # 0.1 output with deviation on `scale` (1 week) from `target`
scale=86400, # 1 day in seconds
midpoint=0.5 # if item's "update_time" is more than 1 day apart from current datetime, relevance score is less than 0.5
)
)
]