Data search processing method and host
By constructing a heterogeneous computing architecture and dynamically adjusting the number of candidate vectors, the problem of excessive resource demand in large-scale data set searches is solved, more efficient data search processing is achieved, and system performance and resource utilization are improved.
Patent Information
- Application Number
- CN202510579238.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-08-01
AI Technical Summary
With the growth of data scale, the existing technology has too high demand for computing resources and storage resources when searching for target vectors that are most similar to query vectors on a large scale data set, which makes it expensive and difficult to scale. The existing hardware accelerators fail to make full use of CPU and hardware resources, resulting in poor system performance.
A heterogeneous computing architecture consisting of host processor, host memory, hardware accelerator and external memory is adopted. By constructing a graph to be searched and calculating the centroid, the number of candidate vectors is dynamically adjusted, and heterogeneous computing and storage resources are used to optimize search efficiency and result quality.
It improves the search efficiency and result quality of large-scale data sets, reduces resource waste, and achieves more efficient data search processing.
Smart Images

Figure CN120407873A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and in particular, to a data search processing method and a host. Background Art
[0002] Approximate Nearest Neighbor Search (ANNS) is a technique for quickly finding the vector most similar to a query vector in a large-scale high-dimensional space, sacrificing a small amount of accuracy in exchange for a higher vector retrieval speed, and has been widely applied in application fields such as recommendation systems, machine learning, information retrieval, and data mining.
[0003] Among them, during the implementation of ANNS, the data set and its index structure are usually maintained in memory, and the processor can directly perform similarity calculations on the query vector and the data set in memory to minimize the latency during vector retrieval. However, with the growth of data scale, the demand for computing resources and storage resources is increasing, which limits the applicable devices of ANNS and affects the vector retrieval efficiency and retrieval quality. Summary of the Invention
[0004] In view of the above problems, this application provides the following solutions:
[0005] In a first aspect of this application, a data search processing method is provided, which is applied to a host processor. The method includes:
[0006] Obtain a query vector;
[0007] Obtain the centroid of each graph to be searched; the graph to be searched is constructed for a query scenario;
[0008] Determine the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid;
[0009] Send a query request; the query request includes the query vector and the number of candidate vectors.
[0010] In an optional implementation, the obtaining the centroid of each graph to be searched includes any one of the following:
[0011] Read the centroid of each graph to be searched from the host memory;
[0012] In response to the centroid calculation request of each graph to be searched, access the corresponding graph to be searched in the external memory, and calculate the centroid of the graph to be searched according to the node vectors of the graph to be searched.
[0013] In an optional implementation, the determining the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid includes:
[0014] Obtain the similarity between the query vector and each of the centroids;
[0015] Determine the number of candidate vectors for each of the graphs to be searched according to the similarity.
[0016] In an alternative implementation, the determining the number of candidate vectors for each of the graphs to be searched according to the similarity includes:
[0017] Determine the candidate vector search ratio for each of the graphs to be searched according to the similarity;
[0018] Determine the total number of candidate vectors for each of the graphs to be searched according to the number of target vectors corresponding to the query vector;
[0019] Group the total number of candidate vectors according to the candidate vector search ratio, and determine the number of candidate vectors for each of the graphs to be searched.
[0020] In an alternative implementation, the determining the total number of candidate vectors for each of the graphs to be searched according to the number of target vectors corresponding to the query vector includes:
[0021] Obtain the number of target vectors corresponding to the query vector;
[0022] Determine a search adjustment coefficient according to the search requirement corresponding to the query vector; the search adjustment coefficient is greater than or equal to 1;
[0023] Determine the total number of candidate vectors for each of the graphs to be searched according to the number of target vectors and the search adjustment coefficient.
[0024] In an alternative implementation, the similarity includes the distance or similarity value between the corresponding centroid and the query vector.
[0025] In an alternative implementation, the constructing the graphs to be searched for the query scenario includes:
[0026] Before obtaining the query vector, partition and construct multiple graphs to be searched according to the dataset to be searched in the query scenario; or, segment the target graph in the query scenario to obtain multiple graphs to be searched;
[0027] Store each of the graphs to be searched in different storage areas in an external memory.
[0028] In an alternative implementation, the sending the query request includes any one of the following:
[0029] Simultaneously send to each of the graphs to be searched Figure 1A corresponding query request; the number of candidate vectors included in each said query request is the number of candidate vectors corresponding to the graph to be searched.
[0030] Send a query request for all the graphs to be searched; the number of candidate vectors included in the query request is the number of candidate vectors corresponding to each graph to be searched.
[0031] The second aspect of the present application provides a data processing method applied to a hardware accelerator. The method includes:
[0032] Receive a query request; the query request includes a query vector and the number of candidate vectors of the graph to be searched, and the number of candidate vectors is determined based on the query vector and the centroid corresponding to the graph to be searched.
[0033] Distribute the query request to different search units of the hardware accelerator.
[0034] Through different said search units, respectively perform candidate vector search on the corresponding graph to be searched in the external memory.
[0035] The third aspect of the present application provides a host, including a host processor and a host memory, wherein:
[0036] The host memory is used to store a plurality of computer instructions.
[0037] The host processor is used to load and execute the plurality of computer instructions to implement the following steps:
[0038] Obtain a query vector.
[0039] Obtain the centroid of each graph to be searched; the graph to be searched is constructed for a query scenario.
[0040] Based on the query vector and the centroid, determine the number of candidate vectors of the corresponding graph to be searched.
[0041] Send a query request; the query request includes the query vector and the number of candidate vectors. Description of the Drawings
[0042] In combination with the drawings and with reference to the following specific embodiments, the above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the original elements and elements are not necessarily drawn to scale.
[0043] Figure 1 It is a schematic flowchart of a data search and processing method proposed in Embodiment 1 of the present application.
[0044] Figure 2 Schematic flowchart of a data search and processing method proposed in the second embodiment of the present application;
[0045] Figure 3 Schematic flowchart of a data search and processing method proposed in the third embodiment of the present application;
[0046] Figure 4 Schematic flowchart of a data search and processing method proposed in the fourth embodiment of the present application;
[0047] Figure 5 Schematic comparison diagram of different processing methods for multiple query vectors in a data search and processing method provided by an embodiment of the present application;
[0048] Figure 6 Schematic structural diagram of a data search and processing device provided by the first embodiment of the present application;
[0049] Figure 7 Schematic structural diagram of a data search and processing device provided by the second embodiment of the present application;
[0050] Figure 8 Schematic structural diagram of each search unit in a data search and processing device provided by the second embodiment of the present application;
[0051] Figure 9 Schematic hardware structure diagram of a host provided by an embodiment of the present application;
[0052] Figure 10 Schematic structural diagram of a data search and processing system provided by an embodiment of the present application. Detailed implementation manners
[0053] The embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. The terms used in the embodiment part of the present application are only used to explain the specific embodiments of the present application, rather than intended to limit the present application. The embodiments of the present application will be described below with reference to the accompanying drawings. Those skilled in the art know that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0054] In the context of the present application and in the above-mentioned drawings, terms such as "first" and "second" are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that such terms can be interchanged under appropriate circumstances, which is only a way of distinguishing objects with the same attributes when describing embodiments of the present application. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion, so that a process, method, system, product or device comprising a series of units need not be limited to those units, but may include other units not clearly listed or inherent to these processes, methods, products or devices.
[0055] Regarding the technical problems described in the background art section, as the data scale continues to grow, the limitations of the implementation method that solely relies on memory for data storage and calculation become increasingly prominent. Especially when facing ultra-large datasets, the implementation process of searching for the target vector most similar to the query vector from them has extremely high memory requirements, resulting in high costs and difficulty in expansion. In response to this, it is proposed to combine storage devices such as disks to solve the memory limitation problem. Data search can be accelerated by constructing the dataset into a graph structure and storing it on the disk. However, the data in these graph structures need to be loaded into the memory for calculation during the search process, which makes the system performance limited by the I / O reading speed of the disk and affects the data search efficiency.
[0056] In addition, it is also proposed to use hardware accelerators such as FPGA (Field Programmable Gate Array), IPU (Intelligent Processing Unit), GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), or ASIC (Application-Specific Integrated Circuit) to store the graph structure of the dataset or the quantized dataset, and directly execute the data search task on the hardware accelerator, that is, search for the node vector or data point similar to the query vector, which releases the resources of the host processor CPU. However, this method does not reuse the resources of the CPU and the hardware accelerator, resulting in the system performance not reaching the optimal level and causing resource waste.
[0057] To further improve the above problems and solve the problem of double bottlenecks in computing and memory faced by the computing architecture composed of the host processor CPU and storage devices (memory, or memory and disk) during the search task of large-scale data sets, this application proposes a computing architecture composed of a host processor, host memory, hardware accelerator, and external memory, which makes full use of heterogeneous computing and storage resources to achieve an efficient search task for large-scale data sets. Based on this computing architecture, an embodiment of this application provides a data search processing method. The data search processing method in the embodiment of this application will be introduced in detail below with reference to the accompanying drawings.
[0058] Referring to Figure 1 , which is a schematic flowchart of a data search processing method proposed in Embodiment 1 of this application. This embodiment describes the implementation process of the data search processing method provided in this application from the host side of the computer device. That is to say, this data search processing method can be applied to a host processor, such as a CPU (Central Processing Unit), such as Figure 1 shown, this data search processing method may include but is not limited to:
[0059] Step S11, obtaining a query vector;
[0060] In the embodiment of this application, the query vector may be an input vector provided by the user, or a vector with a preset dimension obtained by vectorizing the input data provided by the user. For example, in the text search scenario, the query statement input by the user can be encoded to obtain a query vector representing the query statement; in the image retrieval scenario, the features of the input image can be extracted to obtain a query vector representing the input image, etc. This application does not limit the method and content of obtaining the query vector, and can be determined in combination with the actual query scenario.
[0061] Step S12, obtaining the centroid of each graph to be searched; the graph to be searched is constructed for the query scenario;
[0062] In practical applications, the graphs to be searched constructed for different query scenarios are different. The graph to be searched is a graph structure (i.e., graph index) formed by organizing the data set in the corresponding query scenario. The nodes in the graph to be searched represent the feature vectors in the data set, and the edges connecting different nodes represent the association relationships between the corresponding feature vectors, such as the proximity relationship in the application of approximate nearest neighbor search (ANNS), so that when searching for similar vectors of the query vector, it is possible to traverse along the edges of the graph to be searched.
[0063] It should be noted that the graph type of the graph to be searched in this application is not restricted and can be determined in combination with factors such as the query scenario and the data type and scale of the data set. For example: Neighbor Graph: Each node is connected to its K nearest neighbors (such as a K-NN graph); Delaunay Graph, such as NSG (Navigating Spreading-out Graph, an approximate Delaunay graph); Hierarchical Graph: A multi-layer structure accelerates the search, such as HNSW (Hierarchical Navigable Small World, a hierarchical navigable small world graph), etc.; it can also include DPG (Dynamic Proximity Graph, a dynamic proximity graph that can dynamically adjust the edges to maintain the connectivity and search efficiency of the graph). Based on this, in practical applications, for large-scale data sets, it is preferred to construct a graph to be searched with an HNSW graph structure; for data sets to be searched that need to be frequently updated in scenarios such as real-time recommendation systems, a graph to be searched with a DPG graph structure can be constructed, etc.
[0064] In addition, for large-scale data sets, in order to improve the query efficiency and reduce the memory requirements, the data set can be split into multiple data subsets, and for each data subset, a graph to be searched is independently constructed to achieve parallel construction of the graph structure. Optionally, this application can also construct a target graph based on the data set to be searched, and then split the target graph into multiple graphs to be searched, so as to search for candidate vectors similar to the query vector from each graph to be searched according to the corresponding search algorithm. This application does not restrict the implementation method of constructing the graph to be searched.
[0065] In the embodiments of this application, in order to improve the search accuracy or reduce the search resources, it is desired to search for more candidate vectors from the graph to be searched with a higher relevance to the query vector, search for fewer candidate vectors from the graph to be searched with a lower relevance to the query vector, and reduce the interference of such candidate vectors on the required query results. Therefore, compared with searching for a fixed number of candidate vectors from the graph to be searched, this application proposes to dynamically adjust the candidate vector data of the graph to be searched for different query vectors to optimize the search efficiency and result quality.
[0066] In this regard, this application proposes to calculate the centroid of each graph to be searched to represent the node vectors in the corresponding graph to be searched, so as to determine the number of candidate vectors corresponding to each graph to be searched through the similarity calculation with the query vector, which makes the number of candidate vectors of the graph to be searched with a higher relevance to the query vector larger, and the number of candidate vectors of the graph to be searched with a lower relevance to the query vector smaller. Among them, the centroid can be the data / vector of the center point of the corresponding graph to be searched, or the average node vector, etc. This application does not restrict the calculation method of the graph centroid.
[0067] In an alternative implementation, in the process of obtaining the graphs to be searched, the present application may adopt a suitable centroid calculation method to obtain the centroid corresponding to each graph to be searched, and write the centroid into the host memory for storage, so that after obtaining the query vector, the host processor can quickly read the centroid of each graph to be searched from the host memory, quickly complete the subsequent steps, and improve the search efficiency.
[0068] In another alternative implementation, the present application may also calculate the centroid of each graph to be searched online. Since the present application writes the graphs to be searched into an external memory for storage and no longer occupies the storage resources of the host, in this way, in response to the centroid calculation request of each graph to be searched, the host processor can access the corresponding graph to be searched in the external memory, and calculate the centroid of the graph to be searched according to the node vectors of the graph to be searched. The present application does not limit the centroid calculation method.
[0069] Optionally, the present application may be implemented based on a centroid calculation method of the graph topology structure, such as by performing betweenness centrality analysis (i.e., selecting the node vector with the smallest sum of shortest paths as the centroid) or degree centrality analysis (selecting the node with the highest degree as the centroid) on the graph to be searched. Or calculate the centroid based on the node vectors, such as selecting the geometric center point of each node in the graph to be searched as the centroid. In some scenarios, it is also possible to use a hierarchical centroid based on the community structure, such as selecting the node with the most connections within the community as the centroid of the community. According to actual needs, a dynamic weight adjustment method can also be adopted to select the node with the highest influence score as the centroid, etc.
[0070] Step S13: Determine the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid;
[0071] Combined with the above analysis, the present application can calculate the similarity between the query vector and each centroid to determine the relevance between the query vector and the corresponding graph to be searched, so as to configure a larger number of candidate vectors for the graph to be searched with a higher relevance and a smaller number of candidate vectors for the graph to be searched with a lower relevance. The present application does not limit the corresponding relationship between the relevance and the candidate vector data and its representation method.
[0072] Step S14: Send a query request; the query request includes the query vector and the number of candidate vectors.
[0073] After determining the number of candidate vectors corresponding to each graph to be searched according to the method described above, a query request for each graph to be searched can be initiated. The query request may include the query vector and the number of candidate vectors corresponding to each graph to be searched. In this way, in order to obtain the target vector similar to the query vector, the host processor can send a query request.
[0074] In an alternative implementation, since this application searches for candidate vectors similar to the query vector from each graph to be searched separately, the host processor can send a query request for each graph to be searched. At this time, the query request may include the query vector and the number of candidate vectors of the graph to be searched. It can be seen that for query requests for the same query vector, in different sending implementation methods, the number of query requests is different, and the content of the query requests sent can be adjusted accordingly. On the basis of all including the query vector, the graphs to be searched corresponding to the number of candidate vectors included are different.
[0075] In summary, after obtaining the query vector, this application will obtain the centroids of each graph to be searched constructed for the query scenario, and then accurately determine the number of candidate vectors of the corresponding graph to be searched based on the query vector and each centroid, that is, the number of candidate vectors similar to the query vector that need to be searched from each graph to be searched subsequently. Then, a query request including the query vector and the number of candidate vectors is sent to request to search for candidate vectors corresponding to the number of candidate vectors similar to the query vector from each graph to be searched. Compared with requesting to search for a fixed number of candidate vectors similar to the query vector from each graph to be searched, this application improves the quality of the searched candidate vectors and is beneficial to improving the search efficiency.
[0076] Refer to Figure 2 , which is a schematic flowchart of a data search processing method proposed in the second embodiment of this application, applied to the host processor. As Figure 2 shown, the data search processing method proposed in this embodiment may include:
[0077] Step S21, obtain a query vector;
[0078] Step S22, obtain the centroids of each graph to be searched; the graph to be searched is constructed for the query scenario;
[0079] Regarding the implementation processes of Step S21 and Step S22, reference can be made to the descriptions of the corresponding parts in the above embodiments, and this embodiment will not be elaborated here.
[0080] Step S23, obtain the similarity between the query vector and each centroid;
[0081] In order to obtain the relevance between the query vector and each graph to be searched, this application can adopt a suitable similarity algorithm, such as one or more algorithms among the Pearson correlation coefficient, cosine similarity, Euclidean distance, Manhattan distance, Chebyshev distance, Hamming distance, Jaccard distance / Jaccard similarity coefficient, information entropy, etc., to calculate the similarity between the query vector and the centroids of each graph to be searched, and determine the obtained similarity as the relevance between the query vector and the corresponding graph to be searched.
[0082] It can be seen that the similarity obtained in step S23 can be the distance between the corresponding centroid and the query vector, such as Euclidean distance, Manhattan distance, Chebyshev distance, Hamming distance, etc.; it can also correspond to the similarity value between the centroid and the query vector, which can be obtained based on other similarity algorithms different from the above distance algorithms, such as cosine similarity value or similarity value represented by similarity / correlation coefficient, etc. That is to say, different similarity algorithms are adopted in this application to execute step S23, and the specific content of the obtained similarity may be different.
[0083] It should be understood that the above distance measures the difference between the corresponding centroid and the query vector, and there is an inverse proportional relationship between it and the similarity that measures the degree of closeness between the corresponding centroid and the query vector. Step S24 can be directly executed based on this, or step S24 can be executed after converting the distance into similarity.
[0084] Step S24, based on this similarity, determine the candidate vector search ratio of each graph to be searched;
[0085] Based on the above analysis, for the graph to be searched corresponding to a higher similarity, more high-quality candidate vectors can be searched from it. Therefore, this application can determine the number of candidate vectors of each graph to be searched according to the similarity corresponding to each graph to be searched. In a possible implementation, this application can determine the candidate vector search ratio between each graph to be searched according to the proportional relationship between the similarities corresponding to each graph to be searched, ensuring that the candidate vector search ratio of the graph to be searched corresponding to a higher similarity is larger. This application does not limit the implementation method of step S24.
[0086] Optionally, if a distance algorithm such as but not limited to those listed above is used to calculate the similarity between the query vector and the centroid, that is, the similarity in steps S23 and S24 is a distance, this application can use the inverse proportional weighting method to map the distances corresponding to each graph to be searched into the number of candidate vectors. Therefore, after obtaining the distance between the query vector and the centroid corresponding to each graph to be searched, the search weight of the corresponding graph to be searched can be determined according to this distance (which can represent the relevance between the query vector and the corresponding graph to be searched, and is also the similarity between the query vector and the corresponding centroid); the search weight of the graph to be searched with a larger distance is smaller, so as to normalize the search weights of each graph to be searched to obtain the candidate vector search ratio of each graph to be searched.
[0087] Assume that the query vector is represented as q, and the centroid of the i-th graph to be searched is denoted as c i , the distance between the query vector q and the centroid c i can be denoted as d i , and the search weight of the i-th graph to be searched generated by the inverse proportional weighting method is denoted as w i , w i = 1 / (di +(ε), where ε represents a smoothing factor to prevent the denominator of the search weight calculation formula from being zero. ε is usually a small value, and this application does not limit its numerical size. After that, according to the following calculation formula, the search weight can be converted into a probability distribution to achieve the normalization processing of each search weight:
[0088] p i = (j = 1, 2, …, N); (1)
[0089] where w j represents the search weight of the j-th graph to be searched, and ∑ represents the summation operation, that is, summing the search weights corresponding to each of the N graphs to be searched. It can be seen that the greater the distance between the query vector and the centroid of the graph to be searched, the greater the search weight of the corresponding graph to be searched, and the greater the search ratio of the candidate vectors of the graph to be searched.
[0090] Step S25: Determine the total number of candidate vectors for each graph to be searched according to the number of target vectors corresponding to the query vector;
[0091] Step S26: Group the total number of candidate vectors according to the candidate vector search ratio to determine the number of candidate vectors for each graph to be searched.
[0092] In an actual query scenario, according to the actual search requirements, the number of target vectors similar to the query vector to be searched can be determined, denoted as k. The value of k can be different in different query scenarios, and the value of k corresponding to different search requirements in the same query scenario can also be different. Of course, this application can also determine the corresponding default value as the number of target vectors according to the type of search algorithm to achieve the expected recall rate.
[0093] In some embodiments, after obtaining the number k of target vectors corresponding to the query vector according to the method described above but not limited to it, according to the search requirements corresponding to the query vector, a search adjustment coefficient can be determined, denoted as α, α ≥ 1. Among them, the search requirements can include but are not limited to one or more of response time requirements, search result quality requirements, query scenario characteristics, downstream task requirements, etc. This application does not limit the size of the number of target vectors.
[0094] To avoid excessive total number of candidate vectors for search resulting in insufficient resources, usually the maximum value of the search adjustment coefficient allowed by the computing resources of the computer device is configured, denoted as α max . Therefore, α ∈ [1, α max , and its value can be determined through a recall rate-latency curve experiment, or the search adjustment coefficient can be dynamically adjusted in combination with the actual resource situation of the computer device to achieve dynamic adjustment of the total number of candidate vectors. This application does not limit α maxThere is no limit on the value.
[0095] Exemplarily, in scenarios with high recall rates such as recommendation systems and image retrieval, the requirement for response time is relatively loose, and more attention is paid to the integrity and accuracy of search results. Therefore, the determined search adjustment coefficient is relatively large to determine a relatively large total number of candidate vectors. For latency-sensitive scenarios such as real-time recommendation, online advertising, and real-time speech recognition, the requirement for response time is strict, and the determined search adjustment coefficient is relatively small to determine a relatively small total number of candidate vectors, which can reduce the subsequent merging overhead. Additionally, to avoid potential computational waste or insufficient precision caused by fixing the total number of candidate vectors, the computing resources can be dynamically adjusted. For this purpose, an appropriate search adjustment coefficient can be determined based on the actual computing resources of the computer device. For example, the more sufficient the actual computing resources are, the larger the determined search adjustment coefficient can be.
[0096] In this way, based on the search adjustment coefficient and the target vector quantity, the total number of candidate vectors for each graph to be searched can be determined, that is, by performing a multiplication operation on the search adjustment coefficient and the target vector quantity, and taking the resulting product as the total number of candidate vectors, i.e., ∑m i = αk, and α ∈ [1, α max , where m i represents the number of candidate vectors for the i-th graph to be searched. Preferably, under the premise that the recall rate in the query scenario meets the standard, this application can select the smallest search adjustment coefficient and the target vector quantity that meets the query service requirements to reduce resource consumption.
[0097] After that, the total number of candidate vectors (αk) can be directly grouped according to the candidate vector search ratio between different graphs to be searched (such as the above p i ) to determine the number of candidate vectors for each graph to be searched, denoted as m i . By taking the integer of the product result of the candidate vector search ratio corresponding to each graph to be searched and the total number of candidate vectors, the initial number of candidate vectors for the corresponding graph to be searched is obtained, that is, m i float = αk × p i , and the initial number of candidate vectors m i = |m i float |. It can be seen that the initial number of candidate vectors is less than or equal to the corresponding product result. Usually, this method cannot fully allocate the total number of candidate vectors. The difference operation can be performed between the total number of candidate vectors and the sum of each initial number of candidate vectors to obtain the unallocated quantity for the total number of candidate vectors, that is, Δ = αk - ∑m i , where m iRepresents the initial number of candidate vectors for the i-th graph to be searched. For groups with unassigned quantities, it can still be implemented according to the candidate vector search ratio, that is, based on the candidate vector search ratio and the unassigned quantity, update the corresponding initial number of candidate vectors to obtain the number of candidate vectors for the corresponding graph to be searched.
[0098] It should be noted that the method for grouping the total number of candidate vectors includes, but is not limited to, the rounding-down processing method described in the previous paragraph. It can also linearly group the total number of candidate vectors according to the candidate vector search ratio corresponding to each graph to be searched, and determine the number of candidate vectors corresponding to each graph to be searched, etc.
[0099] Step S27, send a query request; the query request includes a query vector and the number of candidate vectors.
[0100] Combined with the relevant description of step S27 above, in an alternative implementation, it is possible to simultaneously send a corresponding query request for each graph to be searched; each query request includes a query vector and the number of candidate vectors for the corresponding graph to be searched, so that after the hardware accelerator in the computer device receives multiple query requests, it can simultaneously respond to multiple query requests and separately perform candidate vector search on the corresponding graphs to be searched in the external memory to obtain the number of candidate vectors corresponding to the number of candidate vectors. Figure 1 In another alternative implementation, after the present application determines the number of candidate vectors corresponding to each graph to be searched, it is also possible to directly send a query request for all graphs to be searched. The query request includes a query vector and the number of candidate vectors corresponding to each graph to be searched, so that the hardware accelerator splits the number of candidate vectors in the query request, splices each split number of candidate vectors with the query vector to form a query request for the corresponding graph to be searched, and responds to the query request to implement the search task for the corresponding graph to be searched.
[0101] In summary, in the embodiment of the present application, after obtaining any query vector, the centroids corresponding to each graph to be searched in the corresponding query scenario are obtained, and then, based on the similarity between the query vector and each centroid, the candidate vector search ratio for the corresponding graph to be searched is determined, which is used to implement dynamic grouping of the total number of candidate vectors to obtain the number of candidate vectors corresponding to each graph to be searched. Instead of using a fixed number of candidate vectors, then, the host processor can send a query request including the query vector and the number of candidate vectors to request to quickly search out the number of candidate vectors corresponding to the number of candidate vectors from the corresponding graph to be searched, improving the quality and efficiency of the search results.
[0102] In summary, in the embodiment of the present application, after obtaining any query vector, the centroids corresponding to each graph to be searched in the corresponding query scenario are obtained, and then, based on the similarity between the query vector and each centroid, the candidate vector search ratio for the corresponding graph to be searched is determined, which is used to implement dynamic grouping of the total number of candidate vectors to obtain the number of candidate vectors corresponding to each graph to be searched. Instead of using a fixed number of candidate vectors, then, the host processor can send a query request including the query vector and the number of candidate vectors to request to quickly search out the number of candidate vectors corresponding to the number of candidate vectors from the corresponding graph to be searched, improving the quality and efficiency of the search results.
[0103] Refer to Figure 3, which is a schematic flowchart of a data search and processing method proposed in the third embodiment of this application. This embodiment can describe an optional acquisition process for each graph to be searched in the query scenario in the data search and processing method proposed above. For example, Figure 3 As shown, the data search and processing method proposed in this embodiment may further include:
[0104] Step S31, obtain the dataset to be searched in the query scenario;
[0105] For the graphs to be searched corresponding to different query scenarios, before performing the search task, the construction and storage of the graphs to be searched can be completed. During the construction process, for any query scenario, such as text / image / product query scenarios, etc., the corresponding text / image dataset, etc. can be obtained as the dataset to be searched in the corresponding query scenario, or the raw data in the dataset can be processed into feature vectors, and the obtained vector dataset can be determined as the dataset to be searched.
[0106] Among them, the above dataset to be searched can be a locally stored dataset, or can be sourced from an open-source dataset on the network, or a personal / private domain dataset, etc. This application places no restrictions on the source, quantity, and type of the dataset to be searched, and it can be determined according to the situation.
[0107] Step S32, construct the target graph of the query scenario based on the dataset to be searched;
[0108] For different types of graph structures, corresponding graph construction methods can be used to implement step S32. During this implementation process, the feature vectors corresponding to each data point in the dataset to be searched can be determined as node vectors, and based on the association relationships between different feature vectors, it can be determined whether the corresponding node vectors are connected, so that each node vector and the corresponding connection relationships form a target graph, and the dataset to be searched is represented by the data structure of the target graph, so as to search for the target vector most similar to the query vector through graph traversal. This application does not elaborate on the implementation process of target graph construction.
[0109] Step S33, segment the target graph to obtain multiple graphs to be searched;
[0110] In order to improve the search efficiency and the utilization rate of memory bandwidth, and avoid long waiting and data interaction, this application proposes to segment the entire target graph into multiple graphs to be searched, and each graph to be searched contains local data in the dataset to be searched, so as to support parallel implementation of local screening of each graph to be searched, and comprehensively combine the candidate vector sets from each graph to be searched to quickly and accurately obtain the target vector most similar to the query vector.
[0111] In practical applications, for different types of target graphs, corresponding graph partitioning algorithms can be adopted to implement the segmentation of the target graph, that is, the graph data structure is divided into N subgraphs, and each subgraph is determined as a graph to be searched. Among them, the graph partitioning algorithms can include, but are not limited to: Linear Deterministic Greedy (LDG) algorithm, Greedy algorithm, Degree-Based Heuristic (DBH) algorithm, Histogram-Directed Randomized Forest (HDRF) algorithm, or PDS (Partitioning with Dynamic Supersteps) algorithm, etc. The operation principles of each image partitioning algorithm are not elaborated in this application.
[0112] In some other embodiments, before obtaining the query vector, this application can also partition and construct multiple graphs to be searched according to the dataset to be searched in the query scenario, that is, first partition the dataset to be searched to obtain multiple data subsets, and then construct a graph to be searched for each data subset. The graph construction process can be the same as the method for constructing the target graph described above, which is not elaborated in this embodiment. The partitioning of the dataset to be searched can be implemented according to factors such as data type or association relationship.
[0113] Step S34: Calculate the centroid of each graph to be searched according to the node vectors in each graph to be searched;
[0114] Step S35: Write the centroid of each graph to be searched into the host memory for storage;
[0115] In some embodiments, after obtaining each graph to be searched for the query scenario, the centroid of each graph to be searched can be directly calculated. The centroid calculation process can refer to the description of the corresponding part in the above embodiments, which is not elaborated here. For the calculated centroid of each graph to be searched, it can be directly written into the host memory for storage, so that after obtaining any query vector in this query scenario, the centroid corresponding to each graph to be searched can be quickly read from the host memory without waiting for the centroid to be calculated, shortening the search time and improving the search efficiency.
[0116] Step S36: Transmit each graph to be searched to the external memory to store a corresponding graph to be searched in different storage areas of the external memory.
[0117] For each to-be-searched graph obtained by the method described above, it can be independently stored in different regions of the external memory, that is, the entire storage area of the external memory is divided into multiple storage regions, and each storage region is configured with at least one independent communication channel (i.e., memory read / write channel) to ensure access isolation between different storage regions. Then, a to-be-searched graph is written into the corresponding storage region through this communication channel for storage, so that each to-be-searched graph is stored in a different storage region. Among them, the starting storage address of each storage region for the to-be-searched graph can be determined based on the base address of the external memory, the address identifier of the storage region, and the maximum capacity of the to-be-searched graph, and the specific address is not limited.
[0118] Among them, the external memory can be a CXL (Compute Express Link, a high-speed processor interconnect technology based on the PCIe (Peripheral Component Interconnect Express) protocol, which realizes high-speed and low-latency communication between heterogeneous computing devices (host processors and hardware accelerators)) Type3 device, such as an HBM (High Bandwidth Memory) device. Through its unique 3D stacking structure and wide bus design, it significantly improves memory bandwidth and energy efficiency. Utilizing its powerful memory resources and memory scalability, it realizes the storage of large-scale data sets, that is, the host processor can write the to-be-searched graph through the memory protocol CXL.mem, and the implementation process is not described in detail in this application.
[0119] In an alternative implementation, to avoid competition for the same storage region during the search task processes executed in parallel for different to-be-searched graphs, reduce memory access conflicts, and improve bandwidth utilization, during the process of partitioning the external memory to obtain multiple independent storage regions, a static partitioning method can be adopted, that is, the external memory is divided into a fixed number of different storage regions according to a fixed partitioning method. A dynamic partitioning method can also be adopted, that is, the number of partitions (i.e., the number of storage regions) is adjusted according to the requirements of the search task, and even the capacity sizes of different storage regions are adjusted, and the channel bandwidth is allocated accordingly to support the parallel search tasks for the to-be-searched graphs stored in each storage region respectively, reducing resource waste. Among them, during the storage region partitioning process, it can also be implemented in combination with the number of physical channels supported by the hardware accelerator and the external storage device, so that the number of storage regions is less than or equal to the number of physical channels.
[0120] Refer to Figure 4 , which is a schematic flowchart of a data search and processing method proposed in Embodiment 4 of this application. This data search and processing method can be applied to a hardware accelerator, such as an FPGA or other processors that support parallel processing tasks, such as the ASIC or other dedicated accelerators listed above, such as Figure 4As shown, the data search method executed by the hardware accelerator may include but is not limited to:
[0121] Step S41, receiving a query request; the query request includes a query vector and the number of candidate vectors of the graph to be searched, and the number of candidate vectors is determined based on the query vector and the centroid of the corresponding graph to be searched;
[0122] Regarding the determination process of the number of candidate vectors corresponding to each graph to be searched, reference may be made to the description process of the data search processing method described from the host processor side above, and this embodiment will not elaborate here.
[0123] In some embodiments, the number of query requests received by the hardware accelerator may be one, and this one query request includes a query vector and the number of candidate vectors corresponding to each graph to be searched. The number of query requests received may also be multiple, and the number may be the same as the number of graphs to be searched. Each of these multiple query requests includes a query vector and the number of candidate vectors of the corresponding graph to be searched.
[0124] Step S42, distributing the query request to different search units of the hardware accelerator;
[0125] Step S43, respectively performing candidate vector search on the corresponding graph to be searched in the external memory through different search units.
[0126] In the embodiment of the present application, after determining each graph to be searched in the query scenario, the same number of search units may be created in the hardware accelerator. These search units support the same search algorithm, such as instantiating multiple search units based on the Approximate Nearest Neighbor Search (ANNS) algorithm. The present application does not limit the creation method of the search units.
[0127] Optionally, for each created search unit, a communication channel may be established between it and different storage areas in the external memory to obtain the corresponding relationship between different graphs to be searched and each search unit. In this way, after the hardware accelerator receives a query request, according to this corresponding relationship, the query request including the query vector and the number of candidate vectors of a single graph to be searched is distributed to the search unit corresponding to the corresponding graph to be searched. For example, the query request including q and m i is sent to the search unit corresponding to the i-th graph to be searched.
[0128] In this way, multiple search units in the hardware accelerator execute simultaneously. For example, after each search unit receives a query request containing a query vector and the number of candidate vectors, it directly starts running. According to the operation principle of the corresponding search algorithm, based on the query vector and the number of candidate vectors received by each search unit itself (which corresponds to the graph to be searched for the search task to be executed by this search unit), the candidate vector search for the corresponding graph to be searched in the external memory is realized. That is, each search unit traverses the graph to be searched stored in the corresponding storage area in the external memory through a communication channel (i.e., an independent access channel established between the hardware accelerator and the external memory, or a memory read / write channel), calculates the similarity (such as distance) between each node vector in the graph to be searched and the query vector, sorts according to the similarity (such as distance sorting), and selects the corresponding number of candidate vectors with higher similarity (such as smaller distance) as candidate vectors. Thus, the graph search task is executed in parallel in multiple storage areas. Since different storage areas exclusively occupy their respective communication channels, independent access and processing of graph data are realized, and the utilization rate of the memory bandwidth is improved.
[0129] Among them, each search unit running in parallel only needs to process the local data stored in a corresponding storage unit, that is, the node vectors included in a graph to be searched, and can quickly screen out potential candidate vectors of the query vector. Compared with directly searching for candidate vectors in the entire target graph, the amount of search data is greatly reduced, and the search efficiency is improved. Moreover, each search unit is independent of each other and does not interfere with each other, and can make full use of the hardware resources for parallel computing, accelerating the query response time and realizing efficient software and hardware co-processing.
[0130] Preferably, in order to improve the search efficiency and accuracy of the graph to be searched, each search unit can configure the size of the candidate set (i.e., candidate pool) according to the number of candidate vectors received, so that during the iterative search process for the corresponding graph to be searched, the node vectors that may contain the most similar vectors to the query vector searched are written into the candidate set as candidate vectors. In each iterative search, the candidate set is updated with the newly searched candidate vectors, so that the similarity between each candidate vector in the updated candidate set and the query vector is higher, that is, it includes several (the number of candidate vectors) candidate vectors with high similarity among the node vectors that have been visited in the graph to be searched. The search process can be determined according to the principle of the corresponding search algorithm and the graph type, which will not be elaborated in this application.
[0131] It can be seen that for each graph to be searched, a candidate set with a size corresponding to the number of candidate vectors is maintained, storing the node vectors that are currently found to be the most similar to the query vector. Each time a new node vector is accessed, its similarity value or distance from the query vector is calculated, and the candidate set is updated. Preferably, to prevent repeated access, the present application can also write the accessed node vectors into the access set, and determine whether the search for all node vectors in the corresponding graph to be searched is completed by calculating whether the difference between the candidate set and the access set is empty. If not, the candidate vectors included in the finally updated candidate set are determined as the initial search results, thereby reducing unnecessary similarity calculations and improving the search efficiency.
[0132] In an alternative implementation, during the execution of the search task for a graph to be searched in the corresponding storage area by each search unit, a set of node vectors is selected from the graph to be searched according to the number of candidate vectors and placed in the candidate set. The node vectors in the candidate set are searched, and during the search process, the accessed node vectors are placed in the access set, and the node vectors in the access set are removed from the candidate set. In this way, by traversing each node vector in the access set and checking whether it is in the candidate set, if it is, it is removed from the candidate set until there are no identical node vectors between the candidate set and the access set, completing the traversal of the entire graph to be searched, effectively avoiding repeated calculation of the similarity between the accessed node vectors and the query vector.
[0133] Optionally, the present application can also calculate the distances between the query vector and each node vector in the graph to be searched according to the ANNS search algorithm, sort the distances, select the corresponding number of candidate nodes, update them to the candidate set, and then determine whether the traversal search of the corresponding graph to be searched is completed by calculating the difference between the candidate set and the access set. The present application does not limit the implementation method of obtaining the initial search results for each search unit based on the search algorithm and traversing the corresponding graph to be searched.
[0134] In some embodiments, the initial search results obtained for each search unit may include the index of the query vector (such as a query identifier for distinguishing different query vectors, such as query_id), the index of the candidate vectors, that is, the candidate vector set from the corresponding graph to be searched (such as the result ID array [1..m N corresponding to each graph to be searched), and the similarity between each candidate vector and the query vector (the distance array [1.. m N(), the target vector quantity of target vectors with higher similarity can be selected according to the similarity between each candidate vector included in all the initially retrieved results screened out and the query vector. For example, according to the similarity sorting from high to low, the target vector quantity of candidate vectors with the top ranking can be selected as the target vectors, etc. The selected target vectors are fed back to the host processor. Thus, for the search of target vectors similar to each query vector, a two-level processing strategy is adopted, so that the initial search results of each graph to be searched have been effectively screened in the local search stage, reducing the computational burden during the global sorting and further reducing the search latency, dynamically optimizing the system performance without reconstructing the hardware.
[0135] In some embodiments, when the host processor constructs multiple graphs to be searched based on the dataset to be searched, according to the data type, the dataset to be searched can be divided into multiple data subsets, and for each data subset, a subgraph is constructed. In this way, after obtaining the query vector, the graphs to be searched corresponding to the query vector can be selected from all the subgraphs, the centroids of each graph to be searched can be obtained to determine the candidate vector quantity of the corresponding graph to be searched, and the corresponding query requests are sent. In this case, the hardware accelerator only needs to distribute the query requests to the search units corresponding to each graph to be searched to implement the search of candidate vectors for each graph to be searched according to the method described above, without searching the subgraphs irrelevant to the query vector, reducing the computational burden.
[0136] In some embodiments, the host processor can obtain multiple query vectors. For the processing process of each query vector, it can all be implemented according to the data search processing method described above. To improve the processing efficiency, for each step of the data search processing method corresponding to different query vectors, a pipelining method can be adopted. In this regard, the present application can divide the implementation processes of the host processor and the hardware accelerator of the computer device for respectively executing the data search processing method into several stages, such as Figure 5 the calculation process of the candidate vector quantity of each graph to be searched by the host processor (taking the CPU as an example for illustration), that is, the CPU processing process, the query request transmission and distribution process, the candidate vector search process of each search unit for the corresponding graph to be searched (abbreviated as the search process), and the merging process of the initial search results of each graph to be searched (abbreviated as the merging process). In Figure 5 it, the squares with the same background color represent the processing process.
[0137] After that, for each processing process of the data search processing method respectively executed for different query vectors, such as Figure 5 shown in Figure (b) in st the first query vector represented by 1 nd query, the second query vector represented by 2 rdThe third query vector represented by query can parallelize the processing procedures belonging to the same stage among the processing procedures represented by their respective corresponding different grids, enabling the host processor and the hardware processor to directly execute the processing procedure of the next query vector for the same stage every time they complete the processing procedure of a query vector. Meanwhile, it does not affect the hardware accelerator or the host processor from executing the processing procedure of the next stage for the previous query vector. It can be seen that, compared with the non-pipelined processing method shown in Figure 5 Figure (a) therein, that is, the data search processing method for completing the first query vector. After the CPU receives the target vector of the first query vector, it then starts the data search processing method for the second query vector, and so on in sequence. The present application adopts the Figure 5 pipelined implementation method shown in Figure (b) therein, avoiding the idle waiting during the processing procedures corresponding to different query vectors, enabling the computer device to overlap the processing procedures of multiple different stages of different query vectors, effectively hiding the latency between stages, significantly reducing the overall response time, and improving the processing efficiency and throughput of the system.
[0138] The above introduced a data search processing method provided by an embodiment of the present application. Next, a device for executing the above data search processing method will be introduced.
[0139] Referring to Figure 6 , it is a schematic structural diagram of a data search processing device provided in Embodiment 1 of the present application. As Figure 6 shown, the data search processing device may include:
[0140] A query vector acquisition module 61, configured to acquire a query vector;
[0141] A centroid acquisition module 62, configured to acquire the centroids of each graph to be searched; the graph to be searched is constructed for a query scenario;
[0142] A candidate vector number determination module 63, configured to determine the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid;
[0143] A query request sending module 64, configured to send a query request; the query request includes the query vector and the number of candidate vectors.
[0144] Optionally, the centroid acquisition module may include any of the following units:
[0145] A centroid reading unit, configured to read the centroids of each graph to be searched from the host memory;
[0146] A centroid calculation unit, configured to, in response to a centroid calculation request for each graph to be searched, access the corresponding graph to be searched in the external memory, and calculate the centroid of the graph to be searched according to the node vectors of the graph to be searched.
[0147] Optionally, the candidate vector quantity determination module may include:
[0148] A first acquisition unit, configured to acquire the similarity between the query vector and each of the centroids;
[0149] A first determination unit, configured to determine the candidate vector quantity of each of the graphs to be searched according to the similarity.
[0150] Optionally, the first determination unit may include:
[0151] A second determination unit, configured to determine the candidate vector search ratio of each of the graphs to be searched according to the similarity;
[0152] A third determination unit, configured to determine the total candidate vector quantity of each of the graphs to be searched according to the target vector quantity corresponding to the query vector;
[0153] A grouping unit, configured to group the total candidate vector quantity according to the candidate vector search ratio, and determine the candidate vector quantity of each of the graphs to be searched.
[0154] Optionally, the third determination unit may include:
[0155] A second acquisition unit, configured to acquire the target vector quantity corresponding to the query vector;
[0156] A search adjustment coefficient determination unit, configured to determine a search adjustment coefficient according to the search requirement corresponding to the query vector; the search adjustment coefficient is greater than or equal to 1;
[0157] A fourth determination unit, configured to determine the total candidate vector quantity of each of the graphs to be searched according to the target vector quantity and the search adjustment coefficient.
[0158] Optionally, when the above similarity is the distance between the corresponding centroid and the query vector, the above first determination unit may include:
[0159] A search weight determination unit, configured to determine the search weight of the corresponding graph to be searched according to the distance; the smaller the search weight corresponding to the graph to be searched with a larger distance;
[0160] A normalization unit, configured to normalize the search weights of each of the graphs to be searched to obtain the candidate vector search ratio of each of the graphs to be searched.
[0161] In the above embodiments, the graph construction module in the above device may include:
[0162] A building unit, configured to partition and build a plurality of graphs to be searched according to a dataset to be searched in a query scenario before obtaining a query vector; or, split a target graph in the query scenario to obtain a plurality of graphs to be searched;
[0163] A storage unit, configured to store each of the graphs to be searched in different storage areas in an external memory.
[0164] Optionally, the above query request sending module may include any of the following sending units:
[0165] A first sending unit, configured to simultaneously send a corresponding query request for each of the graphs to be searched; the number of candidate vectors included in each query request is the number of candidate vectors corresponding to the graph to be searched; Figure 1 A corresponding query request; the number of candidate vectors included in each query request is the number of candidate vectors corresponding to the graph to be searched;
[0166] A second sending unit, configured to send a query request for all the graphs to be searched; the number of candidate vectors included in the query request is the number of candidate vectors corresponding to each of the graphs to be searched.
[0167] Refer to Figure 7 , which is a schematic structural diagram of a data search processing device provided in Embodiment 2 of this application, applied to a hardware accelerator. As Figure 7 shown, the data search processing device may include:
[0168] A receiving module 71, configured to receive a query request; the query request includes a query vector and the number of candidate vectors of the graph to be searched, and the number of candidate vectors is determined according to the query vector and the centroid corresponding to the graph to be searched;
[0169] A distribution module 72, configured to distribute the query request to different search units of the hardware accelerator;
[0170] A search module 73, configured to perform candidate vector search on the corresponding graph to be searched in the external memory through different search units.
[0171] Combined with the data search processing method described from the hardware accelerator side above, as Figure 8 shown, each search unit included in the search module 73 may include:
[0172] A splitting unit, configured to split the number of candidate vectors from the query request and send the number of candidate vectors to a configuration unit;
[0173] A configuration unit, configured to configure the size of the candidate set of the graph to be searched;
[0174] A memory control unit, configured to access the graph to be searched in the corresponding storage area to obtain the node vectors in the graph to be searched;
[0175] A distance calculation unit, configured to receive the query vector sent by the splitting unit, and calculate the similarity between the query vector and each node vector sent by the memory control unit;
[0176] A sorting unit, configured to sort according to the similarity and select candidate vectors;
[0177] A candidate set updating unit, configured to update the candidate set according to the selected candidate vectors.
[0178] An embodiment of the present application also provides a computer program product, including computer-readable instructions, which, when running on an electronic device, enable the electronic device to implement any data search processing method provided by the embodiment of the present application.
[0179] An embodiment of the present application also provides a computer-readable storage medium, which carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, can enable the electronic device to implement any data search processing method provided by the embodiment of the present application.
[0180] Referring to Figure 9 , which is a schematic hardware structure diagram of a host proposed by an embodiment of the present application. The host may include a host processor 91 and a host memory 92, and the two work together to implement the data search processing method proposed by the present application, where:
[0181] The host processor 91 and the host memory 92 can perform data interaction through a bus or a communication component. The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 9 only a bidirectional line is shown in , but it does not mean that there is only one bus or one type of bus.
[0182] Among them, the communication component may include a general-purpose input / output (GPIO) interface, a USB interface, a universal asynchronous receiver / transmitter (UART) interface, or other I / O interfaces, etc. According to needs, the communication component may further include other communication interfaces, such as a CXL interface, to implement communication between the host processor and the hardware accelerator. Of course, the communication component may also include communication components corresponding to wireless communication methods such as wifi, Bluetooth, 5G / 6G, etc., for obtaining the dataset to be searched or the target graph constructed therefrom, and may also receive the query vector or input information input by the user, etc. The type of the communication component may be determined according to actual processing requirements, and no detailed examples are given in this application.
[0183] The host memory 92 may store multiple computer instructions for implementing the data search processing method proposed in the embodiments of the present application, and may also store temporary data during the execution of the data search processing method for the host processor to quickly access. The host processor 91 may load and execute the multiple computer instructions stored in the host memory 92 to implement each step of the data search processing method proposed in the embodiments of the present application, and the implementation process may refer to the description of the corresponding part of the method embodiment above.
[0184] In the embodiments of the present application, the host memory 92 may include storage media such as floppy disks, read-only memory (ROM), random access memory (RAM, which may also be referred to as main memory), magnetic disks, or optical disks. In the embodiments of the present application, the main memory, as the host memory, may be used to store the centroids corresponding to each graph to be searched. The host processor 91 may include any one or more of processors such as a central processing unit (CPU), an APU (Accelerated Processing Unit, which integrates a CPU and a GPU), and a SoC (System on Chip, used for embedded systems).
[0185] It should be understood that Figure 9 the structure of the host shown does not constitute a limitation on the host in the embodiments of the present application. In actual applications, the host may include more or fewer components than Figure 9 shown, or combine some components, and no detailed examples are given in this application.
[0186] Refer to Figure 10, which is a schematic structural diagram of a data search processing system provided by an embodiment of the present application. This data search processing system can be applied to computer devices, such as Figure 10 As shown, the system may include: a host 101, a hardware accelerator 102, and an external memory 103, where:
[0187] The external memory 103 may include multiple storage areas for storing corresponding graphs to be searched in different storage areas, ensuring data access isolation for each graph to be searched; the graphs to be searched are constructed for query scenarios; wherein, each storage area exclusively occupies at least one communication channel to support the hardware accelerator 102 to parallelly implement search tasks for multiple graphs to be searched.
[0188] The host processor in the host 101 can be used to obtain a query vector; obtain the centroids of each graph to be searched; determine the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid; and send a query request, where the query request includes the query vector and the number of candidate vectors. The composition structure of the host 101 can be in accordance with the relevant description of the host embodiment above.
[0189] The hardware accelerator 102 is used to receive the query request, distribute the query request to different search units, and respectively perform candidate vector search on the corresponding graphs to be searched in the external memory 103 through different search units.
[0190] Regarding the implementation process of the data search processing method on each side of the host processor and the hardware accelerator 102, reference can be made to the description of the corresponding side embodiment, and this embodiment will not be elaborated here.
[0191] In some embodiments, the hardware accelerator 102 can be an FPGA or other accelerators supporting parallel computing capabilities. The host processor of the host 101 communicates with the hardware accelerator 102 through a CXL interface. The external memory 103 may include HBM (CXL extended memory), 3D stacked DRAM (non-HBM), other new non-volatile memories with high bandwidth potential, or optical interconnection memories, etc., which can be flexibly configured or adjusted according to actual needs.
[0192] Taking the external memory 103 such as HBM as an example, the present application can utilize multiple communication channels for concurrent memory read and write provided by HBM, which respectively correspond to different storage areas divided in the HBM. After the distribution unit distributes the query requests to each search unit, each search unit accesses the graph to be searched in the corresponding storage area in parallel through an independent communication channel. In the graph to be searched, candidate vectors are filtered according to the number of candidate vectors corresponding to the graph to be searched, and an initial search result in a preset data format is output, which is composed of, for example, the query identifier of the query vector (such as the id of the query vector), an array composed of each candidate vector from the graph to be searched, and an array of similarity degrees corresponding to each candidate vector, which are concatenated together.
[0193] After each search unit feeds back its respective initial search result to the merging unit, the arrays of each candidate vector are merged, and sorted according to the corresponding similarity degrees, and k candidate vectors with higher similarity degrees are selected as target vectors. The target vectors are fed back to the host processor and used as the query result of the query vector to be fed back to the user. It can be seen that the hardware accelerator 102 of the present application, according to the number of candidate vectors corresponding to each graph to be searched received, by configuring the behavior of the search units corresponding to the graphs to be searched, without modifying or reconstructing the hardware architecture, improves the flexibility and maintainability of the system. For example, in the case where the graph to be searched in the query scenario increases or decreases, the storage area of the external memory 103 can be directly adjusted, and the corresponding search units in the hardware accelerator 102 can be dynamically configured, so as to implement the data search processing method for each adjusted graph to be searched.
[0194] It should be understood that Figure 10 the shown system structure does not constitute a limitation to the data search processing system in the embodiments of the present application. In practical applications, the system may include more components than Figure 10 those shown, or combine some components. For example, in the case where the computer device is a terminal device, the data search processing system may further include at least one input component such as a touch sensing unit for sensing touch events on the touch display panel, a keyboard, a mouse, a camera, a pickup, etc.; at least one output component such as a display, a speaker, a vibration mechanism, a lamp, etc.; an antenna; a sensor module; a power module, etc. The hardware structure can be determined according to the type of the terminal device and its functional requirements, and the present application does not list them one by one here.
[0195] In addition, it should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the attached drawings of the device embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines.
[0196] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware. Of course, it can also be implemented by dedicated hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structures used to implement the same function can also be various, such as analog circuits, digital circuits or dedicated circuits. However, for this application, in more cases, software program implementation is a better implementation method. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disc of a computer, and includes several instructions to enable a computer device (which can be a personal computer, training device, or network device, etc.) to execute the methods described in various embodiments of this application.
[0197] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this application are generated in whole or in part. The computer can be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can store or a data external storage such as a training device or a data center that integrates one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).
Claims
1. A data search and processing method, applied to a host processor, the method comprising: Obtaining a query vector; Obtaining the centroid of each graph to be searched; The graph to be searched is constructed for a query scenario; Determining the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid; Sending a query request; the query request includes the query vector and the number of candidate vectors.
2. The method according to claim 1, wherein the obtaining the centroid of each graph to be searched includes any one of the following: Reading the centroid of each graph to be searched from the host memory; In response to the centroid calculation request of each graph to be searched, accessing the corresponding graph to be searched in the external memory, and calculating the centroid of the graph to be searched according to the node vectors of the graph to be searched.
3. The method according to claim 1, wherein the determining the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid includes: Obtaining the similarity between the query vector and each of the centroids; Determining the number of candidate vectors of each graph to be searched according to the similarity.
4. The method according to claim 3, wherein the determining the number of candidate vectors of each graph to be searched according to the similarity includes: Determining the candidate vector search ratio of each graph to be searched according to the similarity; Determining the total number of candidate vectors of each graph to be searched according to the number of target vectors corresponding to the query vector; Grouping the total number of candidate vectors according to the candidate vector search ratio, and determining the number of candidate vectors of each graph to be searched.
5. The method according to claim 4, wherein the determining the total number of candidate vectors of each graph to be searched according to the number of target vectors corresponding to the query vector includes: Obtaining the number of target vectors corresponding to the query vector; Determining a search adjustment coefficient according to the search requirement corresponding to the query vector; The search adjustment coefficient is greater than or equal to 1; Determining the total number of candidate vectors of each graph to be searched according to the number of target vectors and the search adjustment coefficient.
6. The method according to claim 3, wherein: The similarity includes the distance or similarity value between the corresponding centroid and the query vector.
7. The method according to any one of claims 1-6, wherein constructing the graph to be searched for a query scenario includes: Before obtaining the query vector, partitioning and constructing a plurality of graphs to be searched according to the dataset to be searched under the query scenario; Or, splitting the target graph under the query scenario to obtain a plurality of graphs to be searched; Storing each of the graphs to be searched in different storage areas in the external memory.
8. The method according to any one of claims 1-6, wherein the sending the query request includes any one of the following: Simultaneously sending query requests corresponding to each of the graphs to be searched one by one; the number of candidate vectors included in each query request is the number of candidate vectors of the corresponding graph to be searched; Sending a single query request for all the graphs to be searched; the number of candidate vectors included in the query request is the number of candidate vectors corresponding to each of the graphs to be searched.
9. A data processing method, applied to a hardware accelerator, the method comprising: Receiving a query request; The query request includes a query vector and the number of candidate vectors of the graph to be searched, and the number of candidate vectors is determined according to the query vector and the centroid corresponding to the graph to be searched; Distributing the query request to different search units of the hardware accelerator; Performing candidate vector search on the corresponding graph to be searched in the external memory through different search units.
10. A host, comprising a host processor and a host memory, wherein: The host memory is used for storing a plurality of computer instructions; The host processor is used for loading and executing the plurality of computer instructions to implement the following steps: Obtaining a query vector; Obtaining the centroid of each graph to be searched; The graph to be searched is constructed for a query scenario; Determining the number of candidate vectors of the corresponding graph to be searched according to the query vector and the centroid; Sending a query request; the query request includes the query vector and the number of candidate vectors.
Citation Information
Patent Citations
Data search method and device, electronic equipment, storage medium and program product
CN118193195A
Vector indexing method and device based on distributed database and electronic equipment
CN118796837A
Large-scale data search method and device for DRAM (Dynamic Random Access Memory) in-memory calculation, memory, readable storage medium and program product
CN119576997A
Cited By
Graph vector index construction method and device based on GPU and storage medium
CN121807861A