A similar vector existence query method, system, device and storage medium

By combining locality-sensitive hashing and Bloom filter techniques, vectors are quantized and encoded for fast lookup, solving the problem of high computational and storage overhead in similar vector retrieval and achieving efficient and accurate similar vector existence lookup.

CN116561178BActive Publication Date: 2026-02-27CHENGDU UNION BIG DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310518792.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-10
Publication Date
2026-02-27
Estimated Expiration
2043-05-10

AI Technical Summary

Technical Problem

Existing similar vector retrieval techniques suffer from excessive computational and storage overhead when searching for the existence of vectors that are less than a certain threshold distance from the query vector, and are prone to missed detections and false detections.

Method used

By combining locality-sensitive hashing and Bloom filter techniques, vectors are subjected to locality-sensitive quantization encoding. Bloom filters are then used to quickly query the existence of the encoding, and the search range is dynamically adjusted to achieve the effect of no missed detections and no false detections.

Benefits of technology

It effectively reduces the computational and storage overhead of similar vector retrieval, improves query speed and accuracy, and reduces the occurrence of false positives and false negatives.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116561178B_ABST
    Figure CN116561178B_ABST
Patent Text Reader

Abstract

The application provides a similar vector existence query method, system, device and storage medium, relates to the similar vector retrieval technical field, and the method comprises an index construction process and a query process; the index construction process firstly carries out local sensitive hash coding on a preset vector library to obtain a coding library, and records coding parameters simultaneously; then, a plurality of integer number vectors of the coding library are input to a plurality of Bloom filters; the query process firstly calculates a coding search range based on a preset distance threshold and the coding parameters; then, local sensitive hash coding is carried out on a query vector to obtain a query coding vector; finally, the query coding vector is input to the plurality of Bloom filters, and the existence of a similar vector is judged in combination with the coding search range. The application effectively combines the two technologies of local sensitive hash coding and Bloom filter, can dynamically adjust the search range according to the distance threshold during the query, and achieves the query effect without missing detection.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of similar vector retrieval, in particular to a similar vector existence query method, system, device and storage medium. BACKGROUND

[0002] Vector Similarity Search (VSS) is a widely used retrieval technique. Unlike traditional exact search and text matching search, the similar vector search problem is to index a set of vectors in a metric space and find the vector in the index that is closest to the query vector or has a distance less than a certain threshold. Usually, the vector library constructed by the index is large in size and high in dimension. Exhaustive search on the vector library can guarantee 100% recall rate, but the time and computational overhead is too high. Therefore, the core of the similar vector search technology is to construct an index structure with high recall rate and short retrieval time, which is widely used in image and video retrieval, text semantic retrieval, anomaly detection and other problems.

[0003] For a sub-problem of the similar vector search problem, i.e. the similar vector existence query problem, unlike similar vector search, this problem only concerns whether there is a vector in the vector library that is within a certain threshold distance from the query vector, and does not concern which specific vector in the vector library is the similar vector. It can be said that the similar vector existence query problem is a simplified similar vector search problem. If the computational overhead or query time of the similar vector existence query technology is much smaller than that of the similar vector search, the former can partially replace the latter. For example, in the anomaly detection problem, we usually only care whether the approximate vector exists in the vector library, so we can replace it with the similar vector existence query technology. For another example, in the similar vector search process, sometimes we only want to query the approximate vector within a certain threshold distance, but we are not sure whether the required vector exists. At this time, we can first query whether the approximate vector that meets the distance requirement exists (smaller overhead), and then search if it exists (larger overhead). In practice, it is very difficult to completely and accurately query whether the similar vector exists, and it is easy to miss or miss detection, and the retrieval time is longer and the storage overhead is larger. SUMMARY

