Finding K most similar elements for a query in a large gallery of neural network (NN) embeddings is essential in various areas of computer science and industrial applications of artificial intelligence. This paper proposes search algorithms for structured latent spaces (LS) of NNs which allow to speed up top K item retrieval owing to O(1) complexity small candidate gallery subset search. ArcFace-pretrained IResNet50 models are finetuned using Latent Space Configuration (LSC) methodology to obtain new distribution of embeddings with desired geometric properties. Applying the proposed algorithms to embeddings obtained from finetuned models leads to several times speed-up over baseline exhaustive search. Specifically, we report up to 3 times speed-up on GPU and 40% speed-up on CPU compared to the baseline method GPU speed. These results are obtained for the original and reduced numbers of LS dimensions. The results show that LS dimensionality reduction allows to further accelerate the search and even improve rank-N metrics.
Figures & tables
Figure 1: Pretrained model finetuning with LSC. Black arrows indicate operations done once before finetuning. Blue arrows indicate the parameter update loop.
Figure 2: Example of finding Vn11 vectors close to some mean embedding vector when the closest Vn11 vector is already assigned an id .
Figure 3: Pretrained model finetuning while reducing the number of LS dimensions. Here fc is fully-connected projection layer initialized with the same matrix Q , which is used to project embeddings from n orig into n red . Black arrows indicate operations done once before finetuning. Blue arrows show the parameter update loop.
Figure 4: Curves of loss (left) and id prediction accuracy (right) during finetuning.
Method
Device
Time, s
Pretrained
Exp I
Exp II
Exp III
R1/R10
R1/R10
R1/R10
R1/R10
Queries in train set
-
-
Yes
Yes
No
No
Augmentation
-
-
Yes
No
No
Yes
exh. search
GPU
17.5
0.884/0.928
0.944/0.964
0.801/0.83
0.83/0.86
exh. search
CPU
336.4
0.884/0.928
0.944/0.964
0.801/0.83
0.83/0.86
Alg. 1
CPU
12.5
0.266/0.27
0.942/0.958
0.798/0.81
0.818/0.835
Table 1: Gallery ranking metrics and time required for their calculation for n orig =512.
Method
Device
Time, s
Pretrained
Exp I
Exp II
Exp III
R1/R10
R1/R10
R1/R10
R1/R10
Queries in train set
-
-
Yes
Yes
No
No
Augmentation
-
-
Yes
No
No
Yes
exh. search
GPU
12.9
0.87/0.914
0.97/0.99
0.82/0.854
0.846/0.875
exh. search
CPU
280
0.87/0.914
0.97/0.99
0.82/0.854
0.846/0.875
Alg. 1
CPU
7.1
0.266/0.27
0.97/0.99
0.786/0.796
0.825/0.839
Table 2: Gallery ranking metrics and time required for their calculation for n red =160.
Approximate Nearest-Neighbor Search (ANNS) pipelines for high-dimensional neural embeddings spend the bulk of their query time in candidate verification, making it the primary bottleneck in the search process. In this paper, we present PANORAMA, a state-of-the-art refinement technique that accelerates verification by exploiting the inherent spectral decay of these embeddings. Using PCA to compact signal energy, PANORAMA evaluates candidate distances incrementally, computing at each step a strict lower bound on the full-vector distance and dynamically pruning candidates the moment this bound exceeds the running k-th nearest neighbor distance. While PCA's concentration of variance facilitates pruning, it breaks the uniform-variance assumption required by Product Quantization (PQ); we resolve this with a variance-shaping step that redistributes energy across subvectors, rendering accretive refinement compatible with quantized indexes. Optimized for modern memory hierarchies via vectorized bulk-pruning and cache-conscious data layouts, PANORAMA has been upstreamed into the FAISS library across major index families (IVFPQ/Flat, HNSW, and Refine). PANORAMA achieves higher QPS at any target recall with a cost that provably scales inversely with dataset spectral decay, delivering end-to-end speedups of up to 28.9x and outperforming probabilistic methods across all recall bands.
Vansh Ramani, Alexis Schlomer, Akash Nayar +3
IIT Delhi & CMU & UCPH · Carnegie Mellon University · Indian Institute of Technology Delhi +1
Clark Hash is a small method for storing neural embeddings in less space. It normalizes each database vector, applies a deterministic sparse signed Johnson-Lindenstrauss projection, clips the result, and stores a fixed-width scalar-quantized code. Queries stay in floating point and are scored against the stored sketches. In the default 384-dimensional sentence-embedding setting, Clark Hash stores a cosine-search vector in 48 bytes instead of 1536 bytes for dense f32 storage. This is 32x smaller. The method does not need a training pass, learned codebooks, rotations, or corpus statistics before new vectors can be stored. We describe the codec, the Rust implementation, and a multilingual sentence-similarity evaluation on 9,304 labeled pairs from 29 subsets. With a multilingual MiniLM encoder, the 48-byte sketches reached 0.910 and 0.946 macro Pearson correlation with dense cosine scores on STS17 and STS22. Clark Hash is not a new Johnson-Lindenstrauss theorem and it is not a replacement for approximate nearest-neighbor indexes. It is a simple stateless codec for compact embedding storage.
By introducing RSLM (Rotated Scaled Lloyd-Max), a family of training-free vector quantization codecs compressing embeddings to 1--4 bits per dimension, we reduce memory cost and memory bandwidth of a typical large-scale Approximate Nearest Neighbor (ANN) search system, while reducing its complexity and keeping or improving recall across multiple benchmark datasets. State-of-the-art systems filter candidates using coarse partitions, approximately score them to narrow the set, and then rescore the best with higher precision representations (often >=8 bits per dimension). Our relativized codecs can bring this down to 2--4 bits per dimension. We use the properties of the ANN system to encode residual vectors instead of full vectors, both for the approximate scoring phase and the rescoring phase. Since Maximum Inner Product Search (MIPS) is very sensitive to vector norms, we correct the L2 norms of quantized vectors. Our major innovation is that we correct the L2 norm of the final reconstructed vector rather than just the residual. Our rescaling replaces more complicated schemes, such as Anisotropic loss. The residualization scheme gives us a more favorable quality vs size trade-off than generic quantization methods. Our high-performance implementation leverages a block-wise cascaded Fast Walsh-Hadamard Transform (FWHT) with linear-like complexity, AVX SIMD-optimized codebooks, and a steganographic encoding of scaling factors for perfect cache-line alignment.
Rastislav Lenhardt, Teodora Dobos, Thomas Vecchiato +2
Google Zurich, Switzerland · Technical University of Munich Munich, Germany · University of Copenhagen Copenhagen, Denmark +1