Search method and related device

By using the index map quantized with the first precision when FPGA accelerates ANNS, the target cluster is determined using the index map quantized in the first precision and searching in the target cluster, the problem that memory read bandwidth in the FPGA accelerates ANNS is a performance bottleneck, and the effect of improving query speed and accuracy is achieved.

CN119782589APending Publication Date: 2025-04-08LENOVO (BEIJING) LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411958737.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

When FPGA accelerates ANNS, it is necessary to store massive data from the index graph in memory, resulting in memory reading bandwidth becoming a performance bottleneck and affecting query speed.

Method used

By determining the target cluster in the index graph of the first precision quantization and searching in the target cluster with the setting of N-bit search accuracy, a candidate set matching the query vector is obtained, and the amount of data read by memory is reduced.

Benefits of technology

It effectively reduces the memory read bandwidth, improves query speed, and ensures search accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782589A_ABST
    Figure CN119782589A_ABST
Patent Text Reader

Abstract

The present application discloses a search method and related devices, which relate to the field of information processing, including: obtaining a query vector; determining a target cluster in an index map quantized by a first precision according to the query vector, wherein the target cluster includes a plurality of vector nodes having an associated relationship, the index map quantized by the first precision includes at least two clusters, and the distance between the target cluster and the query vector is less than the distance between a non-target cluster and the query vector in the index map quantized by the first precision; searching at least in the target cluster with a set search precision of N bits to obtain a candidate set matching the query vector, wherein the candidate set includes candidate vector nodes, and the value of N is a positive integer less than 5.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing, and in particular to a search method and related devices. Background Art

[0002] Querying in massive data for query content is a basic task in many fields. We can use the high-order space to search for several closest points to a given query point. Among them, graph-based approximate nearest neighbor search (ANNS) is a technology that uses graph structure to accelerate high-dimensional data search. This method can significantly reduce the search path and calculation amount in large-scale data sets, and has excellent performance in query speed and query accuracy. It is currently widely used in various massive data search scenarios.

[0003] Compared with software-implemented ANNS, parallel acceleration of high-dimensional data calculations through hardware such as FPGA (Field-Programmable Gate Array) can achieve greater query per second (QPS) and lower processing latency.

[0004] However, implementing ANNS through FPGA acceleration will also face similar problems as software implementation, that is, the massive data of the index graph needs to be stored in the memory and used for search and reading in each calculation iteration, which requires a high memory reading bandwidth. This also leads to the fact that the computing power advantages of hardware acceleration such as FPGA cannot be effectively utilized, and the reading bandwidth of memory data becomes the performance bottleneck of the entire system, resulting in low query speed. Summary of the invention

[0005] The first aspect of the present application provides a search method, comprising:

[0006] Get query vector;

[0007] According to the query vector, determine a target cluster in an index graph quantized by a first precision, wherein the target cluster includes a plurality of vector nodes having an associated relationship, the index graph quantized by the first precision includes at least two clusters, and a distance between the target cluster and the query vector is less than a distance between a non-target cluster and the query vector in the index graph quantized by the first precision;

[0008] A search is performed at least in the target cluster with a set search precision of N bits to obtain a candidate set matching the query vector, wherein the candidate set includes candidate vector nodes, and the value of N is a positive integer less than 5.

[0009] In a possible implementation, the step of searching at least in the target cluster with a set search accuracy of N bits to obtain a candidate set matching the query vector includes:

[0010] Storing the target cluster in local memory;

[0011] For the query vector, at least the target cluster in the memory is searched with a set search precision of N bits to obtain a candidate set.

[0012] In a possible implementation, determining the target cluster in the index map quantized with the first precision according to the query vector includes:

[0013] Determine information of each cluster in the locally stored index map quantized by the first precision;

[0014] Determine, according to the information of the cluster and the query vector, the distance between each cluster in the index graph quantized with the first precision and the query vector;

[0015] A target cluster is determined in the index map quantized with the first precision according to the distance.

[0016] In a possible implementation, searching the query vector at least in the target cluster in the memory with a search accuracy of N bits to obtain a candidate set includes:

[0017] For the query vector, searching the target cluster in the memory with a set N-bit search precision to obtain a first sequence;

[0018] If the vector node part required for this search is not in the target cluster, searching in the index graph quantized by the first precision according to the query vector with an N-bit search precision, to obtain a second sequence; combining the vector nodes in the first sequence with the vector nodes in the second sequence to obtain a candidate set;

[0019] If all the vector nodes required for this search are in the target cluster, the vector nodes in the first sequence are used as a candidate set.

[0020] In a possible implementation, the step of searching at least in the target cluster with a set search accuracy of N bits to obtain a candidate set matching the query vector includes:

[0021] Searching in the target cluster with a set N-bit search accuracy to obtain a first candidate sequence;

[0022] If the first candidate sequence only includes the third sequence determined by sorting, taking the first candidate sequence as a candidate set, the third sequence includes at least two vector nodes;

[0023] If the first candidate sequence includes a third sequence with a determined order and a fourth sequence with an undetermined order, the search accuracy is improved, and a second candidate sequence is obtained by searching in an index graph quantized by a second accuracy based on each vector node in the fourth sequence based on the improved search accuracy, wherein the fourth sequence includes at least two vector nodes, and the distance between each vector node in the fourth sequence and the query vector is the same and is less than the distance between the vector node in the third sequence and the query vector, and the improved search accuracy is S times the N-bit search accuracy, where S is an integer greater than 2, and the second accuracy is higher than the first accuracy; until a candidate sequence containing only the third sequence is obtained; and the third sequences in each candidate sequence are combined to obtain a candidate set.

[0024] In a possible implementation, before obtaining the query vector, the process further includes:

[0025] Get the current query strategy;

[0026] Accordingly, after obtaining the query vector, it includes:

[0027] According to the query strategy being the first strategy, executing the step of determining the target cluster in the index graph quantized with a first precision according to the query vector;

[0028] Based on the query strategy being the second strategy, a candidate set matching the query vector is obtained by searching in an index graph quantized by a target precision according to the query vector, and the target precision is higher than any non-target precision.

[0029] In a possible implementation, the method further includes:

[0030] Based on the index graph quantized by the target precision, the candidate vector nodes in the candidate set are sorted to obtain search results, and the target precision is higher than the first precision.

[0031] A second aspect of the present application provides a search device, including:

[0032] A first interface, used to receive a query vector;

[0033] A second interface is used to transmit information with an external memory;

[0034] A processor is used to determine a target cluster in an index map quantized by a first precision based on the query vector, the target cluster includes a number of vector nodes with an associated relationship, the index map quantized by the first precision includes at least two clusters, and the distance between the target cluster and the query vector is less than the distance between the non-target cluster and the query vector in the index map quantized by the first precision; requesting the storage structure through the second interface to set an N-bit search precision to search at least in the target cluster to obtain a candidate set matching the query vector, the candidate set including if the candidate vector node, the value of N is a positive integer less than 5.