[0004] The application provides a similar vector existence query method, system, device and storage medium, which effectively combines locality sensitive hash (LSH) and Bloom filter (FB) technologies, performs locality sensitive quantization coding on vectors first, and then uses the Bloom filter to quickly query the coding existence, so as to finally determine whether the target exists, can dynamically adjust the search range according to the coding search range at the time of query, so as to achieve a query effect without missing detection and false detection, and meanwhile, the Bloom filter has a faster query speed and the coding compression capability of the locality sensitive hash, so that the query time can be greatly reduced, and the calculation and storage overheads are greatly reduced compared with conventional similar vector retrieval.

[0005] In a first aspect, the application provides a similar vector existence query method, which comprises an index construction process and a query process.

[0006] The index construction process is as follows:

[0007] The preset vector library is subjected to locality sensitive hash coding to obtain a coding library, and the coding parameters are recorded, wherein the coding library comprises a plurality of integer number vectors.

[0008] The plurality of integer number vectors of the coding library are input into a plurality of Bloom filters.

[0009] The query process is as follows:

[0010] The coding search range is calculated based on the preset distance threshold and the coding parameters.

[0011] The query vector is subjected to locality sensitive hash coding to obtain a query coding vector, wherein the query coding vector is an integer number vector.

[0012] The query coding vector is input into the plurality of Bloom filters, and the existence of the similar vector is determined in combination with the coding search range.

[0013] In the above embodiment, the locality sensitive hash and the Bloom filter are effectively combined, the vector is subjected to locality sensitive quantization coding first, and then the Bloom filter is used to quickly query the coding existence, so as to finally determine whether the target exists, and the search range can be dynamically adjusted according to the distance threshold at the time of query, so as to achieve a query effect without missing detection and false detection.

[0014] As some optional embodiments of the application, the vector library comprises a plurality of floating point number vectors.

[0015] As some optional embodiments of the application, the process of performing locality sensitive hash coding on the preset vector library to obtain a coding library and recording the coding parameters is as follows:

[0016] define a vector library, an encoding size, and an encoding width, and input the vector library, the encoding size, and the encoding width into a local sensitive hashing model;

[0017] perform local sensitive hashing coding on a plurality of floating-point vectors of the vector library based on the local sensitive hashing model to output an encoding library, an encoding parameter projection matrix, and a mean vector.

[0018] As some optional embodiments of the present application, the process of performing local sensitive hashing coding on a plurality of floating-point vectors of the vector library based on the local sensitive hashing model to output an encoding library, an encoding parameter projection matrix, and a mean vector is as follows:

[0019] perform initialization processing on the encoding library, the encoding parameter projection matrix, and the mean vector based on the encoding size;

[0020] randomly generate a floating-point vector, and perform norm standardization processing on the floating-point vector to form the encoding parameter projection matrix;

[0021] perform dot product processing on the floating-point vector of the encoding parameter projection matrix and the integer vector of the encoding library to form a dot product processing result;

[0022] perform mean processing on the dot product processing result to obtain a mean vector, and perform integer coding processing on the dot product processing result, the mean vector, and the encoding width to form the encoding library.

[0023] As some optional embodiments of the present application, the encoding search range is an upper limit value of a ratio of a distance threshold value to the encoding width, wherein the distance threshold value is not greater than the encoding width.

[0024] In the above embodiment, this query range can ensure that when the distance between a vector in the vector library and a query vector is less than the distance threshold value, the difference between the integer encodings of the two is less than or equal to the encoding search range.

[0025] As some optional embodiments of the present application, performing local sensitive hashing coding on the query vector is performing integer coding processing on the query vector based on the encoding parameter projection matrix and the mean vector to form a query encoding vector.

[0026] As some optional embodiments of the present application, the process of inputting the query encoding vector into a plurality of Bloom filters and judging the existence of a similar vector in combination with the encoding search range is as follows:

[0027] input the encoding search range and the query encoding vector into a plurality of Bloom filters, and if there are corresponding integer vectors in all Bloom filters, it is determined that a similar vector exists, otherwise it is determined that a similar vector does not exist.

