Vector data processing method, system and device, storage medium and program product
Through pre -processing and up -dimensional quantification of vectors data, the problem of insufficient accuracy during the searches of the upper vector of the existence of the existence of the existence is solved, and the higher retrieval accuracy and lower accuracy losses are achieved.
Patent Information
- Application Number
- CN202411341433.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-24
AI Technical Summary
The prior art has the problem of insufficient accuracy when searching vectors on the integrated storage and computing chip, resulting in the accuracy loss caused by direct quantization of vectors.
By preprocessing the vector data and determining the dimension-upgrading transformation matrix according to the vector distance invariant constraint rules, the preprocessed vector data is dimensioned-up and quantized to solve the problem of accuracy loss.
It improves the accuracy of vector retrieval and avoids the accuracy loss caused by direct quantization of vectors after the deployment of integrated storage and computing chips. It is suitable for low-bit storage scenarios including integrated storage and computing.
Smart Images

Figure CN119357186A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a vector data processing method, system, device, storage medium and program product. Background Art
[0002] Vector databases are database tools that use vector representation for unstructured data such as voice, text, images, and videos, and implement tasks such as information retrieval, fuzzy matching, semantic analysis, and AI question and answer based on vector retrieval technology. Vector databases have now become the main process for many multimodal application scenarios, directly affecting the performance of business systems and user experience.
[0003] At present, the existing vector retrieval method based on the vector database on the storage-computing integrated chip is as follows: the base database vector and the square value of the base database vector are weighted and spliced into the target vector and deployed on the storage-computing integrated chip, and the vector to be retrieved and the corresponding coefficient are spliced as the input value of the storage-computing integrated chip; the storage-computing integrated chip is used to calculate the inner product of the input vector and the target vector; the calculation results corresponding to different base database vectors are compared to determine the K base database vectors with the highest similarity to the target vector. The existing vector retrieval method has improved the Euclidean distance calculation. Although it has improved the calculation speed and reduced the calculation delay to a certain extent in the storage-computing integrated chip, there is a problem of insufficient precision of the storage-computing integrated chip, such as the precision of RRAM (Resistive Random Access Memory) chip is 4bit-8bit, and the precision of Flash chip is 8bit; the current base database data is generally float32, and there will be precision loss after being deployed with the storage-computing integrated chip. The existing vector retrieval method directly quantizes the vector itself, which cannot solve the precision loss caused by quantization. Summary of the invention
[0004] In response to the problems existing in the prior art, the embodiments of the present invention provide a vector data processing method, system, device, storage medium and program product, which upgrade and quantize vector data based on the vector distance invariant constraint rule, and can solve the problem of accuracy loss caused by direct quantization of vectors after deployment with a storage and computing integrated chip.
[0005] In a first aspect, an embodiment of the present invention provides a vector data processing method, including:
[0006] Preprocessing the vector data to obtain preprocessed vector data;
[0007] According to the vector distance invariance constraint rule, determine the dimension-increasing transformation matrix;
[0008] According to the dimensionality-increasing transformation matrix, the preprocessed vector data is quantized by dimensionality-increasing.
[0009] As an improvement of the above-mentioned scheme, the vector distance invariance constraint rule includes a relative distance invariance constraint and an absolute distance invariance constraint; the relative distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling and quantization is less than the distance between any two vector data not belonging to the same class; the absolute distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling and quantization is the same as the distance between the corresponding two vector data before dimensionality upscaling and quantization.
[0010] As an improvement of the above solution, the step of determining the dimension-raising transformation matrix according to the vector distance invariance constraint rule includes:
[0011] Constructing a loss function according to the vector distance invariance constraint rule;
[0012] The loss function is used to train the base vectors in the vector base, and the loss function is used to perform back propagation to calculate the dimension-raising transformation matrix.
[0013] As an improvement of the above solution, the loss function is constructed according to the vector distance invariance constraint rule, including:
[0014] When performing inverse retrieval, constructing a first quantization function according to the relative distance invariance constraint;
[0015] The loss function is constructed according to the first quantization function.
[0016] As an improvement of the above solution, the loss function is constructed according to the vector distance invariance constraint rule, including:
[0017] When brute force retrieval is performed, a second quantization function is constructed according to the absolute distance invariance constraint;
[0018] The loss function is constructed according to the second quantization function.
[0019] As an improvement of the above solution, constructing a first quantization function according to the relative distance invariance constraint includes:
[0020] Constructing a dimensionality-increasing conversion matrix according to the vector dimension of the vector data and the expected dimension in the high-dimensional space; wherein the expected dimension is determined according to the accuracy or size of the storage-computing integrated chip;
[0021] According to the dimension-raising transformation matrix, the first quantization function is constructed based on the relative distance invariance constraint.
[0022] As an improvement of the above solution, the preprocessing of the vector data to obtain the preprocessed vector data includes:
[0023] The vector data is subjected to at least one of centralization processing, standardization processing and normalization processing to obtain preprocessed vector data.
[0024] In a second aspect, an embodiment of the present invention provides a vector data processing system, including:
[0025] A vector preprocessing module is used to preprocess vector data to obtain preprocessed vector data;
[0026] The vector dimension-upgrading quantization module is used to determine the dimension-upgrading transformation matrix according to the vector distance invariance constraint rule, and perform dimension-upgrading quantization on the preprocessed vector data according to the dimension-upgrading transformation matrix.
[0027] In a third aspect, an embodiment of the present invention provides a vector data processing device, comprising: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the vector data processing method as described in any one of the first aspects is implemented.
[0028] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the vector data processing method as described in any one of the first aspects.
[0029] In a fifth aspect, an embodiment of the present invention provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the vector data processing method as described in any one of the first aspects.
[0030] Compared with the prior art, a vector data processing method, system, device, storage medium and program product in an embodiment of the present invention pre-processes the vector data; then determines the dimensionality increase conversion matrix according to the vector distance invariance constraint rule, and performs dimensionality increase quantization on the pre-processed vector data according to the dimensionality increase conversion matrix, thereby solving the problem of accuracy loss caused by direct quantization of vectors after deployment with a storage and computing integrated chip. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solution of the present invention, the drawings used in the implementation mode will be briefly introduced below. Obviously, the drawings described below are only some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 is a flow chart of a vector data processing method provided by an embodiment of the present invention;
[0033] Figure 2 It is a schematic diagram of the process of deploying base library vectors for a storage-computing integrated chip provided by an embodiment of the present invention;
[0034] Figure 3 It is a schematic diagram of the process of base library vector retrieval for a storage-computation integrated chip provided by an embodiment of the present invention;
[0035] Figure 4 is a structural block diagram of a vector data processing system provided by an embodiment of the present invention;
[0036] Figure 5 It is a structural block diagram of a vector data processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] It is understood that the various numbers involved in the embodiments of the present invention are only for the convenience of description and are not intended to limit the scope of the present application. The size of the sequence number of each process does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic.
[0039] In embodiments of the present invention, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprises", or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article, or device. In the absence of further restrictions, the elements defined by the statement "includes..." do not exclude the presence of other identical elements in the process, method, article, or device including the elements. The term "plurality or several" refers to two or more.
[0040] The following is an explanation of the related technologies involved in the embodiments of the present invention.
[0041] The use of vector data in the vector database includes two links: base database vector generation and vector retrieval, which are generally independent. For example, in the face recognition scenario, the base database vector is generated by entering a face, and the entered face is embedded using models such as faceNet to generate a face vector; the face vector obtained by embedding is stored in the vector database; vector retrieval refers to embedding the retrieved face using models such as faceNet to generate a face vector in the face recognition phase; the face vector generated by embedding is compared with the faces in the vector database one by one to retrieve the closest face. The recommendation scenario also includes two links: base database vector generation and recommendation recall: in the base database vector generation link, the item vectors obtained by calculating the dual-tower model for similar items / user data are stored in the vector database as the base database; in the recommendation recall process, the item data to be retrieved is calculated by a branch of the dual-tower model to obtain the item vector, and the item vector is compared with the base database vector to retrieve the closest vector.
[0042] From the above process, we can know that the base vector generation process is independent of the vector database. As an independent database tool, the vector database is mainly responsible for the addition, deletion, modification and query of the generated base vectors.
[0043] There are many ways to search vector databases. There are many ways to search vector databases. Brute force search and inverted file (IVF) search are two main technologies. Brute force search refers to directly calculating the distance between the vector to be searched and all the vector bases, and returning the top-k vectors with the closest distance. It is generally used in smaller bases. IVF search mainly uses the idea of inverted search to first cluster the vectors and save the vectors under each cluster center. Each time the vector is queried, the nearest centers are found and the vectors under these centers are searched separately; by reducing the search range, the search efficiency can be improved, but the accuracy will be lost, and the computational complexity of vector database retrieval is high. When the dimension of the base vector is d and the number is n, the computational complexity is O(d*n). After optimizing the computational amount, the computational complexity of IVF is O(d*log(n)).
[0044] Currently, there are several existing vector retrieval methods:
[0045] Vector retrieval on the integrated storage and computing chip: Based on the idea of brute force retrieval, the base vector and the square value of the base vector are weighted and spliced into the target vector and deployed on the integrated storage and computing chip. The vector to be retrieved and the corresponding coefficient are spliced as the input value of the integrated storage and computing chip; the integrated storage and computing chip is used to calculate the inner product of the input vector and the target vector; the calculation results corresponding to different base vectors are compared to determine the K base vectors with the highest similarity to the target vector. The existing vector retrieval method has improved the Euclidean distance calculation. Although it has improved the calculation speed and reduced the calculation delay to a certain extent in the integrated storage and computing, there is a problem of insufficient precision of the integrated storage and computing chip. For example, the precision of the RRAM (Resistive Random Access Memory) chip is 4bit-8bit, and the precision of the Flash chip is 8bit; the current base data is generally float32, and there will be precision loss after being deployed with the integrated storage and computing chip. The existing vector retrieval method directly quantizes the vector itself, which cannot solve the precision loss caused by quantization.
[0046] (2) Method for querying base vector objects: First, the deep hashing algorithm is used to calculate the hash value of the base vector to obtain its binary representation. Then, the deep hashing algorithm is used to calculate the hash value of the vector to be searched, and the Hamming distance is used to calculate the candidate objects of the vector to be searched. Compared with feature vectors, binary representation can save a lot of storage resources, especially when the number of candidate objects is in the billions. Deephash is used to quantize the target vector to obtain a high-dimensional binary vector. However, in the same dimension, binary (single bit) contains less information than other precisions (such as 4bit, 8bit). Therefore, when the vector scale becomes larger, the binary method needs to use a higher dimension to express the vector; on the other hand, the Hamming distance is not suitable for calculation on a storage and computing integrated chip.
[0047] (3) Vector retrieval method based on residual quantization: Based on the idea of IVF retrieval, a clustering algorithm is first used to divide the data set into multiple clusters; then the residual vector between each vector and the center of the cluster is calculated, and the residual vector is quantized; in the vector retrieval stage, for the query vector, the cluster to which it belongs is determined by calculating its distance from the center of each cluster, and the residual with the center of the cluster is calculated, and the residual is quantized to obtain the corresponding compressed representation; finally, the compressed representation of the residual vector of the query vector is compared with the compressed representation of the residual vector in the vector set to achieve similarity matching between vectors; this retrieval method uses IVF retrieval, which is not applicable to brute force retrieval scenarios. Since IVF first retrieves the cluster center and then retrieves the clusters corresponding to the nearest one or more cluster centers, it will lose some accuracy; on the other hand, this method solves the dimensionality disaster brought by high-dimensional vectors, that is, the dimension of the vector itself needs to be very high. When the dimension of the original vector is not high, there is a problem of accuracy loss.
[0048] Based on this, an embodiment of the present invention proposes a vector data processing method for storage and computing integration, which performs dimension-upgrading quantization on the vector based on the principles of absolute distance invariance and relative distance invariance, solves the problem of precision loss caused by directly quantizing the vector itself when performing vector retrieval on the existing storage and computing integrated chip, and improves the retrieval accuracy.
[0049] See also Figure 1 , Figure 1 : is a flow chart of a vector data processing method provided by an embodiment of the present invention. The vector data processing method specifically includes:
[0050] S11: preprocessing the vector data to obtain preprocessed vector data;
[0051] S12: Determine the dimension-increasing transformation matrix according to the vector distance invariance constraint rule;
[0052] S13: Perform dimension-upgrading quantization on the preprocessed vector data according to the dimension-upgrading transformation matrix.
[0053] Among them, the vector distance invariance constraint rule includes a relative distance invariance constraint and an absolute distance invariance constraint; the relative distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is less than the distance between any two vector data not belonging to the same class; the absolute distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is the same as the distance between the corresponding two vector data before dimensionality upscaling quantization.
[0054] It should be noted that the vector data processing method for storage and computing integration described in the embodiment of the present invention is executed by a terminal device such as a server, a computer, etc. that is deployed with a vector data processing system for storage and computing integration chips. Among them, the system is part of a storage and computing integration software tool chain for vector databases, and is connected to the vector writing tool and vector retrieval tool of the software tool chain. The vector data processing system includes a vector preprocessing module and a vector dimensionality quantization module.
[0055] The vector preprocessing module is used to perform the preprocessing process in the above step S11. Specifically, the preprocessing includes at least one of centralization, standardization and normalization.
[0056] In the embodiment of the present invention, the vector data is centralized, standardized or normalized so that the vector center point of the processed vector data is the coordinate origin.
[0057] Exemplarily, the vector data is first centralized; for example, the mean avg of the vector data is calculated, and the mean avg is subtracted from each vector data to achieve the centralization of the vector data.
[0058] The centralized vector data is then standardized or normalized; for example, the upper limit vector and lower limit vector of the vector data are calculated, and each vector data is standardized or normalized according to the upper limit vector and the lower limit vector; wherein the upper limit vector and the lower limit vector here can be determined by the maximum value and the minimum value in the vector data, and can also be calculated using statistical algorithms such as KL divergence, which is not specifically limited in the embodiments of the present invention.
[0059] The vector dimension-upgrading quantization module is used to perform the above step S12, convert the vector data output by the vector preprocessing module into a vector in a high-dimensional space based on the vector distance invariance constraint rule, and quantize the vector at the same time. The dimension of the vector data after dimension-upgrading can be adjusted according to the accuracy or size of the storage-computing integrated chip, which is not specifically limited in the embodiment of the present invention.
[0060] It should be understood that after the vector data is quantified by dimension upgrade, the vector base can be deployed or retrieved for the storage-computing integrated chip through a vector writing tool or a vector retrieval tool. Figure 2 As shown, when deploying the base vector for the storage-computing integrated chip, the vector data is the original vector, which is quantized by the above steps S11-S12 and used as the base vector to be written into the vector base of the storage-computing integrated chip through the vector writing tool. Figure 3As shown, when searching for base library vectors for the storage-computing integrated chip, the vector data is the vector to be searched. After the vector to be searched is quantized by the above-mentioned steps S11-S12, the base library vectors in the vector base library of the storage-computing integrated chip are searched by the vector retrieval tool to obtain the top-k base library vectors. It should be understood that the base library vectors in the vector base library are all deployed after the dimensionality increase and quantization processing of the above-mentioned steps S11-S12.
[0061] The embodiment of the present invention can solve the problem of precision loss caused by direct quantization of vectors after deployment of storage-computing integrated chip by determining the dimension-upgrading conversion matrix based on the vector distance invariance constraint rule before base-base vector deployment or base-base vector retrieval, and quantizing the pre-processed vector data based on the dimension-upgrading conversion matrix. The dimension of the vector data after dimension-upgrading can be adjusted according to the needs in combination with the precision or size of the storage-computing integrated chip, so that the vector can be quantized to a specified number of bits, so that the matrix multiplication and addition advantages of the storage-computing integrated chip can be fully utilized, and the accuracy of base-base vector retrieval for the storage-computing integrated chip can be improved.
[0062] Specifically, determining the dimension-raising transformation matrix according to the vector distance invariance constraint rule includes:
[0063] Constructing a loss function according to the vector distance invariance constraint rule;
[0064] The loss function is used to train the base vectors in the vector base, and the loss function is used to perform back propagation to calculate the dimension-raising transformation matrix.
[0065] In the embodiment of the present invention, based on the vector distance invariance constraint rule (including the relative distance invariance constraint and the absolute distance invariance constraint), a loss function is constructed to integrate the two steps of vector dimension increase and quantization. For example, the loss function shown in the following formula (1) is constructed.
[0066] argmin∑L(Quant(R))(1);
[0067] Among them, L represents the loss function, Quant represents the quantization operation, and R represents the dimensionality increase operation.
[0068] Specifically, for brute force search, an absolute distance invariance constraint is used, and for IVF search, a relative distance invariance constraint is used. The following describes in detail the dimensionality increase and quantization process of vector data in combination with the brute force search and IVF search processes.
[0069] In some embodiments, constructing a loss function according to the vector distance invariance constraint rule includes:
[0070] When performing inverse retrieval, constructing a first quantization function according to the relative distance invariance constraint;
[0071] The loss function is constructed according to the first quantization function.
[0072] Further, constructing a first quantization function according to the relative distance invariance constraint includes:
[0073] Constructing a dimensionality-increasing conversion matrix according to the vector dimension of the vector data and the expected dimension in the high-dimensional space; wherein the expected dimension is determined according to the accuracy or size of the storage-computing integrated chip;
[0074] According to the dimension-raising transformation matrix, the first quantization function is constructed based on the relative distance invariance constraint.
[0075] For example, since the base vector is used for vector retrieval, in the case of IVF retrieval, it is necessary to keep the cluster category of the vector unchanged after dimensionality increase, so that the retrieval result remains unchanged. Therefore, for IVF retrieval, a dimensionality increase quantization method based on the relative distance invariance constraint is considered, which requires that the distance between any two vector data belonging to the same category after dimensionality increase quantization is less than the distance between any vector data not belonging to the same category. Based on the relative distance invariance constraint, a loss function is constructed, and the dimensionality increase conversion matrix is calculated. The dimensionality increase conversion matrix is used to increase the dimensionality of the base vector and the vector to be searched. The specific dimensionality increase quantization process is as follows:
[0076] First, assume that the base vector in the vector base used for training is S∈R d×m , to obtain the representation S'∈R of the base vector in high-dimensional space d ' ×m is the target, where d is the vector dimension of the vector data, m is the number of samples of the vector data, d' represents the expected dimension of the vector data after dimensionality upgrade, d'>d. And for any base vector S 0 , S 1 , S 2 , the base vector after dimension upgrade is S 0 ', S 1 ', S 2 ', where S 0 , S 1 Belong to the same category, S 0 , S 2 belong to different categories; based on the relative distance invariance constraint, there are and
[0077] Then assume that the dimension-raising transformation matrix is T∈R d×d ', based on the above inequality, the following first quantization function can be constructed:
[0078] |Quant(S 0 *T)-Quant(S1 *T)|<|Quant(S 0 *T)-Quant(S 2 *T)| (2);
[0079] Among them, Quant represents the quantization operation, that is, replacing the original float data with integer data of specified precision (for example, 8 bits) to meet the computing requirements of the storage and computing integrated chip.
[0080] It should be noted that the embodiment of the present invention does not specifically limit the calculation method used for the quantization operation. For example, the calculation process of the following quantization operation may be used:
[0081] V q =Q*(V x -min(V x ));
[0082] V x '=V q / Q+min(V x );
[0083] Where, Q = S / (max(V x )-min(V x )); S = 1 < <bits-1。V x Represents the original floating-point input, V q Represents the quantized fixed-point value, V x ' represents the floating point number restored according to the quantization parameter, and bits represents the number of quantization bits.
[0084] Quant(S 0 *T) as an example, the upgraded base vector S 0 *T as raw floating point input V x Through the above calculation process, the quantized base vector can be obtained, that is, the floating point number V restored according to the quantization parameter x '.
[0085] In an embodiment of the present invention, the value of the expected dimension d' can be adjusted according to the accuracy of the storage-computing integrated chip. In general, the lower the accuracy of the storage-computing integrated chip, the larger the value of the expected dimension d'. The value of the expected dimension d' can also be set to different values of the expected dimension d', and then the value of the loss function calculated based on the different values of the expected dimension d', and the expected dimension d' corresponding to the lowest value of the loss function is selected, or the expected dimension d' value with the largest value of the loss function is selected according to the size of the storage-computing integrated chip.
[0086] Then, the loss function is constructed according to the first quantization function formula (2) above. For example, triplet loss is used to construct the loss function, and the base vectors in the vector base are used as training data. The value of the dimensionality-increasing transformation matrix T in the loss function is calculated by back propagation to obtain the final dimensionality-increasing transformation matrix T.
[0087] Later, when the vector is deployed, the original d-dimensional vector data A is calculated through A*T to obtain the d'-dimensional base vector after dimensionality upgrade, and the vector writing tool is used to deploy it to the storage and computing integrated chip.
[0088] During vector retrieval, the d-dimensional vector to be retrieved Q is calculated by Q*T to obtain the base vector of d' dimension after dimensional upgrading, and the ID of the subsequent vector is retrieved by using the vector retrieval tool.
[0089] In some embodiments, constructing a loss function according to the vector distance invariance constraint rule includes:
[0090] When brute force retrieval is performed, a second quantization function is constructed according to the absolute distance invariance constraint;
[0091] The loss function is constructed according to the second quantization function.
[0092] Similarly, according to the dimension-raising transformation matrix constructed above, the second quantization function is constructed based on the relative distance invariance constraint.
[0093] For example, during brute force retrieval, consider the dimension-upgrading quantization method based on the absolute distance invariance constraint, requiring that the distance between any two vector data belonging to the same class after dimension-upgrading quantization is the same as the distance between the corresponding vector data before dimension-upgrading quantization. Based on the absolute distance invariance constraint, the loss function is constructed, the dimension-upgrading transformation matrix is calculated, and the dimension-upgrading transformation matrix is used to upscale the base vector and the vector to be searched. The specific dimension-upgrading quantization process is as follows:
[0094] First, assume that the base vector in the vector base used for training is S∈R d×m , to obtain the representation S'∈R of the base vector in high-dimensional space d ' ×m is the target, where d is the vector dimension of the vector data, m is the number of samples of the vector data, d' represents the expected dimension of the vector data after dimensionality upgrade, d'>d. And for any base vector S 0 , S 1 , the base vector after dimension upgrade is S 0 ', S 1 ', where S 0 , S 1 belong to the same category; based on the absolute distance invariance constraint, there is
[0095] Then assume that the transformation matrix is T∈R d×d ', based on the above equation, the following second quantization function can be constructed:
[0096] |Quant(S 0 *T)-Quant(S 1 *T)|=|S 0 -S 1 | (3);
[0097] It should be understood that the calculation process of the quantization operation in formula (3) can refer to the calculation process of the quantization operation in the above-mentioned first quantization function, and will not be repeated here.
[0098] Similarly, the loss function is constructed according to the second quantization function formula (3), such as loss = |Quant(S 0 *T)-Quant(S 1 *T)|-|S 0 -S 1 |, and use the base vectors in the vector base as training data, calculate the value of the dimension-upgrading conversion matrix T in the loss function through back propagation, and obtain the final dimension-upgrading conversion matrix T. When deploying vectors, A*T is used to calculate the original d-dimensional vector data A to obtain the base vector of d' dimensions after dimension-upgrading, and the vector writing tool is used to deploy it to the storage and computing integrated chip. When searching for vectors, Q*T is used to calculate the vector Q to be searched of the d-dimensional vector data to obtain the base vector of d' dimensions after dimension-upgrading, and the vector search tool is used to retrieve the ID of the subsequent vector.
[0099] Compared with the prior art, the beneficial effects of the embodiments of the present invention are:
[0100] (1) By deploying the vector base processing system of the vector preprocessing module and the vector dimension upgrading and quantization module, and connecting the vector writing tool and vector retrieval tool of the software tool chain, preprocessing and dimension upgrading and quantization are performed before base vector deployment and retrieval. This can solve the problem of precision loss caused by direct quantization of vectors after deployment with storage and computing integrated chips, and is suitable for low-bit storage scenarios including storage and computing integrated. At the same time, merging the two steps of dimension upgrading and quantization can reduce the error of the two steps separately and simplify the user operation process.
[0101] (2) Compared with the existing vector retrieval method for storage-computing integrated chips that uses the multiplication and addition characteristics of storage-computing integrated arrays, the impact of the data accuracy of the storage-computing integrated chip is considered, the relative vector is upgraded in dimension and then quantized, which can avoid the accuracy loss caused by direct quantization and is suitable for large-base / low-dimensional scenarios.
[0102] (3) Compared with the existing method of quantizing the target vector by deephashing, the embodiment of the present invention can quantize the vector to a specified number of bits as required. Under the same vector length, it contains less information, which can improve the accuracy under large-scale databases and give full play to the matrix multiplication and addition advantages of the storage and computing integrated chip.
[0103] (4) Compared with the existing vector retrieval method based on residual quantization, the embodiment of the present invention can perform dimension-upgrading quantization for IVF and brute force retrieval respectively, and can obtain higher accuracy in both scenarios.
[0104] See also Figure 4 , Figure 4 1 is a structural block diagram of a vector data processing system provided by an embodiment of the present invention, wherein the vector data processing system comprises:
[0105] A vector preprocessing module 11 is used to preprocess the vector data to obtain preprocessed vector data;
[0106] The vector up-dimensioning quantization module 12 is used to determine the up-dimensioning transformation matrix according to the vector distance invariance constraint rule, and perform up-dimensioning quantization on the pre-processed vector data according to the up-dimensioning transformation matrix.
[0107] In an optional embodiment, the vector distance invariance constraint rule includes a relative distance invariance constraint and an absolute distance invariance constraint; the relative distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is smaller than the distance between any two vector data not belonging to the same class; the absolute distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is the same as the distance between the corresponding two vector data before dimensionality upscaling quantization.
[0108] In an optional embodiment, the vector dimension-upgrading quantization module 12 includes:
[0109] A loss function construction unit, used to construct a loss function according to the vector distance invariance constraint rule;
[0110] The dimension-increasing conversion matrix calculation unit is used to use the loss function to train the base vectors in the vector base library, and use the loss function to perform back propagation to calculate the dimension-increasing conversion matrix.
[0111] In an optional embodiment, the loss function construction unit includes:
[0112] A first quantization function construction subunit is used to construct a first quantization function according to the relative distance invariance constraint during inverted retrieval;
[0113] The first loss function construction subunit is used to construct the loss function according to the first quantization function.
[0114] In an optional embodiment, the loss function construction unit includes:
[0115] A second quantization function construction subunit is used to construct a second quantization function according to the absolute distance invariance constraint when performing brute force retrieval;
[0116] The second loss function construction subunit is used to construct the loss function according to the second quantization function.
[0117] In an optional embodiment, the first quantization function construction subunit includes:
[0118] A dimension-raising conversion matrix construction subunit is used to construct a dimension-raising conversion matrix according to the vector dimension of the vector data and the expected dimension in the high-dimensional space; wherein the expected dimension is determined according to the accuracy or size of the storage-computing integrated chip;
[0119] The quantization function construction subunit is used to construct the first quantization function according to the dimension-raising transformation matrix and based on the relative distance invariance constraint.
[0120] In an optional embodiment, the vector preprocessing module 11 includes:
[0121] The preprocessing unit is used to perform at least one of centralization processing, standardization processing and normalization processing on the vector data to obtain preprocessed vector data.
[0122] It should be noted that the working process of each module in the vector data processing system described in the embodiment of the present invention can refer to the working process of the vector data processing method described in the above embodiment, and the technical effect achieved is the same as the vector data processing method described in the above embodiment, which will not be repeated here.
[0123] See also Figure 5 , Figure 5 2 is a block diagram of a vector data processing device provided in an embodiment of the present invention. The vector data processing device includes a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. When the processor 21 executes the computer program, the steps in the above-mentioned various vector data processing method embodiments are implemented, such as steps S11 to S12.
[0124] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the vector data processing device.
[0125] The vector data processing device may include, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will appreciate that the schematic diagram is merely an example of a vector data processing device and does not constitute a limitation on the vector data processing device. The vector data processing device may include more or fewer components than shown in the diagram, or may combine certain components, or different components. For example, the vector data processing device may also include input and output devices, network access devices, buses, and the like.
[0126] The processor 21 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 21 is the control center of the vector data processing device, and uses various interfaces and lines to connect various parts of the entire vector data processing device.
[0127] The memory 22 can be used to store the computer program and / or module. The processor 21 realizes various functions of the vector data processing device by running or executing the computer program and / or module stored in the memory 22 and calling the data stored in the memory 22. The memory 22 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 22 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0128] Wherein, if the module / unit integrated in the vector data processing device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor 21. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0129] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0130] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, many improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A vector data processing method, characterized in that: include: Preprocessing the vector data to obtain preprocessed vector data; According to the vector distance invariance constraint rule, determine the dimension-increasing transformation matrix; According to the dimensionality-increasing transformation matrix, the preprocessed vector data is quantized by dimensionality-increasing.
2. The vector data processing method according to claim 1, characterized in that: The vector distance invariance constraint rule includes a relative distance invariance constraint and an absolute distance invariance constraint; the relative distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is smaller than the distance between any two vector data not belonging to the same class; the absolute distance invariance constraint indicates that the distance between any two vector data belonging to the same class after dimensionality upscaling quantization is the same as the distance between the corresponding two vector data before dimensionality upscaling quantization.
3. The vector data processing method according to claim 2, characterized in that: Determining the dimension-raising transformation matrix according to the vector distance invariance constraint rule includes: Constructing a loss function according to the vector distance invariance constraint rule; The loss function is used to train the base vectors in the vector base, and the loss function is used to perform back propagation to calculate the dimension-raising transformation matrix.
4. The vector data processing method according to claim 3, characterized in that: The step of constructing a loss function according to the vector distance invariance constraint rule includes: When performing inverse retrieval, constructing a first quantization function according to the relative distance invariance constraint; The loss function is constructed according to the first quantization function.
5. The vector data processing method according to claim 3, characterized in that: The step of constructing a loss function according to the vector distance invariance constraint rule includes: When brute force retrieval is performed, a second quantization function is constructed according to the absolute distance invariance constraint; The loss function is constructed according to the second quantization function.
6. The vector data processing method according to claim 4, characterized in that: The step of constructing a first quantization function according to the relative distance invariance constraint comprises: Constructing a dimensionality-increasing conversion matrix according to the vector dimension of the vector data and the expected dimension in the high-dimensional space; wherein the expected dimension is determined according to the accuracy or size of the storage-computing integrated chip; According to the dimension-raising transformation matrix, the first quantization function is constructed based on the relative distance invariance constraint.
7. The vector data processing method according to claim 1, characterized in that: The preprocessing of the vector data to obtain the preprocessed vector data includes: The vector data is subjected to at least one of centralization processing, standardization processing and normalization processing to obtain preprocessed vector data.
8. A vector data processing system, characterized in that: include: A vector preprocessing module is used to preprocess vector data to obtain preprocessed vector data; The vector dimension-upgrading quantization module is used to determine the dimension-upgrading transformation matrix according to the vector distance invariance constraint rule, and perform dimension-upgrading quantization on the preprocessed vector data according to the dimension-upgrading transformation matrix.
9. A vector data processing device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the vector data processing method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the vector data processing method according to any one of claims 1 to 7.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the vector data processing method described in any one of claims 1 to 7 is implemented.