WO2023065697A1 - 一种乘积量化搜索方法、装置、终端和存储介质 - Google Patents

一种乘积量化搜索方法、装置、终端和存储介质 Download PDF

Info

Publication number
WO2023065697A1
WO2023065697A1 PCT/CN2022/099855 CN2022099855W WO2023065697A1 WO 2023065697 A1 WO2023065697 A1 WO 2023065697A1 CN 2022099855 W CN2022099855 W CN 2022099855W WO 2023065697 A1 WO2023065697 A1 WO 2023065697A1
Authority
WO
WIPO (PCT)
Prior art keywords
dimensional
feature
low
euclidean distance
features
Prior art date
Application number
PCT/CN2022/099855
Other languages
English (en)
French (fr)
Inventor
张号逵
胡文泽
王孝宇
Original Assignee
深圳云天励飞技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳云天励飞技术股份有限公司 filed Critical 深圳云天励飞技术股份有限公司
Publication of WO2023065697A1 publication Critical patent/WO2023065697A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24549Run-time optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2462Approximate or statistical queries

Definitions

  • the present application belongs to the field of computer technology, and in particular relates to a product quantization search method, device, terminal and storage medium.
  • the main goal of the approximate product quantization search algorithm is to retrieve multiple data feature vectors most similar to a given query object from a database containing a large number of data feature vectors under a determined similarity measurement criterion.
  • Approximate product quantitative search is the basis of information retrieval, and it is widely used in various search engines and recommendation systems. How to quickly and accurately implement approximate product quantization search under the condition of limited hardware cost has always been a research hotspot in the field of information retrieval.
  • the search algorithm based on product quantization is a class of algorithms that are currently widely used.
  • the PQ search algorithm splits the high-dimensional features into multiple low-dimensional sub-features, and then uses the clustering algorithm to quantify each sub-feature, so that the high-dimensional floating-point type feature vector is quantified into low-dimensional integer data , thereby significantly reducing the computational overhead required to calculate the similarity between different feature vectors, thereby improving the search speed. Thanks to its simplicity and ease of deployment, various retrieval algorithms based on the PQ algorithm have been widely used in some practical scenarios.
  • Embodiments of the present application provide a product quantization search method, device, terminal, and storage medium, which can improve the accuracy of product quantization search.
  • the first aspect of the embodiment of the present application provides a product quantization search method, including:
  • a product quantization search is performed by using the target feature and the plurality of cluster centers to obtain a reference object with the closest distance to the target object.
  • the high-dimensional neighbor relationship is the high-dimensional Euclidean distance between the sample high-dimensional features associated with each two sample objects among the plurality of sample objects
  • the low-dimensional neighbor relationship is It is the low-dimensional Euclidean distance between the sample low-dimensional features associated with each two sample objects among the plurality of sample objects
  • the loss function of the feature compression network is based on the sum of the high-dimensional Euclidean distance and the The error value between the low-dimensional Euclidean distance corresponding to the high-dimensional Euclidean distance, and the function obtained by the weight value associated with the high-dimensional Euclidean distance, wherein, the value of the weight value and the high-dimensional Euclidean distance associated with it
  • the size of the Euclidean distance is related.
  • the feature compression network includes a residual module and a plurality of backbone modules; the reference high-dimensional features of the reference object are input into the feature compression network, and the reference output by the feature compression network is obtained.
  • the low-dimensional feature includes: inputting the reference high-dimensional feature into the residual module to obtain the first feature output by the residual module; inputting the reference high-dimensional feature into the first of the plurality of backbone modules backbone module, obtain the second feature output by the first backbone module, and input the second feature into the second backbone module in the plurality of backbone modules until the last backbone module in the plurality of backbone modules is obtained.
  • the third feature output by the module wherein the dimensions of the first feature and the third feature are the same; adding the first feature and the third feature to obtain the reference low-dimensional feature.
  • the feature compression unit is used to input the reference high-dimensional feature of the reference object into the feature compression network to obtain the reference low-dimensional feature output by the feature compression network, and the loss function of the feature compression network is based on the high-dimensional neighbor of the sample object The function obtained by the relationship and the low-dimensional neighbor relationship of the sample object;
  • a clustering unit configured to determine multiple cluster centers by using the reference low-dimensional features
  • a feature acquisition unit configured to acquire the target feature of the target object
  • the product quantization search unit is configured to use the target feature and the plurality of cluster centers to perform a product quantization search to obtain a reference object with the closest distance to the target object.
  • the third aspect of the embodiments of the present application provides a terminal, including a memory, a processor, and a computer program stored in the memory and operable on the processor, and the above method is implemented when the processor executes the computer program A step of.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the foregoing method are implemented.
  • the fifth aspect of the embodiments of the present application provides a computer program product, which, when the computer program product runs on a terminal, enables the terminal to execute the steps of the method.
  • the reference low-dimensional features output by the feature compression network are obtained, and multiple cluster centers are determined by using the reference low-dimensional features, and then, the obtained The target feature of the target object, and use the target feature and multiple cluster centers to perform product quantization search to obtain the reference object with the closest distance to the target object.
  • the loss function of the feature compression network is based on the high-dimensional neighbor relationship of the sample object and the above
  • the function obtained from the low-dimensional neighbor relationship of the sample object, using the trained feature compression network to reduce the dimensionality of the reference high-dimensional features can avoid the direct splitting of high-dimensional features into multiple low-dimensional sub-features.
  • the problem of loss of neighbor relationship information can be solved, and the search accuracy can be improved.
  • Fig. 1 is a schematic diagram of the implementation flow of a product quantization search method provided by an embodiment of the present application
  • Fig. 2 is a schematic structural diagram of the feature compression network provided by the embodiment of the present application.
  • FIG. 3 is a schematic diagram of a specific implementation flow of step S101 provided by the embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of a product quantization search device provided in an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
  • the PQ search algorithm needs to split the high-dimensional features into multiple low-dimensional sub-features, and then use the clustering algorithm to quantify each sub-feature, but this method will cause more information loss, resulting in a decrease in the accuracy of the subsequent search process .
  • this application proposes a product quantization search method.
  • the feature compression network is obtained by training the loss function based on the high-dimensional neighbor relationship of the sample object and the low-dimensional neighbor relationship of the sample object, and uses the trained feature compression network to compare the reference Dimensionality reduction of high-dimensional features can avoid the problem of loss of adjacent relationship information between features caused by directly splitting high-dimensional features into multiple low-dimensional sub-features, thereby improving search accuracy.
  • Figure 1 shows a schematic diagram of the implementation flow of a product quantification search method provided by the embodiment of the present application.
  • Devices, set-top boxes, servers, satellite wireless devices and other smart devices can be applied to situations where the accuracy of product quantization search needs to be improved.
  • the above product quantization search method may include the following steps S101 to S104.
  • Step S101 input the reference high-dimensional features of the reference object into the feature compression network to obtain the reference low-dimensional features output by the feature compression network.
  • the reference object refers to an object used for comparison with the target object in the database, and the type of the reference object can be adjusted according to the actual situation, and generally can be an image or the like.
  • the terminal can extract the reference high-dimensional features of the reference object through the feature extraction algorithm, and use the trained feature compression network to convert the reference high-dimensional features of the reference object to Compress to reference low-dimensional vector
  • the network structure of the feature extraction algorithm and the feature compression network can be set according to the actual situation.
  • the loss function of the feature compression network is a function based on the high-dimensional neighbor relationship of the sample object and the low-dimensional neighbor relationship of the sample object.
  • the sample object is the object used to train the feature compression network.
  • the high-dimensional neighbor relationship refers to the neighbor relationship between the sample high-dimensional features associated with every two sample objects in the sample object
  • the low-dimensional neighbor relationship refers to the sample low-dimensional feature associated with every two sample objects in the sample object. neighbor relationship between them.
  • the present application can use the loss function related to the neighbor relationship of the sample object to train the feature compression network to be trained until the feature compression network converges to obtain a trained feature compression network.
  • this application does not limit the algorithm used for model training, for example, it can be implemented by using a gradient descent algorithm.
  • the conventional loss function is generally a function established based on the error between the high-dimensional features of the sample and the low-dimensional features of the sample.
  • the loss function is constructed based on the high-dimensional neighbor relationship and the low-dimensional neighbor relationship.
  • Dimensionality reduction through conventional dimensionality reduction algorithms, or dimensionality reduction through the feature compression network trained by conventional loss functions can keep the low-dimensional features of the sample to maintain certain neighbor relationship information, and because the search process of the nearest neighbor search algorithm is It is realized by using the neighbor relationship between features, therefore, the method provided by the present application improves the integrity of the neighbor relationship in the compression process, thereby improving the search accuracy.
  • ratio d 1 /d 2 of feature compression does not limit the ratio d 1 /d 2 of feature compression, and the ratio d 1 /d 2 of feature compression in practical applications may be 2, 4, 8, etc.
  • Step S102 using reference low-dimensional features to determine multiple cluster centers.
  • each cluster center may represent a type of reference low-dimensional feature, and further characterize a characteristic of a certain object.
  • the index value of the cluster center associated with each reference object can be obtained, for example, when the reference low-dimensional feature of a reference object is far from the cluster center with the identification number 10 Recently, the identification number can be stored as the index value of the reference object, thereby realizing quantization from floating-point data to integer data.
  • the terminal may perform clustering on multiple reference low-dimensional features to obtain multiple clustering centers.
  • the clustering process can be realized by K-Means clustering algorithm or other clustering algorithms.
  • Step S103 acquiring target features of the target object.
  • the target object refers to the object to be queried, and its type is the same as that of the reference object and the sample object.
  • the aforementioned target features may refer to target low-dimensional features of the target object.
  • Step S104 using the target feature and multiple cluster centers to perform product quantization search to obtain the reference object with the closest distance to the target object.
  • the terminal can use the target feature and the cluster center associated with each reference low-dimensional feature to determine the distance between the target feature and each reference low-dimensional feature, and calculate the minimum distance between the reference low-dimensional features
  • the reference object corresponding to the dimension feature is taken as the reference object closest to the target object.
  • the terminal can first calculate the distance between the target feature and each cluster center, and then, according to the index value associated with each reference low-dimensional feature, determine the cluster center associated with each reference low-dimensional feature, and then , the terminal can use the distance between the target feature and the cluster center associated with a reference low-dimensional feature as the distance between the target feature and the reference low-dimensional feature. Since the smaller the distance, the more similar the two features are, therefore, the terminal may use the reference object corresponding to the reference low-dimensional feature with the smallest distance as the reference object closest to the target object.
  • the target feature of the target image can be extracted, and then the distance between the target feature and each cluster center can be calculated, and then, according to the distance between the target feature and each reference low
  • the index value associated with a low-dimensional feature determines the cluster center associated with each reference low-dimensional feature, and then the terminal can use the distance between the target feature and the cluster center associated with a reference low-dimensional feature as the distance between the target feature and the reference
  • the distance between the low-dimensional features, and the reference object corresponding to the reference low-dimensional feature with the smallest distance is used as the reference object closest to the target object.
  • the terminal can determine the scene to which the target image belongs to be the closest to the target image.
  • the reference low-dimensional features output by the feature compression network are obtained, and multiple cluster centers are determined by using the reference low-dimensional features, and then, the obtained The target feature of the target object, and use the target feature and multiple cluster centers to perform product quantization search to obtain the reference object with the closest distance to the target object.
  • the loss function of the feature compression network is based on the high-dimensional neighbor relationship of the sample object and the above
  • the function obtained from the low-dimensional neighbor relationship of the sample object, using the trained feature compression network to reduce the dimensionality of the reference high-dimensional features can avoid the direct splitting of high-dimensional features into multiple low-dimensional sub-features.
  • the problem of loss of neighbor relationship information can be solved, and the search accuracy can be improved.
  • the terminal may construct the feature compression network shown in FIG. 2 .
  • the feature compression network may include a residual module and multiple backbone modules.
  • step S101 may include the following steps S301 to S303.
  • Step S301 input the reference high-dimensional feature into the residual module, and obtain the first feature output by the residual module.
  • the residual module is used to linearly map the reference high-dimensional feature, and the first feature with the same dimension as the reference low-dimensional feature can be obtained.
  • Step S302 input the reference high-dimensional features into the first backbone module among the plurality of backbone modules, obtain the second feature output by the first backbone module, and input the second feature into the second backbone module among the plurality of backbone modules , until the third feature output by the last backbone module among the plurality of backbone modules is obtained.
  • the number H of the above-mentioned plurality of backbone modules can be adjusted according to actual conditions, and generally can be 5 to 10.
  • the first H-1 backbone modules among the above-mentioned multiple backbone modules may adopt the same structure, each including a linear mapping function (Linear), a ReLU (Rectified Linear Units) activation function, and A Batch normalization (BN) layer for dimensionality reduction of reference high-dimensional features.
  • the H-th backbone module among the above-mentioned plurality of backbone modules may include a linear mapping function (Linear) for outputting the third feature whose dimension is d 2 . It can be seen that the dimensions of the first feature and the third feature are the same.
  • the parameter d 3 is the dimension of the input features
  • d 4 is the dimension of the output features.
  • the dimensions of the output features of the first H-1 backbone modules are in, and That is to say, the terminal can reduce the dimension of the reference high-dimensional features to the dimension of d2 through any one of the backbone modules in the first H-1 backbone modules.
  • the terminal can input the reference high-dimensional features to the first backbone module, and the first backbone module maps the reference high-dimensional features to a dimension of The feature of , using the ReLU activation function for this dimension is The features are activated, and the BN layer is used for normalization processing to obtain the dimension The output feature of (that is, the aforementioned second feature). Then, the terminal proceeds to convert the dimension The output features of are input to the second backbone module, and so on, until the terminal has a dimension of The output features of are input to the H-1th backbone module, and the output dimension of the H-1th backbone module is The output features of , and by the Hth backbone module through the linear mapping function, the dimension is The output feature map of is the third feature.
  • Step S303 adding the first feature and the third feature to obtain a reference low-dimensional feature.
  • a reference low-dimensional feature with a dimension of d2 can be obtained.
  • the output value of the backbone module is not directly used as the model output value, but the third feature output by the backbone module is added to the first feature output by the residual module to avoid excessive deviation of the output value of the model
  • the actual eigenvalues which improve the convergence speed of the feature compression network.
  • the terminal After completing the construction of the feature compression network, the terminal can use the loss function obtained based on the high-dimensional neighbor relationship of the sample object and the low-dimensional neighbor relationship of the sample object to train the feature compression network.
  • the above-mentioned high-dimensional neighbor relationship is the high-dimensional Euclidean distance between the sample high-dimensional features associated with every two sample objects among the plurality of sample objects
  • the above-mentioned low-dimensional neighbor relationship is the high-dimensional Euclidean distance between every two sample objects among the multiple sample objects.
  • the loss function of the feature compression network is a function based on the error value between the high-dimensional Euclidean distance and the low-dimensional Euclidean distance corresponding to the high-dimensional Euclidean distance, and the weight value associated with the high-dimensional Euclidean distance .
  • the value of the weight value is related to the magnitude of the associated high-dimensional Euclidean distance.
  • the calculation process of the loss value loss of the loss function may include: calculating the high-dimensional Euclidean distance and the low-dimensional Euclidean distance corresponding to the high-dimensional Euclidean distance error value between Then, calculate the weight value ⁇ ij associated with the high-dimensional Euclidean distance, and use each weight value to weight and add each error value to obtain the accumulated value Next, divide the accumulated value obtained by the square value m 2 of the total number of sample objects to obtain the loss value loss of the loss function. That is, the loss value of the loss function
  • m represents the total number of sample objects, Indicates the high-dimensional Euclidean distance, x i represents the sample high-dimensional feature associated with the i-th sample object, x j represents the sample high-dimensional feature associated with the j-th sample object, Represents the low-dimensional Euclidean distance, y i represents the sample low-dimensional feature associated with the i-th sample object, and y j represents the sample low-dimensional feature associated with the j-th sample object.
  • the calculation process of the weight value ⁇ ij associated with the high-dimensional Euclidean distance may include: obtaining the first hyperparameter ⁇ and the second hyperparameter ⁇ , and calculating the average of each high-dimensional Euclidean distance value mean; use the first hyperparameter ⁇ , the second hyperparameter ⁇ and the mean value to determine multiple disjoint interval ranges; then, according to the target interval range of the high-dimensional Euclidean distance in the multiple interval ranges, Determines the weight value associated with the high-dimensional Euclidean distance.
  • the first hyperparameter ⁇ is greater than the second hyperparameter ⁇ ; the specific values of ⁇ and ⁇ can be set according to the actual situation, and in practical applications, ⁇ can be set to 2, and ⁇ can be set to 0.01.
  • the above multiple ranges may specifically include a first range, a second range and a third range, wherein the values in the second range are smaller than the values in the first range and are greater than the values in the third range. value.
  • the first interval range may refer to less than or equal to If the high-dimensional Euclidean distance is within the range of the first interval, the terminal can calculate the opposite number of the natural logarithm of the quotient of the high-dimensional Euclidean distance and the average value and the first hyperparameter ⁇ and the opposite number The minimum value between is used as the weight value associated with the high-dimensional Euclidean distance.
  • the second interval range may refer to greater than and less than or equal to If the high-dimensional Euclidean distance is within the second interval, the terminal can calculate the inverse of the natural logarithm of the quotient of the high-dimensional Euclidean distance and the average value and put the inverse As the weight value associated with the high-dimensional Euclidean distance.
  • the third range may refer to greater than If the high-dimensional Euclidean distance is within the third interval, the terminal can calculate the opposite number of the natural logarithm of the quotient of the high-dimensional Euclidean distance and the average value and the second hyperparameter ⁇ and the opposite number The maximum value between is used as the weight value associated with the high-dimensional Euclidean distance.
  • using the above weight formula and loss function to train the feature compression network can make the high-dimensional neighbor relationship and low-dimensional neighbor relationship between features with small high-dimensional Euclidean distance more accurate, that is, , after inputting the two reference high-dimensional features with smaller high-dimensional Euclidean distance into the trained feature compression network, the obtained neighbor relationship information between the two reference low-dimensional features will be more complete.
  • the purpose of the product quantization search algorithm is to search for the feature with the closest distance to the target feature. Therefore, this method can make the adjacent relationship information between the features with a closer distance more complete, and further improve the search accuracy.
  • FIG. 4 is a schematic structural diagram of a product quantization search device 400 provided in an embodiment of the present application, and the product quantization search device 400 is configured on a terminal.
  • the product quantization search device 400 may include:
  • the feature compression unit 401 is used to input the reference high-dimensional features of the reference object into the feature compression network to obtain the reference low-dimensional features output by the feature compression network.
  • the loss function of the feature compression network is based on the high-dimensional neighbor relationship of the sample object and the sample The function obtained by the low-dimensional neighbor relationship of the object;
  • the product quantization search unit 404 is configured to use the target feature and multiple cluster centers to perform product quantization search to obtain the reference object with the closest distance to the target object.
  • the above-mentioned high-dimensional neighbor relationship is the high-dimensional Euclidean distance between the sample high-dimensional features associated with every two sample objects in the multiple sample objects
  • the above-mentioned low-dimensional neighbor relationship is the multiple sample objects
  • the loss function of the above-mentioned feature compression network is based on the high-dimensional Euclidean distance and the low-dimensional Euclidean distance corresponding to the high-dimensional Euclidean distance
  • the calculation process of the loss value of the above loss function includes: calculating the error value between the high-dimensional Euclidean distance and the low-dimensional Euclidean distance corresponding to the high-dimensional Euclidean distance ; Calculate the weight value associated with the high-dimensional Euclidean distance, and use each of the weight values to weight and add each of the error values to obtain an accumulated value; combine the accumulated value and the sample object The square value of the total number is divided to obtain the loss value of the loss function.
  • the calculation process of the above weight value includes: obtaining a first hyperparameter and a second hyperparameter, the first hyperparameter is greater than the second hyperparameter; calculating each of the high-dimensional Ou The average value of the Euclidean distance; using the first hyperparameter, the second hyperparameter and the average value to determine a plurality of disjoint interval ranges; according to the high-dimensional Euclidean distance in the plurality of interval ranges Determine the weight value associated with the high-dimensional Euclidean distance within the range of the target interval in .
  • the above-mentioned feature compression network includes a residual module and multiple backbone modules; the above-mentioned feature compression unit 401 can also be specifically used to: input the reference high-dimensional features into the residual module, and obtain the output of the residual module The first feature; input the reference high-dimensional feature into the first backbone module of the plurality of backbone modules, obtain the second feature output by the first backbone module, and input the second feature into the second backbone of the plurality of backbone modules module until the third feature output by the last backbone module among multiple backbone modules is obtained, wherein the dimensions of the first feature and the third feature are the same; the first feature and the third feature are added to obtain a reference low-dimensional feature.
  • the clustering unit 402 may also be specifically configured to: cluster multiple reference low-dimensional features to obtain multiple cluster centers.
  • the above-mentioned product quantization search unit 404 can also be specifically configured to: use the target feature and the cluster center associated with each reference low-dimensional feature to determine the relationship between the target feature and each reference low-dimensional feature The distance; the reference object corresponding to the reference low-dimensional feature with the smallest distance is taken as the reference object closest to the target object.
  • FIG. 5 it is a schematic diagram of a terminal provided in the embodiment of the present application.
  • the terminal 5 may include: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and operable on the processor 50, such as a product quantization search program.
  • the processor 50 executes the computer program 52 , the steps in the above embodiments of the product quantization search method are realized, such as steps S101 to S104 shown in FIG. 1 .
  • the processor 50 executes the computer program 52, it realizes the functions of the modules/units in the above-mentioned device embodiments, such as the feature compression unit 401, clustering unit 402, feature acquisition unit 403 and product Quantization search unit 404 .
  • the computer program can be divided into one or more modules/units, and the one or more modules/units are stored in the memory 51 and executed by the processor 50 to complete the present application.
  • the one or more modules/units may be a series of computer program instruction segments capable of accomplishing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal.
  • the computer program can be divided into: a feature compression unit, a clustering unit, a feature acquisition unit, and a product quantization search unit.
  • each unit is as follows: the feature compression unit is used to input the reference high-dimensional features of the reference object into the feature compression network to obtain the reference low-dimensional features output by the feature compression network, and the loss function of the feature compression network is based on The function obtained by the high-dimensional neighbor relationship of the sample object and the low-dimensional neighbor relationship of the sample object; the clustering unit is used to determine a plurality of cluster centers by using the reference low-dimensional feature; the feature acquisition unit is used to acquire the target object the target feature; a product quantization search unit, configured to use the target feature and the plurality of cluster centers to perform a product quantization search to obtain a reference object with the closest distance to the target object.
  • the terminal may include, but not limited to, a processor 50 and a memory 51 .
  • a processor 50 and a memory 51 .
  • FIG. 5 is only an example of a terminal, and does not constitute a limitation on the terminal. It may include more or less components than those shown in the figure, or combine certain components, or different components, such as the Terminals may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 50 can be a central processing unit (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the storage 51 may be an internal storage unit of the terminal, such as a hard disk or internal memory of the terminal.
  • the memory 51 can also be an external storage device of the terminal, such as a plug-in hard disk equipped on the terminal, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card) etc.
  • the memory 51 may also include both an internal storage unit of the terminal and an external storage device.
  • the memory 51 is used to store the computer program and other programs and data required by the terminal.
  • the memory 51 can also be used to temporarily store data that has been output or will be output.
  • the disclosed device/terminal and method may be implemented in other ways.
  • the device/terminal embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated module/unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments in the present application can also be completed by instructing related hardware through computer programs.
  • the computer programs can be stored in a computer-readable storage medium, and the computer When the program is executed by the processor, the steps in the above-mentioned various method embodiments can be realized.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (Read-Only Memory, ROM) , random access memory (Random Access Memory, RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • electric carrier signal telecommunication signal and software distribution medium, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请适用于计算机技术领域,提供了一种乘积量化搜索方法、装置、终端和存储介质。其中,上述乘积量化搜索方法具体包括:将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;利用所述参考低维特征确定多个聚类中心;获取目标对象的目标特征;利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。本申请的实施例能够提高乘积量化搜索的精度。

Description

一种乘积量化搜索方法、装置、终端和存储介质
本申请要求于2021年10月21日提交中国专利局,申请号为202111229216.1、替换名称为“一种乘积量化搜索方法、装置、终端和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于计算机技术领域,尤其涉及一种乘积量化搜索方法、装置、终端和存储介质。
背景技术
近似乘积量化搜索算法的主要目标是在确定的相似度量准则下,从包含大量数据特征向量的数据库中检索出与给定查询对象最为相似的多条数据特征向量。近似乘积量化搜索是信息检索的基础,在各种搜索引擎及推荐系统中有着非常广泛的应用。如何在硬件成本有限的条件下,快速准确的实现近似乘积量化搜索一直是信息检索领域的一个研究热点。
基于乘积量化(Product Quantization,PQ)的搜索算法是当前应用非常广泛的一类算法。PQ搜索算法是将高维特征拆分为多个低维的子特征,然后利用聚类算法对每段子特征进行量化,进而使高维的浮点类型特征向量被量化为低维的整型数据,从而显著的减少了计算不同特征向量之间相似度时需要的运算开销,以此提升搜索速度。得益于方法简单及易于部署等特点,基于PQ算法的各类检索算法当前已经被广泛的应用到一些实用场景中。
但是,直接从高维浮点型数据量化到低维整型数据将造成较多信息的丢失,进而导致搜索的精度降低。
替换内容
本申请实施例提供一种乘积量化搜索方法、装置、终端和存储介质,可以在提高乘积量化搜索的精度。
本申请实施例第一方面提供一种乘积量化搜索方法,包括:
将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;
利用所述参考低维特征确定多个聚类中心;
获取目标对象的目标特征;
利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。
在本申请的一些实施方式中,所述高维近邻关系为多个所述样本对象中每两个样本对象分别关联的样本高维特征之间的高维欧氏距离,所述低维近邻关系为多个所述样本对象中每两个样本对象分别关联的样本低维特征之间的低维欧氏距离;所述特征压缩网络的损失函数为基于所述高维欧氏距离和与所述高维欧氏距离对应的低维欧氏距离之间的误差值,以及与所述高维欧氏距离关联的权重值得到的函数,其中,所述权重值的取值和与其关联的高维欧氏距离的大小相关。
在本申请的一些实施方式中,所述特征压缩网络包括残差模块和多个主干模块;所述将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,包括:将所述参考高维特征输入所述残差模块,得到所述残差模块输出的第一特征;将所述参考高维特征输入所述多个主干模块中的第一个主干模块,得到所述第一个主干模块输出的第二特征,并将所述第二特征输入所述多个主干模块中的第二个主干模块,直至得到多个主干模块中最后一个主干模块输出的第三特征,其中,所述第一特征和所述第三特征的维度相同;将所述第一特征与所述第三特征相加,得到所述参考低维特征。
本申请实施例第二方面提供的一种乘积量化搜索装置,包括:
特征压缩单元,用于将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;
聚类单元,用于利用所述参考低维特征确定多个聚类中心;
特征获取单元,用于获取目标对象的目标特征;
乘积量化搜索单元,用于利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。
本申请实施例第三方面提供一种终端,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述方法的步骤。
本申请实施例第四方面提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述方法的步骤。
本申请实施例第五方面提供了一种计算机程序产品,当计算机程序产品在终端上运行时,使得终端执行时实现方法的步骤。
本申请的实施方式中,通过将参考对象的参考高维特征输入特征压缩网络中,得到由特征压缩网络输出的参考低维特征,并利用参考低维特征确定多个聚类中心,然后,获取目标对象的目标特征,并利用目标特征和多个聚类中心进行乘积量化搜索,得到与目标对象距离最近的参考对象,由于特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数,利用训练好的特征压缩网络对参考高维特征进行降维,能够避免直接将高维特征拆分为多个低维的子特征导致的特征之间相邻关系信息丢失的问题,进而提高搜索精度。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种乘积量化搜索方法的实现流程示意图;
图2是本申请实施例提供的特征压缩网络的结构示意图;
图3是本申请实施例提供的步骤S101的具体实现流程示意图;
图4是本申请实施例提供的一种乘积量化搜索装置的结构示意图;
图5是本申请实施例提供的终端的结构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护。
PQ搜索算法需要将高维特征拆分为多个低维的子特征,然后利用聚类算法对每段子特征进行量化,但这种方式将造成较多信息的丢失,导致后续的搜索过程精度降低。
因此,本申请提出了一种乘积量化搜索方法,首先基于样本对象的高维近邻关系和样本对象的低维近邻关系得到的损失函数训练得到特征压缩网络,并利用训练好的特征压缩网络对参考高维特征进行降维,能够避免直接将高维特征拆分为多个低维的子特征导致的特征之间相邻关系信息丢失的问题,进而提高搜索精度。
为了说明本申请的技术方案,下面通过具体实施例来进行说明。
图1示出了本申请实施例提供的一种乘积量化搜索方法的实现流程示意图,该方法可以应用于终端上,该终端可以为电脑、手机、可穿戴设备、车载设备、增强现实/虚拟现实设备、机顶盒、服务器、卫星无线设备等智能设备,可适用于需提高乘积量化搜索的精度的情形。
具体的,上述乘积量化搜索方法可以包括以下步骤S101至步骤S104。
步骤S101,将参考对象的参考高维特征输入特征压缩网络中,得到由特征压缩网络输出的参考低维特征。
其中,参考对象是指数据库中用于与目标对象进行比较的对象,参考对象的类型可以根据实际情况进行调整,一般可以为图像等。
在本申请的实施方式中,终端可以通过特征提取算法提取参考对象的参考高维特征,并通过训练好的特征压缩网络,将参考对象的参考高维特征
Figure PCTCN2022099855-appb-000001
压缩为参考低维向量
Figure PCTCN2022099855-appb-000002
具体的,特征提取算法和特征压缩网络的网络结构可以根据实际情况进行设置。而特征压缩网络的损失函数为基于样本对象的高维近邻关系和样本 对象的低维近邻关系得到的函数。
其中,样本对象是用于训练特征压缩网络的对象。高维近邻关系是指样本对象中每两个样本对象分别关联的样本高维特征之间的近邻关系,低维近邻关系是指样本对象的中每两个样本对象分别关联的样本低维特征之间的近邻关系。
也就是说,本申请可以利用与样本对象的近邻关系相关的损失函数,对待训练的特征压缩网络进行训练,直至特征压缩网络收敛,得到训练好的特征压缩网络。
需要说明的是,本申请对模型训练所使用的算法不进行限制,例如可以采用梯度下降算法实现。
常规的损失函数一般是基于样本高维特征与样本低维特征之间的误差建立的函数,而在本申请的实施方式中,基于高维近邻关系和低维近邻关系构建损失函数,相较于通过常规的降维算法进行降维,或者通过利用常规的损失函数训练得到的特征压缩网络进行降维,可以使样本低维特征保持一定的近邻关系信息,又由于最近邻搜索算法的搜索过程是利用特征间的近邻关系实现的,因此,采用本申请提供的方法提高了压缩过程中近邻关系的完整性,进而提高了搜索的精度。
需要说明的是,本申请对特征压缩的比例d 1/d 2不进行限制,实际应用中特征压缩的比例d 1/d 2可以为2、4、8等。
步骤S102,利用参考低维特征确定多个聚类中心。
在本申请的实施方式中,每一个聚类中心可以表征参考低维特征的一种类型,进而表征某个对象的特性。
通过将每个参考对象与聚类中心进行比较,可以得到与每个参考对象关联的聚类中心的索引值,例如当某个参考对象的参考低维特征与标识号为10的聚类中心距离最近,则可以存储该标识号作为该参考对象的索引值,进而实现从浮点型数据量化到整型数据。
在本申请的一些实施方式中,终端可以对多个参考低维特征进行聚类,得到多个聚类中心。其中,聚类的过程可以通过K-Means聚类算法或其他聚类算法实现。
步骤S103,获取目标对象的目标特征。
具体的,目标对象是指待查询对象,其类型与参考对象和样本对象的类型相同。上述目标特征可以指目标对象的目标低维特征。
步骤S104,利用目标特征和多个聚类中心进行乘积量化搜索,得到与目标对象距离最近的参考对象。
在本申请的一些实施方式中,终端可以利用目标特征和与每个参考低维特征关联的聚类中心,确定目标特征与每个参考低维特征之间的距离,并将距离最小的参考低维特征对应的参考对象作为与目标对象距离最近的参考对象。
具体的,终端可以先计算目标特征与每个聚类中心之间的距离,接着,依据与每个参考低维特征关联的索引值,确定与每个参考低维特征关联的聚类中心,进而,终端可以将目标特征与某个参考低维特征关联的聚类中心之间的距离作为目标特征与该参考低维特征之间的距离。由于距离越小说明两个特征之间越相似,因此,终端可以将距离最小的参考低维特征对应的参考对象作为与目标对象距离最近的参考对象。
以目标对象为目标图像为例,当需要进行目标图像的场景识别时,可以提取目标图像的目标特征,再计算目标特征与每个聚类中心之间的距离,接着,依据与每个参考低维特征关联的索引值,确定与每个参考低维特征关联的聚类中心,进而,终端可以将目标特征与某个参考低维特征关联的聚类中心之间的距离作为目标特征与该参考低维特征之间的距离,并将距离最小的参考低维特征对应的参考对象作为与目标对象距离最近的参考对象,此时,终端便可以将目标图像所属的场景确定为与目标图像距离最近的参考图像所属的场景。
本申请的实施方式中,通过将参考对象的参考高维特征输入特征压缩网络中,得到由特征压缩网络输出的参考低维特征,并利用参考低维特征确定多个聚类中心,然后,获取目标对象的目标特征,并利用目标特征和多个聚类中心进行乘积量化搜索,得到与目标对象距离最近的参考对象,由于特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数,利用训练好的特征压缩网络对参考高维特征进行降维,能够避免直接将高维特征拆分为多个低维的子特征导致的特征之间相邻关系信息丢失的问题,进而提高搜索精度。
在本申请的一些实施方式中,终端可以构建图2所示的特征压缩网络。具体的,特征压缩网络中可以包括残差模块和多个主干模块。
相应的,上述步骤S101可以包括以下步骤S301至步骤S303。
步骤S301,将参考高维特征输入残差模块,得到残差模块输出的第一特征。
具体的,残差模块可以包含一个线性映射函数(Linear),线性映射函数具体为f(x)=W 1x,参数
Figure PCTCN2022099855-appb-000003
本申请利用残差模块对参考高维特征进行线性映射,可以得到维度与参考低维特征相同的第一特征。
步骤S302,将参考高维特征输入多个主干模块中的第一个主干模块,得到第一个主干模块输出的第二特征,并将第二特征输入多个主干模块中的第二个主干模块,直至得到多个主干模块中最后一个主干模块输出的第三特征。
具体的,上述多个主干模块的数量H可以根据实际情况进行调整,一般可以为5至10。
在本申请的一些实施方式中,上述多个主干模块中的前H-1个主干模块可以采用相同的结构,均包含一个线性映射函数(Linear),一个ReLU(Rectified Linear Units)激活函数,以及一个批标准化(Batch normalization,BN)层,用于对参考高维特征进行降维。上述多个主干模块中的第H个主干模块可以包含一个线性映射函数(Linear),用于输出维度为d 2的第三特征。可见,第一特征和第三特征的维度相同。
需要说明的是,每个主干模块的线性映射函数的形式可以为f(x)=W 2x,参数
Figure PCTCN2022099855-appb-000004
d 3为输入特征的维度,d 4为输出特征的维度。前H-1个主干模块的输出特征的维度依次为
Figure PCTCN2022099855-appb-000005
Figure PCTCN2022099855-appb-000006
其中,
Figure PCTCN2022099855-appb-000007
Figure PCTCN2022099855-appb-000008
也就是说,终端可以通过在前H-1个主干模块中的任意一个主干模块完成将参考高维特征降维到d 2的维度。
具体的,终端可以将参考高维特征输入到第一个主干模块,由第一个主干模块通过线性映射函数将参考高维特征映射为维度为
Figure PCTCN2022099855-appb-000009
的特征,利用ReLU激活函数对该维度为
Figure PCTCN2022099855-appb-000010
的特征进行激活,并利用BN层进行归一化处理,得到维度
Figure PCTCN2022099855-appb-000011
的输出特征(也即前述第二特征)。然后,终端继续将维度
Figure PCTCN2022099855-appb-000012
的输出特征输入到第二个主干模块,以此类推,直至终端将维 度为
Figure PCTCN2022099855-appb-000013
的输出特征输入到第H-1个主干模块,由第H-1个主干模块输出维度为
Figure PCTCN2022099855-appb-000014
的输出特征,并由第H个主干模块通过线性映射函数将维度为
Figure PCTCN2022099855-appb-000015
的输出特征映射为第三特征。
步骤S303,将第一特征与第三特征相加,得到参考低维特征。
在本申请的实施方式中,通过将第一特征与第三特征相加,可以得到维度为d 2的参考低维特征。
本申请的实施方式中,不是直接将主干模块的输出值作为模型输出值,而是将主干模块输出的第三特征与残差模块输出的第一特征相加,避免了模型的输出值过分偏离实际的特征值,提高了特征压缩网络的收敛速度。
在完成对特征压缩网络的构建之后,终端可以利用基于样本对象的高维近邻关系和样本对象的低维近邻关系得到的损失函数,对特征压缩网络进行训练。
其中,上述高维近邻关系为多个所述样本对象中每两个样本对象分别关联的样本高维特征之间的高维欧氏距离,上述低维近邻关系为多个样本对象中每两个样本对象分别关联的样本低维特征之间的低维欧氏距离。
相应的,特征压缩网络的损失函数为基于高维欧氏距离和与高维欧氏距离对应的低维欧氏距离之间的误差值,以及与高维欧氏距离关联的权重值得到的函数。
在本申请的一些实施方式中,权重值的取值和与其关联的高维欧氏距离的大小相关。
具体的,损失函数的损失值loss的计算过程可以包括:计算高维欧氏距离
Figure PCTCN2022099855-appb-000016
和与高维欧氏距离对应的低维欧氏距离
Figure PCTCN2022099855-appb-000017
之间的误差值
Figure PCTCN2022099855-appb-000018
然后,计算与高维欧氏距离关联的权重值ω ij,并利用每个权重值对每个误差值进行加权相加,得到累加值
Figure PCTCN2022099855-appb-000019
接着,将得到的累加值和样本对象的总数量的平方值m 2相除,得到损失函数的损失值loss。也即,损失函数的损失值
Figure PCTCN2022099855-appb-000020
其中,m表示样本对象的总数量,
Figure PCTCN2022099855-appb-000021
表示高维欧氏距离,x i表示与第i个样本对象关联的样本高维特征,x j表示与第j个样本对象关联的样本高维特征,
Figure PCTCN2022099855-appb-000022
表示低维欧氏距离,y i表 示与第i个样本对象关联的样本低维特征,y j表示与第j个样本对象关联的样本低维特征。
在本申请的一些实施方式中,与高维欧氏距离关联的权重值ω ij的计算过程可以包括:获取第一超参数α和第二超参数β,并计算各个高维欧氏距离的平均值mean;利用第一超参数α、第二超参数β和平均值mean确定互不相交的多个区间范围;然后,根据高维欧氏距离在多个区间范围中所处的目标区间范围,确定与高维欧氏距离关联的权重值。
其中,第一超参数α大于第二超参数β;α和β的具体取值可以根据实际情况设,实际应用中,α可以设置为2,β可以设置为0.01。
上述多个区间范围可以具体包括第一区间范围、第二区间范围和第三区间范围,其中,第二区间内范围的数值均小于第一区间范围内的数值,且均大于第三区间范围内的数值。
在一些实施方式中,第一区间范围可以指小于或等于
Figure PCTCN2022099855-appb-000023
若高维欧氏距离位于第一区间范围内,则终端可以计算高维欧氏距离和平均值之商的自然对数值的相反数
Figure PCTCN2022099855-appb-000024
并将第一超参数α和该相反数
Figure PCTCN2022099855-appb-000025
之间的最小值作为与高维欧氏距离关联的权重值。
在一些实施方式中,第二区间范围可以指大于
Figure PCTCN2022099855-appb-000026
且小于或等于
Figure PCTCN2022099855-appb-000027
若高维欧氏距离位于第二区间范围内,则终端可以计算高维欧氏距离和平均值之商的自然对数值的相反数
Figure PCTCN2022099855-appb-000028
并将该相反数
Figure PCTCN2022099855-appb-000029
作为与高维欧氏距离关联的权重值。
在另一些实施方式中,第三区间范围可以指大于
Figure PCTCN2022099855-appb-000030
若高维欧氏距离位于第三区间范围内,则终端可以计算高维欧氏距离和平均值之商的自然对数值的相反数
Figure PCTCN2022099855-appb-000031
并将第二超参数β和该相反数
Figure PCTCN2022099855-appb-000032
之间的最大值作为与高维欧氏距离关联的权重值。
也即,与高维欧氏距离关联的权重值
Figure PCTCN2022099855-appb-000033
基于上述公式可知,当高维欧氏距离
Figure PCTCN2022099855-appb-000034
则与其关联的权重值ω ij将大于或等于α;而当高维欧氏距离
Figure PCTCN2022099855-appb-000035
则与其关联的权重值ω ij将小于或等于β。进而在损失函数中,高维欧氏距离小的两个样本高维特征所对应的权重更高。
在本申请的实施方式中,利用上述权重公式与损失函数进行特征压缩网络的训练,可以使高维欧氏距离小的特征之间高维近邻关系与低维近邻关系的精度更高,也即,将高维欧氏距离越小的两个参考高维特征输入至训练好的特征压缩网络后,得到的两个参考低维特征之间近邻关系信息将更完整。而乘积量化搜索算法的目的就是搜索与目标特征距离最近的特征,因此,这种方式可以使距离较近的特征之间相邻关系信息更加完整,进而进一步提高搜索精度。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为根据本申请,某些步骤可以采用其它顺序进行。
如图4所示为本申请实施例提供的一种乘积量化搜索装置400的结构示意图,所述乘积量化搜索装置400配置于终端上。
具体的,所述乘积量化搜索装置400可以包括:
特征压缩单元401,用于将参考对象的参考高维特征输入特征压缩网络中,得到由特征压缩网络输出的参考低维特征,特征压缩网络的损失函数为基于样本对象的高维近邻关系和样本对象的低维近邻关系得到的函数;
聚类单元402,用于利用参考低维特征确定多个聚类中心;
特征获取单元403,用于获取目标对象的目标特征;
乘积量化搜索单元404,用于利用目标特征和多个聚类中心进行乘积量化搜索,得到与目标对象距离最近的参考对象。
在本申请的一些实施方式中,上述高维近邻关系为多个样本对象中每两个样本对象分别关联的样本高维特征之间的高维欧氏距离,上述低维近邻关 系为多个样本对象中每两个样本对象分别关联的样本低维特征之间的低维欧氏距离;上述特征压缩网络的损失函数为基于高维欧氏距离和与高维欧氏距离对应的低维欧氏距离之间的误差值,以及与高维欧氏距离关联的权重值得到的函数,其中,权重值的取值和与其关联的高维欧氏距离的大小相关。
在本申请的一些实施方式中,上述损失函数的损失值的计算过程,包括:计算所述高维欧氏距离和与所述高维欧氏距离对应的低维欧氏距离之间的误差值;计算与所述高维欧氏距离关联的权重值,并利用每个所述权重值对每个所述误差值进行加权相加,得到累加值;将所述累加值和所述样本对象的总数量的平方值相除,得到所述损失函数的损失值。
在本申请的一些实施方式中,上述权重值的计算过程,包括:获取第一超参数和第二超参数,所述第一超参数大于所述第二超参数;计算各个所述高维欧氏距离的平均值;利用所述第一超参数、所述第二超参数和所述平均值确定互不相交的多个区间范围;根据所述高维欧氏距离在所述多个区间范围中所处的目标区间范围,确定与所述高维欧氏距离关联的权重值。
在本申请的一些实施方式中,上述特征压缩网络包括残差模块和多个主干模块;上述特征压缩单元401还可以具体用于:将参考高维特征输入残差模块,得到残差模块输出的第一特征;将参考高维特征输入多个主干模块中的第一个主干模块,得到第一个主干模块输出的第二特征,并将第二特征输入多个主干模块中的第二个主干模块,直至得到多个主干模块中最后一个主干模块输出的第三特征,其中,第一特征和第三特征的维度相同;将第一特征与第三特征相加,得到参考低维特征。
在本申请的一些实施方式中,上述聚类单元402还可以具体用于:对多个参考低维特征进行聚类,得到多个聚类中心。
在本申请的一些实施方式中,上述乘积量化搜索单元404还可以具体用于:利用目标特征和与每个参考低维特征关联的聚类中心,确定目标特征与每个参考低维特征之间的距离;将距离最小的参考低维特征对应的参考对象作为与目标对象距离最近的参考对象。
需要说明的是,为描述的方便和简洁,上述乘积量化搜索装置400的具体工作过程,可以参考图1至图3所述方法的对应过程,在此不再赘述。
如图5所示,为本申请实施例提供的一种终端的示意图。该终端5可以 包括:处理器50、存储器51以及存储在所述存储器51中并可在所述处理器50上运行的计算机程序52,例如乘积量化搜索程序。所述处理器50执行所述计算机程序52时实现上述各个乘积量化搜索方法实施例中的步骤,例如图1所示的步骤S101至S104。或者,所述处理器50执行所述计算机程序52时实现上述各装置实施例中各模块/单元的功能,例如图4所示的特征压缩单元401、聚类单元402、特征获取单元403和乘积量化搜索单元404。
所述计算机程序可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器51中,并由所述处理器50执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序在所述终端中的执行过程。
例如,所述计算机程序可以被分割成:特征压缩单元、聚类单元、特征获取单元和乘积量化搜索单元。
各单元具体功能如下:特征压缩单元,用于将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;聚类单元,用于利用所述参考低维特征确定多个聚类中心;特征获取单元,用于获取目标对象的目标特征;乘积量化搜索单元,用于利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。
所述终端可包括,但不仅限于,处理器50、存储器51。本领域技术人员可以理解,图5仅仅是终端的示例,并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端还可以包括输入输出设备、网络接入设备、总线等。
所称处理器50可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器51可以是所述终端的内部存储单元,例如终端的硬盘或内 存。所述存储器51也可以是所述终端的外部存储设备,例如所述终端上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器51还可以既包括所述终端的内部存储单元也包括外部存储设备。所述存储器51用于存储所述计算机程序以及所述终端所需的其他程序和数据。所述存储器51还可以用于暂时地存储已经输出或者将要输出的数据。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对各个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的实施例中,应该理解到,所揭露的装置/终端和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (10)

  1. 一种乘积量化搜索方法,其中,包括:
    将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;
    利用所述参考低维特征确定多个聚类中心;
    获取目标对象的目标特征;
    利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。
  2. 如权利要求1所述的乘积量化搜索方法,其中,所述高维近邻关系为多个所述样本对象中每两个样本对象分别关联的样本高维特征之间的高维欧氏距离,所述低维近邻关系为多个所述样本对象中每两个样本对象分别关联的样本低维特征之间的低维欧氏距离;
    所述特征压缩网络的损失函数为基于所述高维欧氏距离和与所述高维欧氏距离对应的低维欧氏距离之间的误差值,以及与所述高维欧氏距离关联的权重值得到的函数,其中,所述权重值的取值和与其关联的高维欧氏距离的大小相关。
  3. 如权利要求2所述的乘积量化搜索方法,其中,所述损失函数的损失值的计算过程,包括:
    计算所述高维欧氏距离和与所述高维欧氏距离对应的低维欧氏距离之间的误差值;
    计算与所述高维欧氏距离关联的权重值,并利用每个所述权重值对每个所述误差值进行加权相加,得到累加值;
    将所述累加值和所述样本对象的总数量的平方值相除,得到所述损失函数的损失值。
  4. 如权利要求2或3所述的乘积量化搜索方法,其中,所述权重值的计算过程,包括:
    获取第一超参数和第二超参数,所述第一超参数大于所述第二超参数;
    计算各个所述高维欧氏距离的平均值;
    利用所述第一超参数、所述第二超参数和所述平均值确定互不相交的多 个区间范围;
    根据所述高维欧氏距离在所述多个区间范围中所处的目标区间范围,确定与所述高维欧氏距离关联的权重值。
  5. 如权利要求1至3任意一项所述的乘积量化搜索方法,其中,所述特征压缩网络包括残差模块和多个主干模块;
    所述将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,包括:
    将所述参考高维特征输入所述残差模块,得到所述残差模块输出的第一特征;
    将所述参考高维特征输入所述多个主干模块中的第一个主干模块,得到所述第一个主干模块输出的第二特征,并将所述第二特征输入所述多个主干模块中的第二个主干模块,直至得到多个主干模块中最后一个主干模块输出的第三特征,其中,所述第一特征和所述第三特征的维度相同;
    将所述第一特征与所述第三特征相加,得到所述参考低维特征。
  6. 如权利要求1至3任意一项所述的乘积量化搜索方法,其中,所述利用所述参考低维特征确定多个聚类中心,包括:
    对多个所述参考低维特征进行聚类,得到多个聚类中心。
  7. 如权利要求1至3任意一项所述的乘积量化搜索方法,其中,所述利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象,包括:
    利用所述目标特征和与每个所述参考低维特征关联的聚类中心,确定所述目标特征与每个所述参考低维特征之间的距离;
    将所述距离最小的参考低维特征对应的参考对象作为与所述目标对象距离最近的参考对象。
  8. 一种乘积量化搜索装置,其中,包括:
    特征压缩单元,用于将参考对象的参考高维特征输入特征压缩网络中,得到由所述特征压缩网络输出的参考低维特征,所述特征压缩网络的损失函数为基于样本对象的高维近邻关系和所述样本对象的低维近邻关系得到的函数;
    聚类单元,用于利用所述参考低维特征确定多个聚类中心;
    特征获取单元,用于获取目标对象的目标特征;
    乘积量化搜索单元,用于利用所述目标特征和所述多个聚类中心进行乘积量化搜索,得到与所述目标对象距离最近的参考对象。
  9. 一种终端,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求1至7任一项所述方法的步骤。
  10. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述方法的步骤。
PCT/CN2022/099855 2021-10-21 2022-06-20 一种乘积量化搜索方法、装置、终端和存储介质 WO2023065697A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111229216.1 2021-10-21
CN202111229216.1A CN113918598A (zh) 2021-10-21 2021-10-21 一种乘积量化搜索方法、装置、终端和存储介质

Publications (1)

Publication Number Publication Date
WO2023065697A1 true WO2023065697A1 (zh) 2023-04-27

Family

ID=79242273

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/099855 WO2023065697A1 (zh) 2021-10-21 2022-06-20 一种乘积量化搜索方法、装置、终端和存储介质

Country Status (2)

Country Link
CN (1) CN113918598A (zh)
WO (1) WO2023065697A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116881485A (zh) * 2023-06-19 2023-10-13 北京百度网讯科技有限公司 生成图像检索索引的方法及装置、电子设备和介质
CN117037913A (zh) * 2023-10-07 2023-11-10 之江实验室 一种蛋白质多序列比对方法、装置、存储介质及电子设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113918598A (zh) * 2021-10-21 2022-01-11 深圳云天励飞技术股份有限公司 一种乘积量化搜索方法、装置、终端和存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002183206A (ja) * 2000-12-15 2002-06-28 Mitsubishi Electric Corp 類似オブジェクト検索方法及び類似オブジェクト検索装置
CN101334786A (zh) * 2008-08-01 2008-12-31 浙江大学 一种基于规则邻域的数据降维方法
CN109740660A (zh) * 2018-12-27 2019-05-10 深圳云天励飞技术有限公司 图像处理方法及装置
CN111177438A (zh) * 2018-11-12 2020-05-19 深圳云天励飞技术有限公司 图像特征值的搜索方法、装置、电子设备及存储介质
CN112560635A (zh) * 2020-12-10 2021-03-26 深圳云天励飞技术股份有限公司 人脸匹配加速方法、装置、电子设备及存储介质
CN113918598A (zh) * 2021-10-21 2022-01-11 深圳云天励飞技术股份有限公司 一种乘积量化搜索方法、装置、终端和存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002183206A (ja) * 2000-12-15 2002-06-28 Mitsubishi Electric Corp 類似オブジェクト検索方法及び類似オブジェクト検索装置
CN101334786A (zh) * 2008-08-01 2008-12-31 浙江大学 一种基于规则邻域的数据降维方法
CN111177438A (zh) * 2018-11-12 2020-05-19 深圳云天励飞技术有限公司 图像特征值的搜索方法、装置、电子设备及存储介质
CN109740660A (zh) * 2018-12-27 2019-05-10 深圳云天励飞技术有限公司 图像处理方法及装置
CN112560635A (zh) * 2020-12-10 2021-03-26 深圳云天励飞技术股份有限公司 人脸匹配加速方法、装置、电子设备及存储介质
CN113918598A (zh) * 2021-10-21 2022-01-11 深圳云天励飞技术股份有限公司 一种乘积量化搜索方法、装置、终端和存储介质

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116881485A (zh) * 2023-06-19 2023-10-13 北京百度网讯科技有限公司 生成图像检索索引的方法及装置、电子设备和介质
CN117037913A (zh) * 2023-10-07 2023-11-10 之江实验室 一种蛋白质多序列比对方法、装置、存储介质及电子设备
CN117037913B (zh) * 2023-10-07 2024-01-26 之江实验室 一种蛋白质多序列比对方法、装置、存储介质及电子设备

Also Published As

Publication number Publication date
CN113918598A (zh) 2022-01-11

Similar Documents

Publication Publication Date Title
WO2023065697A1 (zh) 一种乘积量化搜索方法、装置、终端和存储介质
WO2020224219A1 (zh) 中文分词方法、装置、电子设备及可读存储介质
Jégou et al. Aggregating local image descriptors into compact codes
US20170316287A1 (en) Image hash codes generated by a neural network
JP5926291B2 (ja) 類似画像を識別する方法および装置
JP6721681B2 (ja) 並列検索動作を実行する方法及び装置
WO2022077646A1 (zh) 一种用于图像处理的学生模型的训练方法及装置
US20160267351A1 (en) Compact and robust signature for large scale visual search, retrieval and classification
KR102363811B1 (ko) 이미지 검색 방법, 장치, 기기 및 판독 가능 저장 매체
US11734341B2 (en) Information processing method, related device, and computer storage medium
WO2023108995A1 (zh) 向量相似度计算方法、装置、设备及存储介质
CN110825894A (zh) 数据索引建立、数据检索方法、装置、设备和存储介质
Wei et al. Projected residual vector quantization for ANN search
WO2019230666A1 (ja) 特徴量抽出装置、方法、及びプログラム
JP6104209B2 (ja) ハッシュ関数生成方法、ハッシュ値生成方法、装置、及びプログラム
WO2022007596A1 (zh) 图像检索系统、方法和装置
WO2023065696A1 (zh) 一种最近邻搜索方法、装置、终端和存储介质
JP6368677B2 (ja) 写像学習方法、情報圧縮方法、装置、及びプログラム
CN111241106A (zh) 近似数据处理方法、装置、介质及电子设备
WO2023030184A1 (zh) 一种数据检索方法及相关设备
CN111767421A (zh) 用于检索图像方法、装置、电子设备和计算机可读介质
JP6152032B2 (ja) ハッシュ関数生成方法、ハッシュ値生成方法、ハッシュ関数生成装置、ハッシュ値生成装置、ハッシュ関数生成プログラム及びハッシュ値生成プログラム
JP2014102772A (ja) 特徴ベクトルの集合で表されるコンテンツ間の類似度を算出するプログラム、装置及び方法
JP6134246B2 (ja) ハッシュ関数生成方法、ハッシュ値生成方法、ハッシュ関数生成装置、ハッシュ値生成装置、ハッシュ関数生成プログラム及びハッシュ値生成プログラム
CN111090743B (zh) 一种基于词嵌入和多值形式概念分析的论文推荐方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22882320

Country of ref document: EP

Kind code of ref document: A1