[0035] In a possible implementation, the method further includes:

[0036] A memory, used for storing a target cluster obtained from an external memory, wherein the target cluster is obtained by requesting the external memory through a second interface;

[0037] Accordingly, the processor is used to search the query vector at least in the target cluster in the memory with a search accuracy of N bits to obtain a candidate set.

[0038] A third aspect of the present application provides a computer program product, comprising computer-readable instructions, which, when executed on an electronic device, enables the electronic device to implement the search method of the first aspect or any implementation of the first aspect.

[0039] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0040] The memory is used to store computer programs;

[0041] The processor is used to execute the computer program so that the electronic device can implement the search method of the above-mentioned first aspect or any implementation manner of the first aspect.

[0042] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the search method of the above-mentioned first aspect or any implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0044] Figure 1It is a flowchart of a search method provided in an embodiment of the present application;

[0045] Figure 2 The embodiment of the present application provides that the search precision of N bits is set to search at least in the target cluster to obtain a candidate set matching the query vector;

[0046] Figure 3 It is a schematic diagram of a process of determining a target cluster in a first precision quantized index map according to the query vector provided by an embodiment of the present application;

[0047] Figure 4 It is a flowchart provided by an embodiment of the present application of searching the target cluster at least in the memory for the query vector with an N-bit search accuracy to obtain a candidate set;

[0048] Figure 5 It is a schematic diagram of the mainboard structure provided in the embodiment of the present application;

[0049] Figure 6 It is a flowchart of setting N-bit search accuracy to search at least in the target cluster to obtain a candidate set matching the query vector provided by an embodiment of the present application;

[0050] Figure 7 is a scenario diagram of the search method provided in an embodiment of the present application;

[0051] Figure 8 is a structural schematic diagram of a search device provided in an embodiment of the present application;

[0052] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0054] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0055] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0056] Figure 1 It is a flowchart of a search method provided in an embodiment of the present application, which may include steps 101 to 103, and these steps are described in detail below.

[0057] 101. Obtain a query vector;

[0058] The query vector is a high-dimensional vector, which converts the query request into a vector form, and contains the entire content of the query request.

[0059] In a possible implementation, the query request statement is converted into a vector form to obtain the query vector.

[0060] 102. According to the query vector, determine a target cluster in an index graph quantized with a first precision, wherein the target cluster includes a plurality of vector nodes having an associated relationship, the index graph quantized with the first precision includes at least two clusters, and a distance between the target cluster and the query vector is less than a distance between a non-target cluster in the index graph quantized with the first precision and the query vector;

[0061] The first precision quantized index graph includes a plurality of clusters, each cluster includes a plurality of vector nodes having an associated relationship, and each vector node corresponds to a piece of information.

[0062] The index graph of the first precision quantization is pre-clustered to obtain a plurality of clusters, and the vector nodes in each cluster have an association relationship.

[0063] In the first precision quantization index map, the distance between each cluster and the query vector is determined based on the cluster, and the cluster with the smallest distance to the query vector is determined as the target cluster.

[0064] In a possible implementation, each cluster has a center, and the distance between the cluster and the query vector is calculated by calculating the distance between the center of the cluster and the query vector.

[0065] In the vector space, the distance between vectors represents the similarity between the two vectors. The smaller the distance, the higher the similarity. Therefore, in this embodiment, in the index map quantized with the first precision, the cluster with the smallest distance to the query vector is determined as the target cluster.

[0066] In a possible implementation, the information of each cluster in the first precision quantized index map can be recorded in advance, so as to use the information of the cluster to calculate the distance between the cluster and the query vector. Figure 3 The process of determining the target cluster is described in detail in .

[0067] 103. Search at least in the target cluster with a set search accuracy of N bits to obtain a candidate set matching the query vector, where the candidate set includes candidate vector nodes, and the value of N is a positive integer less than 5.

[0068] The set N-bit search precision is the search precision corresponding to the index map quantized with the first precision, and the search precision is a smaller search precision.

[0069] For example, when the value of N is 1, a search is performed in the target cluster with a search accuracy of 1 bit to obtain multiple vector nodes matching the query vector. The multiple vector nodes constitute a candidate set.

[0070] Among them, since the target cluster is the cluster with the smallest distance to the query vector in the index graph quantized with the first precision, when the query vector uses ANNS, there is a high probability that the corresponding vector node will be queried from the target cluster. Therefore, in this embodiment, at least the target cluster is searched to obtain the candidate set.

[0071] In a possible implementation, the number of candidate vector nodes included in the candidate set may be predefined, and a set number of candidate vector nodes matching the query vector may be obtained by screening.

[0072] Generally, a set number of vector nodes whose distances to the query vector are sorted from small to large are used as candidate vector nodes.

[0073] In a possible implementation, the target cluster can be first saved locally, and then searched from the local memory. Figure 2 This process is described in detail in .

[0074] In this embodiment, the index map of the first precision quantization includes multiple clusters, each cluster contains a number of vector nodes with an associated relationship. After obtaining the query vector, the target cluster with the shortest distance from the query vector is determined in the index map of the first precision quantization, and then a search is performed at least in the target cluster with a set N-bit search precision to obtain a candidate set matching the query vector. The N-bit search precision is a smaller search precision. During the search process, the cluster level is first screened to reduce the search range, and then the target cluster is searched with N-bit search precision to ensure the search accuracy. This search process ensures query accuracy while improving query speed.

[0075] Figure 2 The present application provides a flowchart of setting N-bit search accuracy to search at least in the target cluster to obtain a candidate set matching the query vector, which may include steps 201 to 202. These steps are described in detail below.

[0076] 201. Store the target cluster in local memory;

[0077] After the target cluster is determined, the determined target cluster is stored in the local memory.

[0078] Among them, the structure for executing this solution can be FPGA. Since the memory of FPGA is small, it can only store information with a small amount of data. Therefore, in this embodiment, the target cluster in the index map quantized with the first precision is stored in the on-chip memory of FPGA, providing a basis for subsequent local fast search.

[0079] In a possible implementation, the local memory may be an on-chip RAM (Random Access Memory) of the FPGA.

[0080] The local memory stores the target cluster in the index map quantized with the first precision, and does not store the relevant information of the index maps quantized with other precisions.

[0081] 202. For the query vector, search at least the target cluster in the memory with a set search accuracy of N bits to obtain a candidate set.

