-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Scalar Quantizer to support signed int8 vectors #3488
Comments
@mdouze @alexanderguzhva Can you please take a look and provide your comments on the approach mentioned above ? I have already made the code changes on my local with AVX2 and NEON intrinsics and tested it with some datasets like cohere, ms_marco, sift, etc. The recall and other performance benchmarks looks good. |
Are you using max inner product search or L2 search? |
@naveentatikonda so, the plan is to use |
@mdouze Initially, we had this approach in our mind. But, it doesn't work for InnerProduct and we want to support both L2 and IP space types. |
@alexanderguzhva I think replacing
I was trying to subtract 128 from all dimensions after loading it with |
@naveentatikonda I mean that adding a new |
Summary: ### Description Add new signed 8 bit scalar quantizer, `QT_8bit_direct_signed` to ingest signed 8 bit vectors ([-128 to 127]). ### Issues Resolved facebookresearch#3488 Pull Request resolved: facebookresearch#3501 Reviewed By: mengdilin Differential Revision: D58639363 Pulled By: mdouze fbshipit-source-id: cf7f244fdbb7a34051d2b20c6f8086cd5628b4e0
Summary: ### Description Add new signed 8 bit scalar quantizer, `QT_8bit_direct_signed` to ingest signed 8 bit vectors ([-128 to 127]). ### Issues Resolved facebookresearch#3488 Pull Request resolved: facebookresearch#3501 Reviewed By: mengdilin Differential Revision: D58639363 Pulled By: mdouze fbshipit-source-id: cf7f244fdbb7a34051d2b20c6f8086cd5628b4e0
Summary: ### Description Add new signed 8 bit scalar quantizer, `QT_8bit_direct_signed` to ingest signed 8 bit vectors ([-128 to 127]). ### Issues Resolved facebookresearch#3488 Pull Request resolved: facebookresearch#3501 Reviewed By: mengdilin Differential Revision: D58639363 Pulled By: mdouze fbshipit-source-id: cf7f244fdbb7a34051d2b20c6f8086cd5628b4e0
Summary
As of today, we have three different 8 bit quantizers
QT_8bit_direct
,QT_8bit_uniform
andQT_8bit
but all three of them only support uint8 vectors ranging from [0 to 255]. If we try to ingest signed 8 bit vectors ([-128 to 127]) using these quantizers then during encoding it will be casted as uint8 values which will change the sign and magnitude of values outside of uint8 range. There are few use cases where customers want to use models like Cohere Embed that generates signed int8 embeddings ranging from [-128 to 127]. To support such use cases we need a new signed 8 bit scalar quantizer.Solution
To solve this problem, we can add a new signed 8 bit quantizer something similar to
QT_8bit_direct
where during encoding it adds128
to each dimension of the vector to bring it into uint8 range to store inuint8_t* code
. Similarly, during decoding or while reconstructing the components128
will be subtracted from each dimension to retrieve the actual signed int8 vector back before computing the distance.The text was updated successfully, but these errors were encountered: