Manuscript Offprint

arXiv:2610.29295

Latent space configuration for neural network finetuning, fast ranking, and embedding dimensionality reduction

Nikita Gabdullin, Anton Raskovalov

Abstract

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)\mathcal{O}(1) complexity of a small candidate gallery subset search routine. ArcFace-pretrained IResNet50 models are finetuned using Latent Space Configuration (LSC) methodology to obtain new distribution of embeddings with desired geometric properties. The application of 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.

Keywords: Neural network finetuning, embedding gallery search, image retrieval, vector systems, latent space configuration.

1 Introduction

Nowadays, various complex systems rely on efficient retrieval of relevant information from extremely large databases. Often this requires data ranking by asserting relevance of database data with the query and returning K most relevant elements (top-K, or top-k, or top-N) [1]. High-dimensional outputs (embeddings) of neural networks (NNs) can directly be used as description vectors that represent the data, so numerical similarity between vectors becomes a measure of relevance [2]. This is widely used in document analysis, recommendation systems, speech and audio recognition [3, 4, 5]. In context of computer vision (CV), this translates to finding K most relevant images in gallery G for a query q. This is essential for e-commerce, face recognition, biometrics, and security [6, 2, 7].

Exhaustive search has O(ng)\mathcal{O}(n_g) complexity since it requires to compare queries with all embeddings in GG with size ngn_g. This is not feasible for galleries of million or billions of elements, so approximate methods are used instead. These methods often require building indexing structures over the gallery for fast retrieval of a smaller subset specific to the given query [8, 9, 10]. While indeed allowing sub-linear scaling, these methods are still computationally expensive and can reduce complexity to O(ng)\mathcal{O}(\sqrt{n_g}) [11].

In this paper we take advantage of geometric properties of vector systems used for NN latent space configuration (LSC) to find a small subset in G and significantly accelerate top K retrieval. LSC is a novel methodology which uses predefined class prototypes to structure and add geometric properties to NN LS during training [12]. It has previously been shown that the complexity of the search of mean vectors of class embeddings for classifier NNs with preconfigured LS is O(1)\mathcal{O}(1), which can be realized with a single sort operation performed on the embedding vector. In context of face recognition this translates to the search of mean vectors of person identity (id) embedding clusters with O(1)\mathcal{O}(1) complexity. Hence, the complete search complexity becomes O(nc)\mathcal{O}(n_c) where ncn_c is id cluster size which can be several orders of magnitude smaller than ngn_g. It is also important that ncn_c depends on the number of images per id (which can differ for different ids) and not ngn_g.

The desired geometry of NN emebdding distribution can be achieved with finetuning. NN pretraining on extremely large general purpose datasets and finetuning on smaller target datasets using supervised or self-supervised learning methods has proven to be very effective in various CV areas [13, 7, 14]. It has recently been shown that finetuning can also be performed using prototype-based training methods [15, 16]. However, most of them use trainable prototypes and require loss functions which complexity grows linearly with the number of clusters, classes, or ids in the gallery nidn_{id} [17, 15, 18]. On the contrary, LSC chooses predefined non-trainable prototypes allowing to avoid nidn_{id} scaling, which is beneficial for training and finetuning on datasets with extremely large nidn_{id} [12].

In this paper we propose two id cluster search algorithms which allow to rapidly identify a small candidate subset of gallery embeddings which similarity with the query needs to be assessed. These algorithms require that NN LS possesses certain geometric properties, so configuring LS during finetuning is essential for fast high-accuracy retrieval. The application of the proposed algorithms to embeddings of finetuned NN leads to several times speed-up on GPU and 40% speed-up on CPU compared to exhaustive search performed on GPU. The latter is particularly important for low computational budget and edge applications where GPU resources are limited or unavailable.

The rest of the paper is organized as follows: Section 2 outlines the LSC methodology for finetuning, Section 3 describes the proposed search algorithms, Section 4 summarizes experimental results, Section 5 discusses potential application scenarios of proposed methods, and Section 6 concludes the paper.

References (36)