[0082] Among them, for the query vector, a search is performed in the target cluster stored in the memory, and most of the search process is executed locally. When the hardware device adopts FPGA, the search is performed locally in the FPGA, and the computing power advantage of FPGA hardware acceleration is used to improve the search speed.

[0083] Here, searching the target cluster in the memory with a set N-bit search accuracy achieves the same search accuracy as searching in the memory storing the index map.

[0084] The target cluster includes a number of vector nodes with associated relationships. For the query vector, a search in the target cluster can obtain a number of vector nodes matching the query vector.

[0085] Among them, any one of the multiple vector nodes matching the query vector may only match part of the dimensions of the query vector, and the combination of multiple vector nodes matches the query vector as a whole.

[0086] In a possible implementation, the cluster center is used as a starting navigation point for search iteration to obtain a candidate set.

[0087] In a possible implementation, the search may be first performed in the locally stored target cluster. If the vector node part required for the search is not in the target cluster, the search may be performed in the index graph quantized with the first precision. Figure 4 This process is described in detail in .

[0088] In a possible implementation, the target cluster is searched with a set search accuracy. If the order of multiple vector nodes in the candidate sequence obtained by the query is uncertain, a query can be performed in a higher precision quantized index graph with a higher search accuracy to determine the order of the vector nodes with uncertain order. Figure 6 This process is described in detail in .

[0089] In this embodiment, the determined target cluster is stored in the local memory. For the query vector, the target cluster is searched at least in the memory with a search accuracy of N bits set to obtain a candidate set, thereby transferring the search process to the local execution and utilizing the computing power advantage of FPGA hardware acceleration to improve the search speed.

[0090] Figure 3 This is a flow chart of determining a target cluster in a first precision quantized index map according to the query vector provided by an embodiment of the present application, which may include steps 301 to 303, and these steps are described in detail below.

[0091] 301. Determine information of each cluster in the locally stored first-precision quantized index map;

[0092] The vectors in the index graph quantized with the first precision are clustered in advance to obtain a plurality of clusters, each of which contains a plurality of vector nodes having an associated relationship.

[0093] The information of each cluster in the index map quantized with the first precision is pre-stored locally, so that after receiving the query vector, the target cluster can be directly determined by using the information of the cluster stored locally, thereby improving the query efficiency.

[0094] In a possible implementation, the information of each cluster includes identity information of each cluster and center information of each cluster.

[0095] 302. Determine the distance between each cluster in the first precision quantized index graph and the query vector according to the information of the cluster and the query vector;

[0096] In the high-dimensional vector space, the distance between the information of each cluster and the query vector is calculated. The distance represents the similarity between each cluster and the query vector. The more similar they are, the smaller the distance is, and vice versa.

[0097] The cluster information represents the corresponding cluster in the first precision quantization index map. Accordingly, based on the cluster information and the query vector, the distance between the cluster corresponding to the cluster information and the query vector can be determined.

[0098] In a possible implementation, the distance between each cluster center information and the query vector may be used to represent the distance between each cluster and the query vector, and the distance is made to correspond to the cluster identity information.

[0099] The cluster center information may be a specific number of vector nodes belonging to the cluster center, and the cluster center information is a feature that can characterize the cluster to which it belongs.

[0100] 303. Determine a target cluster in the first precision quantized index map according to the distance.

[0101] According to the distance between each cluster and the query vector in the index graph of the first quantization accuracy, the similarity between each cluster and the query vector can be determined, and a target cluster with the highest similarity can be selected.

[0102] After obtaining the distances between each cluster and the query vector, the distances may be sorted to determine the smallest distance, and the cluster corresponding to the smallest distance is used as the target cluster.

[0103] The center information of each cluster is an attribute that can characterize the cluster to which it belongs. It is possible to first determine whether it contains the query vector based on the center information, and calculate the distance between it and the query vector to determine the cluster that contains the query vector and is closest to the query vector.

[0104] After the target cluster is determined, the target cluster is used as the target cluster in the entire process of querying the query vector, and the target cluster of the query will not be changed.

[0105] In this embodiment, first, the information of each cluster in the first precision quantized index map stored locally is determined; then, based on the information of each cluster and the query vector, the distance between each cluster in the first precision quantized index map and the query vector is determined; finally, based on the distance, the target cluster is determined in the first precision quantized index map, thereby achieving the goal of determining a cluster of vector nodes in the massive vector nodes in the index map, and subsequently mainly performing queries in this cluster of vector nodes, thereby reducing the difficulty of queries and improving query efficiency.

[0106] Figure 4 The embodiment of the present application provides a flowchart for setting N-bit search accuracy to search the target cluster at least in the memory for the query vector to obtain a candidate set, which may include steps 401 to 404. These steps are described in detail below.

[0107] 401. Search the target cluster in the memory with a set N-bit search precision for the query vector to obtain a first sequence;

[0108] Among them, for the search of the index map quantized with the first precision, the search precision of N bits is set. Correspondingly, the target cluster in the memory is a part of the index map quantized with the first precision, and the search for the target cluster is also performed with the search precision of N bits set.

[0109] Here, for the query vector, a search is performed in the target cluster in the memory with an N-bit search accuracy set to obtain multiple vector nodes matching the query vector.

[0110] Among them, the cluster center of the target cluster can be used as the navigation point of the search. Starting from the navigation point, the distances between each vector node of the cluster and the query vector are determined in sequence according to the order of direct connection and indirect connection of the cluster center, and the determined distances are used to sort each vector node in order from high to low to obtain a first sequence.

[0111] In a possible implementation, the iterative search method uses the center of the target cluster as the starting navigation point, searches for a specific number of vector nodes adjacent to the navigation point, determines the distance between each adjacent vector node and the query vector, and the distance between the target cluster bus and the query vector, and sorts the navigation point and adjacent nodes of this search from small to large according to the distance to the query vector to obtain a sequence, obtains a candidate set, and completes one round of iteration; the next iterative process is generally based on the vector node with the smallest distance determined in the previous iterative process as the navigation point, searches for adjacent vector nodes around the navigation point, sorts the navigation point and adjacent nodes of this search from small to large to obtain another sequence, and further sorts the sequence with the sequence determined in the historical search process until the iterative search is completed, and the final sequence is determined as the candidate set.

[0112] If the vector node with the smallest distance determined in this iteration is the same as the vector node with the smallest distance determined in the historical search process, the vector node with the second smallest distance is determined as the navigation point for the next iteration, and the iterative search process is repeated in this way.

[0113] The iterative search termination condition may be that the number of iterative searches reaches a preset limit on the number of iterations, or that the candidate set obtained by the search approaches the query vector. This application does not impose any restrictions on the termination condition.

[0114] The search range may be preset, for example, the number of vector nodes to be searched in each iteration.

