-
Notifications
You must be signed in to change notification settings - Fork 1k
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
int4 doesn't handle cosine
similarity correctly
#13614
Labels
Comments
Actually, this might be a bug. Looking at the code, I am not sure we normalize the vectors when building the quantizer & using cosine. |
Yep, not normalizing during quantile merging is the actual bug. I have a local patch that fixes this. Need to write up some tests & will push up a change soon. Good find @naveentatikonda! |
glove-200
cosine
similarity correctly
benwtrent
added a commit
that referenced
this issue
Aug 5, 2024
When quantizing vectors in a COSINE vector space, we normalize them. However, there is a bug when building the quantizer quantiles and we didn't always use the normalized vectors. Consequently, we would end up with poorly configured quantiles and recall will drop significantly (especially in sensitive cases like int4). closes: #13614
benwtrent
added a commit
that referenced
this issue
Aug 5, 2024
When quantizing vectors in a COSINE vector space, we normalize them. However, there is a bug when building the quantizer quantiles and we didn't always use the normalized vectors. Consequently, we would end up with poorly configured quantiles and recall will drop significantly (especially in sensitive cases like int4). closes: #13614
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
just with some default settings,
glove-200
does poorly withint4
HNSW and when usingcosine
. The bug occurs on merge. When recalculating the quantiles, the vectors aren't normalized like they should, so the quantiles will get all out of whack. We can actually see this in some of the below experiments. All these values should indicate a normalized vectory, however some of the results are > 1 or < -1.Some experiments I have done:
Dynamic confidence interval:
0.693
(I regrettably didn't get the quantiles here...)int4
vectors are used0.189
(minQuantile=-1.2686034, maxQuantile=1.3250866)0.5 confidence interval (locally patched to allow it):
int4
vectors building the graph0.649
(minQuantile=-0.277436, maxQuantile=0.29298353)0.75 confidence interval (locally patched to allow it):
int4
vectors building the graph0.535
(minQuantile=-0.48500386, maxQuantile=0.5028781)0.9 confidence interval:
int4
vectors building the graph0.407
(minQuantile=-0.71112806, maxQuantile=0.73441404)The text was updated successfully, but these errors were encountered: