A large-scale image retrieval acceleration method and device based on non-uniform quantization
By decoupling the feature space through principal component analysis and non-uniform quantization strategies, short and long codes are generated, solving the problems of large errors and resource waste in traditional quantization methods, achieving efficient image retrieval, and improving the performance of retrieval systems deployed on FPGAs.
Patent Information
- Application Number
- CN202611464280.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2026-08-19
- Filing Date
- 2026-09-20
- Publication Date
- 2026-11-24
AI Technical Summary
Existing traditional quantization methods suffer from large errors and resource waste in large-scale image retrieval, especially under FPGA deployment, resulting in slow query speed and failing to effectively improve the throughput and energy efficiency of the retrieval system.
A large-scale image retrieval method based on non-uniform quantization is adopted. Principal component analysis is used to decouple the feature space, and a differentiated hybrid bit-width quantization strategy is combined to generate short and long codes. The search pipeline is reconstructed using FPGA hardware to perform efficient approximate nearest neighbor search.
While ensuring retrieval recall, it significantly reduces index storage space and online search latency, solving the problems of resource waste and pipeline blockage in traditional methods, and achieving high concurrency and low latency image retrieval.
Smart Images

Figure CN123157931A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image retrieval and hardware acceleration technology, specifically to an FPGA-accelerated method for large-scale high-dimensional image feature approximate nearest neighbor search based on non-uniform quantization. Background Technology
[0002] Large-scale image retrieval is a fundamental and core task in the fields of computer vision and information retrieval. Faced with massive amounts of high-dimensional image feature data, quickly and accurately searching for candidate results most similar to the query image is a key technical challenge. In practical engineering applications, due to the extremely high time and computational cost of accurately calculating the distances between all image feature vectors, systems typically employ Approximate Nearest Neighbor Search (ANNS) techniques. Vector quantization, as the mainstream dimensionality reduction method in ANNS, significantly compresses memory usage by mapping a high-dimensional continuous space to a finite discrete encoding, and utilizes table lookups or bitwise operations to achieve rapid distance estimation.
[0003] Currently, quantization-based approximate nearest neighbor search faces two main technical bottlenecks: The first is traditional quantization techniques, represented by Product Quantization (PQ). This approach typically divides a high-dimensional data vector into multiple independent subspaces according to their dimensionality and independently applies clustering algorithms to train local subcodebooks within each subspace. However, this method suffers from a fundamental theoretical flaw: a lack of a clear theoretical error bound. Its codebook construction heavily relies on heuristic clustering of the data distribution, and distance estimation directly uses the quantized center points instead of the true vectors, making it difficult to strictly control quantization errors. When processing complex or unknown real-world high-dimensional large-scale image data, it easily leads to a significant drop in recall and poor generalization ability, posing accuracy risks to reliable deployment in practical engineering. The second type is the industry-leading uniform random quantization retrieval method. This technique aims to ensure the robustness of distance estimation through random orthogonal rotation and uniform bit-width compression, theoretically providing an error bound. However, its "uniform quantization bit-width" strategy suffers from significant waste of space and computational resources in practical applications. High-dimensional image feature data typically exhibits a significant long-tail characteristic, meaning that the information contribution (i.e., variance) of different dimensions to distance calculation is severely uneven. This scheme ignores this characteristic and adopts a one-size-fits-all bit-width allocation mechanism, uniformly quantizing all data dimensions to the same number of bits. This results in secondary dimensions, which contain very little information, being quantized with the same precision as the primary dimensions.
[0004] As data dimensions and volumes continue to increase, this uniform strategy results in significant waste of index storage space and introduces a large amount of unnecessary distance calculation overhead. Especially in customized hardware acceleration scenarios that are sensitive to memory and computing resources, such as FPGA deployments, excessive memory access bandwidth requirements and redundant computations can severely slow down the system's query speed, which has become a key bottleneck restricting the improvement of throughput and energy efficiency of existing retrieval systems. Summary of the Invention
[0005] To address the problems of large errors in traditional quantization methods and resource waste and hardware pipeline blockages caused by uniform quantization in large-scale image retrieval, this invention proposes a method for accelerating large-scale image retrieval based on non-uniform quantization. This method decouples and performs non-uniform quantization on the feature space through principal component analysis and reconstructs the search pipeline on the FPGA hardware, thereby significantly reducing index storage space and online search latency while maintaining retrieval recall.
[0006] The technical solution of this invention is as follows:
[0007] A method for accelerating large-scale image retrieval based on non-uniform quantization includes the following steps:
[0008] S1: The principal component analysis algorithm is used to decouple the feature space of the image dataset to be indexed, decoupling all the original feature vectors into principal component vectors and secondary component vectors.
[0009] S2: Cluster the decoupled principal component vectors to generate inverted clusters, normalize local residuals, and perform random orthogonal rotations to obtain the principal component inverse mapping vectors;
[0010] S3: Based on a differentiated non-uniform mixed bit-width quantization strategy, short codes and long codes of each major component vector are generated; and local constant factors of each major component vector are extracted.
[0011] S4: Input the query vector and decouple it into a primary component vector and a secondary component vector. Calculate the distance between the primary component vector of the query vector and the centroid of each inverted cluster in parallel. Select several inverted clusters with the closest spatial distance as candidate clusters. Start the time-division multiplexing mechanism of the computing unit to pre-calculate common parameters that are strongly correlated with the current query vector for the candidate clusters.
[0012] S5: Based on the long code, short code, local constant factors and common parameters, perform fine distance calculation on the top few closest clusters in the candidate clusters to generate a global filtering threshold;
[0013] S6: Sequentially perform high-concurrency coarse screening on the remaining clusters in the candidate clusters, and use a dual-path operator split architecture to perform coarse distance calculation and context information preparation; perform hard filtering on the coarse distance based on the global filtering threshold, and push the surviving vectors that pass the filtering along with the context information into the asynchronous buffer array for data flow isolation.
[0014] S7: Extract the surviving vector from the asynchronous buffer array, extract the long code using the identification information of the surviving vector, perform fine distance calculation and reordering, and output the retrieval results.
[0015] Furthermore, the step of decoupling all original feature vectors into primary component vectors and secondary component vectors includes:
[0016] The covariance matrix of the image dataset to be indexed is calculated based on the principal component analysis algorithm. ,in The feature matrix after centering the image dataset. The number of high-dimensional original feature vectors in the image dataset;
[0017] The covariance matrix is decomposed into eigenvalues to obtain the corresponding eigenvalues. and its orthogonal eigenvectors; where Represents the original total dimensions of the image;
[0018] The original feature space is orthogonally divided into two parts based on the cumulative variance contribution rate threshold. The main component subspace and remainder of each feature dimension The secondary component subspace of each feature dimension; any original feature vector They are then decoupled into the corresponding principal component vectors. With secondary component vectors .
[0019] Furthermore, the principal component inverse mapping vector is obtained based on the following method:
[0020] The K-Means clustering algorithm is used to cluster all principal component vectors after decoupling, generating independent inverted clusters and their corresponding centroid vectors;
[0021] The principal component vectors within each inverted cluster are transformed into local residual vectors relative to the centroid vector of their respective inverted clusters, and then executed. Norm normalization yields the local residual unit vector;
[0022] The local residual unit vector is rotated to eliminate geometric bias, resulting in the principal component inverse mapping vector.
[0023] Furthermore, the differential non-uniform mixed bit-width quantization strategy generates short and long codes for each major component vector, including:
[0024] Multi-bit quantization is performed on the inverse mapping vector of the principal component. The most significant bit of the inverse mapping vector of the principal component is encapsulated into a short code by single-bit quantization, and the remaining bits except the most significant bit are encapsulated into a long code by multi-bit quantization. Single-bit quantization is performed on the minor component vector, and the standard deviation is extracted for error compensation.
[0025] Furthermore, in step S3, the extraction of local constant factors for each principal component vector includes four core local constant factors. , , , The formula is:
[0026]
[0027]
[0028]
[0029]
[0030] in, This represents the quantization error term caused by the unbiased estimation of the principal components; Principal component vector The centroid vector of the inverted cluster to which it belongs. , To invert the total number of clusters; To be related to the principal component vector The corresponding minor component vector; Principal component vector The local residual unit vector; This represents the dot product of vectors.
[0031] Furthermore, in step S4, the common parameters strongly correlated with the current query vector are pre-calculated for the candidate clusters, including four cluster-level common parameters. , , , The formula is as follows:
[0032]
[0033]
[0034]
[0035]
[0036] in, , They are query vectors The primary and secondary component vectors; express The square of the L2 norm; Indicates to Truncation error term during calculation; These are empirical parameters; The centroid vector corresponding to the candidate cluster. , The total number of candidate clusters; This represents the sum of the principal components of the query residual vector. .
[0037] Furthermore, in step S5, based on the long code, short code, local constant factors, and common parameters, fine-grained distance calculations are performed on the top few closest clusters in the candidate clusters to generate a global filtering threshold, including:
[0038] Select the inverted cluster with the closest spatial distance from the candidate clusters as the first cluster, and the remaining inverted clusters as the second cluster;
[0039] Based on the query vector, long code, short code, local constant factors, and common parameters, calculate the fine distance between each principal component vector in the first cluster and the query vector. :
[0040]
[0041] in, This represents the centroid vector corresponding to the first cluster; , These represent short code and long code, respectively; The bit width for multi-bit quantization;
[0042] The fine distances are sorted using a parallel sorting network to select local optimal candidate sets, and the maximum fine distance value in the local optimal candidate sets is used as the global filtering threshold.
[0043] Furthermore, in step S6, a dual-path operator splitting architecture is used for coarse distance calculation and context information preparation; hard filtering is performed on the coarse distance based on a global filtering threshold, and the surviving vectors that pass the filter, along with the context information, are pushed into an asynchronous buffer array for data flow isolation, specifically including:
[0044] A dual-path operator splitting architecture is adopted. One path calculates the approximate distance between the main component vectors in the second cluster and the query vector based on the query vector, short code, local constant factors, and common parameters. :
[0045]
[0046] in, This represents the centroid vector corresponding to the second cluster;
[0047] Another synchronous path prepares context information for subsequent fine-grained distance calculations, including packaged local constant factors. Common parameters Operator data And identification information consisting of inverted cluster identifiers, group identifiers, and relative vector identifiers;
[0048] The coarse distance is compared with the global filtering threshold using a hardware comparator. The main component vectors whose coarse distance is greater than the global filtering threshold are filtered out, and the remaining main component vectors are used as surviving vectors.
[0049] The surviving vectors and their corresponding context information are pushed into an asynchronous buffer queue to isolate the data flow between the coarse screening and fine sorting stages.
[0050] Further, in step S7, the surviving vector is extracted from the asynchronous buffer array, the long code is extracted using the identification information of the surviving vector, and fine distance calculation and reordering are performed to output the retrieval results, including:
[0051] Extract the surviving vector and its corresponding context information from the asynchronous buffer queue, and determine the base address of the target cluster to which the surviving vector belongs in memory based on the inverted cluster identifier in the identifier information of the surviving vector;
[0052] Based on the base address, the group identifier and the relative vector identifier in the identifier information, the storage address of the long code is calculated and the long code is read using the following discrete non-contiguous addressing formula:
[0053]
[0054] in, This is the storage address for the long code. As the base address, For identification information, For multi-bit quantization, the bit width Dimension scaling factor;
[0055] Based on the context information of the read long code and surviving vectors, perform fine distance calculation to calculate the fine distance between each surviving vector and the query vector;
[0056] And through a parallel sorting network, fine-grained distance sorting is performed, outputting the Top-ranked vectors closest to the query vector. The identification information and fine distance of an approximate nearest neighbor image vector.
[0057] A large-scale image retrieval acceleration device based on non-uniform quantization includes:
[0058] The index data construction module is used to obtain the principal component vectors and secondary component vectors of the original feature vectors through the principal component analysis algorithm, and generate short codes and long codes of each principal component vector based on a differentiated non-uniform mixed bit width quantization strategy, and extract the local constant factors of each principal component vector.
[0059] The nearest cluster filtering module is used to calculate the distance between the principal component vector of the query vector and the centroid of each inverted cluster in parallel, filter out several inverted clusters with the closest spatial distance as candidate clusters, and pre-calculate common parameters that are strongly correlated with the current query vector for the candidate clusters;
[0060] The first fine screening module is used to perform fine distance calculation on the top few closest clusters in the candidate clusters based on the long code, short code, local constant factors and common parameters, and generate a global filtering threshold.
[0061] The coarse screening and isolation module is used to perform coarse distance calculation and context information preparation for the remaining clusters in the candidate clusters using a dual-path operator splitting architecture; it performs hard filtering on the coarse distance based on a global filtering threshold, and pushes the surviving vectors that pass the filtering along with the context information into an asynchronous buffer array for data flow isolation.
[0062] The second fine screening module is used to extract the surviving vector from the asynchronous buffer array, extract long codes using the identification information of the surviving vector, perform fine distance calculation and reordering, and output the retrieval results.
[0063] The beneficial effects of this invention compared to the prior art are as follows:
[0064] (1) It breaks the fixed bit width limitation of traditional uniform quantization. Through feature space decoupling and non-uniform mixed bit width quantization mechanism, it implements high-precision multi-bit quantization for the main features and extreme compression and error compensation for the secondary features, which greatly reduces the computing power cost of offline training and the redundancy of index physical storage space.
[0065] (2) On the hardware side, the traditional global coarse-to-fine search strategy that is prone to pipeline blockage due to the generation of a large amount of irregular intermediate data is abandoned. High-quality filtering thresholds are generated in advance by pre-local fine distance calculation. Combined with the core operator diversion and asynchronous asymmetric FIFO cache design, the problem of low-level data flow interruption caused by high randomness threshold filtering is effectively solved, and the physical diversion of key computing operators and high concurrency and low latency throughput of massive image features are realized. Attached Figure Description
[0066] Figure 1 This is the basic process of the indexing stage in the embodiments of the present invention.
[0067] Figure 2 This is the overall system architecture in the embodiments of the present invention.
[0068] Figure 3 This refers to the fine distance calculation and candidate set maintenance steps in this embodiment of the invention.
[0069] Figure 4 This refers to the coarse distance calculation and filtering steps in the embodiments of the present invention.
[0070] Figure 5 This is a comparison of the comprehensive performance of search scenarios in this embodiment of the invention, where (a) is a comparison of index building time, (b) is a comparison of index size, (c) is a comparison of search execution time, and (d) is a comparison of recall rate.
[0071] Figure 6 This is a comparison of system throughput and recall performance in an embodiment of the present invention, where (a) is the comparison result on the SIFT1M dataset and (b) is the comparison result on the GIST dataset. Detailed Implementation
[0072] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0073] like Figure 1 and Figure 2 As shown, this embodiment provides a method for accelerating large-scale image retrieval based on non-uniform quantization, which divides the computational architecture into an offline non-uniform quantization index construction stage and an online hardware-accelerated search stage; including the following steps:
[0074] I. Offline Non-Uniform Quantization Index Construction Stage
[0075] S1. The image dataset to be indexed is decoupled in feature space using principal component analysis (PCA) algorithm, decoupling all original feature vectors into principal component vectors and secondary component vectors; specifically as follows:
[0076] Input the image dataset to be indexed It contains A high-dimensional original feature vector, a single original feature vector is denoted as . ,in , All are positive integers. Represents the original total dimension of the image.
[0077] First, statistical analysis of the image dataset is performed on the software side (CPU side). covariance matrix (in For image datasets The eigenvalues are obtained by centering the eigenma matrix and then performing eigenvalue decomposition on the covariance matrix. and its orthogonal eigenvectors.
[0078] Based on the preset cumulative variance contribution rate threshold (set to 99% in this embodiment), the following is calculated: The smallest positive integer Therefore, using orthogonal rotation matrices... The original The 3D feature space is orthogonally partitioned into two mutually exclusive feature spaces: one containing the first feature space and the other containing the second feature space. The main component subspace of each feature dimension and containing the remainder The minor component subspace of each feature dimension. Any original feature vector They are then decoupled into the corresponding principal component vectors. With secondary component vectors .
[0079] S2. Perform inverted clustering, local residual normalization, and random orthogonal rotation on the decoupled principal component vectors, as follows:
[0080] The K-Means clustering algorithm is used to cluster the principal component vectors after decoupling all the original feature vectors, dividing them into groups. A number of disjoint inverted index clusters (of which) (A positive integer representing the total number of clusters), and generate the corresponding... A high-dimensional centroid vector; The centroid vectors corresponding to each inverted index cluster are stored in a static cache (BRAM) on-chip.
[0081] To eliminate the interference of absolute image magnitude on distance decision within the feature space, assume any inverted cluster... The centroid vector is ( The system iterates through each principal component vector belonging to the inverted index cluster. Transform it relative to the center of mass The local residual vector, and perform strict Norm normalization projects all data points onto a high-dimensional unit hypersphere; the local residual unit vector is obtained after local residual normalization. It satisfies the following algebraic definition:
[0082]
[0083] To eliminate the geometric bias of the offline codebook towards specific data space orientations, a random orthogonal matrix is introduced. The local residual unit vector is rotated to obtain the principal component inverse mapping vector. .
[0084] S3. Based on a differentiated non-uniform mixed bit-width quantization strategy, short and long codes for each major component vector are generated, as follows:
[0085] For the inverse mapping vector of the main components containing the main information This gives it a high-precision multi-bit quantization width. (in are positive integers and ).extract The most significant bit, i.e. the sign bit, is encapsulated as a 1-bit short code. ,when hour ,otherwise Among them, dimension index , Represents the principal component inverse mapping vector The One dimension, Short code The Each dimension; and its absolute value implement Scalar quantization of bits to generate low-order long code .
[0086] For secondary component vectors Then directly calculate the standard deviation of each dimension. This is used for probability error boundary compensation during subsequent online retrieval. Through this non-uniform decoupling compression, the system can directly save nearly 50% of physical memory at the base database level.
[0087] S4. Extract the cluster-level offline factors of each principal component vector and package them into an inverted index file, as follows:
[0088] To completely hide the complex nonlinear operators and floating-point operations in online distance measurement on the hardware accelerator card (FPGA), this invention decomposes and reorganizes the distance calculation formula in the offline stage, merges all constants unrelated to the query vector, and extracts four core local constant factors for each major component vector and its corresponding inverted index cluster in advance:
[0089]
[0090]
[0091]
[0092]
[0093] in, This represents the quantization error term caused by the unbiased estimation of the principal components; Principal component vector The centroid vector of the inverted cluster to which it belongs; To be related to the principal component vector The corresponding minor component vector; This represents the dot product of vectors.
[0094] After extraction, in order to closely match the burst read and wide bus execution efficiency of the hardware, the short codes of the generated major component vectors are... Long code Local constant factors and the original image ID are organized and packaged in a 64-byte (512-bit) memory-aligned normalized format, outputting an inverted index file (IVF index) and stored in HBM. In HBM, short codes for every 1024 principal component vectors are used. Long code Local constant factors are grouped together, and each group is assigned a group ID. The relative vector ID is set according to the position of each principal component vector in each group.
[0095] II. Online Hardware Acceleration Search Phase
[0096] This phase completely offloads the search and reordering process to an AMD Alveo V80 hardware acceleration card equipped with dual-stack high-bandwidth memory (HBM2e). The overall hardware architecture is as follows: Figure 2 As shown, in order to completely avoid the bottleneck of hardware pipeline interruption caused by the generation of a large amount of irregular intermediate data in the traditional "first global coarse screening and then fine screening", this invention reconstructs and solidifies a dedicated full pipeline computing path consisting of four core functional stages (steps S5~S8) in hardware.
[0097] S5. Neighbor Cluster Selection and Parameter Pre-calculation: The distance between the query vector and the centroid of each inverted index cluster is calculated in parallel. Several inverted index clusters with the closest spatial distance are selected as candidate clusters, and the time-division multiplexing mechanism of computing units is activated to pre-calculate common parameters for the candidate clusters; as detailed below:
[0098] For the original high-dimensional query feature vector input in a single image retrieval The CPU first decouples it into principal component vectors. With secondary component vectors .
[0099] First, the hardware accelerator card reads the centroid vectors of all inverted clusters one by one from the BRAM. and the current query vector The data is then input into a distance calculation unit, which is a parallel computing array consisting of 128 processing units (PEs) to perform parallel calculations on the query vector. Principal component vector Square Euclidean distance between the centroid vector and the centroid vector ,Will With each centroid vector The corresponding inverted cluster ID is concatenated into 48 bits and enters the cluster filtering unit. This cluster filtering unit consists of four parallel sorting buckets (each bucket having a depth of...). A multi-bucket sorting network consisting of 48 buckets (with a width of 48) is used to calculate the results based on the squared Euclidean distances. A number of inverted index clusters were selected as candidate clusters (of which...) are positive integers and ).
[0100] Immediately afterwards, this Each inverted cluster ID is input into the distance calculation unit again, and based on these inverted cluster IDs, the corresponding centroid vectors are read out from the BRAM one by one. and the centroid vector The data is input into the distance calculation unit, and then the parallel computing array in the distance calculation unit is deeply reused to pre-calculate four cluster-level common parameters that are strongly correlated with the current query vector for the selected candidate clusters:
[0101]
[0102]
[0103]
[0104]
[0105] in, Represents the minor component vector The square of the L2 norm; Represents the secondary component vector Truncation error term during calculation; This is an empirical parameter, with a value of 0.58. The centroid vector corresponding to the candidate cluster. ; This represents the sum of the principal components of the query residual vector. .
[0106] Selected Each inverted cluster ID and its corresponding public parameters Push in together The parameters are suspended in the FIFO for later use; in addition, the distance calculation unit also calculates... And store it in DRAM for later use.
[0107] S6. Based on the long code, short code, local constant factors, and common parameters, perform fine-grained distance calculations on the top few closest clusters in the candidate clusters to generate a global filtering threshold; specifically as follows:
[0108] Selecting spatial distances among candidate clusters recent former One inverted index cluster is designated as the first cluster, and the remaining inverted index clusters are designated as the second cluster.
[0109] Reading local constant factors from HBM , 3. Short code With long code ;from Read common parameters from parameter FIFO ,coef_4; Read the data corresponding to the first cluster from DRAM. Right now , Let be the centroid vector corresponding to the first cluster; input the above operator into the fine distance calculation unit to calculate the fine distance between each principal component vector in the first cluster and the query vector. The fine distance calculation unit is as follows: Figure 3 As shown, the system reads local constant factors, short codes, and long codes from HBM respectively, and places them into factor FIFO, short code FIFO, and long code FIFO respectively. It should be noted that in step S4, the four local constant factors of each principal component vector are... , , 2. 3. The data is stored consecutively in HBM. During the read operation, four local constant factors are also retrieved. Therefore, it's necessary to truncate the retrieved local constant factors, extracting only those needed for calculating the fine distance. 2. 3. For example Figure 3 As shown, the short code read from HBM Read from DRAM Perform dot product calculation Then, a fixed-point to floating-point conversion is performed, and the result is stored in a FIFO; similarly, the long code dot product is calculated. Without the need for fixed-point to floating-point conversion, the long code dot product and the short code dot product are input together into the operator combination unit to calculate the fine distance between each principal component vector in the first cluster and the query vector. The calculation formula is as follows:
[0110]
[0111] in, This represents the fine distance between the query vector and the principal component vectors in the first cluster. This represents the centroid vector corresponding to the first cluster.
[0112] The calculated fine distance value The output is fed into a parallel sorting network consisting of 32 hardware sorting buckets. Through K rounds of closed-loop shift iteration (where K represents the K nearest neighbors the query vector ultimately needs to find), a local optimum candidate set with the smallest fine distance is selected (the candidate set size is K). The candidate set is placed in a register for later use, and the maximum fine distance value in the local optimum candidate set is used as the global filtering threshold. .
[0113] S7. A dual-path operator splitting architecture is adopted for coarse distance calculation and context information preparation. Hard filtering of the coarse distance is performed based on a global filtering threshold, and the surviving vectors that pass the filter, along with the context information, are pushed into an asynchronous buffer array for data flow isolation, solving the problem of data flow interruptions caused by high-randomness filtering; specifically as follows:
[0114] A dual-path operator splitting architecture is adopted, including path A for calculating coarse distance and path B for preparing context information for subsequent fine distance calculation.
[0115] Branch A: Read local constant factors from HBM , 1 and short code ;from Read common parameters from parameter FIFO ,coef_1; Read the value corresponding to the second cluster from DRAM Right now , The centroid vector corresponding to the second cluster is used; the above operator is input into the coarse distance calculation unit to calculate the coarse distance between each principal component vector in the second cluster and the query vector. The coarse distance calculation unit is as follows: Figure 4 As shown in the figure, the process of reading local constant factors and short codes from HBM and calculating the short code dot product is omitted. The process. Short code dot product result. After output, the results are distributed to two branches. Similar to S6, the local constant factors read from HBM include... , 1. 2. 3, while calculating the coarse distance only requires... and 1. Therefore, the system first performs local constant factorization, and then... and 1. Input to branch A, and... and 3. Input to branch B.
[0116] Based on the rough distance calculation formula, the local constant factor 1. Short code dot product and common parameters 0、 By combining operators, a coarse distance can be obtained. :
[0117]
[0118] in, This represents the approximate distance between the query vector and the principal component vectors in the second cluster.
[0119] Branch B: Dot product of the short code Perform a left shift operation (multiplication) ),get Then it is compared with the local constant factor read from HBM. 3, from Common parameters read from the parameter FIFO 2. It is packaged together with the vector addressing ID, which consists of the inverted cluster ID, group ID, and relative vector ID (each vector in the second cluster has a packet).
[0120] Subsequently, the system initiates a threshold-based filtering operation: the 64 parallel hardware comparators instantiated in the filtering module will split the output of channel A. With global filtering threshold Perform numerical comparison. If... If the current principal component vector fails the filtering, its context information packet is discarded directly; This indicates that the current principal component vector has passed the screening. It is treated as a surviving vector, and its context information is retained. The context information is then split into stages and placed into the factor FIFO, ... In Parameter FIFO, Operator FIFO and ID FIFO.
[0121] S8. Perform final fine distance calculations and merge the results for the surviving vectors after coarse screening, as follows:
[0122] When calculating the fine distance, the system directly reuses the fine distance calculation unit in S6. However, unlike S6, according to the fine distance calculation formula, since the surviving vectors were already obtained in S7... (Already placed in the operator FIFO), so in step S8, it is not necessary to repeatedly read the local constant factors and short codes of the surviving vectors from HBM. It is only necessary to read the long codes corresponding to these surviving vectors.
[0123] The system uses factor FIFO, The context information corresponding to the surviving vector is extracted from the parameter FIFO, operator FIFO, and ID FIFO. Based on the valid data popped from the ID FIFO array, the bound 32-bit ID is extracted; the base address of the target cluster to which the surviving vector belongs in HBM is quickly retrieved by using the lower 6 bits of the ID relative to the cluster ID. By combining the group ID and relative vector ID stored in HBM, discrete discontinuous addressing is performed according to the following formula to find the long code address corresponding to the surviving vector and read it out:
[0124]
[0125] in, The dimension scaling factor is mul = d / 128.
[0126] Based on the context information of the read long code and surviving vectors, the fine-grained distance calculation unit in S6 is reused to calculate the fine-grained distance between each surviving vector and the query vector. Then, the multi-bucket parallel sorting network in the fine-grained distance calculation unit is reused. During initialization, one bucket is fixed to the previous bucket generated in S6. Top- of an inverted index cluster The candidate set is used, while the initial values of the registers within all other buckets are uniformly assigned to the global filtering threshold. Finally, the Top-Number array with the closest distance to the query vector (image) is obtained. The ID and fine distance of an approximate nearest neighbor image vector are used to complete a single image retrieval process.
[0127] The present invention proposes a method for accelerating large-scale image retrieval based on non-uniform quantization, which achieves significant technical progress in terms of index building efficiency, system online throughput and retrieval accuracy when processing massive high-dimensional image data.
[0128] This invention underwent comparative testing on multiple datasets, such as... Figure 5 As shown, gray represents the widely deployed general-purpose vector search engine FAISS, while blue represents the present method. (The text then repeats the first two characters, which are likely errors in the original and can be omitted.) Set the number of nearest neighbors to return. Firstly, regarding index building speed, such as... Figure 5 As shown in (a), the general-purpose search engine FAISS introduces a large overhead of clustering optimization and multi-dimensional fine-grained space partitioning in the offline stage in pursuit of the ultimate storage compression rate. In contrast, our method introduces PCA to evaluate dimensional contribution and directly calculates and allocates non-uniform quantization bit width, which significantly reduces the cost of offline training.
[0129] Secondly, in terms of search speed, such as Figure 5 (c) Thanks to the underlying non-uniform quantization operator, which eliminates the complex lookup and decoding overhead, the execution time of this invention is significantly reduced in the distance calculation stage. Traditional engines heavily rely on asymmetric distance lookup and decoding operations when calculating distance, which easily leads to cache misses. The non-uniform quantization operator of this invention maps data into a compact bitstream format that is highly compatible with the SIMD instruction set, transforming complex floating-point calculations into low-level bit operations, demonstrating high-efficiency concurrent performance on various datasets.
[0130] Furthermore, the performance-space gain ratio is a core metric for evaluating the practicality of an algorithm in system design. Regarding the index space, although this invention expands the index space compared to the FAISS method, see [link to relevant documentation]. Figure 5 (b) However, it significantly reduces index construction time. Furthermore, while greatly improving speed, the method of this invention, with B=7 or B=9 configuration, can accurately capture the core distribution space of high-dimensional vectors, maintaining a high recall rate. See [link to related documentation]. Figure 5 (d)
[0131] Secondly, regarding online retrieval speed and accuracy, this invention achieves early hardware-level filtering of massive invalid candidate images through software and hardware co-optimization and the use of high-quality thresholds. For example... Figure 6As shown, this invention selects a cutting-edge FPGA-based IVF-PQ acceleration architecture as a baseline model for comparative testing. The throughput curves of the baseline IVF-PQ model under FLOAT32 configuration are compared experimentally. Under the same data precision conditions, the throughput of the proposed method on both the SIFT1M and GIST datasets is significantly better than the baseline method. Especially in the high recall range, thanks to the hardware-level filtering of a large number of invalid computations by a high-quality threshold, this invention exhibits high throughput stability, effectively mitigating performance degradation. From the underlying architecture level, this fully verifies the rationality and efficiency of the quantization strategy and architecture design of this invention.
[0132] Finally, it should be noted that the above embodiments are intended to illustrate the technical solutions of the present invention and do not constitute any limitation on the present invention. Those skilled in the art should fully understand that modifications to the technical solutions described in the foregoing embodiments or equivalent substitutions for any part or all of the technical features are entirely feasible. Such modifications or substitutions, as long as they do not depart from the scope of protection defined by the claims of the present invention, should be considered reasonable extensions of the present invention.
Claims
1. A method for accelerating large-scale image retrieval based on non-uniform quantization, characterized in that, include: S1: The principal component analysis algorithm is used to decouple the feature space of the image dataset to be indexed, decoupling all the original feature vectors into principal component vectors and secondary component vectors. S2: Cluster the decoupled principal component vectors to generate inverted clusters, normalize local residuals, and perform random orthogonal rotations to obtain the principal component inverse mapping vectors; S3: Based on a differentiated non-uniform mixed bit-width quantization strategy, short codes and long codes of each major component vector are generated; and local constant factors of each major component vector are extracted. S4: Input the query vector and decouple it into a primary component vector and a secondary component vector. Calculate the distance between the primary component vector of the query vector and the centroid of each inverted cluster in parallel. Select several inverted clusters with the closest spatial distance as candidate clusters. Start the time-division multiplexing mechanism of the computing unit to pre-calculate common parameters that are strongly correlated with the current query vector for the candidate clusters. S5: Based on the long code, short code, local constant factors and common parameters, perform fine distance calculation on the top few closest clusters in the candidate clusters to generate a global filtering threshold; S6: Sequentially perform high-concurrency coarse screening on the remaining clusters in the candidate clusters, and use a dual-path operator split architecture to perform coarse distance calculation and context information preparation; Hard filtering is performed on the coarse distance based on the global filtering threshold, and the surviving vectors that pass the filter, along with context information, are pushed into an asynchronous buffer array for data flow isolation. S7: Extract the surviving vector from the asynchronous buffer array, extract the long code using the identification information of the surviving vector, perform fine distance calculation and reordering, and output the retrieval results.
2. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 1, characterized in that, In step S1, the step of decoupling all original feature vectors into primary component vectors and secondary component vectors includes: The covariance matrix of the image dataset to be indexed is calculated based on the principal component analysis algorithm. ,in The feature matrix after centering the image dataset. The number of high-dimensional original feature vectors in the image dataset; The covariance matrix is decomposed into eigenvalues to obtain the corresponding eigenvalues. and its orthogonal eigenvectors; where Represents the original total dimensions of the image; The original feature space is orthogonally divided into two parts based on the cumulative variance contribution rate threshold. The main component subspace and remainder of each feature dimension The secondary component subspace of each feature dimension; any original feature vector They are then decoupled into the corresponding principal component vectors. With secondary component vectors .
3. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 2, characterized in that, In step S2, the principal component inverse mapping vector is obtained based on the following method: The K-Means clustering algorithm is used to cluster all principal component vectors after decoupling, generating independent inverted clusters and their corresponding centroid vectors; The principal component vectors within each inverted cluster are transformed into local residual vectors relative to the centroid vector of their respective inverted clusters, and then executed. Norm normalization yields the local residual unit vector; The local residual unit vector is rotated to eliminate geometric bias, resulting in the principal component inverse mapping vector.
4. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 3, characterized in that, In step S3, the differential non-uniform mixed bit-width quantization strategy generates short and long codes for each major component vector, including: Multi-bit quantization is performed on the inverse mapping vector of the principal component. The most significant bit of the inverse mapping vector of the principal component is encapsulated into a short code by single-bit quantization, and the remaining bits except the most significant bit are encapsulated into a long code by multi-bit quantization. Single-bit quantization is performed on the minor component vector, and the standard deviation is extracted for error compensation.
5. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 4, characterized in that, In step S3, the extraction of local constant factors for each principal component vector includes four core local constant factors. , , , The formula is: in, This represents the quantization error term caused by the unbiased estimation of the principal components; Principal component vector The centroid vector of the inverted cluster to which it belongs. , To invert the total number of clusters; To be related to the principal component vector The corresponding minor component vector; Principal component vector The local residual unit vector; This represents the dot product of vectors.
6. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 5, characterized in that, In step S4, the common parameters strongly correlated with the current query vector are pre-calculated for the candidate clusters, including four cluster-level common parameters. , , , The formula is as follows: in, , They are query vectors The primary and secondary component vectors; express The square of the L2 norm; Indicates to Truncation error term during calculation; These are empirical parameters; The centroid vector corresponding to the candidate cluster. , The total number of candidate clusters; This represents the sum of the principal components of the query residual vector. .
7. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 6, characterized in that, In step S5, based on the long code, short code, local constant factors, and common parameters, fine-grained distance calculations are performed on the top few closest clusters in the candidate clusters to generate a global filtering threshold, including: Select the inverted cluster with the closest spatial distance from the candidate clusters as the first cluster, and the remaining inverted clusters as the second cluster; Based on the query vector, long code, short code, local constant factors, and common parameters, calculate the fine distance between each principal component vector in the first cluster and the query vector. : in, This represents the centroid vector corresponding to the first cluster; , These represent short code and long code, respectively; The bit width for multi-bit quantization; The fine distances are sorted using a parallel sorting network to select local optimal candidate sets, and the maximum fine distance value in the local optimal candidate sets is used as the global filtering threshold.
8. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 7, characterized in that, In step S6, a dual-path operator splitting architecture is used to perform coarse distance calculation and context information preparation; Hard filtering is performed on the coarse distance based on a global filtering threshold, and the surviving vectors that pass the filter, along with context information, are pushed into an asynchronous buffer array for data stream isolation. Specifically, this includes: A dual-path operator splitting architecture is adopted. One path calculates the approximate distance between the main component vectors in the second cluster and the query vector based on the query vector, short code, local constant factors, and common parameters. : in, This represents the centroid vector corresponding to the second cluster; Another synchronous path prepares context information for subsequent fine-grained distance calculations, including packaged local constant factors. Common parameters Operator data And identification information consisting of inverted cluster identifiers, group identifiers, and relative vector identifiers; The coarse distance is compared with the global filtering threshold using a hardware comparator. The main component vectors whose coarse distance is greater than the global filtering threshold are filtered out, and the remaining main component vectors are used as surviving vectors. The surviving vectors and their corresponding context information are pushed into an asynchronous buffer queue to isolate the data flow between the coarse screening and fine sorting stages.
9. The method for accelerating large-scale image retrieval based on non-uniform quantization according to claim 8, characterized in that, In step S7, the surviving vector is extracted from the asynchronous buffer array, the long code is extracted using the identification information of the surviving vector, and fine distance calculation and reordering are performed to output the retrieval results, including: Extract the surviving vector and its corresponding context information from the asynchronous buffer queue, and determine the base address of the target cluster to which the surviving vector belongs in memory based on the inverted cluster identifier in the identifier information of the surviving vector; Based on the base address, the group identifier and the relative vector identifier in the identifier information, the storage address of the long code is calculated and the long code is read using the following discrete non-contiguous addressing formula: in, This is the storage address for the long code. As the base address, For identification information, For multi-bit quantization, the bit width Dimension scaling factor; Based on the context information of the read long code and surviving vectors, perform fine distance calculation to calculate the fine distance between each surviving vector and the query vector; And through a parallel sorting network, fine-grained distance sorting is performed, outputting the Top-ranked vectors closest to the query vector. The identification information and fine distance of an approximate nearest neighbor image vector.
10. A large-scale image retrieval acceleration device based on non-uniform quantization, characterized in that, include: The index data construction module is used to obtain the principal component vectors and secondary component vectors of the original feature vectors through the principal component analysis algorithm, and generate short codes and long codes of each principal component vector based on a differentiated non-uniform mixed bit width quantization strategy, and extract the local constant factors of each principal component vector. The nearest cluster filtering module is used to calculate the distance between the principal component vector of the query vector and the centroid of each inverted cluster in parallel, filter out several inverted clusters with the closest spatial distance as candidate clusters, and pre-calculate common parameters that are strongly correlated with the current query vector for the candidate clusters; The first fine screening module is used to perform fine distance calculation on the top few closest clusters in the candidate clusters based on the long code, short code, local constant factors and common parameters, and generate a global filtering threshold. The coarse screening and isolation module is used to perform coarse distance calculation and context information preparation on the remaining clusters in the candidate clusters using a dual-path operator splitting architecture. Hard filtering is performed on the coarse distance based on the global filtering threshold, and the surviving vectors that pass the filter, along with context information, are pushed into an asynchronous buffer array for data flow isolation. The second fine screening module is used to extract the surviving vector from the asynchronous buffer array, extract long codes using the identification information of the surviving vector, perform fine distance calculation and reordering, and output the retrieval results.