[0115] 402. If the vector nodes required for the current search are not in the target cluster, search the index graph quantized with the first precision for the vector nodes required for the current search and not in the target cluster according to the query vector and with N-bit search precision set to obtain a second sequence.

[0116] In the search process, since a search range is set for each search, the search range may be the number of vector nodes involved in the current search.

[0117] Among them, in this search process, the navigation point is used as a reference to search for each vector node within the search range adjacent to the navigation point. Since the search process selects the vector node closest to the query vector obtained in the previous search, after multiple iterative searches, the navigation point of this search may be close to the edge of the target cluster. This results in that in this search process, the number of vector nodes adjacent to the vector node serving as the navigation point in the target cluster cannot reach the set number of vector nodes. There are only some vector nodes required for this search in the target cluster, and the search process cannot be completed by searching only in the target cluster.

[0118] Therefore, if only part of the vector nodes required for this search are in the target cluster, and the first precision quantization index graph to which the target cluster belongs contains all the vector nodes required for this search, the vector nodes not included in the target cluster can continue to be searched in the first precision quantization index graph.

[0119] The vector nodes searched in the index graph quantized with the first precision are sorted according to their distances from the query vector to obtain a second sequence, which may include one or more vector nodes.

[0120] The first precision quantized index map is stored in a storage structure outside the FPGA, and the storage structure may be a DDR SDRAM (Double Data Rate Synchronous Dynamic Random Access Memory) onboard the FPGA.

[0121] Among them, a search request can be generated based on the query vector and the navigation point of this query to request to search for the corresponding vector node based on the first precision quantized index map in the DDR when using ANNS, and receive the retrieved vector nodes fed back by the DDR side. The vector nodes are sorted from small to large according to the distance to obtain a second sequence.

[0122] Accordingly, the DDR side may exclude the range of the target cluster in the index map quantized by the first precision, search the query vector according to the navigation point of this query, and obtain multiple vector nodes and the distance between each vector node and the query vector.

[0123] Since only the query vector is used to search for some vector nodes adjacent to the navigation point in the first precision quantized index map in DDR, the search involves less data than searching for all vector nodes adjacent to the navigation point in the first precision quantized index map. The bandwidth required for searching in the first precision quantized index map is smaller, thereby improving query efficiency.

[0124] 403. Combine the vector nodes in the first sequence and the vector nodes in the second sequence to obtain a candidate set;

[0125] The vector nodes in the first sequence obtained by searching the target cluster in the local memory and the vector nodes in the second sequence combination obtained by searching the index graph quantized by the first precision are combined to obtain a candidate set of the query vector.

[0126] In a possible implementation, the vector nodes in the two sequences are arranged in order from small to large according to the distance, and a set number of vector nodes are determined therefrom to obtain a candidate set.

[0127] In a possible implementation, the second sequence contains the same vector nodes as those in the first sequence, and the vector nodes may be deduplicated, and the vector nodes use the smaller distance between the two sequences.

[0128] In a possible implementation, the number of vector nodes may be set for the candidate set.

[0129] As an example, the set number of candidate sets is 100, the obtained first sequence includes 150 vector nodes, and the second sequence may include 100 vector nodes. When the vector nodes in the first sequence and the vector nodes in the second sequence are combined, 100 vector nodes are determined as the candidate set.

[0130] 404. If all the vector nodes required for this search are in the target cluster, the vector nodes in the first sequence are used as a candidate set.

[0131] If the query vector is searched in the target cluster, the target cluster contains all the vector nodes required for this search, indicating that the query for the query vector only needs to be searched in the target cluster, and no search is required in the index graph quantized with the first precision.

[0132] Each vector node in the first sequence is used as a candidate set.

[0133] Figure 5 : is a schematic diagram of the mainboard structure provided in an embodiment of the present application, the mainboard includes an FPGA 501 and an onboard DDR 502, the FPGA can interact with the onboard DDR. The memory on the FPGA uses an on-chip RAM, the on-board DDR stores at least a first precision quantized index map, and the on-chip RAM stores a target cluster in the first precision quantized index map.

[0134] Wherein, after receiving the query vector and determining the target cluster using the query vector, FPGA501 downloads the target cluster from the onboard DDR and saves it into the on-chip RAM. The onboard DDR saves the complete first-precision quantized index map.

[0135] In this embodiment, with a search precision of N bits set, a search is performed for a target cluster of a query vector in a memory to obtain a first sequence. If part of the vector nodes required for this search are not in the target cluster, based on the query vector, with a search precision of N bits set, a search is performed in an index map quantized with a first precision for vector nodes required for this search and not in the target cluster to obtain a second sequence. The vector nodes in the first sequence are combined with the vector nodes in the second sequence to obtain a candidate set. If all the vector nodes required for this search are in the target cluster, the vector nodes in the first sequence are used as a candidate set. Compared with performing the entire search in an index map quantized with a first precision using a query vector, in the search process of this embodiment, most of the data involved in the search process is obtained from the memory, and only a small amount of data needs to be obtained from the complete index map quantized with a first precision. The bandwidth required for searching in the index map quantized with a first precision is smaller, thereby improving the search efficiency while ensuring the integrity of this search.

[0136] Figure 6The present application provides a flowchart of setting an N-bit search accuracy to search at least in the target cluster to obtain a candidate set matching the query vector, which may include steps 601 to 604. These steps are described in detail below.

[0137] 601. Search in the target cluster with a set N-bit search accuracy to obtain a first candidate sequence;

[0138] The search for the index map quantized with the first precision is performed with a set search precision of N bits. Since the target cluster in the memory is part of the index map quantized with the first precision, the search for the target cluster is also performed with a set search precision of N bits.

[0139] Wherein, for the query vector, with a set N-bit search accuracy, a search is performed in the target cluster in the memory to obtain a first candidate sequence consisting of a plurality of vector nodes matching the query vector.

[0140] The vector nodes in the first candidate sequence are sorted from small to large based on the distance to the query vector.

[0141] After obtaining the first candidate sequence, the conditions of the vector nodes contained therein are determined. If the first candidate sequence only contains the third sequence whose order is determined, step 602 is executed; if the first candidate sequence contains the third sequence whose order is determined and the fourth sequence whose order is not determined, steps 603-604 are executed.

[0142] 602. If the first candidate sequence only includes the third sequence determined by sorting, use the first candidate sequence as a candidate set, and the third sequence includes at least two vector nodes;

[0143] The first candidate sequence includes a set number of vector nodes, which are specifically sorted from small to large in terms of distance from the query vector.

[0144] The first candidate sequence is used as a candidate set, and each vector node in the first candidate sequence matches the query vector.

[0145] The sorting is determined by the distance between the vector node at the end of the sorting in the third sequence and the query vector, which is greater than the distance between the vector node after the third sequence.