[0028] In the above embodiments, in a second aspect, the present application provides a similar vector existence query system, the system comprises:

[0029] An index construction unit, which firstly performs local sensitive hash coding on a preset vector library to obtain a coding library, while recording the coding parameters thereof, wherein the coding library comprises a plurality of integer number vectors; and then inputs the integer number vectors of the coding library to a plurality of Bloom filters;

[0030] A query unit, which firstly calculates a coding search range based on a preset distance threshold and the coding parameters; then performs local sensitive hash coding on a query vector to obtain a query coding vector, wherein the query coding vector is an integer number vector; and finally inputs the query coding vector to the plurality of Bloom filters, and judges the existence of similar vectors in combination with the coding search range.

[0031] In a third aspect, the present application provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the similar vector existence query method when executing the computer program.

[0032] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, wherein the computer program is executable by a processor to implement the similar vector existence query method.

[0033] The present application has the following beneficial effects: the present application effectively combines local sensitive hash and Bloom filter, and designs a vector coding and query method which is sensitive to vector distance and dynamic, and can dynamically adjust the coding search range according to the distance threshold during query, so as to achieve the query effect of no missed detection and false detection; at the same time, by using the faster query speed of Bloom filter and the coding compression capability of local sensitive hash, the query time can be greatly reduced, and the operation and storage overheads are greatly reduced compared with the conventional similar vector retrieval method. BRIEF DESCRIPTION OF DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be considered as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0035] Figure 1 is a flowchart of the similar vector existence query method according to the embodiments of the present application;

[0036] Figure 2This is a schematic diagram illustrating the distance sensitivity of local sensitive hashing according to an embodiment of the present invention;

[0037] Figure 3 This is a schematic diagram illustrating the case where similar vectors are encoded into different integers using local sensitive hashing, as described in an embodiment of the present invention. Detailed Implementation

[0038] To better understand the above technical solutions, the technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments and specific features in the embodiments are detailed descriptions of the technical solutions of the present invention, rather than limitations thereof. In the absence of conflict, the technical features in the embodiments and embodiments can be combined with each other.

[0039] It should also be understood that, in order to simplify the description of the invention and thus aid in the understanding of at least one embodiment, multiple features may sometimes be grouped into a single embodiment, drawing, or description thereof in the foregoing description of the embodiments of the invention. However, this method of disclosure does not imply that the subject matter of the invention requires more features than those mentioned in the claims. In fact, the embodiments contain fewer features than all the features of the single embodiment disclosed above.

[0040] Example 1

[0041] This invention provides a method for querying the existence of similar vectors. The technical problem to be solved by this method is defined as follows:

[0042] There exists a vector library V = {v1, v2, ..., v...} N}, where each vector is a D-dimensional floating-point vector v i ∈R D For any query vector q∈R D and distance threshold δ∈R + Query whether an R-dimensional floating-point vector v exists in the vector library V. i The Euclidean distance to the query vector q is no greater than the distance threshold δ, that is:

[0043]

[0044] The method can reduce the false negative rate (i.e., the probability of judging that a similar vector does not exist when it actually exists), the false positive rate (i.e., the probability of judging that a similar vector exists when it actually does not exist), and the computation and storage overhead.

[0045] Please see Figure 1 The method includes an index building process and a query process;

[0046] (1) The index building process is as follows:

