Resource data retrieval method, device, electronic device and storage medium
By performing orthogonal matrix feature processing and scaling factor quantization on the initial vectors of resource data, the problems of high memory usage and slow search speed under large-scale user data are solved, and higher retrieval accuracy and storage efficiency are achieved.
Patent Information
- Application Number
- CN202211238792.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-10-11
AI Technical Summary
Existing resource data retrieval methods have problems of high memory usage and slow search speed under large-scale user data, and the accuracy of the ANNS+ quantization method is not high.
By using a preset orthogonal matrix to perform feature processing on the initial vector and using a scaling factor to perform quantization, it is ensured that the quantized vector has a higher degree of uniform distribution, reduces information loss, and improves the accuracy of similarity calculation.
It effectively reduces information loss during the quantification process, improves the accuracy and efficiency of resource data retrieval, and reduces storage space occupation.
Smart Images

Figure CN115794809B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a method, device, electronic device, and storage medium for retrieving resource data. Background Art
[0002] With the development of internet technology, resource data retrieval technology has emerged, with applications such as short videos, images, and articles. Approximately Nearest Neighbor Search (ANNS) is a widely used retrieval method. Given a feature vector to be recommended or retrieved, it searches an existing database for several feature vectors that are most similar to it, which serve as the search result. However, when the amount of user data is large, this method can lead to high memory usage and slow search speeds.
[0003] Related art uses the ANNS+ quantization method, specifically using a scaling factor to convert the floating-point format of feature vectors into integer format, thereby reducing memory usage and improving retrieval speed. However, because the representation range of floating-point formats is often larger than that of integer formats, if the scaling factor is too large during the quantization process, a large number of feature vectors will be lost; if the scaling factor is too small, smaller elements in the feature vector will experience significant information loss. Therefore, the ANNS+ quantization method in related art has low accuracy. Summary of the Invention
[0004] The present disclosure provides a method, device, electronic device, and storage medium for retrieving resource data to at least address the problem of low retrieval accuracy in related technologies. The technical solutions of the present disclosure are as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a method for retrieving resource data is provided, comprising:
[0006] Obtaining an initial first vector of resource data and a plurality of quantized second vectors; wherein the quantized second vectors are obtained by feature processing the initial second vector in the data set using a preset orthogonal matrix and quantizing the feature-processed second vectors using a scaling factor, and the feature-processed second vectors have a higher uniformity distribution than the initial second vectors;
[0007] Performing feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and performing quantization processing on the feature-processed first vector to obtain a first vector;
[0008] The similarities between the first vector and the plurality of quantized second vectors are respectively calculated, a preset number of quantized second vectors having the highest similarities are determined, and resource data corresponding to the preset number of quantized second vectors are used as search results.
[0009] In a possible implementation, the orthogonal matrix is obtained by:
[0010] Obtaining an initial orthogonal matrix and a plurality of the initial second vectors;
[0011] Performing feature processing on the plurality of initial second vectors respectively using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors;
[0012] Constructing a mapping function, the mapping function including, when an element of the second vector after the feature processing exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of an average of the absolute values of the elements in the second vector after the feature processing;
[0013] An initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing is used as the orthogonal matrix.
[0014] In a possible implementation, the scaling factor is obtained by:
[0015] After multiplying the feature-processed second vector by an initial scaling factor, the obtained product is rounded to obtain a quantized first intermediate second vector;
[0016] Dividing the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector;
[0017] By using a preset optimization algorithm, an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector is used as the scaling factor.
[0018] In a possible implementation, the quantizing the second vector after feature processing by using the scaling factor includes:
[0019] Multiplying the feature-processed second vector by the scaling factor to obtain a second intermediate second vector;
[0020] When the floating-point value of an element in the second intermediate second vector exceeds a representation range of a pre-quantized integer format, determining the quantization value of the element to be a preset value;
[0021] When the floating-point values of the elements in the second intermediate second vector do not exceed the representation range, the second intermediate second vector is rounded.
[0022] In a possible implementation, the first boundary value and the second boundary value in the mapping function are the same; and the quantizing the second vector after feature processing by using the scaling factor includes:
[0023] multiplying the feature-processed second vector by a scaling factor to obtain a third intermediate second vector;
[0024] When the floating-point value of an element in the third intermediate second vector exceeds a second boundary value of a representation range of a pre-quantized integer format, determining the quantization value of the element to be the second boundary value;
[0025] When the floating-point values of the elements in the third intermediate second vector do not exceed the representation range, the third intermediate second vector is rounded.
[0026] In a possible implementation, the method further includes:
[0027] The data set is updated using the quantized second vector to obtain an updated data set.
[0028] According to a second aspect of an embodiment of the present disclosure, there is provided a device for retrieving resource data, comprising:
[0029] a first acquisition module, configured to acquire an initial first vector and a plurality of quantized second vectors of resource data; wherein the quantized second vectors are obtained by performing feature processing on the initial second vector in the data set using a preset orthogonal matrix and quantizing the feature-processed second vectors using a scaling factor, and wherein the degree of uniform distribution of the feature-processed second vectors is higher than that of the initial second vectors;
[0030] A first processing module is configured to perform feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and perform quantization processing on the feature-processed first vector to obtain a first vector;
[0031] The retrieval module is used to respectively calculate the similarity between the first vector and the plurality of quantized second vectors, determine a preset number of quantized second vectors with the highest similarity, and use the resource data corresponding to the preset number of quantized second vectors as the retrieval result.
[0032] In a possible implementation, the apparatus further includes:
[0033] A second acquisition module, configured to acquire an initial orthogonal matrix and a plurality of the initial second vectors;
[0034] A second processing module is configured to perform feature processing on each of the plurality of initial second vectors using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors;
[0035] a construction module, configured to construct a mapping function, the mapping function including, when an element of the second vector after feature processing exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of an average of the absolute values of the elements in the second vector after feature processing;
[0036] The first determining module is configured to use an initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing as the orthogonal matrix.
[0037] In a possible implementation, the apparatus further includes:
[0038] a third processing module, configured to multiply the feature-processed second vector by an initial scaling factor and round the resulting product to obtain a quantized first intermediate second vector;
[0039] a dequantization module, configured to divide the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector;
[0040] The second determining module is configured to use a preset optimization algorithm to take an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector as the scaling factor.
[0041] In a possible implementation, the apparatus further includes:
[0042] a third processing module, configured to multiply the feature-processed second vector by a scaling factor to obtain a second intermediate second vector;
[0043] a first quantization module, configured to determine, when a floating-point value of an element in the second intermediate second vector exceeds a representation range of a pre-quantized integer format, a quantization value of the element to be a preset value;
[0044] The second quantization module is configured to perform rounding processing on the second intermediate second vector when the floating-point values of the elements in the second intermediate second vector do not exceed the representation range.
[0045] In a possible implementation, the apparatus further includes:
[0046] a third processing module, configured to multiply the feature-processed second vector by a scaling factor to obtain a third intermediate second vector;
[0047] a third quantization module, configured to determine, when a floating-point value of an element in the third intermediate second vector exceeds a second boundary value of a representation range of a pre-quantized integer format, a quantization value of the element as the second boundary value, wherein the second boundary value is the same as the first boundary value in the mapping function;
[0048] The second quantization module is configured to perform rounding processing on the third intermediate second vector when the floating-point values of the elements in the third intermediate second vector do not exceed the representation range.
[0049] In a possible implementation, the apparatus further includes:
[0050] An updating module is configured to update the data set using the quantized second vector to obtain an updated data set.
[0051] According to a third aspect of an embodiment of the present disclosure, a server is provided, including:
[0052] processor;
[0053] a memory for storing instructions executable by the processor;
[0054] The processor is configured to execute the instructions to implement the resource data retrieval method as described in any one of the embodiments of the present disclosure.
[0055] According to a third aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the resource data retrieval method as described in any one of the embodiments of the present disclosure.
[0056] According to a fourth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes instructions. When the instructions are executed by a processor of a server, the server can execute the resource data retrieval method as described in any one of the embodiments of the present disclosure.
[0057] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:
[0058] In the embodiment of the present disclosure, an orthogonal matrix is used to perform feature processing on the initial second vector in the data set, so that the second vector after feature processing is closer to a uniform distribution than the initial second vector. The initial second vector corresponding to the resource data usually conforms to a normal distribution, that is, a large number of elements are concentrated near 0, and a small number of elements are located far away from 0. At this time, if the initial second vector is directly quantized, the data in the floating-point format is mapped to the representation range of the integer format with a smaller representation range, and a scaling factor needs to be multiplied. If the scaling factor is selected to be small, it will result in a large loss of information of elements near 0; if the scaling factor is selected to be large, it will result in an increase in the number of elements exceeding the representation range, thereby also causing a large loss of information. In the embodiment of the present disclosure, the distribution characteristics of the initial second vector are changed by an orthogonal matrix, so that it is close to a uniform distribution, so that the element values will not be concentrated near the value of 0 in large numbers, and quantization will not cause a large loss of information near 0, nor will it cause too many elements to exceed the representation range of the integer format, thereby reducing the information loss caused by quantization. In the disclosed embodiment, feature processing is also performed on the initial first vector to obtain the first vector, ensuring that the distance between the initial first vector and the initial second vector is the same as the distance between the first vector and the quantized second vector. Thus, the similarity between the first vector and the quantized second vector can represent the similarity between the initial first vector and the initial second vector. Because the quantized second vector has no information loss, the disclosed embodiment achieves a high retrieval accuracy.
[0059] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0061] Figure 1 The figure is a flowchart of a method for retrieving resource data according to an exemplary embodiment.
[0062] Figure 2 The figure is a flowchart of a method for retrieving resource data according to an exemplary embodiment.
[0063] Figure 3 The figure is a block diagram of a device for searching resource data according to an exemplary embodiment.
[0064] Figure 4 It is a block diagram of an electronic device according to an exemplary embodiment.
[0065] Figure 5 The figure is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0066] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0067] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0068] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0069] Related resource data retrieval techniques utilize the property that multiplying two vectors by the same orthogonal matrix does not change their distance. The following solution is proposed: The original search vector is multiplied by the orthogonal matrix to obtain a processed search vector. The same operation is performed on each vector in the search dataset, multiplying them by the same orthogonal matrix to obtain multiple processed vectors. The similarity between the processed search vector and the multiple processed vectors is calculated, and the vector with the highest similarity is determined as the search result. The orthogonal matrix is obtained by multiplying the original search vector by the orthogonal matrix to obtain the processed search vector. The original search vector is multiplied by a scaling factor and rounded to an integer to obtain a quantized search vector. The difference between the processed search vector and the quantized search vector is determined, and the orthogonal matrix corresponding to the minimum difference is used as the orthogonal matrix. This method is effective for low-bit vectors, but for high-bit vectors, such as those with more than 8 bits, the difference between the two vectors is minimal, making it less effective in reducing information loss caused by quantization.
[0070] Another related resource data retrieval technology uses ANNS combined with dimensional quantization. For each element of the search vector, a scaling factor is assigned to each element, mitigating the accuracy loss caused by uneven data distribution. However, during storage, the quantized vector data is stored. During retrieval, due to the non-uniform scaling factors, the elements must be converted back to floating-point format for calculation based on their corresponding scaling factors. Therefore, ANNS combined with dimensional quantization only saves storage space but does not improve search speed.
[0071] Based on actual technical requirements similar to those described above, embodiments of the present disclosure propose a method, device, electronic device, and storage medium for retrieving resource data.
[0072] Figure 1 FIG1 is a flowchart showing a method for retrieving resource data according to an exemplary embodiment. Figure 1 As shown, the method is used in a server and includes the following steps.
[0073] Step S101, obtaining an initial first vector of resource data and a plurality of quantized second vectors; wherein the quantized second vectors are obtained by feature processing the initial second vector in the data set using a preset orthogonal matrix, and quantizing the feature-processed second vector using a scaling factor, and the uniform distribution degree of the feature-processed second vector is higher than the uniform distribution degree of the initial second vector.
[0074] In an embodiment of the present disclosure, the resource data may include video resources, voice resources, picture resources, text resources, etc. The resource data may include resource data to be searched. The initial first vector may include a vector that can characterize the characteristics of the resource data. The initial first vector of the resource data may be extracted using an artificial neural network, or the initial first vector of the resource data may be obtained using a dictionary mapping method. The embodiment of the present disclosure does not limit the method of obtaining the initial first vector. In an embodiment of the present disclosure, the quantized second vector may be obtained from an updated data set. The updated data set may include multiple quantized second vectors. The quantized second vector may be used to index the corresponding resource data. In one example, the updated data set may exist in a database, storing the quantized second vector for indexing the corresponding resource data. In one example, the data set may also exist in multiple databases, where the database may include a master database and a slave database, etc.
[0075] In the embodiment of the present disclosure, the initial second vector can be obtained from the data set before the update. The feature processing of the initial second vector in the data set using a preset orthogonal matrix includes rotating, translating or scaling the initial second vector in the data set using a preset orthogonal matrix to obtain the second vector after feature processing. The method of obtaining the preset orthogonal matrix in the embodiment of the present disclosure includes any method of determining it through objective function optimization in the prior art. As long as the feature matrix is used to perform feature processing on the initial second vector, so that the uniform distribution degree of the second vector after feature processing is higher than the uniform distribution degree of the initial second vector, it should be covered within the scope of protection of this application.
[0076] In the embodiment of the present disclosure, the second vector after feature processing is quantized using a scaling factor. For example, the original second vector after feature processing exists in a floating-point format, and the quantized second vector exists in an integer format. In one example, if the representation range of the floating-point format is larger than the representation range of the integer format, for example, the floating-point format is 32 bits and the integer format is 8 bits. It is necessary to multiply the vector data in the floating-point format by the scaling factor so that the product value is mapped to the representation range of the 8-bit integer format. In one example, if the value of the scaling factor is set to a relatively large value, after the floating-point value is multiplied by the scaling factor, the product exceeds the representation range of the integer format, and the quantization value corresponding to the floating-point value can be set to a preset value. In one example, the preset value may include a boundary value of the representation range.
[0077] Step S103 : performing feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and performing quantization processing on the feature-processed first vector to obtain a first vector.
[0078] In an embodiment of the present disclosure, the initial first vector is feature-processed using the same orthogonal matrix as the orthogonal matrix used to process the initial second vector. The feature processing may include, but is not limited to, rotation processing, translation processing, or scaling processing. This makes the distance between the initial first vector and the initial second vector the same as the distance between the initial second vector and the second vector after feature processing. Furthermore, the first vector after feature processing is quantized. In one example, if the representation range of the floating-point format of the first vector after feature processing is the same as the representation range of the pre-quantized integer format, the first vector after feature processing is rounded to obtain the first vector. In another example, if the representation range of the floating-point format of the first vector after feature processing is different from the representation range of the pre-quantized integer format, the first vector after feature processing is multiplied by a scaling factor to map it to within the representation range of the pre-quantized integer format to obtain the first vector. The scaling factor here may be the same as or different from the scaling factor used to process the second vector.
[0079] Step S105 , respectively calculating similarities between the first vector and the plurality of quantized second vectors, determining a preset number of quantized second vectors with the highest similarities, and taking resource data corresponding to the preset number of quantized second vectors as search results.
[0080] In the embodiment of the present disclosure, the calculation of the similarity between the first vector and the quantized second vector may include the following methods: similarity is obtained by calculating the Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, Mahalanobis distance, vector inner product or Pearson correlation coefficient of the two vectors, and the embodiment of the present disclosure does not limit this. The similarity between the first vector and the multiple quantized second vectors is calculated separately. For example, the first vector is A, and the multiple quantized second vectors are a, b, c, d, e..., and the similarity between A and a is calculated and recorded as x1; the similarity between A and b is calculated and recorded as x2; the similarity between A and c is calculated and recorded as x3; the similarity between A and d is calculated and recorded as x4; the similarity between A and d is calculated and recorded as x4; the similarity between A and e is calculated and recorded as x5, and so on. Determine the preset number of quantized second vectors with the highest similarity. In one example, the preset number of second vectors with the highest similarity can be determined by comparison method. In another example, the preset number of second vectors with the highest similarity can be determined by sorting method. In the embodiment of the present disclosure, the preset number can be determined according to the number of pre-retrieved resource data, such as 50 or 80. The resource data corresponding to the preset number of quantized second vectors are used as the retrieval result.
[0081] In an embodiment of the present disclosure, an orthogonal matrix is used to perform feature processing on the initial second vector in the data set, so that the uniform distribution degree of the second vector after feature processing is higher than the uniform distribution degree of the initial second vector. The initial second vector corresponding to the resource data usually conforms to the normal distribution, that is, a large number of elements are concentrated near 0, and a small number of elements are located far away from 0. At this time, if the initial second vector is directly quantized, the data in the floating point format is mapped to the representation range of the integer format with a smaller representation range, and a scaling factor needs to be multiplied. If the scaling factor is selected to be small, it will result in a large loss of information of elements near 0; if the scaling factor is selected to be large, it will result in an increase in the number of elements exceeding the representation range, thereby also causing a large loss of information. In an embodiment of the present disclosure, the distribution characteristics of the initial second vector are changed by an orthogonal matrix, so that it is close to a uniform distribution, so that the element values will not be concentrated near the value of 0 in large numbers, and quantization will not cause a large loss of information near 0, nor will it cause too many elements to exceed the representation range of the integer format, thereby reducing the information loss caused by quantization.
[0082] In the disclosed embodiment, feature processing is also performed on the initial first vector to obtain the first vector, ensuring that the distance between the initial first vector and the initial second vector is the same as the distance between the first vector and the quantized second vector. Thus, the similarity between the first vector and the quantized second vector can represent the similarity between the initial first vector and the initial second vector. Because the quantized second vector has no information loss, the disclosed embodiment achieves a high retrieval accuracy.
[0083] In a possible implementation, the orthogonal matrix is obtained by:
[0084] Obtaining an initial orthogonal matrix and a plurality of the initial second vectors;
[0085] Performing feature processing on the plurality of initial second vectors respectively using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors;
[0086] Constructing a mapping function, the mapping function including, when an element of the second vector after the feature processing exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of an average of the absolute values of the elements in the second vector after the feature processing;
[0087] An initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing is used as the orthogonal matrix.
[0088] In the embodiment of the present disclosure, the initial orthogonal matrix can be randomly generated. The initial orthogonal matrix is used to perform feature processing on multiple initial second vectors respectively to obtain multiple feature-processed second vectors. In the embodiment of the present disclosure, the first boundary value may include a minimum boundary value or a maximum boundary value of a preset range. When the element of the second vector after feature processing exceeds the first boundary value, the value of the element is set to the first boundary value, which may include: if the element of the second vector after feature processing exceeds the minimum boundary value of the preset range, the value of the element is set to the minimum boundary value; if the element of the second vector after feature processing exceeds the maximum boundary value of the preset range, the value of the element is set to the maximum boundary value. In one example, in the mapping function, when the element of the second vector after feature processing does not exceed the first boundary value, the value of the element does not change. In one example, the multiple may include a multiple of 2 or within a preset range above and below centered on 2. The initial orthogonal matrix can be expressed as , the initial second vector can be expressed as , the second vector after feature processing can be expressed as The mapping function can be expressed as:
[0089] (1)
[0090] in, for The elements in ,in, represents the mean, represents the absolute value. According to the definition of uniform distribution, assuming dimensional vector Satisfied The uniform distribution on , where .but ,Right now Therefore, if the second vector after feature processing The closer to the above mapping function, the better the second vector after feature processing The closer it is to a uniform distribution.
[0091] In the embodiment of the present disclosure, the initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing is used as the orthogonal matrix. The distance between the mapping function and the second vector after the feature processing can be represented by a norm, such as the 1-norm, the 2-norm, the Frobenius norm, the infinity norm, etc. The objective function can be expressed as:
[0092] (2)
[0093] The optimal orthogonal matrix in the above formula (2) can be determined by singular value decomposition .
[0094] In the disclosed embodiments, a mapping function with a uniform distribution property is constructed. The distances between multiple feature-processed second vectors and the mapping function are calculated to determine an initial orthogonal matrix with the minimum distance, which serves as the orthogonal matrix. This orthogonal matrix is then used to perform feature processing on the initial second vectors, making the feature-processed second vectors more uniformly distributed, thereby improving retrieval accuracy.
[0095] In a possible implementation, the scaling factor is obtained by:
[0096] After multiplying the feature-processed second vector by an initial scaling factor, the obtained product is rounded to obtain a quantized first intermediate second vector;
[0097] Dividing the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector;
[0098] By using a preset optimization algorithm, an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector is used as the scaling factor.
[0099] In an embodiment of the present disclosure, the initial scaling factor may include a randomly set scaling factor. Quantizing the second vector after feature processing may include multiplying the second vector after feature processing by the scaling factor and performing rounding processing to obtain a quantized first intermediate second vector. In one example, the scaling factor is denoted as s, and the initial second vector is denoted as X, then the first intermediate second vector can be expressed as [X×s], where [] represents rounding. The dequantized vector U can be expressed as U=[X×s] / s. In one example, the preset optimization algorithm may include a least squares method to calculate min|UX|. The initial scaling factor that satisfies the min|UX| condition is used as the scaling factor.
[0100] In the embodiment of the present disclosure, by constructing a distance model between the dequantized second vector and the feature-processed second vector, a preset optimization algorithm can be used to solve the optimal scaling factor. This scaling factor can reduce the information loss of the initial second vector caused by quantization, thereby further improving the accuracy of the search.
[0101] In a possible implementation, the quantizing the second vector after feature processing by using the scaling factor includes:
[0102] Multiplying the feature-processed second vector by the scaling factor to obtain a second intermediate second vector;
[0103] When the floating-point value of an element in the second intermediate second vector exceeds a representation range of a pre-quantized integer format, determining the quantization value of the element to be a preset value;
[0104] When the floating-point values of the elements in the second intermediate second vector do not exceed the representation range, the second intermediate second vector is rounded.
[0105] In the embodiment of the present disclosure, when the representation range of the floating-point format of the elements in the second vector after feature processing is greater than the representation range of the pre-quantized integer format, it is necessary to use a scaling factor to map the feature-processed second vector in floating-point format to within the representation range of the integer format. Specifically, when the floating-point value of the element in the second intermediate second vector exceeds the representation range of the pre-quantized integer format, the quantization value of the element is determined to be a preset value. When the floating-point value of the element in the second intermediate second vector does not exceed the representation range, the element is rounded to obtain the quantized second vector. Taking the conversion of the floating-point format to the 8-bit integer format as an example, refer to formula (3),
[0106] (3)
[0107] In formula (3) The floating point value representing the second vector element after feature processing. represents the scaling factor. If the floating point value exceeds the range [-128,127] of the 8-bit integer format, the element The quantization value of is set to a preset value, for example, , the default value is 127; , the default value is -128. The floating point value of the element is within the representation range, and the quantized value of the element is a floating point value. With scaling factor The product of Round up afterwards.
[0108] In the disclosed embodiments, a method for quantizing a feature-processed second vector is provided, which can map the floating-point values of the elements in the feature-processed second vector to within the representation range of an integer format. Because the feature-processed second vector has a higher degree of uniformity than the initial second vector, the quantization results in less information loss, which facilitates improved subsequent retrieval accuracy.
[0109] In a possible implementation, the first boundary value and the second boundary value in the mapping function are the same; and the quantizing the second vector after feature processing by using the scaling factor includes:
[0110] multiplying the feature-processed second vector by a scaling factor to obtain a third intermediate second vector;
[0111] When the floating-point value of an element in the third intermediate second vector exceeds a second boundary value of a representation range of a pre-quantized integer format, determining the quantization value of the element to be the second boundary value;
[0112] When the floating-point values of the elements in the third intermediate second vector do not exceed the representation range, the third intermediate second vector is rounded.
[0113] In the embodiment of the present disclosure, when the floating-point value of the element in the third intermediate second vector exceeds the second boundary value of the pre-quantized integer format representation range, the quantization value of the element is determined to be the second boundary value, wherein the second boundary value may include a minimum second boundary value and a maximum second boundary value. That is, if the floating-point value of the element in the third intermediate second vector exceeds the minimum second boundary value of the pre-quantized integer format representation range, the quantization value of the element is determined to be the minimum second boundary value; if the floating-point value of the element in the third intermediate second vector exceeds the maximum second boundary value of the pre-quantized integer format representation range, the quantization value of the element is determined to be the maximum second boundary value. In the embodiment of the present disclosure, when the floating-point value of the element in the third intermediate second vector does not exceed the representation range, the third intermediate second vector is rounded. The specific implementation method is the same as that of the above embodiment and will not be repeated here.
[0114] Unlike the above-described embodiment, the disclosed embodiment sets the first boundary value of the mapping function to be the same as the second boundary value, obtains an orthogonal matrix based on the above-described mapping function, and performs feature processing on the initial second vector using the orthogonal matrix to obtain a feature-processed second vector. The elements of the feature-processed second vector are uniformly distributed within the above-described first boundary value. Since the first boundary value is the same as the second boundary value of the pre-quantized integer format representation range, when the feature-processed second vector is quantized, very few elements will overflow the representation range of the integer format, thereby improving the quantization precision and further improving the accuracy of the retrieval.
[0115] In a possible implementation manner, the data set is updated using the quantized second vector to obtain an updated data set.
[0116] In the embodiment of the present disclosure, the initial second vector stored in the data set before the update is in floating-point format, which occupies a large amount of memory. In addition, the distribution of elements in the initial second vector usually conforms to the normal distribution, and the information loss after quantization is relatively large. Therefore, in the embodiment of the present disclosure, a preset orthogonal matrix is used to perform feature processing on the initial second vector in the data set, and a scaling factor is used to perform quantization processing on the second vector after feature processing, so that the second vector after feature processing is closer to a uniform distribution than the initial second vector. Furthermore, since the quantized second vector has a smaller amount of data than the initial second vector in floating-point format, the storage space of the second vector can be greatly saved by updating the data set with multiple quantized second vectors. Therefore, in the embodiment of the present disclosure, the quantized second vector is used to update the data set and serve as an index for the resource data of the updated data set, which can improve the accuracy of retrieval and reduce the memory space occupied.
[0117] Figure 2 FIG1 is a flowchart showing a method for retrieving resource data according to an exemplary embodiment. Figure 2 As shown, the method is used in a server and includes the following steps.
[0118] Step S201: Obtain an initial orthogonal matrix and a plurality of initial second vectors.
[0119] In the embodiment of the present disclosure, the initial orthogonal matrix can be randomly generated. The initial orthogonal matrix is used to perform feature processing on the plurality of initial second vectors to obtain a plurality of feature-processed second vectors.
[0120] Step S203 : performing feature processing on the plurality of initial second vectors respectively using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors.
[0121] Step S205, constructing a mapping function, which includes setting the value of the element to the first boundary value when the element of the second vector after the feature processing exceeds the first boundary value, wherein the first boundary value is set to a multiple of the average of the absolute values of the elements in the second vector after the feature processing.
[0122] In the embodiment of the present disclosure, in the above-mentioned mapping function, if the element of the second vector after the feature processing does not exceed the first boundary value, the value of the element does not change. In one example, the multiple can include a multiple of 2 or a preset range above and below 2 as the center. In the embodiment of the present disclosure, the closer the second vector after the feature processing is to the above-mentioned mapping function, the closer the second vector after the feature processing is to a uniform distribution.
[0123] Step S207 : using an initial orthogonal matrix that satisfies the minimum distance between the mapping function and the plurality of second vectors after feature processing as the orthogonal matrix.
[0124] In the embodiment of the present disclosure, an initial orthogonal matrix that satisfies the minimum distance between the mapping function and the plurality of second vectors after feature processing is used as the orthogonal matrix. The distance between the mapping function and the second vector after feature processing can be represented by a norm, such as a 1-norm, a 2-norm, a Frobenius norm, an infinity norm, etc.
[0125] Step S209 : multiplying the feature-processed second vector by the initial scaling factor, and rounding the obtained product to obtain a quantized first intermediate second vector.
[0126] Step S211 : Divide the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector.
[0127] In the embodiment of the present disclosure, the initial scaling factor may include a randomly set scaling factor. Quantizing the feature-processed second vector may include multiplying the feature-processed second vector by the scaling factor and then rounding it to obtain a quantized first intermediate second vector.
[0128] Step S213 , using a preset optimization algorithm, taking an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector as the scaling factor.
[0129] In the disclosed embodiment, the scaling factor is denoted as s, and the initial second vector is denoted as X. The first intermediate second vector can be expressed as [X × s], where [] indicates rounding. The dequantized vector U can be expressed as U = [X × s] / s. In one example, the preset optimization algorithm may include a least squares method to calculate min|UX|. The initial scaling factor that satisfies the min|UX| condition is used as the scaling factor.
[0130] Step S101, obtaining an initial first vector of resource data and a plurality of quantized second vectors; wherein the quantized second vectors are obtained by feature processing the initial second vector in the data set using a preset orthogonal matrix, and quantizing the feature-processed second vector using a scaling factor, and the uniform distribution degree of the feature-processed second vector is higher than the uniform distribution degree of the initial second vector.
[0131] In an embodiment of the present disclosure, the resource data may include video resources, voice resources, picture resources, text resources, etc. The resource data may include resource data to be searched. The initial first vector may include a vector that can characterize the characteristics of the resource data. The initial first vector of the resource data may be extracted using an artificial neural network, or the initial first vector of the resource data may be obtained using a dictionary mapping method. The embodiment of the present disclosure does not limit the method for obtaining the initial first vector. In an embodiment of the present disclosure, the quantized second vector may be obtained from an updated data set. The updated data set may include multiple quantized second vectors. The quantized second vector may be used to index the corresponding resource data.
[0132] In the embodiment of the present disclosure, the initial second vector can be obtained from a data set before the update. The feature processing of the initial second vector in the data set using a preset orthogonal matrix includes performing rotation processing, translation processing, or scaling processing on the initial second vector in the data set using the preset orthogonal matrix to obtain the feature-processed second vector.
[0133] Step S103 : performing feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and performing quantization processing on the feature-processed first vector to obtain a first vector.
[0134] In the disclosed embodiment, the initial first vector is feature-processed using the same orthogonal matrix as that used to process the initial second vector. Feature processing may include, but is not limited to, rotation, translation, or scaling. This ensures that the distance between the initial first vector and the initial second vector is the same as the distance between the initial second vector and the feature-processed second vector.
[0135] Step S105 , respectively calculating similarities between the first vector and the plurality of quantized second vectors, determining a preset number of quantized second vectors with the highest similarities, and taking resource data corresponding to the preset number of quantized second vectors as search results.
[0136] In an embodiment of the present disclosure, the calculation of the similarity between the first vector and the quantized second vector may include the following multiple methods: similarity is obtained by calculating the Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, Mahalanobis distance, vector inner product or Pearson correlation coefficient of the two vectors, and the present disclosure does not limit this. In one example, a comparison method can be used to determine a preset number of second vectors with the highest similarity. In another example, a sorting method can be used to determine a preset number of second vectors with the highest similarity. In an embodiment of the present disclosure, the preset number can be determined based on the number of pre-retrieved resource data.
[0137] The disclosed embodiments are based on the public DEEP-10M dataset and the public GLOVE-1.2M dataset, and are compared with the above-mentioned ANNS+dimension quantization method and the method without orthogonal matrix quantization, and the performance indicators shown in Table 1 below are obtained.
[0138]
[0139] Compared to the traditional ANNS+ dimensional quantization solution, this solution can achieve a computational speedup of over 1.5 times. This is due to the Intel AVX512 instruction set's excellent support for Int8 computations, meaning that computations between integer vectors are faster than those between floating-point vectors. Furthermore, it can save 75% of memory overhead, as integer vectors occupy significantly less space than raw floating-point numbers.
[0140] It should be understood that although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the figure may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0141] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can be referred to each other, and each embodiment focuses on the differences from other embodiments. For related parts, please refer to the description of other method embodiments.
[0142] Figure 3 FIG. 1 is a block diagram of a resource data retrieval device according to an exemplary embodiment. Figure 3 , the apparatus 300 comprises:
[0143] A first acquisition module 301 is configured to acquire an initial first vector and a plurality of quantized second vectors of resource data; wherein the quantized second vectors are obtained by performing feature processing on the initial second vectors in the data set using a preset orthogonal matrix and quantizing the feature-processed second vectors using a scaling factor, and wherein the uniform distribution of the feature-processed second vectors is higher than that of the initial second vectors;
[0144] A first processing module 303 is configured to perform feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and perform quantization processing on the feature-processed first vector to obtain a first vector;
[0145] The retrieval module 305 is configured to respectively calculate the similarity between the first vector and the plurality of quantized second vectors, and the preset number of quantized second vectors with the highest similarity, and use the resource data corresponding to the preset number of quantized second vectors as the retrieval result.
[0146] In a possible implementation, the apparatus further includes:
[0147] A second acquisition module, configured to acquire an initial orthogonal matrix and a plurality of the initial second vectors;
[0148] A second processing module is configured to perform feature processing on each of the plurality of initial second vectors using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors;
[0149] a construction module, configured to construct a mapping function, the mapping function including, when an element of the second vector after feature processing exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of an average of the absolute values of the elements in the second vector after feature processing;
[0150] The first determining module is configured to use an initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing as the orthogonal matrix.
[0151] In a possible implementation, the apparatus further includes:
[0152] a third processing module, configured to multiply the feature-processed second vector by an initial scaling factor and round the resulting product to obtain a quantized first intermediate second vector;
[0153] a dequantization module, configured to divide the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector;
[0154] The second determining module is configured to use a preset optimization algorithm to take an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector as the scaling factor.
[0155] In a possible implementation, the apparatus further includes:
[0156] a third processing module, configured to multiply the feature-processed second vector by a scaling factor to obtain a second intermediate second vector;
[0157] a first quantization module, configured to determine, when a floating-point value of an element in the second intermediate second vector exceeds a representation range of a pre-quantized integer format, a quantization value of the element to be a preset value;
[0158] The second quantization module is configured to perform rounding processing on the second intermediate second vector when the floating-point values of the elements in the second intermediate second vector do not exceed the representation range.
[0159] In a possible implementation, the apparatus further includes:
[0160] a third processing module, configured to multiply the feature-processed second vector by a scaling factor to obtain a third intermediate second vector;
[0161] a third quantization module, configured to determine, when a floating-point value of an element in the third intermediate second vector exceeds a second boundary value of a representation range of a pre-quantized integer format, a quantization value of the element as the second boundary value, wherein the second boundary value is the same as the first boundary value in the mapping function;
[0162] The second quantization module is configured to perform rounding processing on the third intermediate second vector when the floating-point values of the elements in the third intermediate second vector do not exceed the representation range.
[0163] In a possible implementation, the apparatus further includes:
[0164] An updating module is configured to update the data set using the quantized second vector to obtain an updated data set.
[0165] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0166] Figure 4 4 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 400 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0167] Reference Figure 4 The electronic device 400 may include one or more of the following components: a processing component 402 , a memory 404 , a power component 406 , a multimedia component 408 , an audio component 410 , an input / output (I / O) interface 412 , a sensor component 414 , and a communication component 416 .
[0168] The processing component 402 generally controls the overall operation of the electronic device 400, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 402 may include one or more modules to facilitate interaction between the processing component 402 and other components. For example, the processing component 402 may include a multimedia module to facilitate interaction between the multimedia component 408 and the processing component 402.
[0169] The memory 404 is configured to store various types of data to support operations on the electronic device 400. Examples of such data include instructions for any application or method operating on the electronic device 400, contact data, phone book data, messages, pictures, videos, etc. The memory 404 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, optical disk, or graphene memory.
[0170] The power supply assembly 406 provides power to the various components of the electronic device 400. The power supply assembly 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 400.
[0171] The multimedia component 408 includes a screen that provides an output interface between the electronic device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, it may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensors can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action. In some embodiments, the multimedia component 408 includes a front-facing camera and / or a rear-facing camera. When the electronic device 400 is in an operating mode, such as a capture mode or a video mode, the front-facing camera and / or the rear-facing camera can receive external multimedia data. Each front-facing camera and the rear-facing camera can have a fixed optical lens system or have focal length and optical zoom capabilities.
[0172] The audio component 410 is configured to output and / or input audio signals. For example, the audio component 410 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 400 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 404 or transmitted via the communication component 416. In some embodiments, the audio component 410 also includes a speaker for outputting audio signals.
[0173] I / O interface 412 provides an interface between processing component 402 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, volume buttons, a start button, and a lock button.
[0174] The sensor assembly 414 includes one or more sensors for providing various aspects of status assessment for the electronic device 400. For example, the sensor assembly 414 can detect the open / closed state of the electronic device 400, the relative positioning of components, such as the display and keypad of the electronic device 400. The sensor assembly 414 can also detect changes in the position of the electronic device 400 or components of the electronic device 400, the presence or absence of user contact with the electronic device 400, the orientation or acceleration / deceleration of the device 400, and temperature changes of the electronic device 400. The sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 414 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 414 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0175] The communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices. The electronic device 400 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 416 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0176] In an exemplary embodiment, the electronic device 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0177] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 404 including instructions, which can be executed by the processor 420 of the electronic device 400 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0178] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions, and the instructions can be executed by the processor 420 of the electronic device 400 to implement the above method.
[0179] Figure 5 FIG. 5 is a block diagram of a server according to an exemplary embodiment. For example, the server 500 may be a server. Figure 5 The server 500 includes a processing component 520, which further includes one or more processors, and a memory resource represented by a memory 522 for storing instructions, such as applications, that can be executed by the processing component 520. The application stored in the memory 522 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 520 is configured to execute the instructions to perform the above-described method.
[0180] The server 500 may also include a power supply component 524 configured to perform power management of the server 500, a wired or wireless network interface 526 configured to connect the server 500 to a network, and an input / output (I / O) interface 528. The server 500 may operate based on an operating system stored in the memory 522, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0181] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as memory 522 including instructions. The instructions can be executed by a processor of server 500 to perform the above method. The storage medium can be a computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
[0182] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions, and the instructions can be executed by a processor of the server 500 to implement the above method.
[0183] It should be noted that the above-mentioned devices, servers, computer-readable storage media, computer program products, etc. can also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments and will not be described one by one here.
[0184] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0185] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for retrieving resource data, characterized in that: include: Obtain an initial first vector of resource data and multiple quantized second vectors; wherein the quantized second vector is obtained by performing feature processing on the initial second vector in the data set using a preset orthogonal matrix, and quantizing the feature-processed second vector using a scaling factor, and the uniform distribution degree of the feature-processed second vector is higher than the uniform distribution degree of the initial second vector; wherein the orthogonal matrix is obtained by: obtaining an initial orthogonal matrix and multiple initial second vectors; performing feature processing on multiple initial second vectors respectively using the initial orthogonal matrix to obtain multiple feature-processed second vectors; constructing a mapping function, wherein the mapping function includes, when an element of the feature-processed second vector exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of the mean of the absolute values of the elements in the multiple feature-processed second vectors; and taking the initial orthogonal matrix that satisfies the minimum distance between the mapping function and the multiple feature-processed second vectors as the orthogonal matrix; Performing feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and performing quantization processing on the feature-processed first vector to obtain a first vector; The similarities between the first vector and the plurality of quantized second vectors are respectively calculated, a preset number of quantized second vectors having the highest similarities are determined, and resource data corresponding to the preset number of quantized second vectors are used as search results.
2. The method according to claim 1, characterized in that The scaling factor is obtained by: After multiplying the feature-processed second vector by an initial scaling factor, the obtained product is rounded to obtain a quantized first intermediate second vector; Dividing the first intermediate second vector by the initial scaling factor to obtain a dequantized second vector; By using a preset optimization algorithm, an initial scaling factor that satisfies the minimum distance between the second vector after the feature processing and the dequantized second vector is used as the scaling factor.
3. The method according to claim 1, characterized in that The quantizing process of the second vector after feature processing by using the scaling factor includes: Multiplying the feature-processed second vector by the scaling factor to obtain a second intermediate second vector; When the floating-point value of an element in the second intermediate second vector exceeds a representation range of a pre-quantized integer format, determining the quantization value of the element to be a preset value; When the floating-point values of the elements in the second intermediate second vector do not exceed the representation range, the second intermediate second vector is rounded.
4. The method according to claim 1, wherein The first boundary value and the second boundary value in the mapping function are the same; and the quantizing of the second vector after feature processing by using the scaling factor includes: multiplying the feature-processed second vector by a scaling factor to obtain a third intermediate second vector; When the floating-point value of an element in the third intermediate second vector exceeds a second boundary value of a representation range of a pre-quantized integer format, determining the quantization value of the element to be the second boundary value; When the floating-point values of the elements in the third intermediate second vector do not exceed the representation range, the third intermediate second vector is rounded.
5. The method according to claim 1, characterized in that Also includes: The data set is updated using the quantized second vector to obtain an updated data set.
6. A resource data retrieval device, characterized in that: include: a first acquisition module, configured to acquire an initial first vector and a plurality of quantized second vectors of resource data; wherein the quantized second vectors are obtained by performing feature processing on the initial second vector in the data set using a preset orthogonal matrix and quantizing the feature-processed second vectors using a scaling factor, and wherein the degree of uniform distribution of the feature-processed second vectors is higher than that of the initial second vectors; A first processing module is configured to perform feature processing on the initial first vector using the orthogonal matrix to obtain a feature-processed first vector, and perform quantization processing on the feature-processed first vector to obtain a first vector; a retrieval module, configured to respectively calculate similarities between the first vector and the plurality of quantized second vectors, determine a preset number of quantized second vectors having the highest similarities, and use resource data corresponding to the preset number of quantized second vectors as retrieval results; A second acquisition module, configured to acquire an initial orthogonal matrix and a plurality of the initial second vectors; A second processing module is configured to perform feature processing on each of the plurality of initial second vectors using the initial orthogonal matrix to obtain a plurality of feature-processed second vectors; a construction module, configured to construct a mapping function, the mapping function including, when an element of the second vector after feature processing exceeds a first boundary value, setting the value of the element to the first boundary value, wherein the first boundary value is set to a multiple of an average of the absolute values of the elements in the second vector after feature processing; The first determining module is configured to use an initial orthogonal matrix that satisfies the minimum distance between the mapping function and the second vectors after the feature processing as the orthogonal matrix.
7. A server, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the resource data retrieval method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the resource data retrieval method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Fast orthogonal projection
CN107636639A