[0146] In a possible implementation, during the search for the query vector, vector nodes greater than a set number are searched and obtained, and the searched vector nodes are sorted from small to large according to the distance from the query vector, and the set number of vector nodes ranked first are determined, and the other vector nodes are removed to obtain a first candidate sequence.

[0147] As an example, the number is set to 100, and the query vector is searched in the target cluster to obtain 101 vector nodes, which are sorted from small to large according to the distance between the vector nodes and the query node. Among them, the distance between the 101st vector node and the query node is greater than the distance between the 100th vector node and the query node, then the first candidate sequence composed of the first 100 vector nodes is determined as the candidate set.

[0148] 603. If the first candidate sequence includes a third sequence whose order is determined and a fourth sequence whose order is not determined, improve the search precision, and search in the index graph quantized by the second precision based on each vector node in the fourth sequence based on the improved search precision to obtain a second candidate sequence, wherein the fourth sequence includes at least two vector nodes, and the distance between each vector node in the fourth sequence and the query vector is the same and smaller than the distance between the vector node in the third sequence and the query vector, and the improved search precision is S times the N-bit search precision, where S is an integer greater than 2, and the second precision is higher than the first precision; until a candidate sequence including only the third sequence is obtained;

[0149] Among them, in the first candidate sequence obtained by searching the index graph based on the first precision quantization, there may be a situation where the distances between multiple vector nodes and the query vector are the same, but in fact the actual distances between the multiple vector nodes and the query vector are different. The reason why the distances are the same is because the data precision of each vector node in the index graph quantized by the first precision is low. Therefore, it is impossible to accurately determine the distance between each vector node and the query vector. Therefore, a higher precision query is performed in the index graph quantized by the second precision to determine a more accurate distance between the multiple vector nodes and the query vector.

[0150] Among them, if the first candidate sequence includes the third sequence and the fourth sequence, the vector nodes in the first candidate sequence are sorted from small to large according to their distances to the query vector, the fourth sequence is after the third sequence, and the distances between the vector nodes in the fourth sequence and the query vector are the same.

[0151] Among them, the number of vector nodes included in the third sequence is less than the set number of vector nodes included in the candidate set, and the sum of the number of vector nodes included in the third sequence and the fourth sequence is greater than the set number. The first candidate sequence cannot directly determine the candidate set, and the boundary of the first candidate sequence cannot be accurately sorted.

[0152] Therefore, the search accuracy is improved, and a search is performed in the index map quantized by the second precision with a higher bit search accuracy. Since the order cannot be determined only by the vector nodes included in the fourth sequence, the search can be performed only based on the vector nodes included in the fourth sequence to determine their order.

[0153] The improved search accuracy is a specific multiple of the N-bit search accuracy, and the value of S can be 4 times, 8 times, 16 times, 32 times, etc.

[0154] As an example, the set number of candidate vector nodes in the candidate set is 100. The query vector is searched in the target cluster to obtain 120 vector nodes, which are sorted from small to large according to the distance between the vector nodes and the query node. Among them, the distance between the 89th vector node and the query node is less than the distance between the 90th vector node and the query node, and the distance between the 90th vector node and the query node to the 120th vector node and the query node are the same, then the first 89 vector nodes are determined as the third sequence, and the 90th to 120th vector nodes are determined as the fourth sequence.

[0155] In a possible implementation, the index map of the second precision quantization and the index map of the first precision quantization may be stored in the same storage structure, such as FPGA onboard DDR.

[0156] In one possible implementation, since the storage space of the onboard DDR is limited and the storage space required for the high-precision quantized index map is huge, the high-precision quantized index map can be stored in a remote memory pool through CXL (Compute Express Link) technology to meet the needs of ultra-large-scale vector ANNS.

[0157] Since the data of the first-precision quantized index map is relatively small, the full-precision quantized index map, which is rarely accessed but has a huge amount of data, is cached in the local DDR4 or remote memory pool, achieving a balance between high efficiency and ultra-large scale.

[0158] In a possible implementation, the storage structure also stores at least one index map quantized with a higher precision than the second precision. When the fourth sequence also exists in the second candidate sequence searched in the second precision quantized index map, the vector nodes in the fourth sequence in the second candidate sequence are used to further search according to the index map quantized with a third precision to obtain the sorting of the vector nodes in the fourth sequence in the second candidate sequence, and obtain the third candidate sequence, and so on, until a candidate sequence containing only the third sequence is obtained.

[0159] As an example, the index graph includes 20,000 vector nodes, and the candidate set requires 150 vector nodes. The query vector is searched in the target cluster through the index graph of the first quantization accuracy to obtain 170 vector nodes, which are sorted from small to large according to the distance between the vector node and the query node. Among them, the sorting of the first 120 vector nodes is determined, and their distances with the query node are all less than the distance between the 121st vector node and the query node, and the distances between the 121st to 170th vector nodes and the query node are the same. The 121st to 170th vector nodes are searched using the data in the index graph of the second quantization accuracy, and the 121st to 170th vector nodes are sorted to obtain the order of the 121st to 148th vector nodes. However, the distances between the 149th to 153th vector nodes and the query node are the same, and the sorting of these four vector nodes cannot be determined. The data in the index graph of the third quantization accuracy is further searched, and the 149th to 153th vector nodes are sorted to obtain the order of the 149th to 153th vector nodes.

[0160] 604. Combine the third sequences in the candidate sequences to obtain a candidate set.

[0161] Among them, after searching the index graph with two or more levels of precision quantization, a candidate sequence corresponding to each precision quantization index graph search is obtained, and there is a third sequence in each candidate sequence. The third sequences are combined to obtain a candidate set, and the order of each vector node in the candidate set is determined.

[0162] As an example, the ordering of the 1st to 120th vector nodes is determined by searching the index graph of the first quantization precision, the ordering of the 121st to 148th vector nodes is determined by searching the index graph of the second quantization precision, and the ordering of the 149th to 150th vector nodes is determined by searching the index graph of the third quantization precision. The above orderings are combined to obtain the 1st to 150th candidate vector nodes in the candidate set.

[0163] Since a lower precision quantized index graph is first used for query, the efficiency of vector search is improved. Moreover, a higher precision quantized index graph is used to calculate the rearrangement at the boundary of the candidate sequence obtained by the search to ensure the correctness of the search results, thereby improving the query efficiency without losing the result recall rate.

[0164] In a possible implementation, each candidate vector node in the candidate set retains the distance calculation result under its corresponding quantization precision.

[0165] As an example, the 1st to 90th candidate vector nodes are determined in the index map of first precision quantization, and their distances from the query vector in the index map of first precision quantization are recorded; the 91st to 97th candidate vector nodes are determined in the index map of second precision quantization, and their distances from the query vector in the index map of second precision quantization are recorded; the 98th to 100th candidate vector nodes are determined in the index map of third precision quantization, and their distances from the query vector in the index map of third precision quantization are recorded.