[0047] (1.1) For the pre-defined vector library V = {v1, v2, ..., v...} N Perform locality-sensitive hashing to obtain the encoding library C = {c1, c2, ..., c}. N}, and simultaneously record its encoding parameters, wherein the vector library V = {v1, v2, ..., v N The encoding library C = {c1, c2, ..., c...} comprises N D-dimensional floating-point vectors. N It includes N R-dimensional integer vectors;

[0048] In this embodiment of the invention, a preset vector library V = {v1, v2, ..., v...} is used. N Perform locality-sensitive hashing to obtain the encoding library C = {c1, c2, ..., c}. N The process of recording its encoding parameters is as follows:

[0049] (1.11) Define a vector library V = {v1, v2, ..., v...} N}, encoding size R and encoding width W, and the vector library V = {v1, v2, ..., v N The encoding size R and encoding width W are input to the locality-sensitive hashing model;

[0050] (1.12) Based on the locality-sensitive hashing model, the vector library V = {v1, v2, ..., v...} is processed. N Locality-sensitive hashing is performed on N D-dimensional floating-point vectors to output a coding library C = {c1, c2, ..., c}. N The encoding parameters include the projection matrix U and the mean vector M.

[0051] Specifically, the Locality Sensitive Hash (LSH) encoding involved in this embodiment of the invention is a classic vector quantization method. This embodiment makes minor improvements to achieve encoding that is more sensitive to distance thresholds. First, the encoding size R of the vector needs to be set. R can be any positive integer; a larger value results in higher accuracy but also higher storage and computational overhead. When memory is sufficient, R = D is a suitable choice. Then, an encoding width W (a floating-point number) needs to be set. After LSH encoding, two vectors encoded as the same integer value have a maximum distance of W in the projection space. A smaller W results in higher query accuracy but also higher storage overhead. If the minimum distance threshold δ for the query is known, W = 2δ can be set if memory allows.

[0052] After selecting the encoding size R and encoding width W, the following locality-sensitive hashing algorithm is executed:

[0053] ①Based on the encoding size R, the encoding library C = {c1, c2, ..., c...} N The encoding parameter projection matrix U and the mean vector M are initialized.

[0054] ② Randomly generate floating-point vector u i And for the floating-point vector u i Norm normalization (L2 normalization) is performed to form the coding parameter projection matrix U = {u1, u2, ..., u...} R};

[0055] ③ Project the encoding parameter matrix u = {u1, u2, ..., u...} R The floating-point vector and encoding library C = {c1, c2, ..., c} N The integer vector dot product is processed to form the result C at the dot product point. ji ;

[0056] ④ The result of the dot product is C ji Perform mean processing to obtain the mean vector M. i And based on the result C of the dot product processing ji Mean vector M i And the encoding width W is processed into integers to form an encoding library C = {c1, c2, ..., c...} N};

[0057] Specifically, the computer algorithm for locality-sensitive hashing is as follows:

[0058]

[0059]

[0060] The locality-sensitive hashing used in this embodiment of the invention has good distance sensitivity properties. Please refer to [link to relevant documentation]. Figure 2 Three vectors, v1, v2, and v3, are projected onto random hyperplanes u1 and u2, respectively. After projection, the locality-sensitive hash codes C of two adjacent vectors v1 and v2 are... 11 and C 12 C 21 and C 22 They are all very similar. After encoding as integers, based on the appropriate encoding width W, C 11 and C 12 C 21 and C 22 They will also be encoded as the same or adjacent integers. The encoding of v3, C... 23 Although in the projection direction u2 and C 21 and C 22 Close to, but in another projection direction u1, it is similar to C.11 and C 12 far apart, will be encoded into different integers with a large difference. When the size of the encoding width W is close to D, there is a large probability that at least one projection direction makes the vectors with a distance not close to be encoded into two integers with a large difference.

[0061] (1.2) input the integer vector of each dimension of the encoding library C = {c1, c2,..., c N} into R Bloom filters to complete the index construction process;

[0062] In the embodiments of the present application, the Bloom filter is a classical data structure that can be used to quickly query the existence of an element. Since the present application does not have special use of this method, the algorithm process will not be described in detail in the embodiments of the present application. It only needs to be explained that a Bloom filter can be established on a set of integers, and then it can be quickly queried (constant time complexity) whether a certain integer exists in the set. The Bloom filter can guarantee no missed detection, that is, if the queried integer exists in the set, it can be determined to exist. However, there is a certain false positive rate, that is, when the queried integer does not exist in the set, there is a small probability of false positive. By increasing the local sensitive hash algorithm and the encoding search range, the false positive rate can be reduced to an acceptable range. In theory, the Bloom filter used here can be replaced by a Cuckoo Filter (CF) filter or other data structures with the same function.

