Qdrant gives different and incorrect results with DatetimeRange filter
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 34.7k
- Forks
- 2.7k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 187
Description
To my knowledge, semantic similarity score is absolute, not relative.
However, using the DatetimeRange filter, I get different results when the date range is expanded. The correct document disappears even though it should be within the range.
eg, given the question and searching for range > 2022:
from qdrant_client.http import models as qdrant_models
from langchain_community.vectorstores import Qdrant
# skip loading of vector store
vector_store.similarity_search(question,k=15,
filter=qdrant_models.Filter(
must=qdrant_models.FieldCondition(key='meeting_date',
range=qdrant_models.DatetimeRange(gte='2022-01-01')))
)
This gives (doc id | doc title | score)
[('CR-ID-REPLACED', <title replaced>, 0.63587),
('CR-ID-REPLACED', <title replaced>, 0.62937194),
('CR-ID-REPLACED', <title replaced>, 0.629144),
('CR-ID-REPLACED', <title replaced>, 0.6280967),
('CR-ID-REPLACED',<title replaced>, 0.6271694)]
Which is incorrect. The relevant doc is not retrieved. However, if i include a max date, the result is correct.
vector_store.similarity_search(question,k=15,
filter=qdrant_models.Filter(
must=qdrant_models.FieldCondition(key='meeting_date',
range=qdrant_models.DatetimeRange(gte='2022-01-01', lte='2023-01-01'))))
[('CR-ID-REPLACED', <title replaced> 0.66140205), # <-- correct document!
('CR-ID-REPLACED', <title replaced>, 0.6271694),
('CR-ID-REPLACED', <title replaced>, 0.6211362),
('CR-ID-REPLACED', <title replaced>, 0.62014866),
('CR-ID-REPLACED', <title replaced>, 0.6195655)]
I also get the correct docs above if i dont set any date range filters. eg,
vector_store.similarity_search(question,k=15)
What I don't understand is why does this behavior happen?
- The correct doc has the highest score, but it completely disappear when we dont include a max date even though it should logically be in the same set?
- Furthermore, None of the documents retrieved in the 2nd query are the same! I expect at least some overlap?
This is boggling the mind. Would appreciate any help!
versions
Qdrant version v1.12.4
Using the langchain qdrant abstraction
langchain-community==0.2.17
qdrant-client==1.12.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two DatetimeRange-filtered similarity_search calls and the unfiltered call with Qdrant v1.12.4, qdrant-client 1.12.1, and langchain-community 0.2.17. Compare the returned documents and scores, then trace the relevant Qdrant filtering and search behavior; done means the discrepancy is explained and a regression test demonstrates consistent results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- databases, machine-learning, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100