[0166] Among them, when the first-precision quantized index graph is used for search, the ordering of most vector nodes can be determined, and only a small number of vector nodes require high-precision data acquisition and calculation, which significantly reduces the demand for memory bandwidth and computing resources, and provides space for further improving the system's QPS.

[0167] Among them, the range can be defined according to the number of vector nodes. For example, 100 vector nodes are searched in a certain iteration, and 100 vector nodes are added in the next iteration search. The search is performed on the 100 added vector nodes, and the vector node with the smallest distance from the query vector determined by the previous iteration search is used as the navigation point. The vector nodes involved in each iterative search are determined. The vector nodes are the vector nodes adjacent to the navigation point in the high-dimensional vector space.

[0168] In this embodiment, a search is performed in the target cluster with a set N-bit search accuracy to obtain a first candidate sequence; if the first candidate sequence only includes the third sequence determined by sorting, the first candidate sequence is used as a candidate set, and the third sequence includes at least two vector nodes; if the first candidate sequence includes the third sequence determined by sorting and the fourth sequence not determined by sorting, the search accuracy is improved, and a search is performed in an index graph quantized by the second accuracy based on each vector node in the fourth sequence and the improved search accuracy to obtain a second candidate sequence, the fourth sequence includes at least two vector nodes, the distance between each vector node in the fourth sequence and the query vector is the same and less than the distance between the vector node in the third sequence and the query vector, and the improved search accuracy is S times the N-bit search accuracy. S is an integer greater than 2, and the second precision is higher than the first precision; until a candidate sequence containing only the third sequence is obtained; the third sequence in each candidate sequence is combined to obtain a candidate set, and the target cluster is searched based on a lower search precision. If a candidate sequence determined by sorting can be searched, the candidate sequence determined by sorting is used as the candidate set. If the boundary of the obtained candidate sequence cannot be accurately sorted, a higher search precision is used for the vector nodes at the boundary to search in an index map quantized by a higher precision to determine the sorting of the vector nodes at the boundary. In a multi-level quantization manner, the search is performed in the index maps quantized by each precision in order from low to high, and the main search is performed in the index map quantized by low precision, and the search amount in the index map quantized by high precision is small, which greatly reduces the amount of data obtained from the storage structure storing the high precision quantized index map for each query.

[0169] In a possible implementation, before obtaining the query vector, the process further includes:

[0170] Get the current query strategy;

[0171] The current query strategy may be set based on experience.

[0172] As an example, the query strategy to be adopted may be selected according to the data dimension of the query vector.

[0173] The lower the data dimension of the query vector is, the less data is obtained during the query. Therefore, when the dimension of the query vector is less than the set dimension threshold, the second strategy is adopted, otherwise, the first strategy is adopted.

[0174] As an example, the query strategy to be adopted may be selected based on the amount of data contained in the index graph quantified by the target accuracy.

[0175] Among them, the larger the amount of data contained in the index map quantized by the target accuracy, the larger the amount of data obtained during the query. Therefore, when the amount of data contained in the index map quantized by the target accuracy is less than the set data amount threshold, the first strategy is adopted, otherwise, the second strategy is adopted.

[0176] The current query strategy may be the one used in the last search, and the query strategy used in the last search is still used.

[0177] Accordingly, after obtaining the query vector, it includes:

[0178] According to the query strategy being the first strategy, executing the step of determining the target cluster in the index graph quantized with a first precision according to the query vector;

[0179] The first strategy is the search method in the aforementioned embodiment, specifically searching in an index map quantized with multiple levels of precision to determine a candidate set.

[0180] For the explanation of the search process, please refer to the explanation in the aforementioned method embodiment, which will not be repeated in this embodiment.

[0181] The query strategy is the second strategy. According to the query vector, a search is performed in an index graph quantized by a target precision to obtain a candidate set matching the query vector. The target precision is higher than any non-target precision.

[0182] The second strategy is to search only in the index map quantized by the target precision, where the target precision is the highest precision and may also be referred to as full precision, which is higher than the first precision.

[0183] Among them, if the current query strategy is the second strategy, directly based on the query vector, search in the index graph quantized by the target accuracy, and the distance between each vector node and the query vector is the most accurate. Use the distance to sort from small to large, determine the set number of vector nodes, and obtain the candidate set.

[0184] In this embodiment, a query strategy can be set, and different query processes are executed for different query strategies. When the query strategy is the first strategy, a search is performed in an index map quantized with multiple levels of precision to determine a candidate set; when the query strategy is the second strategy, a search is performed only in an index map quantized with the highest precision according to the query vector to obtain a candidate set, thereby implementing different search strategies according to different requirements, and achieving high search flexibility.

[0185] In a possible implementation, after obtaining a candidate set matching the query vector, the following steps are further included:

[0186] Based on the index graph quantized by the target precision, the candidate vector nodes in the candidate set are sorted to obtain a search result, and the target precision is higher than the first precision.

[0187] Among them, the target precision quantization can be the highest precision quantization for the index graph, and the target precision quantization can also be called full precision quantization. The data of each vector node in the index graph of the target precision quantization is the most accurate.

[0188] Among them, the order of each candidate vector node in the candidate set is obtained based on a search of a lower precision quantization index map. Since the data in the index map of the first precision quantization is not precise enough, the order may be inaccurate. Therefore, after obtaining the candidate set, the candidate vector nodes in the subsequent set are reordered based on the index map of the target precision quantization to determine the accurate order of each candidate vector node.

[0189] In one possible implementation, the candidate set can be obtained only based on the index graph quantized by the first precision. During the reordering process, each candidate vector node is searched in the index graph quantized by the target precision to determine the distance between each candidate vector node and the query vector in the index graph quantized by the target precision, and each candidate vector node is sorted according to the distance to obtain the search result.

[0190] In one possible implementation, the candidate set is obtained based on multiple precision quantized index graphs. If it does not involve searching in the target precision quantized index graph, during the reordering process, each candidate vector node is searched in the target precision quantized index graph to determine the distance between each candidate vector node and the query vector in the target precision quantized index graph, and each candidate vector node is sorted according to the distance to obtain the search result.

[0191] In one possible implementation, the candidate set is obtained based on multiple precision quantized index graphs. If it involves searching in the target precision quantized index graph, in the reordering process, in addition to the candidate vector nodes searched in the target precision quantized index graph, the remaining candidate vector nodes are searched in the target precision quantized index graph to determine the distance between the remaining candidate vector nodes in the target precision quantized index graph and the query vector. Based on the distance between the candidate vector nodes searched in the target precision quantized index graph and the query vector and the distance between the remaining candidate vector nodes in the target precision quantized index graph and the query vector, each candidate vector node is sorted to obtain the search result.

