Data retrieval processing method, data retrieval method, device and electronic equipment
By constructing an attribute feature graph structure and converting it into a low-precision vector, the problems of low recall ability and high cost of retrieval with attribute vectors are solved, and efficient data retrieval is achieved.
Patent Information
- Application Number
- CN202211239859.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-10-11
AI Technical Summary
The existing technology of vector retrieval with attributes has the problem of low recall capability and high cost. Especially when the number of attribute condition combinations increases, the recall capability decreases significantly and the cost increases significantly.
By generating a graph structure of target retrieval data with the same attribute features, connecting the graph structure according to the similarity between the attribute features, and converting the initial feature vector into the target feature vector, a high-precision graph structure is constructed to improve the neighborhood quality, and then converted into a low-precision vector after the graph is built to improve the retrieval efficiency.
It improves the neighborhood quality in the graph structure, reduces the recall loss caused by quantization, enhances the recall capability of attribute retrieval and improves retrieval efficiency.
Smart Images

Figure CN115827624B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data retrieval processing method, a data retrieval method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] With the advancement of data processing technology, the need to abstract unstructured data into vectors is increasing. Accurately searching large amounts of high-dimensional data is often very time-consuming. To address this, vector retrieval algorithms for approximate neighbor queries have been proposed. These algorithms can perform approximate neighbor queries on vectors in a relatively short time.
[0003] However, with the development of modern recommendation systems, vector retrieval requires the addition of attribute constraints, such as the data category or entity type. There are two main approaches to attribute-based vector retrieval: one is to perform similarity calculations based on the vectors and then filter based on the attributes; the other is to first filter based on the attributes and then search only within the domain of vectors that meet the conditions.
[0004] However, in the first approach, because data with similar vectors does not necessarily have the same attributes, and vector search itself does not consider attribute conditions, the resulting vectors are completely unrelated to the attributes. This significantly reduces recall as the number of attribute condition combinations increases. The second approach relies on pre-filtering and screening of attributes, making it impossible to use graph indexes. Furthermore, filtering costs increase significantly as the number of attributes increases. Therefore, current attribute-based vector searches suffer from low recall and high costs. Summary of the Invention
[0005] The present disclosure provides a data retrieval processing method, a data retrieval method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product to at least address the problems of low recall capability and high cost in related art for attributed vector retrieval. The technical solutions of the present disclosure are as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, a method for processing retrieved data is provided, comprising:
[0007] Acquire retrieval data, wherein the retrieval data includes a corresponding initial feature vector and attribute features;
[0008] For target retrieval data having the same attribute feature, generating a graph structure corresponding to the attribute feature, the graph structure comprising a plurality of nodes, each of the nodes comprising an initial feature vector of the target retrieval data and a corresponding attribute feature;
[0009] According to the similarity between each attribute feature, the graph structures corresponding to each attribute feature are connected to obtain the connected target graph structure;
[0010] The initial feature vector of each node in the target graph structure is converted into a target feature vector to obtain a target graph structure after vector conversion.
[0011] In one embodiment, at least one node among the multiple nodes of the graph structure has a first neighbor node, and the first neighbor node is a node in which the distance between the initial feature vector of the node in the graph structure and the initial feature vector of the at least one node meets a first preset condition; the graph structures corresponding to the respective attribute features are connected according to the similarity between the respective attribute features to obtain a connected target graph structure, including: for each node of the graph structure, determining a corresponding second neighbor node, the second neighbor node is a node in which the similarity between the corresponding attribute feature and the attribute feature of the node meets a second preset condition; establishing a connection relationship between each node and the corresponding second neighbor node to obtain a connected target graph structure.
[0012] In one embodiment, after establishing the connection relationship between each node and the corresponding second neighbor node, the method further includes: recording the node information of each node, the node information including the initial feature vector and corresponding attribute features of the node, and the first neighbor node and second neighbor node corresponding to the node.
[0013] In one embodiment, the initial feature vector is a floating point vector having a first byte number, and the target feature vector is an integer vector having a second byte number, wherein the first byte number is greater than the second byte number.
[0014] In one embodiment, after obtaining the search data, the method further includes: determining a preset number of target attribute features based on the attribute features corresponding to the search data, wherein the target attribute features are used to represent the search starting point.
[0015] In one embodiment, the retrieved data includes at least one of text data, image data, audio data or video data.
[0016] According to a second aspect of an embodiment of the present disclosure, there is provided a data retrieval method, comprising:
[0017] Obtaining a data retrieval request, wherein the data retrieval request includes data to be retrieved and attribute characteristics corresponding to the data to be retrieved;
[0018] In the target graph structure obtained by the vector conversion method for processing the retrieved data as described in the first aspect above, determining the target attribute feature that the attribute feature matches;
[0019] The target attribute feature is used as a search entry to retrieve search data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets a similarity condition, and the search data is used as a search result.
[0020] In one embodiment, the target graph structure includes a preset number of target attribute features; determining the target attribute feature that matches the attribute feature includes: obtaining the similarity between the attribute feature and each target attribute feature respectively; and determining the target attribute feature with the greatest similarity as the target attribute feature that matches the attribute feature.
[0021] In one embodiment, the data to be retrieved includes a feature vector having the same vector format as a target feature vector of the retrieved data.
[0022] According to a third aspect of an embodiment of the present disclosure, a data retrieval processing device is provided, including:
[0023] A retrieval data acquisition module is configured to acquire retrieval data, wherein the retrieval data includes a corresponding initial feature vector and attribute features;
[0024] A graph structure generating module is configured to execute a target search data with the same attribute feature, and generate a graph structure corresponding to the attribute feature, wherein the graph structure includes a plurality of nodes, each of which includes an initial feature vector of the target search data and a corresponding attribute feature;
[0025] A target graph structure generation module is configured to connect the graph structures corresponding to the attribute features according to the similarity between the attribute features to obtain a connected target graph structure;
[0026] The vector conversion module is configured to convert the initial feature vector of each node in the target graph structure into a target feature vector to obtain the target graph structure after vector conversion.
[0027] According to a fourth aspect of an embodiment of the present disclosure, there is provided a data retrieval device, comprising:
[0028] A retrieval request acquisition module is configured to execute and acquire a data retrieval request, wherein the data retrieval request includes the data to be retrieved and the attribute characteristics corresponding to the data to be retrieved;
[0029] An attribute feature matching module is configured to determine a target attribute feature of the attribute feature matching in a target graph structure after vector conversion obtained by the method for processing retrieved data as described in the first aspect above;
[0030] The retrieval module is configured to use the target attribute feature as a retrieval entry, retrieve retrieval data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets a similarity condition, and use the retrieval data as a retrieval result.
[0031] According to the fifth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the processing method for retrieving data as described in the first aspect above or to implement the data retrieval method as described in the second aspect above.
[0032] According to the sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the processing method for retrieving data as described in the first aspect above or execute the data retrieval method as described in the second aspect above.
[0033] According to the seventh 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 an electronic device, the electronic device is capable of executing the processing method for retrieving data as described in the first aspect above or executing the data retrieval method as described in the second aspect above.
[0034] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: by obtaining retrieval data, for target retrieval data with the same attribute features, a graph structure corresponding to the attribute features is generated, and according to the similarity between the attribute features, the graph structures corresponding to the attribute features are connected to obtain a connected target graph structure, and then the initial feature vector of each node in the target graph structure is converted into a target feature vector, thereby obtaining a target graph structure after vector conversion. Since this embodiment constructs a graph structure by using a high-precision initial feature vector, it is possible to improve the neighborhood quality in the graph structure, and the attribute features of the retrieval data are taken into account during the mapping process, it can be used for retrieval with attributes; by converting the high-precision initial feature vector of each node into a low-precision target feature vector after the mapping is completed, the efficiency of subsequent retrieval can also be improved.
[0035] 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
[0036] 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.
[0037] Figure 1 The figure is a flowchart showing a method for retrieving data according to an exemplary embodiment.
[0038] Figure 2 The figure is a flowchart showing steps of connecting a graph structure according to an exemplary embodiment.
[0039] Figure 3 The figure is a flowchart showing a method for retrieving data according to another exemplary embodiment.
[0040] Figure 4 The figure is a flow chart showing a data retrieval method according to an exemplary embodiment.
[0041] Figure 5 The figure is a flowchart showing steps of determining target attribute characteristics according to an exemplary embodiment.
[0042] Figure 6 The figure is a block diagram of a processing device for retrieving data according to an exemplary embodiment.
[0043] Figure 7 The figure is a block diagram showing a data retrieval device according to an exemplary embodiment.
[0044] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment.
[0045] Figure 9 is a block diagram of an electronic device according to another exemplary embodiment. DETAILED DESCRIPTION
[0046] 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.
[0047] 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.
[0048] 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.
[0049] In related technologies, there are two main approaches for general vector retrieval: one involves quantizing and compressing vectors, speeding up data operations at the expense of some precision. The other involves using graph indexes, which treat nearby vectors as neighbors and perform searches within the graph during queries, thereby accelerating retrieval. Commonly used quantization methods often balance speed and precision, trading some precision for improved query efficiency and reduced memory space.
[0050] For attributed vector retrieval, a related technique proposes a method that first performs a vector search and then filters the vector search results by label. This method can be easily extended to related vector retrieval schemes, whether graph indexing or quantization compression, simply by expanding the candidate results of the vector search. However, many vector search methods are very sensitive to the size of the candidate set, and increasing the candidate set size will significantly reduce search performance. In addition, vector search itself does not consider attribute conditions, resulting in the searched vector results being completely unrelated to the attributes. As the number of attribute condition combinations increases, the recall capability of this method will also be significantly reduced.
[0051] Related technology 2 proposes an attribute query processing framework based on product quantization (PQ quantization). This pre-processes vectors with PQ quantization and compression. During a query, all features that meet the attribute conditions are first scanned before the query is performed. To reduce the overhead of scanning attribute conditions, this approach also proposes partitioning data based on attribute values. Adjacent attribute values are stored together, allowing for quick search of the corresponding partitions based on the attribute values, thus reducing the amount of space to scan. However, this approach first filters vectors by attributes and then searches the filtered vectors. While this method can achieve a high recall rate, its filtering efficiency decreases as the number of attribute categories increases, making it difficult to guarantee efficient retrieval. Furthermore, since part of this method's overhead is in attribute filtering, quantization can only accelerate a portion of the process, resulting in a limited acceleration. Furthermore, this approach cannot be used in graph indexing, but only in PQ quantization-compressed nearest neighbor query algorithms.
[0052] Related technology three proposes a graph index-based attribute query processing framework. This framework mixes vector distance and attribute distance. Vector distance uses inner product distance, and attribute distance uses XOR distance. In the mixed distance, vector distance plays a dominant role, and attribute distance is only fine-tuned. Since this method does not put attribute distance in a dominant position, it can guarantee a high recall rate in scenarios with a small number of attributes. When the number of attributes increases, the recall rate will drop sharply. In addition, by using the XOR method to process attributes, as the number of attribute combinations increases, more and more attributes will be mixed into the same attributes. For example, for an attribute value of 1, all attribute values that are not 1 are the same. This will lead to the loss of the attribute navigation function, and it cannot be guaranteed that the retrieved features will meet the attribute conditions.
[0053] Based on this, Figure 1 As shown, a method for processing data retrieval is provided. This embodiment uses the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0054] In step S110 , retrieval data is acquired.
[0055] The retrieval data may be data material used for data retrieval, that is, the data resource relied upon during the retrieval. The retrieval data may include at least one of text data, image data, audio data, or video data. Specifically, the retrieval data includes a corresponding initial feature vector and attribute features. The attribute features are used to characterize the data category, data attributes, etc. of the retrieval data, for example, whether it is text data, image data, or other data. The initial feature vector is a vector representation of the retrieval data after vectorization. For example, by vectorizing a certain image data, the initial feature vector corresponding to the image data can be obtained.
[0056] In this embodiment, the search data may be pre-stored in the server or stored in other data storage systems accessible to the server. In order to implement attributed vector search in this embodiment, the server first obtains the search data and performs corresponding processing through the following steps.
[0057] In step S120 , target data with the same attribute characteristics are retrieved, and a graph structure corresponding to the attribute characteristics is generated.
[0058] The graph structure is a nonlinear structure. Specifically, the graph structure may include multiple nodes. In the graph structure, any two nodes may be related, that is, the adjacency relationship between nodes can be arbitrary. In this embodiment, each node in the graph structure includes the initial feature vector of the target retrieval data and the corresponding attribute features.
[0059] Specifically, the server can classify the retrieved data according to the attribute features corresponding to the retrieved data, and generate a graph structure corresponding to the attribute features for target retrieval data with the same attribute features. That is, for each target retrieval data under each attribute feature, a graph structure corresponding to the attribute feature is generated. For example, if there are n attribute features in the retrieval data, n corresponding graph structures can be generated, and the nodes of each graph structure are composed of target retrieval data under the corresponding attribute feature. Specifically, for the target retrieval data under attribute feature Mi (representing the i-th attribute feature, where i is any number between 1 and n), a graph structure corresponding to attribute feature Mi can be generated.
[0060] In step S130 , based on the similarities between the attribute features, the graph structures corresponding to the attribute features are connected to obtain a connected target graph structure.
[0061] The target graph structure is a graph structure obtained by connecting the graph structures corresponding to each of the aforementioned attribute features. The target graph structure can reflect all search data. Similarity can be the degree of similarity between two attributes. In this embodiment, similarity is used to measure the degree of similarity between any two attribute features. It can be specifically determined by the vector distance between the two. That is, the closer the distance between the two, the higher the similarity, and the farther the distance between the two, the lower the similarity.
[0062] In this embodiment, the server connects the graph structures corresponding to the aforementioned attribute features to obtain a connected target graph structure. Specifically, when connecting the graph structures corresponding to the attribute features, the connection can be made based on the similarity between the attribute features. For example, with respect to the graph structure of attribute feature Mi, the graph structure of attribute feature Mi can be connected to the graph structures corresponding to one or more attribute features with higher similarity based on the similarity between attribute feature Mi and other attribute features.
[0063] In step S140 , the initial feature vector of each node in the target graph structure is converted into a target feature vector to obtain a target graph structure after vector conversion.
[0064] The accuracy of the initial feature vector is higher than that of the target feature vector. Specifically, the initial feature vector is a vector representation of the search data after vectorization, and the target feature vector is a vector representation of the initial feature vector with higher accuracy converted to a lower-precision vector.
[0065] Since the graph structure includes multiple nodes, and the target graph structure is formed by connecting the graph structures corresponding to the various attribute features, the target graph structure includes all the nodes of the graph structures corresponding to the various attribute features. In addition, since each node includes the initial feature vector corresponding to the search data, and the initial feature vector is a vector representation of the search data after vectorization. In this embodiment, in order to achieve higher vectorization accuracy, when vectorizing the search data, a higher-precision initial feature vector is used, and the graph structure is constructed based on this to improve the neighborhood quality in the graph structure. After the graph is constructed, the higher-precision initial feature vector of each node is converted into a lower-precision target feature vector to improve the efficiency of subsequent retrieval.
[0066] In the above-mentioned method for processing retrieval data, the server obtains retrieval data, generates a graph structure corresponding to the attribute features for target retrieval data with the same attribute features, and connects the graph structures corresponding to the attribute features according to the similarity between the attribute features to obtain the connected target graph structure, and then converts the initial feature vector of each node in the target graph structure into a target feature vector, thereby obtaining the target graph structure after vector conversion. Since this embodiment constructs the graph structure by using a high-precision initial feature vector, it can improve the neighborhood quality in the graph structure, and takes into account the attribute features of the retrieval data during the mapping process, it can be used for retrieval with attributes; by converting the high-precision initial feature vector of each node into a low-precision target feature vector after the mapping is completed, the efficiency of subsequent retrieval can also be improved.
[0067] In an exemplary embodiment, the above-mentioned initial feature vector with higher precision can be a floating-point number vector with a first byte number, and the above-mentioned target feature vector with lower precision can be an integer vector with a second byte number, wherein the first byte number is greater than the second byte number, and therefore, the precision of the initial feature vector is higher than the precision of the target feature vector.
[0068] Specifically, the initial feature vector can be FP32 (Full Precise Float 32, i.e., full-precision floating-point number), which occupies 4 bytes, totaling 32 bits, including 1 sign bit, 8 exponent bits, and 23 mantissa bits. The initial feature vector can also be FP16 (Float, i.e., half-precision floating-point number), which occupies 2 bytes, totaling 16 bits, including 1 sign bit, 5 exponent bits, and ten significant digits.
[0069] The target feature vector can be INT8 (i.e., an eight-bit integer), which occupies 1 byte, a total of 8 bits. It has the characteristics of small data volume, low energy consumption, and relatively fast calculation speed.
[0070] The following uses the example of an initial feature vector of FP32 and a target feature vector of INT8 to further illustrate the specific quantization process. Specifically, the following quantization definition can be used for reference during quantization:
[0071]
[0072] in, represents the rounding function, It is defined as the number that minimizes the difference between quantize(x) / scale and the absolute value of x, and can be obtained by the least squares method. is the initial feature vector to be transformed, quantize(x) is the target feature vector after transformation, when When it is greater than or equal to 127, the converted vector is 127. When it is less than or equal to -128, the converted vector is -128, and when When it is between -128 and 127, the converted vector is The integer part of .
[0073] In this embodiment, the corresponding target feature vector is obtained by quantizing the initial feature vector. Because the target feature vector has the characteristics of small data size, low energy consumption, and relatively fast calculation speed, retrieval efficiency can be improved by performing calculations based on the target feature vector during retrieval. Furthermore, because this embodiment converts the high-precision vector into a low-precision vector after the image is formed, rather than directly using the low-precision vector for image formation, the recall loss caused by quantization is greatly reduced.
[0074] In an exemplary embodiment, at least one of the multiple nodes in the graph structure has a first neighbor node, wherein the first neighbor node is a node in the graph structure whose distance between the initial feature vector of the node and the initial feature vector of at least one node satisfies a first preset condition. Specifically, the first preset condition can be a pre-set node distance threshold condition. Since all nodes in the same graph structure have the same corresponding attribute characteristics, when constructing the graph structure, based on all the retrieval data of the same attribute characteristic, arbitrarily select one retrieval data as the base node, and calculate the distance between the initial feature vector of other retrieval data of the attribute characteristic and the initial feature vector of the retrieval data as the base node respectively, and use the other retrieval data whose distance satisfies the first preset condition, that is, the distance is less than the pre-set node distance threshold, as the first neighbor node of the base node, and establish a connection between the base node and the first neighbor node. By completing similar processing of all retrieval data of the same attribute characteristic, the graph structure corresponding to the attribute characteristic can be obtained. Therefore, the first neighbor node of a node is also a node with a connection relationship with it in the graph structure.
[0075] Based on this, Figure 2 As shown, in step S130, according to the similarity between each attribute feature, the graph structures corresponding to each attribute feature are connected to obtain a connected target graph structure, which may specifically include:
[0076] In step S210 , for each node in the graph structure, a corresponding second neighbor node is determined.
[0077] Among them, the second neighbor node can be a node whose similarity between the corresponding attribute feature and the attribute feature of the node meets the second preset condition. The second preset condition can be a condition of a pre-set similarity threshold between attribute features. Specifically, for any node, the similarity between the attribute feature and other attribute features can be obtained respectively based on the attribute feature corresponding to the node, and the second neighbor node of the arbitrary node can be determined from the graph structure corresponding to other attribute features whose similarity meets the second preset condition (that is, the similarity is greater than the similarity threshold). For example, if there are graph structures A and graph structures B corresponding to other attribute features whose similarity is greater than the similarity threshold, then the distance between the arbitrary node and all nodes in the graph structure A is further obtained, and the distance between the arbitrary node and all nodes in the graph structure B is obtained, and the node closest to the distance in the graph structure A and the node closest to the distance in the graph structure B are used as the second neighbor node of the arbitrary node.
[0078] In one scenario, the second neighbor nodes can also be determined based on the number of the first neighbor nodes of the arbitrary node. Specifically, if the number of the first neighbor nodes of the arbitrary node is j, then first, based on the attribute feature corresponding to the node, the similarity between the attribute feature and other attribute features is obtained respectively, and the graph structures corresponding to the j other attribute features with the highest similarity are determined, thereby determining the corresponding j second neighbor nodes therefrom, that is, from each graph structure corresponding to the j other attribute features, the node with the closest distance is determined as the second neighbor node of the arbitrary node.
[0079] In step S220, a connection relationship is established between each node and the corresponding second neighbor node to obtain a connected target graph structure.
[0080] Specifically, after the server determines the second neighbor node of each node in the graph structure through the above steps, it establishes a connection relationship between the node and the corresponding second neighbor node, thereby obtaining a connected target graph structure.
[0081] In this embodiment, for each node in the graph structure, a corresponding second neighbor node is determined, and a connection relationship is established between each node and the corresponding second neighbor node, resulting in a connected target graph structure. Because each second neighbor node and the connected node belong to a graph structure with different attribute characteristics, connecting them ensures graph connectivity, allowing searches to quickly locate the neighborhood of the required attribute characteristics, thereby improving search efficiency.
[0082] In an exemplary embodiment, in step S220, after establishing a connection relationship between each node and the corresponding second neighbor node, the above method may further include: recording node information of each node. The node information includes the initial feature vector and the corresponding attribute feature of the node, as well as the first neighbor node and the second neighbor node corresponding to the node. Since the first neighbor node is a neighbor node with the same attribute feature as the node, and the second neighbor node is a neighbor node with different attribute features but similar attribute features as the node, the recorded node information can be used to quickly jump to the neighborhood of the required attribute feature during retrieval, which not only ensures the connectivity of the graph, but also effectively improves the retrieval efficiency.
[0083] In an exemplary embodiment, after obtaining the search data in step S110, the method may further include determining a preset number of target attribute features based on the attribute features corresponding to the search data. The target attribute features are used to represent the search starting point, i.e., the image is searched from the target attribute features as the starting point. The preset number may be a pre-set number of target attribute features, which can be set based on the actual scenario.
[0084] Specifically, after obtaining the search data, the server can further obtain the attribute features corresponding to the search data. For example, if there are Q different attribute features, a preset number of attribute features can be randomly selected as target attribute features. In subsequent searches, the graph can be searched from the target attribute features as the starting point, or the closest target attribute feature can be selected from the target attribute features as the search starting point. Because the attributes themselves greatly constrain the search space of the vector, this can improve search efficiency.
[0085] In an exemplary embodiment, Figure 3 As shown, the following takes the initial feature vector as FP32 and the target feature vector as INT8 as an example to further illustrate the above retrieval data processing method, which specifically includes the following steps:
[0086] In step S310 , retrieval data is obtained.
[0087] The retrieved data includes the corresponding attribute features and the initial feature vector after vector calculation of the original data using FP32.
[0088] In step S320, a preset number of target attribute features are determined according to the attribute features corresponding to the search data.
[0089] A preset number of attribute features are randomly selected from the attribute features corresponding to the retrieved data as target attribute features.
[0090] In step S330 , target search data corresponding to each attribute feature is retrieved to generate a graph structure corresponding to the attribute feature.
[0091] Specifically, for each attribute characteristic of the target search data, a graph structure corresponding to that attribute characteristic is generated. For example, if the search data contains n attribute characteristics, n corresponding graph structures can be generated, with each graph structure's nodes consisting of the target search data under the corresponding attribute characteristic. Specifically, for the target search data under attribute characteristic Mi (representing each i attribute characteristic, where i is any number between 1 and n), a graph structure corresponding to attribute characteristic Mi can be generated.
[0092] In step S340 , the graph structures corresponding to the respective attribute features are connected to obtain a connected target graph structure.
[0093] Specific parameters can be Figure 2 The embodiment shown is not described in detail in this embodiment.
[0094] In step S350 , the vectors of the nodes in the target graph structure are converted to obtain a target graph structure after vector conversion.
[0095] Convert the FP32 vector of each node in the target graph structure into an INT8 vector to obtain the target graph structure after vector conversion.
[0096] Since this embodiment constructs a graph structure by using high-precision FP32 vectors, the neighborhood quality in the graph structure can be improved, and the attribute characteristics of the retrieval data are taken into account during the mapping process, it can be used for attributed retrieval; after the mapping is completed, the high-precision FP32 vector of each node is converted into a low-precision INT8 vector. Since the low-precision vector is not directly used for mapping, the recall rate loss caused by quantization is greatly reduced, and the efficiency of subsequent retrieval can also be improved.
[0097] In an exemplary embodiment, Figure 4 As shown, a data retrieval method is also provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method may specifically include the following steps:
[0098] In step S410, a data retrieval request is obtained.
[0099] A data retrieval request is an instruction or command for instructing a terminal to perform a data retrieval. Specifically, the data retrieval request may include the data to be retrieved and the attribute characteristics corresponding to the data to be retrieved. The data to be retrieved may be a search keyword, and the attribute characteristics may be the data category or data attribute of the specified search result.
[0100] In this embodiment, when a user needs to perform data retrieval, he or she may initiate a data retrieval request to the terminal. The terminal may then obtain the corresponding data retrieval request and scan and retrieve data based on subsequent steps.
[0101] In step S420 , in the target graph structure, target attribute features that match the attribute features are determined.
[0102] Among them, the target graph structure is based on the above Figures 1 to 3 The graph structure after vector conversion obtained by the processing method of the retrieved data shown in the figure. The target attribute feature is the starting point for the retrieval determined based on the attribute feature in the data retrieval request.
[0103] Specifically, as can be seen from the above-described method for processing retrieval data, after the target graph structure is constructed, a preset number of target attribute features are reserved for retrieval entry. In this embodiment, the target attribute feature that matches the attribute feature can be the target attribute feature that is most similar to the attribute feature among the target attribute features reserved by the target graph structure.
[0104] In step S430, the target attribute feature is used as a search entry to retrieve the search data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets the similarity condition, and the search data is used as the search result.
[0105] Among them, the similarity condition can be a condition corresponding to a similarity threshold, for example, it can be a condition that the similarity is greater than the similarity threshold. Specifically, in this embodiment, for the data to be retrieved, it is only necessary to find the vector field with the same attributes in the target graph structure, that is, to retrieve all the retrieval data with the same attribute characteristics as the data to be retrieved as the retrieval result. It is also possible to retrieve all the retrieval data with the same attribute characteristics as the data to be retrieved, and further determine the retrieval data that meets the similarity condition from the obtained retrieval data based on the similarity condition as the retrieval result. Therefore, the terminal can use the above-mentioned determined target attribute characteristics as the retrieval entry, obtain the retrieval data with the same attribute characteristics as the data to be retrieved and the data similarity with the data to be retrieved that meets the similarity condition through retrieval, and use the retrieval data as the retrieval result.
[0106] Since the target graph structure takes the attribute characteristics of the retrieval data into consideration during the mapping process, during retrieval, the target attribute characteristics determined above that match the attribute characteristics of the data to be retrieved are used as the retrieval entry, so that the search space of the vector can be constrained by the attribute characteristics to narrow the query space and improve the retrieval efficiency.
[0107] In an exemplary embodiment, the target graph structure may include a preset number of target attribute features, such as Figure 5 As shown, in step S420, determining the target attribute feature for attribute feature matching may further include:
[0108] In step S510, the similarities between the attribute features and each target attribute feature are obtained.
[0109] The similarity refers to the degree of similarity between the attribute feature and each target attribute feature, which can be specifically measured by the distance between the vectors of the two. In this embodiment, the terminal can respectively obtain the similarity between the attribute feature in the data retrieval request and each target attribute feature in the target graph structure.
[0110] In step S520 , the target attribute feature with the greatest similarity is determined as the target attribute feature that matches the attribute feature.
[0111] In this embodiment, based on the similarities between the attribute features of the data retrieval request and each target attribute feature, the terminal determines the target attribute feature with the highest similarity as the target attribute feature that matches the attribute feature, and then uses the target attribute feature as the search entry for the search. This can narrow the query space and improve search efficiency.
[0112] In an exemplary embodiment, the data to be retrieved includes a feature vector having the same vector format as a target feature vector of the retrieved data, wherein the vector format is a form for vectorization or a type for vectorization.
[0113] Specifically, the aforementioned method for processing retrieval data reveals that the target graph structure is obtained by converting the vectors of each node. The converted target feature vectors are characterized by small data size, low energy consumption, and relatively fast computation speed. Therefore, during retrieval, vectorizing the data to be retrieved using the same vector format improves query efficiency. Furthermore, because the target graph structure converts high-precision vectors into low-precision vectors only after graphing is complete, rather than directly using low-precision vectors for graphing, the recall loss caused by quantization is also reduced.
[0114] It should be understood that although Figure 1-Figure 5The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1-Figure 5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0115] 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.
[0116] Figure 6 FIG. 1 is a block diagram of a data retrieval processing device according to an exemplary embodiment. Figure 6 The device includes a retrieval data acquisition module 602, a graph structure generation module 604, a target graph structure generation module 606 and a vector conversion module 608.
[0117] The retrieval data acquisition module 602 is configured to acquire retrieval data, wherein the retrieval data includes the corresponding initial feature vector and attribute features;
[0118] A graph structure generating module 604 is configured to perform a target search for data with the same attribute characteristics, and generate a graph structure corresponding to the attribute characteristics, wherein the graph structure includes a plurality of nodes, each of which includes an initial feature vector of the target search data and a corresponding attribute characteristic;
[0119] The target graph structure generating module 606 is configured to connect the graph structures corresponding to the attribute features according to the similarity between the attribute features to obtain the connected target graph structure;
[0120] The vector conversion module 608 is configured to convert the initial feature vector of each node in the target graph structure into a target feature vector to obtain a target graph structure after vector conversion.
[0121] In an exemplary embodiment, at least one node among the multiple nodes of the graph structure has a first neighbor node, and the first neighbor node is a node whose distance between the initial feature vector of the node in the graph structure and the initial feature vector of the at least one node meets a first preset condition; the target graph structure generation module is configured to perform: for each node of the graph structure, determine the corresponding second neighbor node, the second neighbor node is a node whose similarity between the corresponding attribute feature and the attribute feature of the node meets a second preset condition; establish a connection relationship between each node and the corresponding second neighbor node to obtain the connected target graph structure.
[0122] In an exemplary embodiment, the device also includes a node information recording module, which is configured to perform: recording node information of each node, wherein the node information includes the initial feature vector and corresponding attribute features of the node, and the first neighbor node and second neighbor node corresponding to the node.
[0123] In an exemplary embodiment, the initial feature vector is a floating point number vector having a first byte number, and the target feature vector is an integer number vector having a second byte number, where the first byte number is greater than the second byte number.
[0124] In an exemplary embodiment, the apparatus further includes a target attribute feature determination module configured to execute: determining a preset number of target attribute features based on the attribute features corresponding to the search data, wherein the target attribute features are used to represent the search starting point.
[0125] In an exemplary embodiment, the retrieved data includes at least one of text data, image data, audio data, or video data.
[0126] 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.
[0127] Figure 7 FIG. 1 is a block diagram of a data retrieval device according to an exemplary embodiment. Figure 7 The device includes a retrieval request acquisition module 702, an attribute feature matching module 704 and a retrieval module 706.
[0128] The retrieval request acquisition module 702 is configured to execute and acquire a data retrieval request, wherein the data retrieval request includes the data to be retrieved and the attribute characteristics corresponding to the data to be retrieved;
[0129] The attribute feature matching module 704 is configured to determine the target attribute feature of the attribute feature matching in the target graph structure after the vector conversion obtained according to the above-mentioned processing method for retrieving data;
[0130] The retrieval module 706 is configured to use the target attribute feature as a retrieval entry, retrieve retrieval data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets a similarity condition, and use the retrieval data as a retrieval result.
[0131] In an exemplary embodiment, the target graph structure includes a preset number of target attribute features; the attribute feature matching module is configured to perform: obtaining the similarity between the attribute features and each target attribute feature respectively; and determining the target attribute feature with the greatest similarity as the target attribute feature that matches the attribute feature.
[0132] In an exemplary embodiment, the to-be-retrieved data includes a feature vector having the same vector format as a target feature vector of the retrieved data.
[0133] 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.
[0134] Figure 8 FIG2 is a block diagram illustrating an electronic device Z00 for data retrieval or data retrieval according to an exemplary embodiment. For example, the electronic device Z00 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, or the like.
[0135] Reference Figure 8 The electronic device Z00 may include one or more of the following components: a processing component Z02 , a memory Z04 , a power supply component Z06 , a multimedia component Z08 , an audio component Z10 , an input / output (I / O) interface Z12 , a sensor component Z14 , and a communication component Z16 .
[0136] The processing component Z02 generally controls the overall operation of the electronic device Z00, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component Z02 may include one or more processors Z20 to execute instructions to perform all or part of the steps of the aforementioned method. Furthermore, the processing component Z02 may include one or more modules to facilitate interaction between the processing component Z02 and other components. For example, the processing component Z02 may include a multimedia module to facilitate interaction between the multimedia component Z08 and the processing component Z02.
[0137] Memory Z04 is configured to store various types of data to support operations on electronic device Z00. Examples of such data include instructions for any application or method operating on electronic device Z00, contact data, phone book data, messages, pictures, videos, and the like. Memory Z04 can be implemented using any type of volatile or non-volatile memory 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.
[0138] The power supply assembly Z06 provides power to various components of the electronic device Z00. The power supply assembly Z06 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 Z00.
[0139] The multimedia component Z08 includes a screen that provides an output interface between the electronic device Z00 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, the screen 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 may 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 Z08 includes a front-facing camera and / or a rear-facing camera. When the electronic device Z00 is in an operating mode, such as a capture mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and the rear-facing camera may have a fixed optical lens system or have focal length and optical zoom capabilities.
[0140] The audio component Z10 is configured to output and / or input audio signals. For example, the audio component Z10 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device Z00 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in the memory Z04 or transmitted via the communication component Z16. In some embodiments, the audio component Z10 also includes a speaker for outputting audio signals.
[0141] I / O interface Z12 provides an interface between processing component Z02 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0142] The sensor assembly Z14 includes one or more sensors for providing various aspects of status assessment for the electronic device Z00. For example, the sensor assembly Z14 can detect the open / closed state of the electronic device Z00, the relative positioning of components, such as the display and keypad of the electronic device Z00. The sensor assembly Z14 can also detect changes in the position of the electronic device Z00 or components of the electronic device Z00, the presence or absence of user contact with the electronic device Z00, the orientation or acceleration / deceleration of the device Z00, and temperature changes of the electronic device Z00. The sensor assembly Z14 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly Z14 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 Z14 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0143] The communication component Z16 is configured to facilitate wired or wireless communication between the electronic device Z00 and other devices. The electronic device Z00 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 Z16 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component Z16 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.
[0144] In an exemplary embodiment, the electronic device Z00 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.
[0145] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory Z04 including instructions. The instructions are executable by a processor Z20 of the electronic device Z00 to perform the above-described method. For example, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, or the like.
[0146] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions. The instructions can be executed by the processor Z20 of the electronic device Z00 to implement the above method.
[0147] Figure 9 FIG. 1 is a block diagram of an electronic device S00 for processing or retrieving data according to an exemplary embodiment. For example, the electronic device S00 may be a server. Figure 9 The electronic device S00 includes a processing component S20, which further includes one or more processors and a memory resource represented by a memory S22 for storing instructions executable by the processing component S20, such as an application. The application stored in the memory S22 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component S20 is configured to execute the instructions to perform the above method.
[0148] The electronic device S00 may further include a power supply component S24 configured to perform power management of the electronic device S00, a wired or wireless network interface S26 configured to connect the electronic device S00 to a network, and an input / output (I / O) interface S28. The electronic device S00 may operate based on an operating system stored in the memory S22, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0149] In an exemplary embodiment, a computer-readable storage medium including instructions is further provided, such as a memory S22 including instructions. The instructions may be executed by a processor of the electronic device S00 to perform the above method. The storage medium may be a computer-readable storage medium, such as a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, or the like.
[0150] 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 electronic device S00 to implement the above method.
[0151] It should be noted that the above-mentioned devices, electronic devices, 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.
[0152] 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.
[0153] 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 processing retrieval data, characterized in that: The method comprises: Acquire search data, the search data including corresponding initial feature vectors and attribute features, the initial feature vector being a vector representation of the search data after vectorization, the search data including at least one of text data, image data, audio data, or video data; For target retrieval data having the same attribute feature, generating a graph structure corresponding to the attribute feature, the graph structure comprising a plurality of nodes, each of the nodes comprising an initial feature vector of the target retrieval data and a corresponding attribute feature; According to the similarity between each attribute feature, the graph structures corresponding to each attribute feature are connected to obtain the connected target graph structure; The initial feature vector of each node in the target graph structure is converted into a target feature vector to obtain a target graph structure after vector conversion, wherein the accuracy of the initial feature vector is higher than the accuracy of the target feature vector, and the target feature vector is a vector representation after converting the high-precision initial feature vector into a low-precision vector.
2. The method according to claim 1, characterized in that At least one node among the multiple nodes of the graph structure has a first neighbor node, where the first neighbor node is a node whose distance between an initial feature vector of the node in the graph structure and the initial feature vector of the at least one node satisfies a first preset condition; The method of connecting the graph structures corresponding to the attribute features according to the similarity between the attribute features to obtain the connected target graph structure includes: For each node of the graph structure, determining a corresponding second neighbor node, where the second neighbor node is a node whose similarity between the corresponding attribute feature and the attribute feature of the node meets a second preset condition; A connection relationship is established between each node and the corresponding second neighbor node to obtain the connected target graph structure.
3. The method according to claim 2, characterized in that After establishing the connection relationship between each node and the corresponding second neighbor node, the method further includes: The node information of each node is recorded, where the node information includes the initial feature vector and corresponding attribute features of the node, as well as the first neighbor node and the second neighbor node corresponding to the node.
4. The method according to any one of claims 1 to 3, characterized in that The initial feature vector is a floating point number vector having a first byte number, and the target feature vector is an integer number vector having a second byte number, where the first byte number is greater than the second byte number.
5. The method according to any one of claims 1 to 3, characterized in that After obtaining the search data, the method further includes: A preset number of target attribute features are determined according to the attribute features corresponding to the search data, and the target attribute features are used to represent the search starting point.
6. The method according to any one of claims 1 to 3, characterized in that The retrieval data includes at least one of text data, image data, audio data or video data.
7. A data retrieval method, characterized in that: The method comprises: Obtaining a data retrieval request, wherein the data retrieval request includes data to be retrieved and attribute characteristics corresponding to the data to be retrieved; Determining target attribute features that match the attribute features in a target graph structure obtained after vector conversion by the method for processing retrieved data according to any one of claims 1 to 6; The target attribute feature is used as a search entry to retrieve search data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets a similarity condition, and the search data is used as a search result.
8. The method according to claim 7, characterized in that The target graph structure includes a preset number of target attribute features; and determining the target attribute features that match the attribute features includes: Obtaining the similarity between the attribute feature and each target attribute feature; The target attribute feature with the greatest similarity is determined as the target attribute feature that matches the attribute feature.
9. The method according to claim 7, characterized in that The data to be retrieved includes a feature vector having the same vector format as a target feature vector of the retrieved data.
10. A processing device for retrieving data, characterized in that: include: a search data acquisition module configured to acquire search data, the search data including a corresponding initial feature vector and attribute features, the initial feature vector being a vector representation of the search data after vectorization, the search data including at least one of text data, image data, audio data, or video data; A graph structure generating module is configured to execute a target search data with the same attribute feature, and generate a graph structure corresponding to the attribute feature, wherein the graph structure includes a plurality of nodes, each of which includes an initial feature vector of the target search data and a corresponding attribute feature; A target graph structure generation module is configured to connect the graph structures corresponding to the attribute features according to the similarity between the attribute features to obtain a connected target graph structure; The vector conversion module is configured to convert the initial feature vector of each node in the target graph structure into a target feature vector to obtain the target graph structure after vector conversion, wherein the accuracy of the initial feature vector is higher than the accuracy of the target feature vector, and the target feature vector is a vector representation after converting the high-precision initial feature vector into a low-precision vector.
11. A data retrieval device, characterized in that: include: A retrieval request acquisition module is configured to execute and acquire a data retrieval request, wherein the data retrieval request includes the data to be retrieved and the attribute characteristics corresponding to the data to be retrieved; an attribute feature matching module configured to determine a target attribute feature of the attribute feature matching in a target graph structure after vector conversion obtained by the method for processing retrieved data according to any one of claims 1 to 6; The retrieval module is configured to use the target attribute feature as a retrieval entry, retrieve retrieval data that has the same attribute feature as the data to be retrieved and whose data similarity with the data to be retrieved meets a similarity condition, and use the retrieval data as a retrieval result.
12. An electronic device, 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 data retrieval processing method according to any one of claims 1 to 6 or the data retrieval method according to any one of claims 7 to 9.
13. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data retrieval processing method according to any one of claims 1 to 6 or implement the data retrieval method according to any one of claims 7 to 9.
Citation Information
Patent Citations
Text classification method and device
CN107463658A
Index structure establishment method and device, equipment and storage medium
CN113190645A