This message was deleted.
# community-help
s
This message was deleted.
n
I can raise a github issue unless you believe it is for the client to calculate the vector distance for the keyword search hits. I think it causes confusion because it looks like those hits are way off when in fact they are not.
j
Yup, we've already fixed this issue, it will be part of the next RC release. For keyword search results, we'll remove
vector_distance
from the response, because that doesn't apply to keyword searches
n
I was hoping you would instead calc the vector distance for these hits to make it easier on the client 😅. But thats ok, I think I’ll just do it on my client end.
j
But keyword searches don't have a concept of vector distance, since they are not retrieved from the vector index
n
But you can look up the vector for the keyword search hit based on the id and you have the query vector so calculating the cosine distance between these two should be possible. I apologize in advance because I don’t the internal implementation details for typesense and maybe this is way off 🙈
j
Hmmmm! I guess you could do that... but if the embedding model had already placed this result in the same "vicinity" as it's neighboring results, it would have already been returned by the nearest-neighbor search. The fact that it was a keyword match, instead of a vector match most likely means that the embedding model didn't pick this up as a close result (due to the models' internal behavior)
So if you calculate the vector distance like how you describe, I suspect it will look way off, compared to the other nearest neighbor matches
n
Actually I have some examples where the keyword search results also get a decent vector distance - not as small as the vector search hits but good enough. For example (a made up example) - if use
k
as 10 in your vector query but the document that was at k=11 was missed by vector search but was picked up keyword search say. This document might not be that far off in vector distance to the others.
j
But then the sorting would look off, if the vector distance for a keyword match result is larger than it's adjacent results...
n
True. But for sorting when doing hybrid search we should focus on the
"hybrid_search_info": {"rank_fusion_score": 0.699999988079071},
score. I feel correcting the vector distance just makes the output “consistent” and anyone displaying this distances and scores (like in my case) can trust the keyword search scores and vector distance numbers being output by typesense out of the box.
j
Yeah, I see where you're coming from. So the way we caught this issue is because a few users were confused why a result with vector_distance of 2 was showing up even though they've set
distance_threshold: 0.5
... So we figured, let's remove the vector distance field since it has invalid data. If we now calculate the vector distance manually for keyword search results, that will still be confusing in the scenario above
n
Understood. My last suggestion would be if this can be controlled via a flag 🙈
You might need to support calculating vector distance for keyword search hits if someone comes up with a rank aggregation function that depends on these scores unlike rank fusion score RRF which cares only about the position. But this is more further into the future. 😅 An example of such score would be relative score fusion option in Weaviate which adds the normalized score of the keyword and vector search scores.
j
Good to know! Will keep this in mind for the future
👍 1