[0192] In this embodiment, after the candidate set is determined, the candidate vector nodes in the candidate set are sorted based on the index map quantized by the target precision to obtain the search results. The target precision is higher than the first precision, and at least a preliminary search is performed using the target cluster in the index map quantized by low precision to obtain the candidate set. The bandwidth required during the preliminary search is relatively small, and the candidate vector nodes in the subsequent set are re-sorted using the index map quantized by high precision, so that accurate search results can be obtained, thereby improving the search efficiency while ensuring the accuracy of the search results.

[0193] Figure 7It is a scenario diagram of the search method provided in an embodiment of the present application. The method is applied in an FPGA, on which an on-chip RAM is provided. In this application scenario, a storage structure DDR4 is also provided on the mainboard.

[0194] Among them, the DDR4 stores three precision quantization index maps, namely low-precision quantization index map, medium-precision quantization index map and full-precision quantization index map. In this scenario, the low-precision quantization index map is a 1-bit quantization index map, the medium-precision quantization index map uses an 8-bit quantization index map, and the full-precision quantization index map uses a 32-bit quantization index map.

[0195] Among them, the FPGA adopts AANS search.

[0196] Among them, FPGA receives the query vector, uses the query vector to perform index graph cluster calculation, determines the target cluster, requests the target cluster from DDR4, DDR4 feeds back the target cluster to FPGA, and FPGA stores the received target cluster in the on-chip RAM.

[0197] The FPGA searches the target cluster in the on-chip RAM through ANNS search and searches for the node data corresponding to the query vector. If the target cluster contains all the vector nodes required for this search, the vector nodes corresponding to the query vector are searched and a sequence is generated according to the distance between each vector node and the query vector.

[0198] If the target cluster only contains some of the vector nodes required for this search, after searching the target cluster, continue to query the remaining vector nodes required for this search in the 1-bit quantization index map in DDR4, search the vector nodes obtained in the target cluster and the 1-bit quantization index map, and generate a sequence according to the distance from the query vector.

[0199] Among them, the sequence includes candidate areas and areas to be removed. There is a specific area 701 at the boundary between the candidate area and the area to be removed. The distances between each vector node in the specific area and the query vector are equal. The 8-bit quantized index map is further used to search the distances between each vector node in the specific area and the query vector to achieve query calculation reordering; if the specific area still does not exist after query reordering with the 8-bit quantized index map, the 32-bit quantized index map is further used to perform query calculation reordering to obtain the candidate area with determined sorting.

[0200] The above sorting process is a preliminary search process for vector nodes. Subsequently, all candidate vector nodes in the candidate area need to be re-sorted through the 32-bit quantized index map to obtain the final sorting result.

[0201] Among them, for the query of a certain query vector, multiple iterative query methods can be used to finally obtain the candidate regions that are determined by sorting.

[0202] This solution uses an external storage structure and FPGA on-chip RMA to perform multi-level caching for index maps. The data of a single cluster in the 1-bit quantized index map that needs to be accessed frequently but has a small data volume is cached in the on-chip RAM, while the full-precision quantized index map that is not frequently accessed but has a huge data volume is cached in the external storage structure, achieving a balance between high efficiency and ultra-large scale.

[0203] Moreover, multi-level cache enables a large amount of candidate node data to be obtained from on-chip RAM, while multi-level quantization greatly reduces the amount of data obtained from DDR4 for each query. With the combined effect of the two, the entire query search time of the query vector will be significantly reduced, effectively reducing the latency of ANNS.

[0204] A search method provided by an embodiment of the present application is introduced above, and a device for executing the above search method will be introduced below.

[0205] See also Figure 8 , Figure 8 Schematic diagram of a search device provided in an embodiment of the present application. Figure 8 As shown, the search device 800 includes:

[0206] The first interface 801 is used to receive a query vector;

[0207] The second interface 802 is used to transmit information with an external memory;

[0208] Processor 803 is used to determine a target cluster in an index graph quantized by a first precision based on the query vector, the target cluster includes a number of vector nodes with an associated relationship, the index graph quantized by the first precision includes at least two clusters, and the distance between the target cluster and the query vector is less than the distance between the non-target cluster and the query vector in the index graph quantized by the first precision; request the storage structure through the second interface to set an N-bit search precision to search at least in the target cluster to obtain a candidate set matching the query vector, the candidate set including if the candidate vector node, the value of N is a positive integer less than 5.

[0209] In a possible implementation, the method further includes:

[0210] A memory, used for storing a target cluster obtained from an external memory, wherein the target cluster is obtained by requesting the external memory through a second interface;

[0211] Accordingly, the processor is used to search the query vector at least in the target cluster in the memory with a search accuracy of N bits to obtain a candidate set.

[0212] In a possible implementation, the processor determines the target cluster in the first precision quantized index map according to the query vector, including:

[0213] Determine information of each cluster in the locally stored index map quantized by the first precision;

[0214] Determine, according to the information of the cluster and the query vector, the distance between each cluster in the index graph quantized with the first precision and the query vector;

[0215] A target cluster is determined in the index map quantized with the first precision according to the distance.

[0216] In a possible implementation, the processor searches for the query vector at least in the target cluster in the memory with a search accuracy of N bits to obtain a candidate set, including:

[0217] For the query vector, the target cluster in the memory is searched with a set N-bit search precision to obtain a first sequence;

[0218] If the vector node part required for this search is not in the target cluster, according to the query vector, the N-bit search precision is set to search in the index graph quantized by the first precision to obtain a second sequence; the vector nodes in the first sequence are combined with the vector nodes in the second sequence to obtain a candidate set;

[0219] If all the vector nodes required for this search are in the target cluster, the vector nodes in the first sequence are used as the candidate set.

[0220] In a possible implementation, the processor searches at least in the target cluster with a set N-bit search accuracy to obtain a candidate set matching the query vector, including:

[0221] Searching in the target cluster with a set N-bit search accuracy to obtain a first candidate sequence;

[0222] If the first candidate sequence only includes the third sequence determined by sorting, taking the first candidate sequence as a candidate set, the third sequence includes at least two vector nodes;

[0223] If the first candidate sequence includes a third sequence with a determined order and a fourth sequence with an undetermined order, the search accuracy is improved, and a second candidate sequence is obtained by searching in an index graph quantized by a second accuracy based on each vector node in the fourth sequence based on the improved search accuracy, wherein the fourth sequence includes at least two vector nodes, and the distance between each vector node in the fourth sequence and the query vector is the same and is less than the distance between the vector node in the third sequence and the query vector, and the improved search accuracy is S times the N-bit search accuracy, where S is an integer greater than 2, and the second accuracy is higher than the first accuracy; until a candidate sequence containing only the third sequence is obtained; and the third sequences in each candidate sequence are combined to obtain a candidate set.