[0063] In this step of the present application, a Bloom filter is constructed for each column of the encoding library C ∈ Z N×R , that is, R Bloom filters are constructed, and the i-th Bloom filter is established on the set {C 1i , C 2i ..., C Ni}.

[0064] (2) The query process is as follows:

[0065] (2.1) based on the preset distance threshold δ and the encoding parameters recorded in the index construction process, the encoding search range is calculated;

[0066] This step calculates the query range of the distance threshold δ in each Bloom filter. If a certain vector v i in the vector library has a distance less than δ from the query vector q, but δ > W, there is a certain probability that the two vectors are encoded into different integers. Please refer to Figure 3 , the query vector q will be encoded into integer 7, and the vector v i is encoded into 6;

[0067] The calculation of the query range is as follows:

[0068]

[0069] That is, the encoding search range is an upper limit value of the ratio of the distance threshold value and the encoding width, wherein the distance threshold value is not greater than the encoding width; this query range can guarantee that when the distance between the vector v and the query vector q is less than delta, the difference between the integer encodings of the two is less than or equal to S.

[0070] (2.2) Locally sensitive hash coding is performed on the query vector q to obtain a query encoding vector Q={Q1, Q2,..., Q R}, wherein the query encoding vector Q={Q1, Q2,..., Q R} is an R-dimensional integer number vector.

[0071] That is, using the encoding parameters U and M in (1), the encoding Q={Q1, Q2,..., Q R} of q can be obtained, wherein:

[0072]

[0073] (2.3) The query encoding vector Q={Q1, Q2,..., Q R} is input into R Bloom filters, and the existence of a similar vector is judged in combination with the encoding search range.

[0074] In the embodiment of the application, the existence judgment process of the similar vector is as follows:

[0075] (2.31) The encoding search range and the query encoding vector are input into several Bloom filters;

[0076] (2.32) If there are corresponding integer number vectors in all Bloom filters, it is judged that the similar vector exists, otherwise, it is judged that the similar vector does not exist.

[0077] Specifically, the computer algorithm for judging the existence of the similar vector is as follows:

[0078]

[0079]

[0080] The input of the query similar vector existence algorithm in the embodiment of the application includes R Bloom filters, an encoding query range S and a query encoding Q={Q1, Q2,..., Q R}. The Bloom filter (BF i (t)) is used in the form of a function call, which means querying whether the integer value t exists in the Bloom filter BF i .

[0081] In summary, the embodiment of the present application effectively combines the two technologies of locality sensitive hashing (LSH) and Bloom filter (FB), firstly performs locality sensitive quantization coding on the vector, then uses the Bloom filter to quickly query the existence of the coding, and finally judges whether the target exists, can dynamically adjust the search range according to the coding search range during the query, so as to achieve the query effect without missing detection, at the same time, by using the faster query speed of the Bloom filter and the coding compression capability of the locality sensitive hashing, the query time can be greatly reduced, and the calculation and storage overheads are greatly reduced compared with the conventional similar vector retrieval.

[0082] Embodiment 2

[0083] The present application provides a small sample panel defect detection system, which corresponds to the method of embodiment 1, and the system comprises:

[0084] (1) an index construction unit, which firstly performs locality sensitive hashing coding on a preset vector library V={v1, v2,..., v N} to obtain a coding library C={c1, c2,..., c N}, and records the coding parameters, wherein the coding library c={c1, c2,..., c N} comprises N R-dimensional integer number vectors; and then inputs the N R-dimensional integer number vectors of the coding library C={c1, c2,..., c N} into R Bloom filters;

