Data search method and device, storage medium and computer program product
By directly performing vector recall processing in the storage and computing integrated module, the problems of large data transmission volume and high delay in vector recall technology in big data scenarios are solved, which improves computing efficiency and reduces energy consumption.
Patent Information
- Application Number
- CN202410876901.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-11-01
AI Technical Summary
In big data scenarios, the existing vector recall technology has low computing efficiency and increased energy consumption due to the large data transmission volume and high transmission delay.
The processor determines the dimensional expansion bit number, expands the vector data of the bottom library, and transmits it to the integrated storage module, and directly performs vector recall processing in the integrated storage module to avoid transferring the calculation results to the CPU for further processing.
It reduces the amount of data transmission, reduces the transmission delay, improves the computing efficiency, and reduces energy consumption.
Smart Images

Figure CN118885642A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data search method and device, a storage medium, and a computer program product. Background Art
[0002] Vector recall technology is to retrieve the vector data that is closest to the vector data to be queried in a given vector data set according to a certain measurement method. Vector recall technology is widely used in recommendation systems, image retrieval, natural language processing, face matching and reasoning and other fields. The current vector recall technology uses a combination of CPU and storage and computing to transmit the results of storage and computing to the CPU, which is further processed by the CPU to obtain the final vector recall result. However, with the rapid development of big data, more and more systems have tens of millions or hundreds of millions of base vector data. In this scenario, tens of millions or hundreds of millions of calculation results need to be transmitted to the CPU, resulting in large data transmission volume and high transmission latency, which in turn leads to low computing efficiency and increased energy consumption. Summary of the invention
[0003] The embodiments of the present application provide a data search method and device, a storage medium, and a computer program product, which can improve computing efficiency and reduce energy consumption.
[0004] The technical solution of this application is implemented as follows:
[0005] In a first aspect, an embodiment of the present application provides a data search device, the device comprising: a processor and a storage and computing module;
[0006] The processor is used to determine the number of dimension expansion bits based on the input base database vector data; perform dimension expansion processing on the base database vector data based on the number of dimension expansion bits to obtain the base database vector data after dimension expansion; and transmit the base database vector data after dimension expansion to the storage and computing integrated module;
[0007] The storage and computing integrated module is used to use the expanded base database vector data to perform vector recall processing on the input vector data to be queried, and obtain search result data.
[0008] In a second aspect, an embodiment of the present application provides a data search method, the method comprising:
[0009] The processor determines the number of dimensional expansion bits based on the input base library vector data;
[0010] The processor performs dimension expansion processing on the base database vector data based on the number of dimension expansion bits to obtain the base database vector data after dimension expansion;
[0011] The storage-computing integrated module uses the expanded base database vector data to perform vector recall processing on the input vector data to be queried to obtain search result data.
[0012] In a third aspect, an embodiment of the present application proposes a storage medium on which a computer program is stored, and the computer program implements the above-mentioned data search method when executed.
[0013] In a fourth aspect, an embodiment of the present application proposes a computer program product, including a computer program, which implements the above-mentioned data search method when executed.
[0014] The embodiment of the present application provides a data search method and device, a storage medium, and a computer program product, wherein the device includes: a processor and a storage-computing integrated module; the processor is used to determine the number of dimensional expansion bits based on the input base library vector data; the base library vector data is expanded based on the number of dimensional expansion bits to obtain the base library vector data after dimensional expansion; and the base library vector data after dimensional expansion is transmitted to the storage-computing integrated module; the storage-computing integrated module is used to use the base library vector data after dimensional expansion to perform vector recall processing on the input vector data to be queried to obtain search result data. Using the above implementation scheme, the constants stored in the CPU are decomposed based on the base library vector data to obtain the base library vector data after dimensional expansion, and then transmitted to the storage-computing integrated module, and the overall process of vector recall is directly implemented in the storage-computing integrated module, avoiding the process of transmitting the result of the storage-computing integrated calculation to the CPU for further processing, reducing the amount of data transmission, and reducing the transmission delay, thereby improving the computing efficiency and reducing energy consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A schematic diagram of a storage-computing integrated technology based on memristors;
[0016] Figure 2 A schematic diagram of a deployment solution for vector recall technology based on storage-computing integration;
[0017] Figure 3 A schematic diagram of the structure of a data search device provided in an embodiment of the present application;
[0018] Figure 4 A schematic diagram of an exemplary storage-computing integrated module provided in an embodiment of the present application;
[0019] Figure 5 A schematic diagram of the system architecture of an exemplary data search device provided in an embodiment of the present application;
[0020] Figure 6 A schematic diagram of module implementation steps of an exemplary data search device provided in an embodiment of the present application;
[0021] Figure 7 A flowchart of a data search method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0024] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. It should also be noted that the terms "first\second\third" involved in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second\third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0025] The storage-computing integrated technology is a technology that uses a memory cross array to implement matrix-vector multiplication. By inputting source data into the storage array threshold weight parameters, in-situ calculations are performed in the storage unit to obtain the required calculation results.
[0026] See also Figure 1 It is a storage and computing technology based on memristors. It mainly uses the non-volatile resistance of the device to encode the data matrix into the resistance value of the device. By using Ohm's law, voltage is applied on one side of the device and current is read on the other side, thus completing the multiplication operation between voltage and conductance. The device can be prepared in a cross-shaped manner to achieve multi-dimensional multiplication operations. Figure 1 , each column is a device of the memristor, the input voltage is [v1, v2, v3], and the conductance is Matrix, deploy each row of the matrix conductance value on each column of the memristor device, apply each output voltage to each column of the device, and output the current value of each row of the device, where each output current value I i =∑ j G ij V j Therefore, a memristor can be equivalent to the superposition of an adder, a multiplier and a memory.
[0027] Based on the above calculation principle, in the matrix multiplication and addition operation, it is only necessary to add voltage once, and then obtain the output current signal of each column of the mobile phone to obtain the matrix-vector multiplication operation in sequence.
[0028] The vector recall process is to retrieve the K vectors that are closest or approximately closest to the query vector y in a given vector data set X according to a certain metric. At present, the vector recall process based on the storage-computation integration technology is as follows: In order to adapt to the matrix multiplication and addition operation of the storage-computation integration, the Euclidean distance operation is converted into a vector-matrix operation. The specific conversion is as shown in formula (1), that is, the minimum value of the Euclidean distance is converted into the maximum value of the matrix operation.
[0029]
[0030] in, It is a matrix-vector multiplication operation, which can be efficiently implemented based on storage and computing integration. 2 It is calculated offline in advance and recorded as B, which is stored in the CPU. When , all vector multiplication and addition results are transmitted to the CPU, and then added to B stored in the CPU to obtain the K vectors that are closest or approximately closest to the query vector y.
[0031] For the deployment scheme of vector recall technology based on storage-computing integration, see Figure 2 , the storage-computing integrated chip includes the matrix X. After receiving the input y, it performs Calculate and output the calculation result to the CPU, and add it to B in the CPU.
[0032] However, the current method of implementing vector recall based on integrated storage and computing mainly adopts a combination of CPU and integrated storage and computing. The results of the integrated storage and computing calculation need to be transmitted to the CPU for further processing by the CPU to give the final recall result. The data transmission overhead is large, and the speed of data transmission also affects the calculation speed, resulting in reduced computing efficiency and increased energy consumption.
[0033] The present application embodiment provides a data search device 1, such as Figure 3 As shown, the data search device 1 may include: a processor 10 and a storage and computing integrated module 11;
[0034] The processor 10 is used to determine the number of dimension expansion bits based on the input base database vector data; perform dimension expansion processing on the base database vector data based on the number of dimension expansion bits to obtain the base database vector data after dimension expansion; and transmit the base database vector data after dimension expansion to the storage and computing integrated module 11;
[0035] The storage and computing integrated module 11 is used to use the expanded base database vector data to perform vector recall processing on the input vector data to be queried, and obtain search result data.
[0036] The data search method used by the data search device proposed in the embodiment of the present application is applied to scenarios such as image retrieval, recommendation system, natural language processing, face matching, large-scale + external knowledge base reasoning, etc.
[0037] In the embodiment of the present application, the processor may be a CPU.
[0038] In the embodiment of the present application, the storage-computing-in-one module is located in the storage-computing-in-one chip.
[0039] In the embodiment of the present application, the CPU and the integrated storage and computing chip are connected via a communication module. The communication module can be a device such as a bus to achieve communication connection. The specific one can be selected according to actual conditions, and the embodiment of the present application does not make any specific limitation.
[0040] In an embodiment of the present application, the implementation process of determining the number of expanded dimension bits based on the input base library vector data, the processor is also used to perform the following steps: determine the vector data to be decomposed based on the base library vector data; translate the vector data to be decomposed a preset distance to obtain the translated vector data to be decomposed; determine the number of expanded dimension bits based on the translated vector data to be decomposed.
[0041] In the embodiment of the present application, the calculation process of the bias of the vector data to be decomposed is shown in formula (2).
[0042] bias=-0.5|x| 2 (2)
[0043] Among them, x is the base library vector data.
[0044] It should be noted that after the processor determines the vector data to be decomposed based on the base vector data, it is necessary to decompose the vector data to be decomposed so that it can adapt to the storage and computing integrated chip. Specifically, the vector data to be decomposed is translated by a preset distance to obtain the translated vector data to be decomposed; the number of dimensional expansion bits is determined based on the translated vector data to be decomposed; the base vector data is expanded based on the number of dimensional expansion bits to obtain the expanded base vector data.
[0045] It should be noted that bias is a one-dimensional vector. When the dimension of the base vector data is relatively large, the value of bias will be a relatively large negative number. Since each unit of the storage-computing integrated chip can only support a limited range of data, it can only support the precision of int2-int8, that is, when the precision is int4, each unit can represent a maximum integer between -7 and 7. Therefore, if the decomposition is directly performed based on the value in bias, it will take up more storage-computing integrated units, wasting computing resources. Therefore, the bias is translated as a whole by a preset distance, which does not affect the distance comparison between the base vector data and the vector data to be queried. Moreover, the data of bias1 after translation is much smaller than that of bias, and it is both positive and negative, which greatly reduces the usage of storage-computing integrated units and avoids wasting computing resources.
[0046] In the embodiment of the present application, the preset distance is the mean value of the vectors to be decomposed.
[0047] The specific process of translating the vector data to be decomposed by a preset distance to obtain the translated vector data to be decomposed can be referred to formula (3).
[0048] bias1=bias-mean(bias) (3)
[0049] Among them, bias1 is the vector data to be decomposed after translation, bias is the vector data to be decomposed, and mean(bias) is the mean of bias.
[0050] In an embodiment of the present application, the implementation process of determining the number of dimension expansion bits according to the vector data to be decomposed after translation, the processor is also used to perform the following steps: determining the maximum value of the vector data to be decomposed after translation; determining the number of dimension expansion bits based on the maximum value and a preset data precision value.
[0051] First, the maximum value max1 of the vector data to be decomposed after translation is determined using formula (4).
[0052] max1=max|bias1| (4)
[0053] Then, the minimum m is obtained using formula (5) as the number of expanded bits.
[0054] (2 b-1 -1)*m>=max1 (5)
[0055] Wherein, b is the preset data precision value.
[0056] In the embodiment of the present application, the preset data precision value is the data precision value supported by the storage and computing integrated chip, which can be 2 bits, 3 bits, 4 bits, etc. The specific value can be selected according to the actual situation, and the embodiment of the present application does not make specific limitations.
[0057] For example, if b=3 bits and max1=32, then according to formula (5), m=32, that is, both the vector data to be queried and the vector data to be decomposed after translation need to be expanded to 32 dimensions.
[0058] In an embodiment of the present application, the bottom library vector data is expanded based on the number of expansion bits to obtain the bottom library vector data after expansion, and the processor is also used to execute the following process: determine a first value based on the translated vector data to be decomposed, the number of expansion bits and the preset data precision value; if the first value is less than or equal to the first threshold, determine the first vector data of the number of expansion bits using the translated vector data to be decomposed and the number of expansion bits, and add the first vector data to the bottom library vector data to obtain the bottom library vector data after expansion; if the first value is greater than the first threshold, determine the second vector data of the number of expansion bits using the translated vector data to be decomposed, the preset data precision value and the number of expansion bits, and add the second vector data to the bottom library vector data to obtain the bottom library vector data after expansion.
[0059] It should be noted that it is necessary to ensure that the product of the m-bit vector data of the expanded dimension of the vector data to be queried and the m-bit vector data of the expanded dimension of the base database vector data is equal to bias1[i].
[0060] In the embodiment of the present application, the first value W is first calculated according to formula (6). The purpose of calculating the first value is to calculate whether the last digit of the extension exceeds the range of the storage-calculation-integrated precision.
[0061] W=(L%(m-1))-(2 b-1 -1) (6)
[0062] Among them, L=bias[i] corresponding to the i-th base library vector data.
[0063] In the embodiment of the present application, the first threshold is 0.
[0064] In an optional embodiment, if W≤0, it indicates that the last digit does not exceed the range of the integrated storage and computing precision. At this time, the first vector data is obtained by decomposing according to formula (7).
[0065] [L / / (m-1)]*(m-1)[L%(m-1) / / 1](7)
[0066] In another optional embodiment, if W>0, it represents the range of the last bit of super storage and computing precision. At this time, it is decomposed according to formula (8) to obtain the second vector data.
[0067] [L / / (m-1)+1]*W+[L / / (m-1)]*(m-1-W)+[2 b-1 -1](8)
[0068] For example, the original vector dimension of the video is n=128, the dimension to be expanded is m=32, the recall storage and computing integrated chip precision is b=3, and it is assumed that bias1[i]=85 corresponding to a certain video, and W=20 is calculated according to formula (6). W is greater than 0, so formula (8) is selected, and the following is calculated: [3]*20+[2]*11+[3]=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3]. The extension bit of the vector data to be queried is [1]*32, so the extension part of the vector data to be queried is multiplied by the extension part of the base vector data, and the result is 85, which is consistent with bias1[i].
[0069] For example, bias1[i] corresponding to a certain video = -92. According to formula (3), W = -2, which is less than 0. Therefore, formula (7) is selected to obtain: [-3]*31+[1] = [-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,1]. The extension bit of the vector data to be queried is [1]*32. Therefore, the extension part of the vector data to be queried is multiplied by the extension part of the base vector data, and the result is -92, which is consistent with bias1[i].
[0070] It should be noted that the calculation can be performed in real time according to the size of bias1[i] each time, or the vector data corresponding to all the values that can be represented by the m-dimensional vector can be calculated in advance according to formula (6)-formula (8), and then, when a bias1[i] comes, the corresponding vector data is found by table lookup, and then the vector data is expanded to the corresponding base library vector data. Finally, the base library vector data becomes n+m dimensional. The specific selection can be made according to the actual situation, and the embodiment of the present application does not make specific limitations.
[0071] In an embodiment of the present application, after receiving the expanded base database vector data, the storage and computing integrated module is also used to deploy the expanded base database vector data.
[0072] In an embodiment of the present application, the storage and computing integrated module encodes the expanded base library vector data into resistance values and then deploys them.
[0073] In the embodiment of the present application, the data search device further includes: a vector processing module to be queried;
[0074] The processor is further used to transmit the number of expanded dimension bits to the vector processing module to be queried;
[0075] A vector processing module to be queried is used to perform dimension expansion processing on the vector data to be queried based on the number of dimension expansion bits to obtain the vector data to be queried after dimension expansion; and input the vector data to be queried after dimension expansion into the storage and computing integrated module;
[0076] The storage and computing integrated module is also used to perform vector recall processing on the expanded vector data to be queried and the expanded base vector data to obtain search result data.
[0077] It should be noted that the vector processing module to be queried may be located in a storage-computing integrated chip, or may be an independent module in a data search device. The specific module may be selected according to actual conditions, and the embodiments of the present application do not make any specific limitation.
[0078] It should be noted that the communication module also connects the to-be-queried vector processing module to the processor, so that the processor can transmit the dimension expansion bit number to the to-be-queried vector processing module.
[0079] In an embodiment of the present application, the dimension expansion processing is performed on the vector data to be queried based on the number of dimension expansion bits to obtain the expanded vector data to be queried. The vector processing module to be queried also implements the following steps: a third vector data with the number of dimension expansion bits is added after the vector data to be queried to obtain the expanded vector data; each bit of the third vector data takes a preset value.
[0080] In an optional embodiment, each bit of the third vector data has a value of 1; that is, the preset value is 1.
[0081] For example, the vector y=[y1, y2, ..., yn] is expanded to y=[y1, y2, ..., yn, 1, 1, 1, 1, 1], with a total of n+m dimensions, where n is the dimension of the original vector data to be queried, and n+m is the dimension of the vector data to be queried after the expansion.
[0082] In the embodiment of the present application, the query vector processing module encodes the expanded query vector data into voltage and inputs it into the storage and calculation module, performs calculations with the expanded base vector data, and outputs search result data. The entire calculation process is completed in the storage and calculation module, and there is no need to perform additional data transmission when calculating the expanded base vector data, thereby improving the calculation efficiency.
[0083] Based on the above embodiment, for example, the schematic diagram of the storage and computing module is shown in Figure 4 , the expanded base vector data X' consisting of the original base vector data X and the expanded m-bit vector data is deployed by column, and matrix multiplication and addition operations are performed on the input expanded vector data to be queried consisting of the original vector data to be queried [y1, y2, ...yn] and the expanded m-bit vector data [1,1, ...1].
[0084] It can be understood that the constants stored in the CPU are decomposed based on the base library vector data to obtain the expanded base library vector data, which is then transmitted to the storage and computing integrated module. The overall process of vector recall is directly implemented in the storage and computing integrated module, avoiding the process of transmitting the results of the storage and computing integrated calculation to the CPU for further processing, reducing the amount of data transmission, and reducing the transmission delay, thereby improving computing efficiency and reducing energy consumption.
[0085] Based on the above embodiment, the system architecture of the data search device can be seen in Figure 5 According to the function processor, it can be divided into: base vector input module, base vector processing module, wherein the base vector processing module includes: information acquisition module to be decomposed, information translation module to be decomposed, dimension expansion bit acquisition module and base vector dimension expansion module, the storage integrated chip includes vector processing module to be queried, storage and computing integrated module and vector recall result output module, wherein the storage and computing integrated module includes: storage and computing integrated computing module and dimension expansion base vector deployment module. The communication module is respectively connected to the base vector dimension expansion module and the dimension expansion base vector deployment module, the dimension expansion bit acquisition module and the base vector processing module to be queried.
[0086] based on Figure 5 , the steps for implementing each module of the data search device can be found in Figure 6 , including:
[0087] S1. In the base vector processing module, the bias of the vector data to be decomposed is obtained based on the input base vector data X, that is, bias = -0.5|X| 2 .
[0088] S2. In the base vector processing module, bias is translated to obtain the translated vector data bias1 to be decomposed.
[0089] S3. In the base vector processing module, the number of dimension expansion bits m is obtained based on bias1.
[0090] S4. In the base database vector processing module, the base database vector data is expanded based on the number of expansion bits m.
[0091] S5. The communication module transmits the number of dimension expansion bits m to the to-be-queried vector processing module, and the to-be-queried vector processing module expands the dimension of the to-be-queried vector data based on the number of dimension expansion bits m.
[0092] S6. The communication module transmits the expanded base database vector data to the expanded base database vector deployment module, and the expanded base database vector deployment module deploys the expanded base database vector data to the storage and computing integrated array.
[0093] S7. The storage-computing integrated computing module performs vector recall calculation based on the input of the vector processing module to be queried and the underlying database vector data deployed in the storage-computing integrated manner.
[0094] S8. The vector recall structure output module outputs the calculation result of the storage and computing integrated calculation module.
[0095] Based on the above embodiment, a data search process in a video recommendation scenario is proposed. Specifically, firstly, the user and the video are represented as vector data using deep learning technology, and then the vector recall technology is used to recommend videos to the user. That is, the vector data y to be queried represents the user vector, and the base vector data is the video vector of the video platform, that is, each video corresponds to a vector data x i , all video vectors constitute the base vector set X, and vector recall is to calculate the similarity between the user vector y and each video vector in the base vector set X. Specifically, firstly, based on the input video base vector set X, the bias of the vector data to be decomposed is determined, and then the bias is translated by mean(bias) to obtain bias1, and then the number of expanded digits m is determined according to the maximum value max|bias1| of bias1 and the precision b supported by the storage and computing integration, and each video vector is expanded according to m, and the user vector is expanded according to m, and the expanded video vector is deployed in the storage and computing integration chip, and the expanded video vector is used to calculate the input expanded user vector, output the video result, and recommend the video result to the user.
[0096] Based on the above embodiments, the present application also proposes a data search method, such as Figure 7 As shown, the method may include:
[0097] S101. The processor determines the number of dimension expansion bits based on the input base library vector data.
[0098] The data search method proposed in the embodiment of the present application is applied to scenarios such as image retrieval, recommendation system, natural language processing, face matching, large-scale + external knowledge base reasoning, etc.
[0099] In the embodiment of the present application, the processor may be a CPU.
[0100] In the embodiment of the present application, the storage-computing-in-one module is located in the storage-computing-in-one chip.
[0101] In the embodiment of the present application, the CPU and the integrated storage and computing chip are connected via a communication module. The communication module can be a device such as a bus to achieve communication connection. The specific one can be selected according to actual conditions, and the embodiment of the present application does not make any specific limitation.
[0102] In an embodiment of the present application, the processor determines the vector data to be decomposed based on the base database vector data; translates the vector data to be decomposed by a preset distance to obtain the translated vector data to be decomposed; and determines the number of expanded dimension bits based on the translated vector data to be decomposed.
[0103] In the embodiment of the present application, the calculation process of the bias of the vector data to be decomposed is shown in formula (2).
[0104] bias=-0.5|x| 2 (2)
[0105] Among them, x is the base library vector data.
[0106] It should be noted that after the processor determines the vector data to be decomposed based on the base vector data, it is necessary to decompose the vector data to be decomposed so that it can adapt to the storage and computing integrated chip. Specifically, the vector data to be decomposed is translated by a preset distance to obtain the translated vector data to be decomposed; the number of dimensional expansion bits is determined based on the translated vector data to be decomposed; the base vector data is expanded based on the number of dimensional expansion bits to obtain the expanded base vector data.
[0107] It should be noted that bias is a one-dimensional vector. When the dimension of the base vector data is relatively large, the value of bias will be a relatively large negative number. Since each unit of the storage-computing integrated chip can only support a limited range of data, it can only support the precision of int2-int8, that is, when the precision is int4, each unit can represent a maximum integer between -7 and 7. Therefore, if the decomposition is directly performed based on the value in bias, it will take up more storage-computing integrated units, wasting computing resources. Therefore, the bias is translated as a whole by a preset distance, which does not affect the distance comparison between the base vector data and the vector data to be queried. Moreover, the data of bias1 after translation is much smaller than that of bias, and it is both positive and negative, which greatly reduces the usage of storage-computing integrated units and avoids wasting computing resources.
[0108] It should be noted that the preset distance is the mean value of the vector to be decomposed.
[0109] The specific process of translating the vector data to be decomposed by a preset distance to obtain the translated vector data to be decomposed can be referred to formula (3).
[0110] bias1=bias-mean(bias) (3)
[0111] Among them, bias1 is the vector data to be decomposed after translation, bias is the vector data to be decomposed, and mean(bias) is the mean of bias.
[0112] It should be noted that the process by which the processor determines the number of dimension expansion bits based on the translated vector data to be decomposed specifically includes: determining the maximum value of the translated vector data to be decomposed; and determining the number of dimension expansion bits based on the maximum value and a preset data precision value.
[0113] First, the maximum value max1 of the vector data to be decomposed after translation is determined using formula (4).
[0114] max1=max|bias1| (4)
[0115] Then, the minimum m is obtained using formula (5) as the number of expanded bits.
[0116] (2 b-1 -1)*m>=max1 (5)
[0117] Wherein, b is the preset data precision value.
[0118] In the embodiment of the present application, the preset data precision value is the data precision value supported by the storage and computing integrated chip, which can be 2 bits, 3 bits, 4 bits, etc. The specific value can be selected according to the actual situation, and the embodiment of the present application does not make specific limitations.
[0119] For example, if b=3 bits and max1=32, then according to formula (5), m=32, that is, both the vector data to be queried and the vector data to be decomposed after translation need to be expanded to 32 dimensions.
[0120] S102. The processor performs dimension expansion processing on the base library vector data based on the number of dimension expansion bits to obtain the base library vector data after dimension expansion.
[0121] In an embodiment of the present application, the processor determines a first value based on the translated vector data to be decomposed, the number of expanded dimensional bits and a preset data precision value; if the first value is less than or equal to a first threshold value, the translated vector data to be decomposed and the number of expanded dimensional bits are used to determine first vector data of the number of expanded dimensional bits, and the first vector data is added to the base library vector data to obtain the expanded base library vector data; if the first value is greater than the first threshold value, the translated vector data to be decomposed, the preset data precision value and the number of expanded dimensional bits are used to determine second vector data of the number of expanded dimensional bits, and the second vector data is added to the base library vector data to obtain the expanded base library vector data.
[0122] It should be noted that it is necessary to ensure that the product of the m-bit vector data of the expanded dimension of the vector data to be queried and the m-bit vector data of the expanded dimension of the base database vector data is equal to bias1[i].
[0123] In the embodiment of the present application, the first value W is first calculated according to formula (6). The purpose of calculating the first value is to calculate whether the last digit of the extension exceeds the range of the storage-calculation-integrated precision.
[0124] W=(L%(m-1))-(2 b-1 -1) (6)
[0125] Among them, L=bias[i] corresponding to the i-th base library vector data.
[0126] In the embodiment of the present application, the first threshold is 0.
[0127] In an optional embodiment, if W≤0, it indicates that the last digit does not exceed the range of the integrated storage and computing precision. At this time, the first vector data is obtained by decomposing according to formula (7).
[0128] [L / / (m-1)]*(m-1)[L%(m-1) / / 1](7)
[0129] In another optional embodiment, if W>0, it represents the range of the last bit of super storage and computing precision. At this time, it is decomposed according to formula (8) to obtain the second vector data.
[0130] [L / / (m-1)+1]*W+[L / / (m-1)]*(m-1-W)+[2 b-1 -1](8)
[0131] For example, the original vector dimension of the video is n=128, the dimension to be expanded is m=32, the recall storage and computing integrated chip precision is b=3, and it is assumed that bias1[i]=85 corresponding to a certain video, and W=20 is calculated according to formula (6). W is greater than 0, so formula (8) is selected, and the following is calculated: [3]*20+[2]*11+[3]=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3]. The extension bit of the vector data to be queried is [1]*32, so the extension part of the vector data to be queried is multiplied by the extension part of the base vector data, and the result is 85, which is consistent with bias1[i].
[0132] For example, bias1[i] corresponding to a certain video = -92. According to formula (3), W = -2, which is less than 0. Therefore, formula (7) is selected to obtain: [-3]*31+[1] = [-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,1]. The extension bit of the vector data to be queried is [1]*32. Therefore, the extension part of the vector data to be queried is multiplied by the extension part of the base vector data, and the result is -92, which is consistent with bias1[i].
[0133] It should be noted that the calculation can be performed in real time according to the size of bias1[i] each time, or the vector data corresponding to all the values that can be represented by the m-dimensional vector can be calculated in advance according to formula (6)-formula (8), and then, when a bias1[i] comes, the corresponding vector data is found by table lookup, and then the vector data is expanded to the corresponding base library vector data. Finally, the base library vector data becomes n+m dimensional. The specific selection can be made according to the actual situation, and the embodiment of the present application does not make specific limitations.
[0134] In an embodiment of the present application, after receiving the expanded base database vector data, the storage and computing integrated module is also used to deploy the expanded base database vector data.
[0135] In an embodiment of the present application, the storage and computing integrated module encodes the expanded base library vector data into resistance values and then deploys them.
[0136] S103, the storage and computing integrated module uses the expanded base database vector data to perform vector recall processing on the input vector data to be queried to obtain search result data.
[0137] It should be noted that after the processor obtains the expanded base database vector data, it will also transmit the number of expanded dimensional bits to the vector processing module to be queried; the vector processing module to be queried performs dimensional expansion processing on the vector data to be queried based on the number of expanded dimensional bits to obtain the expanded vector data to be queried; and inputs the expanded vector data to be queried into the storage and computing integrated module; thereafter, the storage and computing integrated module performs vector recall processing on the expanded vector data to be queried and the expanded base database vector data to obtain search result data.
[0138] It should be noted that the vector processing module to be queried may be located in a storage-computing integrated chip, or may be an independent module in a data search device. The specific module may be selected according to actual conditions, and the embodiments of the present application do not make any specific limitation.
[0139] It should be noted that the communication module also connects the to-be-queried vector processing module to the processor, so that the processor can transmit the dimension expansion bit number to the to-be-queried vector processing module.
[0140] In an embodiment of the present application, the process in which the vector processing module to be queried performs dimension expansion processing on the vector data to be queried based on the number of dimension expansion bits to obtain the vector data to be queried after dimension expansion specifically includes: the vector processing module to be queried adds third vector data with the number of dimension expansion bits after the vector data to be queried to obtain the vector data to be queried after dimension expansion; each bit of the third vector data takes a preset value.
[0141] In an optional embodiment, each bit of the third vector data has a value of 1; that is, the preset value is 1.
[0142] For example, the vector y=[y1, y2, ..., yn] is expanded to y=[y1, y2, ..., yn, 1, 1, 1, 1, 1], with a total of n+m dimensions, where n is the dimension of the original vector data to be queried, and n+m is the dimension of the vector data to be queried after the expansion.
[0143] In the embodiment of the present application, the query vector processing module encodes the expanded query vector data into voltage and inputs it into the storage and calculation module, performs calculations with the expanded base vector data, and outputs search result data. The entire calculation process is completed in the storage and calculation module, and there is no need to perform additional data transmission when calculating the expanded base vector data, thereby improving the calculation efficiency.
[0144] It can be understood that the constants stored in the CPU are decomposed based on the base library vector data to obtain the expanded base library vector data, which is then transmitted to the storage and computing integrated module. The overall process of vector recall is directly implemented in the storage and computing integrated module, avoiding the process of transmitting the results of the storage and computing integrated calculation to the CPU for further processing, reducing the amount of data transmission, and reducing the transmission delay, thereby improving computing efficiency and reducing energy consumption.
[0145] An embodiment of the present application provides a storage medium having a computer program stored thereon. The computer-readable storage medium stores one or more programs. The one or more programs can be executed by one or more processors and applied to a data search device. The computer program implements the data search method as described above.
[0146] Based on the above embodiments, an embodiment of the present application provides a computer program product, including a computer program, which can be executed by one or more processors, and the computer program implements the data search method as described above.
[0147] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / random access memory (RAM), a disk, or an optical disk), and includes a number of instructions for enabling an image display device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0149] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A data search device, characterized in that: The device comprises: a processor and a storage-computing integrated module; The processor is used to determine the number of dimension expansion bits based on the input base database vector data; perform dimension expansion processing on the base database vector data based on the number of dimension expansion bits to obtain the base database vector data after dimension expansion; and transmit the base database vector data after dimension expansion to the storage and computing integrated module; The storage and computing integrated module is used to use the expanded base database vector data to perform vector recall processing on the input vector data to be queried, and obtain search result data.
2. The device according to claim 1, characterized in that The data search device further includes: a vector processing module to be queried; The processor is further configured to transmit the number of dimension expansion bits to the vector processing module to be queried; The to-be-queried vector processing module is used to perform dimension expansion processing on the to-be-queried vector data based on the dimension expansion bit number to obtain the dimension-expanded to-be-queried vector data; and input the dimension-expanded to-be-queried vector data into the storage-computation integrated module; The storage-computing integrated module is also used to perform vector recall processing on the expanded vector data to be queried and the expanded base vector data to obtain the search result data.
3. The device according to claim 1, characterized in that The processor is further used to determine the vector data to be decomposed based on the base database vector data; translate the vector data to be decomposed by a preset distance to obtain the translated vector data to be decomposed; and determine the number of expanded dimension bits based on the translated vector data to be decomposed.
4. The device according to claim 3, characterized in that The preset distance is the mean value of the vectors to be decomposed.
5. The device according to claim 3, characterized in that The processor is further used to determine the maximum value of the vector data to be decomposed after the translation; and determine the number of expanded dimensional bits based on the maximum value and a preset data precision value.
6. The device according to claim 3, characterized in that The processor is also used to determine a first value based on the translated vector data to be decomposed, the number of expanded dimensional bits and the preset data precision value; if the first value is less than or equal to a first threshold, the translated vector data to be decomposed and the number of expanded dimensional bits are used to determine the first vector data of the number of expanded dimensional bits, and the first vector data is added to the base library vector data to obtain the expanded base library vector data; if the first value is greater than the first threshold, the translated vector data to be decomposed, the preset data precision value and the number of expanded dimensional bits are used to determine the second vector data of the number of expanded dimensional bits, and the second vector data is added to the base library vector data to obtain the expanded base library vector data.
7. The device according to claim 2, characterized in that The to-be-queried vector processing module is further used for adding third vector data with the number of dimensional expansion bits after the to-be-queried vector data to obtain the to-be-queried vector data after dimensional expansion; each bit value of the third vector data is a preset value.
8. The device according to claim 1, characterized in that The storage and computing integrated module is also used to deploy the expanded base database vector data.
9. A data search method, characterized in that: The method comprises: The processor determines the number of dimensional expansion bits based on the input base library vector data; The processor performs dimension expansion processing on the base database vector data based on the dimension expansion bit number to obtain the base database vector data after dimension expansion; The storage-computing integrated module uses the expanded base database vector data to perform vector recall processing on the input vector data to be queried to obtain search result data.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the method according to claim 9 is implemented.
11. A computer program product, comprising a computer program, characterized in that The computer program implements the method of claim 9 when being executed.