[0224] In a possible implementation, before obtaining the query vector, the processor is further configured to:

[0225] Get the current query strategy;

[0226] Accordingly, after obtaining the query vector, the processor is further configured to:

[0227] According to the query strategy being the first strategy, executing the step of determining the target cluster in the index graph quantized with a first precision according to the query vector;

[0228] Based on the query strategy being the second strategy, a candidate set matching the query vector is obtained by searching in an index graph quantized by a target precision according to the query vector, and the target precision is higher than any non-target precision.

[0229] In one possible implementation, the processor is further configured to:

[0230] Based on the index graph quantized by the target precision, the candidate vector nodes in the candidate set are sorted to obtain search results, and the target precision is higher than the first precision.

[0231] For the explanation of the functions of the components in the search device, please refer to the explanation in the aforementioned method embodiment, which will not be repeated in this embodiment.

[0232] In this embodiment, the index map of the first precision quantization includes multiple clusters, each cluster contains a number of vector nodes with an associated relationship. After obtaining the query vector, the target cluster with the shortest distance from the query vector is determined in the index map of the first precision quantization, and then a search is performed at least in the target cluster with a set N-bit search precision to obtain a candidate set matching the query vector. The N-bit search precision is a smaller search precision. During the search process, the cluster level is first screened to reduce the search range, and then the target cluster is searched with N-bit search precision to ensure the search accuracy. This search process ensures query accuracy while improving query speed.

[0233] The present application also provides an electronic device in an embodiment. Fig. 9 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the search method in the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Fig. 9 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0234] like Fig. 9 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 to a random access memory (RAM) 903. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 903. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0235] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a memory card, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Fig. 9 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0236] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the search methods provided in the embodiments of the present application.

[0237] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any search method provided in the embodiment of the present application.

[0238] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0239] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0240] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0241] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A search method, comprising: Get query vector; According to the query vector, determine a target cluster in an index graph quantized by a first precision, wherein the target cluster includes a plurality of vector nodes having an associated relationship, the index graph quantized by the first precision includes at least two clusters, and a distance between the target cluster and the query vector is less than a distance between a non-target cluster and the query vector in the index graph quantized by the first precision; A search is performed at least in the target cluster with a set search precision of N bits to obtain a candidate set matching the query vector, wherein the candidate set includes candidate vector nodes, and the value of N is a positive integer less than 5.

2. The search method according to claim 1, wherein the step of searching at least in the target cluster with a set search accuracy of N bits to obtain a candidate set matching the query vector comprises: Storing the target cluster in local memory; For the query vector, at least the target cluster in the memory is searched with a set search precision of N bits to obtain a candidate set.

3. The search method according to claim 2, wherein determining the target cluster in the first precision quantized index map according to the query vector comprises: Determine information of each cluster in the locally stored index map quantized by the first precision; Determine, according to the information of the cluster and the query vector, the distance between each cluster in the index graph quantized with the first precision and the query vector; A target cluster is determined in the index map quantized with the first precision according to the distance.

4. The search method according to claim 2, wherein the step of searching the query vector at least in the target cluster in the memory with an N-bit search accuracy to obtain a candidate set comprises: For the query vector, searching the target cluster in the memory with a set N-bit search precision to obtain a first sequence; If part of the vector nodes required for this search is not in the target cluster, according to the query vector, the vector nodes required for this search and not in the target cluster are searched in the index graph quantized by the first precision with an N-bit search precision set to obtain a second sequence; the vector nodes in the first sequence are combined with the vector nodes in the second sequence to obtain a candidate set; If all the vector nodes required for this search are in the target cluster, the vector nodes in the first sequence are used as a candidate set.

5. The search method according to claim 1, wherein the step of searching at least in the target cluster with a set search accuracy of N bits to obtain a candidate set matching the query vector comprises: Searching in the target cluster with a set N-bit search accuracy to obtain a first candidate sequence; If the first candidate sequence only includes the third sequence determined by sorting, taking the first candidate sequence as a candidate set, the third sequence includes at least two vector nodes; If the first candidate sequence includes a third sequence with a determined order and a fourth sequence with an undetermined order, the search accuracy is improved, and a second candidate sequence is obtained by searching in an index graph quantized by a second accuracy based on each vector node in the fourth sequence based on the improved search accuracy, wherein the fourth sequence includes at least two vector nodes, and the distance between each vector node in the fourth sequence and the query vector is the same and is less than the distance between the vector node in the third sequence and the query vector, and the improved search accuracy is S times the N-bit search accuracy, where S is an integer greater than 2, and the second accuracy is higher than the first accuracy; until a candidate sequence containing only the third sequence is obtained; and the third sequences in each candidate sequence are combined to obtain a candidate set.

6. The search method according to claim 1, before obtaining the query vector, further comprising: Get the current query strategy; Accordingly, after obtaining the query vector, it includes: According to the query strategy being the first strategy, executing the step of determining the target cluster in the index graph quantized with a first precision according to the query vector; Based on the query strategy being the second strategy, a candidate set matching the query vector is obtained by searching in an index graph quantized by a target precision according to the query vector, and the target precision is higher than any non-target precision.

7. The search method according to any one of claims 1 to 6, further comprising: Based on the index graph quantized by the target precision, the candidate vector nodes in the candidate set are sorted to obtain search results, and the target precision is higher than the first precision.

8. A search device, comprising: A first interface, used to receive a query vector; A second interface is used to transmit information with an external memory; A processor is used to determine a target cluster in an index map quantized by a first precision based on the query vector, the target cluster includes a number of vector nodes with an associated relationship, the index map quantized by the first precision includes at least two clusters, and the distance between the target cluster and the query vector is less than the distance between the non-target cluster and the query vector in the index map quantized by the first precision; requesting the storage structure through the second interface to set an N-bit search precision to search at least in the target cluster to obtain a candidate set matching the query vector, the candidate set including if the candidate vector node, the value of N is a positive integer less than 5.

9. The search device according to claim 8, further comprising: A memory, used for storing a target cluster obtained from an external memory, wherein the target cluster is obtained by requesting the external memory through a second interface; Accordingly, the processor is used to search the query vector at least in the target cluster in the memory with a search accuracy of N bits to obtain a candidate set.

10. A computer program product, comprising computer-readable instructions, which, when executed on an electronic device, enables the electronic device to implement the search method according to any one of claims 1 to 7.

Citation Information

Cited By

  • External storage vector retrieval method and device based on graph abstraction and storage medium

    CN121743547A