[0085] In the embodiment of the present application, the preset vector library V={v1, v2,..., v N} is subjected to locality sensitive hashing coding to obtain a coding library C={c1, c2,..., c N}, and the process of recording the coding parameters is as follows:

[0086] (1.11) defining the vector library V={v1, v2,..., v N}, the coding size R and the coding width W, and inputting the vector library V={v1, v2,..., v N}, the coding size R and the coding width W into a locality sensitive hashing model;

[0087] (1.12) performing locality sensitive hashing coding on the N D-dimensional floating point number vectors of the vector library V={v1, v2,..., v N} based on the locality sensitive hashing model, to output the coding library C={c1, c2,..., c N}, the coding parameter projection matrix U and the mean vector M;

[0088] (2) a query unit, which firstly calculates an encoding search range S based on a preset distance threshold δ and the encoding parameter; then performs local sensitive hash coding on a query vector q to obtain a query encoding vector Q={Q1, Q2,..., Q R}, wherein the query encoding vector Q={Q1, Q2,..., Q R} is an integer number vector; and finally inputs the query encoding vector Q={Q1, Q2,..., Q R} into R Bloom filters and judges the existence of a similar vector in combination with the encoding search range s.

[0089] The query range is calculated as follows:

[0090]

[0091] That is, the encoding search range is an upper limit value in the ratio of the distance threshold to the encoding width, wherein the distance threshold is not greater than the encoding width; this query range can guarantee that when the distance between the vector v and the query vector q is less than δ, the difference between the integer encodings of the two is less than or equal to S;

[0092] In the embodiment of the application, the existence judgment process of the similar vector is as follows:

[0093] (2.31) input the encoding search range and the query encoding vector into a plurality of Bloom filters;

[0094] (2.32) if there are corresponding integer number vectors in all Bloom filters, it is determined that the similar vector exists, otherwise, it is determined that the similar vector does not exist.

[0095] The system effectively combines local sensitive hash and Bloom filter, designs a vector encoding and query method sensitive to vector distance and dynamic, can dynamically adjust the encoding search range according to the distance threshold δ at the time of query, so as to achieve the query effect of no missed detection and false detection; at the same time, by using the faster query speed of Bloom filter and the coding compression capability of local sensitive hash, the query time can be greatly reduced, and the operation and storage overheads are greatly reduced compared with the conventional similar vector retrieval method.

[0096] Embodiment 3

[0097] The application provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the similar vector existence query method of embodiment 1 when executing the computer program.

[0098] The computer device provided in the embodiment can implement the method of embodiment 1, and details are not repeated here.

[0099] Embodiment 4

[0100] The application provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the similarity vector existence query method in the embodiment 1.

[0101] The computer readable storage medium provided in the embodiment can realize the method in the embodiment 1, and details are not described here again to avoid repetition.

[0102] The processor can be a central processing unit (CPU), and can also be 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, and the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0103] The above embodiments only illustrate the principles and effects of the application, and are not used to limit the application. Any person skilled in the art can modify or change the above embodiments without departing from the spirit and scope of the application. Therefore, all equivalent modifications or changes made by those skilled in the art without departing from the spirit and technical ideas of the application should be covered by the claims of the application.

Claims

1. A method for querying the existence of similar vectors, characterized in that, The method includes an index building process and a query process; The index building process is as follows: Locality-sensitive hashing is performed on a preset vector library to obtain an encoding library, and its encoding parameters are recorded. The encoding library includes several integer vectors. Input several integer vectors from the encoding library into several Bloom filters; The query process is as follows: The encoding retrieval range is calculated based on the preset distance threshold and the encoding parameters; The calculation of the encoding retrieval range is as follows: ; Where S represents the encoding retrieval range, W represents the preset distance threshold, and W represents the encoding width. The encoding retrieval range has an upper limit of the ratio of the distance threshold to the encoding width, and the distance threshold is not greater than the encoding width. The query vector is subjected to locality-sensitive hashing to obtain a query encoded vector, wherein the query encoded vector is an integer vector; The query encoding vector is input into several Bloom filters, and the existence of similar vectors is determined by combining the encoding retrieval range. The process of determining the existence of similar vectors by combining the encoding retrieval range is as follows: Input the encoding retrieval range S and the query encoding vector into several Bloom filters. For each dimension of the query encoding vector, search in its corresponding Bloom filter with the query encoding vector as the center and the positive and negative encoding retrieval range S as the radius. If the corresponding integer vector exists in all Bloom filters, it is determined that the similar vector exists; otherwise, it is determined that the similar vector does not exist.

2. The method for querying the existence of similar vectors according to claim 1, characterized in that, The vector library includes several floating-point vectors.

3. The method for querying the existence of similar vectors according to claim 2, characterized in that, The process of performing locality-sensitive hashing on a pre-defined vector library to obtain an encoded library, while simultaneously recording its encoding parameters, is as follows: Define the vector library, encoding size, and encoding width, and input the vector library, encoding size, and encoding width into the locality sensitive hashing model; Based on the locality-sensitive hashing model, several floating-point vectors in the vector library are encoded using locality-sensitive hashing to output the encoding library, the encoding parameter projection matrix, and the mean vector.

4. The method for querying the existence of similar vectors according to claim 3, characterized in that, The process of performing locality-sensitive hashing (LSH) encoding on several floating-point vectors in the vector library to output the encoding library, the encoding parameter projection matrix, and the mean is as follows: The encoding library, encoding parameter projection matrix, and mean vector are initialized based on the encoding size. Randomly generate floating-point number vectors and perform norm normalization on the floating-point number vectors to form the encoding parameter projection matrix; The floating-point vector of the encoding parameter projection matrix and the integer vector of the encoding library are multiplied by a dot to form the result of the dot product. The dot product result is averaged to obtain a mean vector. Integer encoding is then performed based on the dot product result, the mean vector, and the encoding width to form an encoding library.

5. The method for querying the existence of similar vectors according to claim 1, characterized in that, Locality-sensitive hashing of the query vector is based on the encoding parameter projection matrix and the mean vector. The query vector is encoded by integers to form the query encoded vector.

6. A similarity vector existence query system, characterized in that, The system includes: The index building unit first performs local sensitive hashing on a preset vector library to obtain an encoding library, and records its encoding parameters. The encoding library includes several integer vectors. Then, the several integer vectors of the encoding library are input into several Bloom filters. The query unit first calculates the encoding retrieval range based on a preset distance threshold and the encoding parameters; then it performs local sensitive hashing on the query vector to obtain a query encoding vector, wherein the query encoding vector is an integer vector; finally, it inputs the query encoding vector into several Bloom filters and determines the existence of similar vectors in conjunction with the encoding retrieval range. The calculation of the encoding retrieval range is as follows: ; Where S represents the encoding retrieval range, W represents the preset distance threshold, and W represents the encoding width. The encoding retrieval range has an upper limit of the ratio of the distance threshold to the encoding width, and the distance threshold is not greater than the encoding width. The process of determining the existence of similar vectors by combining the encoding retrieval range is as follows: Input the encoding retrieval range S and the query encoding vector into several Bloom filters. For each dimension of the query encoding vector, search in its corresponding Bloom filter with the query encoding vector as the center and the positive and negative encoding retrieval range S as the radius. If the corresponding integer vector exists in all Bloom filters, it is determined that the similar vector exists; otherwise, it is determined that the similar vector does not exist.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes a computer program, it implements the similarity vector existence query method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements a similar vector existence query method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Approximate member query method based on hamming distance

    CN109062941A

  • Image query method and system based on content semantic metadata

    CN110413807A