Vector retrieval method and device, equipment and storage medium

By predicting multiple search starting points and prefetching their corresponding feature vectors from memory, the problem of memory access limitation in the prior art is solved, and more efficient vector retrieval performance is achieved.

CN119903217APending Publication Date: 2025-04-29HUAWEI TECH CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311427572.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-28
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In the prior art, in the process of vector search, memory access is limited, resulting in limited memory access concurrency and low memory bandwidth utilization, which in turn increases the delay of vector search tasks.

Method used

By predicting multiple search start points, prefetching the feature vectors of their corresponding neighbor nodes from memory, increasing the memory fetch concurrency to memory, and skipping some search start points to accelerate the prefetching process when updating the access priority queue.

Benefits of technology

Improves the performance of vector retrieval, reduces the delay of vector retrieval tasks, and improves the bandwidth utilization and access concurrency of memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903217A_ABST
    Figure CN119903217A_ABST
Patent Text Reader

Abstract

The invention discloses a vector retrieval method and device, equipment and a storage medium, and belongs to the technical field of data processing. The method comprises the following steps: predicting a plurality of search starting points according to an access priority queue, wherein the search starting points are nodes which do not traverse neighbor nodes in the access priority queue; pre-fetching feature vectors of neighbor nodes corresponding to the plurality of search starting points from a memory; updating the access priority queue based on a feature vector of a neighbor node corresponding to a first type of search starting point, the first type of search starting point being a search starting point of which the feature vector of the neighbor node has been pre-fetched in the plurality of search starting points; and if the updated access priority queue meets a retrieval ending condition, outputting a vector retrieval result of the query vector based on the updated access priority queue. According to the method, by predicting the multiple search starting points, the updating frequency of the access priority queue is improved, and then the vector retrieval performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a vector retrieval method, device, equipment and storage medium. Background Art

[0002] Vector retrieval is to search for the top-K reference vectors that are close to the query vector in a given vector dataset according to a certain metric. Usually, vector retrieval is implemented using a retrieval algorithm based on graph index, such as the hierarchical navigable small world (HNSW) algorithm.

[0003] In the related art, the process of implementing vector retrieval based on graph index is as follows: select a vector from a vector data set, and add the node corresponding to the vector in the graph index of the vector data set to the access priority queue. Use the head node in the access priority queue as the search starting point, determine the node identifiers of multiple neighbor nodes corresponding to the search starting point based on the graph index of the vector data set, and then read the feature vectors of the multiple neighbor nodes from the memory according to the node identifiers of the multiple neighbor nodes. Finally, according to the distance between the feature vectors of the multiple neighbor nodes and the query vector, insert the multiple neighbor nodes into the access priority queue so that each node in the access priority queue is arranged in ascending order according to the vector distance between the feature vector of the node and the query vector. Return to the step of using the head node in the access priority queue as the search starting point, and perform the next round of vector search. Perform multiple rounds of search in the above manner to approximate the query vector, thereby obtaining the Top-K reference vectors that are close to the query vector, i.e., the vector retrieval result.

[0004] However, when the above method obtains the feature vector of the neighbor node corresponding to the search starting point within a single search round, the amount of memory access is limited by the number of neighbor nodes corresponding to the search starting point, resulting in a small amount of memory access within a single search round, limited memory access concurrency, and low memory bandwidth utilization, which in turn causes hardware computing resources to be wasted on waiting for the access results of the feature vector of the neighbor node, making the latency of a single vector retrieval task relatively high. Summary of the invention

[0005] The present application provides a vector search method, apparatus, device and storage medium, which can increase the memory access concurrency during vector search and improve the vector search performance. The technical solution is as follows.

[0006] In a first aspect, a vector retrieval method is provided, comprising:

[0007] Predict multiple search starting points based on an access priority queue, the access priority queue includes multiple nodes, and the multiple nodes are arranged in sequence according to the size of the vector distance between the feature vectors of the multiple nodes and the query vector, and the search starting point is a node in the access priority queue whose neighbor nodes have not been traversed; pre-fetch the feature vectors of the neighbor nodes corresponding to the multiple search starting points from the memory; update the access priority queue based on the feature vectors of the neighbor nodes corresponding to the first type of search starting points, the first type of search starting point is the search starting point of the feature vectors of the neighbor nodes that have been pre-fetched among the multiple search starting points; if the updated access priority queue meets the retrieval end condition, then output the vector retrieval result of the query vector based on the updated access priority queue.

[0008] It can be seen that when a computer device performs a vector retrieval task, it can predict multiple search starting points for an access priority queue, and increase the number of search starting points to increase the memory access concurrency when pre-fetching feature vectors. Since multiple search starting points are predicted based on an access priority queue, after pre-fetching the feature vector of the neighboring node corresponding to the first type of search starting point, the feature vector of the neighboring node corresponding to the first type of search starting point can be used to update the access priority queue. That is, when updating the access priority queue, the access priority queue can be updated by skipping at least one search starting point among multiple search starting points in the order of pre-fetching feature vectors from the memory to predict a new search starting point. In this way, the update frequency of the access priority queue is increased, thereby improving the vector retrieval performance.

[0009] Optionally, the multiple search starting points include a first search starting point and a second search starting point, and the vector distance between the feature vector of the first search starting point and the query vector is smaller than the vector distance between the feature vector of the second search starting point and the query vector; and pre-fetching the feature vectors of the neighbor nodes corresponding to the multiple search starting points from the memory includes: first pre-fetching the feature vectors of the neighbor nodes corresponding to the first search starting point from the memory, and then pre-fetching the feature vectors of the neighbor nodes corresponding to the second search starting point.

[0010] By pre-fetching the feature vectors of neighbor nodes corresponding to multiple search starting points from the memory in sequence, the memory access concurrency is increased. At the same time, based on the feature vectors of neighbor nodes corresponding to multiple search starting points, the possibility of searching for nodes closer to the query vector is higher, and the feature vectors of neighbor nodes corresponding to multiple search starting points are used to update the access priority queue, which also improves the diversity and accuracy of the nodes in the access priority queue.

[0011] Optionally, pre-fetching feature vectors of neighbor nodes corresponding to the first search starting point from the memory first, and then pre-fetching feature vectors of neighbor nodes corresponding to the second search starting point, includes: estimating the pre-fetching duration of feature vectors of neighbor nodes corresponding to the first search starting point; if the pre-fetching duration is less than or equal to a specified duration, pre-fetching feature vectors of neighbor nodes corresponding to the first search starting point from the memory first, and then pre-fetching feature vectors of neighbor nodes corresponding to the second search starting point.

[0012] Optionally, after estimating the pre-fetching duration of the feature vector of the neighbor node corresponding to the first search starting point, the method further includes: if the pre-fetching duration is greater than the specified duration, skipping the first search starting point and directly pre-fetching the feature vector of the neighbor node corresponding to the second search starting point.

[0013] That is, when pre-fetching the feature vector of a neighboring node corresponding to a certain search starting point, it is possible to determine whether to skip the search starting point when pre-fetching the feature vector of the neighboring node by estimating the pre-fetching time of the feature vector of the neighboring node corresponding to the search starting point.

[0014] Optionally, the memory includes a local memory and a remote memory; the feature vectors of the neighbor nodes corresponding to the first search starting point are first pre-fetched from the memory, and then the feature vectors of the neighbor nodes corresponding to the second search starting point are pre-fetched, including: if the feature vectors of the neighbor nodes corresponding to the first search starting point are located in the local memory, the feature vectors of the neighbor nodes corresponding to the first search starting point are pre-fetched from the local memory, and then the feature vectors of the neighbor nodes corresponding to the second search starting point are pre-fetched.

[0015] Optionally, the method further includes: if the feature vector of the neighbor node corresponding to the first search starting point is located in the remote memory, skipping the first search starting point and directly pre-fetching the feature vector of the neighbor node corresponding to the second search starting point.

[0016] That is, when pre-fetching the feature vector of a neighbor node corresponding to a certain search starting point, it is possible to determine whether to skip the search starting point when pre-fetching the feature vector of the neighbor node by estimating whether the feature vector of the neighbor node corresponding to the search starting point is located in the local memory.

[0017] It can be seen that when obtaining the feature vectors of neighbor nodes corresponding to multiple search starting points, you can selectively skip a certain search starting point, pre-fetch the feature vectors of neighbor nodes corresponding to other search starting points, and update the access priority queue. That is, the implementation of this application pre-fetches the feature vectors of neighbor nodes by skipping the search starting point, speeding up the update speed of the access priority queue, thereby improving the vector retrieval efficiency.

[0018] Optionally, skipping the first search starting point and directly pre-fetching the feature vector of the neighbor node corresponding to the second search starting point includes: skipping the first search starting point and determining the number of skipped search starting points among the multiple search starting points; if the number of skipped search starting points is less than a first threshold, pre-fetching the feature vector of the neighbor node corresponding to the second search starting point.

[0019] Optionally, after determining the number of skipped search starting points among the multiple search starting points, the method further includes: if the number of skipped search starting points is equal to the first threshold, pre-fetching the feature vectors of the neighbor nodes corresponding to the skipped search starting points, and suspending the updating of the access priority queue; updating the access priority queue based on the feature vectors of the neighbor nodes corresponding to the first type of search starting points includes: updating the access priority queue based on the feature vectors of the neighbor nodes corresponding to the skipped search starting points.

[0020] That is, when the number of skipped search starting points is equal to the first threshold, in order to avoid skipping the search starting point with the smallest vector distance between the feature vector and the query vector, it is necessary to first obtain the feature vector of the neighbor node corresponding to the skipped search starting point to update the access priority queue, and then readjust the search direction based on the updated access priority queue to predict the new search starting point.

[0021] Therefore, when the number of skipped search starting points is equal to the first threshold, the access priority queue is stopped from being updated based on the feature vectors of the neighboring nodes corresponding to the subsequent search starting points, and the access priority queue needs to be updated once based on the feature vectors of the neighboring nodes corresponding to the skipped search starting points before the subsequent search operation can be performed. In this way, it is possible to avoid skipping the search starting points that are close to the query vector, which causes the retrieval direction to deviate from the query vector, thereby ensuring the accuracy of the vector retrieval.

[0022] Optionally, pre-fetching from the memory the feature vectors of neighbor nodes corresponding to the multiple search starting points includes: if the number of updates of the access priority queue is equal to a second threshold, and there is a second type of search starting point in the last predicted search starting point, then pre-fetching from the memory the feature vectors of neighbor nodes corresponding to the multiple search starting points, and then pre-fetching the feature vectors of neighbor nodes corresponding to the second type of search starting point, the second type of search starting point being the search starting point whose feature vectors of neighbor nodes were not pre-fetched in the last predicted search starting point.

[0023] As the number of updates of the access priority queue increases, the neighbor nodes of the predicted search starting point are closer to the query node corresponding to the query vector. Therefore, when the number of updates of the access priority queue is equal to the second threshold, the feature vectors of the neighbor nodes corresponding to the search starting point predicted by the access priority queue can be obtained first, and then the search starting point predicted by the access priority queue whose update number is less than the second threshold is pre-fetched. The operation of pre-fetching the feature vectors of the corresponding neighbor nodes is performed to avoid the problem of slow retrieval progress due to pre-fetching a large number of feature vectors of temporarily unused neighbor nodes, thereby improving the vector retrieval performance.

[0024] Optionally, it is characterized in that the method further includes: if the number of times the access priority queue has been updated is less than a third threshold, executing the step of predicting multiple search starting points based on the access priority queue.

[0025] Optionally, the method also includes: if the access priority queue has been updated a number of times greater than or equal to the third threshold, determining multiple target nodes in the access priority queue that have not traversed neighbor nodes; obtaining feature vectors of neighbor nodes corresponding to the multiple target nodes; updating the access priority queue based on the feature vectors of neighbor nodes corresponding to the multiple target nodes; and outputting the vector retrieval result of the query vector based on the updated access priority queue.

[0026] That is, when the number of updates is large enough, the nodes in the updated access priority queue may tend to a stable state. At this time, in order to improve the pre-fetching efficiency of feature vectors and speed up the retrieval progress, the nodes in the access priority queue that have not traversed neighbor nodes can be processed in batches.

[0027] Optionally, obtaining the feature vectors of neighbor nodes corresponding to the multiple target nodes includes: determining at least one neighbor node from the neighbor nodes corresponding to the multiple target nodes, the feature vector of the at least one neighbor node being located in the same remote memory; and obtaining the feature vector of the at least one neighbor node from the remote memory.

[0028] Since the feature vector of each node may be located in the local memory or in the remote memory, the corresponding pre-fetch duration of the feature vector is also different. Based on this, after determining the neighbor nodes corresponding to multiple target nodes, the neighbor nodes corresponding to the multiple target nodes can be classified according to the storage location of the feature vector of each neighbor node. For at least one neighbor node whose feature vector is stored in the same remote memory, the feature vector of the at least one neighbor node is batch obtained from the remote memory to improve the reading efficiency of the feature vector.

[0029] Optionally, before obtaining the feature vector of the neighbor node, the method also includes: determining whether the feature vector of the target neighbor node has been pre-fetched during the historical search process, and the target neighbor node is any neighbor node determined based on the access priority queue; if the feature vector of the target neighbor node has been pre-fetched during the historical search process, the target neighbor node is discarded.

[0030] That is, in order to avoid repeatedly reading the feature vector of the same node from the memory, for the target node that has not traversed the neighbor nodes in the access priority queue, after determining the neighbor nodes corresponding to multiple target nodes, it is necessary to first check the neighbor nodes for duplication to determine whether the feature vector of the neighbor node has been pre-fetched during the historical search process.

[0031] In a second aspect, a vector search device is provided, wherein the vector search device has the function of implementing the vector search method in the first aspect. The vector search device includes at least one module, and the at least one module is used to implement the vector search method provided in the first aspect.

[0032] In a third aspect, a computer device is provided, the computer device comprising a processor and a memory, the memory being used to store a computer program for executing the vector retrieval method provided in the first aspect. The processor is configured to execute the computer program stored in the memory to implement the vector retrieval method described in the first aspect.

[0033] Optionally, the computer device may further include a communication bus, which is used to establish a connection between the processor and the memory.

[0034] In a fourth aspect, a computer-readable storage medium is provided, wherein the storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the vector retrieval method described in the first aspect.

[0035] In a fifth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a computer, the computer executes the vector retrieval method described in the first aspect.

[0036] The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 is a structural schematic diagram of a computer device provided in an embodiment of the present application;

[0038] Figure 2 It is a flowchart of a vector search method provided in an embodiment of the present application;

[0039] Figure 3 1 is a schematic diagram of a scheduling sequence of a vector request packet provided in an embodiment of the present application;

[0040] Figure 4 It is a schematic diagram of the corresponding relationship between the number of updates of an access priority queue and the success rate of predicting a search starting point provided by an embodiment of the present application;

[0041] Figure 5 is a structural schematic diagram of a vector retrieval device provided in an embodiment of the present application;

[0042] Figure 6 It is a schematic diagram of a processing node architecture provided by an embodiment of the present application;

[0043] Figure 7 It is a structural diagram of a memory access engine provided in an embodiment of the present application;

[0044] Figure 8 It is a schematic diagram of the structure of a memory provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0046] For ease of understanding, before explaining the vector retrieval method provided in the present application, the terminology, application background and implementation environment involved in the embodiments of the present application are first introduced.

[0047] First, the terms involved in the embodiments of the present application are introduced.

[0048] 1. Nearest neighbor search (NNS)

[0049] NNS is an algorithm that searches for the element with the smallest vector distance to a given query item within a certain distance metric and a search space. Approximate Nearest Neighbor Search (ANNS) is an inexact nearest neighbor search algorithm.

[0050] 2. Vector search

[0051] Vector retrieval is to search for the top-K reference vectors with a close vector distance to the query vector in a given vector dataset according to a certain metric, so as to obtain the vector retrieval result of the query vector.

[0052] The vector distance between two vectors includes, but is not limited to, Euclidean distance, cosine distance, inner product distance, Hamming distance, etc.

[0053] 3. Graph Index

[0054] A graph index is a data structure used in database systems to speed up data query and update. It is also a special index that is usually used to store graphic data, such as maps or 3D models. The graph index of the database system can quickly find graphics that intersect with a given geometric figure, or find graph nodes in the graph that meet specific conditions.

[0055] 4. Unlayered navigable small world (NSW)

[0056] NSW is a vector retrieval algorithm based on graph index. The algorithm ensures that each node in the graph index has adjacent nodes (i.e., neighbor nodes), there is a connection between two adjacent nodes, and the number of neighbor nodes corresponding to each node can be specified.

[0057] The process of constructing a graph index by the NSW algorithm is as follows: when a new node is inserted into the graph, the m nodes closest to the new node are found (the value of m can be set by the user), and the lines connecting the new node to the m nodes are connected.

[0058] The process of NSW algorithm performing vector retrieval is as follows: traverse the neighbor nodes corresponding to the search starting point, determine the neighbor node closest to the query node (that is, the node corresponding to the query vector), and then use the neighbor node as the search starting point for a new round of search, repeating the above process until multiple rounds of search are completed to find the query vector, or the Top-K reference vectors that are close to the query vector.

[0059] 5. Hierarchical navigating small world (HNSW)

[0060] HNSW is a vector retrieval algorithm based on graph index, which is an improvement on the above NSW algorithm. It consists of multiple layers of proximity graphs, so it is called hierarchical NSW method. In other words, the HNSW algorithm will build a multi-layer navigation graph based on a graph according to the rules, and in the multi-layer navigation graph, the nodes contained in the navigation graph closer to the upper layer are sparser and the distance between the nodes is farther; the nodes contained in the navigation graph closer to the lower layer are denser and the distance between the nodes is closer.

[0061] The process of constructing a graph index by the HNSW algorithm is as follows: when a new node needs to be inserted, the HNSW algorithm first saves the new node in layer 0, then randomly selects a layer number, traverses from this layer layer by layer, inserts the new node in each layer, and connects the corresponding m neighbor nodes according to the composition rules of the NSW algorithm until layer 0. Among them, the connection between the high layer and the low layer is the highway, which can skip the traversal of irrelevant nodes in the current layer and quickly determine the nearest node.

[0062] The process of executing vector retrieval by the HNSW algorithm is as follows: starting from the top layer, first search for the node closest to the query node (i.e. the node corresponding to the query vector) in the navigation graph of this layer, and use this node as the starting point for the next layer search, and continue to search for the node closest to the query node in the next layer. In this way, the query node or the neighboring nodes of the query node can be quickly searched.

[0063] Among them, above layer 0, starting from the specified search starting point, the node closest to the query node is searched and used as the search starting point for the next round of search. In layer 0, the Top-K reference nodes that are close to the query node (i.e., the graph nodes corresponding to the Top-K reference vectors) are determined.

[0064] That is, the HNSW algorithm adopts a skip list-like idea, skipping a large number of nodes far from the query node at a high level, so as to quickly locate nodes close to the query node, thereby narrowing the search range. When constructing a graph, a heuristic search method is used to select neighbor nodes that need to be connected, thereby preventing the occurrence of disconnected graphs.

[0065] Secondly, the relevant background of the embodiments of the present application is introduced.

[0066] Vector retrieval can be applied to many fields, such as image search, product search and recommendation, multimodal recommendation system, voice question and answer, storage compression and deduplication, and gene analysis. Regarding vector retrieval, the industry currently commonly uses graph index-based retrieval algorithms, such as the HNSW algorithm.

[0067] Among them, the process of performing vector retrieval based on the graph index is: select a vector from the vector data set, and add the node corresponding to the vector in the graph index of the vector data set to the access priority queue. Take the head node in the access priority queue as the search starting point, determine the node identifiers of multiple neighbor nodes corresponding to the search starting point based on the graph index of the vector data set, and then read the feature vectors of the multiple neighbor nodes from the memory according to the node identifiers of the multiple neighbor nodes. Finally, according to the distance between the feature vectors of the multiple neighbor nodes and the query vector, insert the multiple neighbor nodes into the access priority queue so that each node in the access priority queue is arranged in order from small to large according to the vector distance between the feature vector of the node and the query vector. Return to the step of taking the head node in the access priority queue as the search starting point, and perform the next round of vector search. Perform multiple rounds of search in the above manner to approximate the query vector, so as to obtain the Top-K reference vectors with a close distance to the query vector, that is, the vector retrieval result.

[0068] For ease of understanding, assume that the access priority queue includes nodes A, B, C, D, and E, which are arranged in sequence, and the vector distance between each feature vector and the query vector is sorted as: node D < node F < node G < node M < node N, where node A, node B, and node C have not traversed neighbor nodes. Based on the above access priority queue, node A with the smallest vector distance is determined as the search starting point, and the node identifiers of the three neighbor nodes E, F, and G corresponding to node A are determined based on the graph index. Based on the node identifiers of neighbor nodes E, F, and G, the feature vectors of nodes E, F, and G are read, and then the access priority queue is updated according to the vector distances between the feature vectors of nodes E, F, and G and the query vector.

[0069] If the vector distances between the feature vectors of nodes E, F, and G and the query vector are sorted as follows: node E < node F < node G, and the vector distance between the feature vector of node E and the query vector is smaller than that of node A, the vector distance between the feature vector of node F and the query vector is smaller than that of node A, and the vector distance between the feature vector of node G and the query vector is greater than that of node A and smaller than that of node B, then the updated access priority queue includes nodes E, node F, node A, node G, node B, node C, node D, and node E arranged in sequence.

[0070] Based on the updated access priority queue, node A is marked as a node that has traversed neighbor nodes, and node D is no longer used as the search starting point. When performing the next round of search, node E with the smallest vector distance and no neighbor nodes traversed is used as the search starting point, and the above "read the feature vector of the neighbor node - calculate the vector distance - update the access priority queue" operation is repeated until the search end condition is met, and the vector search result of the query vector is output.

[0071] In the above-mentioned vector retrieval process, when obtaining the feature vector of the neighbor node corresponding to the search starting point based on the access priority queue, the access to the memory is limited by the number of neighbor nodes corresponding to the search starting point, the access to the memory is small, the concurrency of memory access is limited, and the memory bandwidth utilization is low.

[0072] Moreover, the reading of the feature vectors of the neighboring nodes corresponding to the search starting point is local, and the acquisition time of the feature vectors of different neighboring nodes is different. In addition, the search starting point used in a new round of search must be determined after the access priority queue is updated. As a result, the computing resources of the computer device executing the vector retrieval task are wasted on waiting for the access results of the feature vectors of the neighboring nodes, making the delay of a single vector retrieval task relatively high.

[0073] Based on this, the embodiment of the present application provides a vector retrieval method, which predicts multiple search starting points according to the access priority queue, and increases the pre-fetching amount of feature vectors by increasing the number of search starting points, so as to improve the concurrency of memory access to the memory and improve the bandwidth utilization of the memory. At the same time, for multiple search starting points predicted by the same access priority queue, any search starting point that first obtains the feature vector of the corresponding neighbor node can be used to update the access priority queue, that is, for an access priority queue, it supports skipping a certain search starting point (equivalent to crossing search rounds), and uses the feature vectors of the neighbor nodes corresponding to other search starting points to update the access priority queue, thereby improving the vector retrieval performance and the retrieval efficiency.

[0074] Finally, the implementation environment of the embodiments of the present application is introduced.

[0075] Figure 1 A schematic diagram of the structure of a computer device is shown, which may be a terminal device or a server, or other devices including hardware such as a general-purpose processor, a graphics processing unit (GPU) or an accelerator, and is used to execute the vector retrieval method provided in an embodiment of the present application.

[0076] See also Figure 1 The computer device includes at least one processor 101 , a communication bus 102 , a memory 103 and at least one communication interface 104 .

[0077] The processor 101 may be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or may be one or more integrated circuits for implementing the solution of the present application, such as an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0078] The communication bus 102 is used to transmit information between the above components. The communication bus 102 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 1 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0079] The memory 103 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 103 may exist independently and be connected to the processor 101 via the communication bus 102. The memory 103 may also be integrated with the processor 101.

[0080] The communication interface 104 uses any transceiver-like device for communicating with other devices or communication networks. The communication interface 104 includes a wired communication interface and may also include a wireless communication interface. Among them, the wired communication interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless communication interface may be a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof, etc.

[0081] As an example, the processor 101 may include one or more CPUs, such as Figure 1 CPU0 and CPU1 are shown in the figure.

[0082] As an example, a computer device may include multiple processors, such as Figure 1 1 and 105. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0083] In some embodiments, the computer device may further include an output device and an input device. The output device communicates with the processor 101 and may display information in a variety of ways. For example, the output device may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device communicates with the processor 101 and may receive user input in a variety of ways. For example, the input device may be a mouse, a keyboard, a touch screen device, or a sensor device.

[0084] In some embodiments, the memory 103 is used to store the program code 110 for executing the solution of the present application, and the processor 101 can execute the program code 110 stored in the memory 103. The program code 110 may include one or more software modules, and the computer device may implement the following by the processor 101 and the program code 110 in the memory 103. Figure 2 The vector retrieval method provided by the embodiment.

[0085] Next, the vector retrieval method provided in the embodiment of the present application is explained in detail.

[0086] See also Figure 2 , Figure 2 is a flowchart of a vector retrieval method provided in an embodiment of the present application, which can be applied to Figure 1The computer device shown may specifically be the processor 101 in the computer device. The method includes the following steps.

[0087] Step 201: predict multiple search starting points based on the access priority queue.

[0088] The access priority queue includes multiple nodes, and the multiple nodes are arranged in sequence according to the vector distance between the feature vectors of the multiple nodes and the query vector, and the search starting point is a node in the access priority queue whose neighbor nodes have not been traversed.

[0089] As an example, multiple nodes in the access priority queue are arranged in ascending order of the vector distance between the feature vector and the query vector, the vector distance between the feature vector of the head node (i.e., the first node) in the access priority queue and the query vector is the smallest, and the vector distance between the feature vector of the tail node (i.e., the last node) and the query vector is the largest. In other words, the head node in the access priority queue is closest to the query node (i.e., the node corresponding to the query vector), and the tail node in the access priority queue is farthest from the query node.

[0090] For the nodes in the access priority queue, each node corresponds to a node information, which includes node ID, vector ID, vector distance, whether the neighbor nodes have been traversed, etc. Since the feature vectors in the vector database correspond one-to-one to the nodes in the graph index, each node added to the access priority queue based on the graph index corresponds to a unique node ID and vector ID, and the vector distance is the distance between the node's feature vector and the query vector. Whether the neighbor nodes have been traversed indicates whether the operation of pre-fetching the feature vectors of the corresponding neighbor nodes has been performed for the node during the historical search process. If the neighbor nodes have been traversed, the feature vectors of the neighbor nodes corresponding to the node have been pre-fetched from the memory; if the neighbor nodes have not been traversed, the feature vectors of the neighbor nodes corresponding to the node have not been pre-fetched from the memory.

[0091] As an example, the node identifier may be a node ID.

[0092] Optionally, when there are multiple processors, GPUs, and accelerators implementing vector retrieval in parallel, the node information of each node in the access priority queue further includes a device identifier to indicate a device storing the feature vector of the node.

[0093] In some embodiments, the implementation process of step 201 is: based on the node information of each node in the access priority queue, the nodes that have not traversed neighboring nodes are filtered out from the access priority queue to obtain multiple candidate nodes; based on the vector distance between the feature vector of each candidate node and the query vector, multiple search starting points are predicted.

[0094] It should be understood that in the first round of search, it is necessary to specify a node from the vector database as the search starting point. At this time, only the specified node is recorded in the access priority queue. Therefore, the number of search starting points determined based on the access priority queue is 1. In the subsequent search process, when there is only one candidate node that has not traversed neighbor nodes in the access priority queue, the number of search starting points determined based on the access priority queue is also 1. When there are multiple candidate nodes that have not traversed neighbor nodes in the access priority queue, the candidate node with the smallest vector distance between the feature vector and the query vector is determined as the search starting point corresponding to the current search round, that is, the operation of obtaining the feature vector of the neighbor node corresponding to the search starting point must be performed to approximate the query node corresponding to the query vector through multiple rounds of search. In the embodiment of the present application, for other candidate nodes, considering that in the subsequent search process, it is possible to use the candidate node as the search starting point to perform the operation of obtaining the feature vector of the neighbor node, therefore, it can also be determined as the search starting point in advance, and the feature vector of the neighbor node corresponding to the search starting point can be pre-fetched.

[0095] Among them, when predicting multiple search starting points based on screening out multiple candidate nodes, there are the following two situations.

[0096] The first case: based on the vector distance between the feature vector of each candidate node and the query vector, multiple candidate nodes are sequentially determined as search starting points corresponding to the current search round and subsequent search rounds.

[0097] In this case, the number of candidate nodes is the same as the number of predicted search starting points, that is, the nodes in the access priority queue that have not traversed neighboring nodes are directly determined as the search starting points.

[0098] As an example, when there are 5 candidate nodes in the access priority queue, the candidate node with the smallest vector distance can be determined as the first search starting point according to the vector distance between the feature vector of each candidate node and the query vector, and the candidate node with the second smallest vector distance can be determined as the second search starting point, and so on, and the candidate node with the largest vector distance can be determined as the fifth search starting point, thus obtaining 5 search starting points.

[0099] The second case: based on the prediction node number threshold, multiple search starting points are determined from multiple candidate nodes according to the vector distance between the feature vector of each candidate node and the query vector.

[0100] In this case, the number of candidate nodes is greater than the number of search starting points, and the search starting points are some of the multiple candidate nodes.

[0101] The prediction node number threshold is the number of search starting points allowed to be determined based on an access priority queue without affecting the accuracy of the vector search result, and can be a value determined based on experience. For example, the prediction round threshold can be 2, 3, etc.

[0102] As an example, when there are 5 candidate nodes and the prediction round threshold is 2, the candidate node with the smallest vector distance can be determined as the first search starting point, and the candidate node with the second smallest vector distance can be determined as the second search starting point according to the vector distance between the feature vector of each candidate node and the query vector, thereby obtaining 2 search starting points.

[0103] It should be noted that the embodiment of the present application does not limit the number of nodes in the access priority queue whose neighbor nodes have not been traversed and the number of predicted search starting points.

[0104] In this embodiment, the search starting points of multiple search rounds can be predicted for the access priority queue. Compared with the scheme of using the head node of the access priority queue as the search starting point and performing the search for neighbor nodes based on one search starting point, the embodiment of the present application predicts multiple search starting points and can perform the operation of searching for neighbor nodes respectively along the directions of multiple search starting points based on one access priority queue to obtain nodes closer to the query vector, thereby improving the memory access concurrency when obtaining the feature vector of the neighbor node based on the search starting point, and the utilization rate of the memory access bandwidth.

[0105] Step 202: pre-fetch feature vectors of neighbor nodes corresponding to multiple search starting points from the memory.

[0106] In some embodiments, the multiple search starting points include a first search starting point and a second search starting point, and the vector distance between the feature vector of the first search starting point and the query vector is smaller than the vector distance between the feature vector of the second search starting point and the query vector. At this time, the implementation process of step 202 is: first pre-fetch the feature vector of the neighbor node corresponding to the first search starting point from the memory, and then pre-fetch the feature vector of the neighbor node corresponding to the second search starting point.

[0107] It should be understood that the neighbor nodes of the search starting point with the smallest vector distance between the feature vector and the query vector are more likely to be close to the nodes of the query vector. Therefore, when pre-fetching feature vectors of neighbor nodes corresponding to multiple search starting points from the memory, the feature vectors of neighbor nodes corresponding to multiple search starting points can be obtained in sequence according to the order of the vector distance between the feature vector of the search starting point and the query vector from small to large.

[0108] It should be noted that the embodiment of the present application only takes the number of multiple search starting points as 2 as an example, but does not constitute a limitation on the number of multiple search starting points, that is, the multiple search starting points predicted based on the same access priority queue may also include other search starting points in addition to the above-mentioned first search starting point and the second search starting point.

[0109] When pre-fetching the feature vectors of the neighboring nodes corresponding to each search starting point in the memory, the implementation process is similar. Here, taking the first search starting point as an example, the implementation process of pre-fetching the feature vectors of the corresponding neighboring nodes is explained.

[0110] In one possible implementation, the process of pre-fetching the feature vector of the neighbor node corresponding to the first search starting point is: based on the node identifier of the first search starting point, determining the node identifier of the neighbor node corresponding to the first search starting point from the graph index of the vector database; based on the node identifier of the neighbor node corresponding to the first search starting point, reading the feature vector of the neighbor node corresponding to the first search starting point from the memory.

[0111] As an example, the neighbor node corresponding to the first search starting point can be determined based on the neighbor node list of the first search starting point. The neighbor node list of the first search starting point records the node information of at least one neighbor node corresponding to the first search starting point, such as the node identifier, vector identifier, memory access address, memory access address length, etc. of the neighbor node. Among them, the memory access address indicates the storage location of the feature vector of the neighbor node in the memory, and the memory access address length indicates the length of the storage location corresponding to the feature vector of the neighbor node in the memory. Based on the memory access address and the memory access address length, a unique storage address of the feature vector can be determined from the memory.

[0112] Optionally, the neighbor node list and feature vector of each node are stored in the same memory.

[0113] In this embodiment, the concurrency of memory access is increased by pre-fetching feature vectors of neighbor nodes corresponding to multiple search starting points from the memory in sequence. At the same time, based on the feature vectors of neighbor nodes corresponding to multiple search starting points, the possibility of searching for nodes closer to the query vector is higher, and the feature vectors of neighbor nodes corresponding to multiple search starting points are used to update the access priority queue, which also improves the diversity and accuracy of the nodes in the access priority queue.

[0114] As the number of updates of the access priority queue increases, the search starting point predicted by the access priority queue may correspond to the same neighbor node as the search starting point predicted in the historical search process, and the feature vector of the neighbor node has been pre-fetched in the previous search process. Therefore, when pre-fetching the feature vector of the neighbor node corresponding to the search starting point from the memory based on the predicted search starting point, the neighbor node corresponding to the search starting point can be checked for duplication first to determine whether the feature vector of the neighbor node has been pre-fetched in the historical search process, so as to avoid repeatedly reading the feature vector of the same node from the memory.

[0115] Based on this, before reading the feature vector of the neighbor node corresponding to the first search starting point from the memory, first determine whether the feature vector of the neighbor node corresponding to the first search starting point has been pre-fetched in the historical search process. If the feature vector of the target neighbor node has been pre-fetched in the historical search process, then when reading the feature vector of the neighbor node corresponding to the first search starting point, the target neighbor node is discarded.

[0116] The target neighbor node here is any neighbor node among the neighbor nodes corresponding to the first search starting point.

[0117] In this way, by checking whether the feature vector of the target neighbor node is obtained repeatedly, it is possible to avoid repeated access to the memory for the feature vector of the same node, thereby improving the memory access efficiency and vector retrieval efficiency.

[0118] In some embodiments, during the vector retrieval process, the nodes whose feature vectors have been acquired and the vector distance between the feature vectors and the query vector has been calculated can be recorded in the visited queue. For any node, by querying the visited queue, it can be determined whether the feature vector of the node has been pre-fetched during the historical search process.

[0119] Taking the above-mentioned target neighbor node as an example, in a possible implementation method, according to the node identifier of the target neighbor node, the node information of each visited node in the visited queue is traversed. If the target neighbor node exists in the visited queue, it is determined that the feature vector of the target neighbor node has been pre-fetched during the historical search process. There is no need to repeatedly pre-fetch the feature vector of the target neighbor node, and the calculation can be directly called. If the target neighbor node does not exist in the visited queue, it is determined that the feature vector of the target neighbor node has not been pre-fetched during the historical search process. Here, it is necessary to perform the operation of pre-fetching the feature vector on the target neighbor node.

[0120] Since the embodiment of the present application predicts multiple search starting points based on the access priority queue, although the feature vectors of the neighboring nodes corresponding to some search starting points have been pre-fetched from the memory, in the subsequent search process, no further search will be performed based on the neighboring node, that is, the feature vector of the neighboring node is not used to search for the next node. Moreover, each search starting point may correspond to the same neighboring node, and multiple pre-fetch requests may be initiated for the same neighboring node. If multiple nodes are recorded in the visited queue in sequence according to the order of pre-fetching feature vectors during the search process, it takes a long time to determine whether the feature vector of the node has been pre-fetched in the historical search process based on the visited queue.

[0121] Based on this, the present application also provides a "lossy" visited queue, that is, for nodes that have pre-fetched feature vectors, only one record corresponds to it in the visited queue. In other words, the visited queue of the embodiment of the present application does not record the nodes corresponding to multiple pre-fetched feature vectors in full in the order in which the feature vectors are obtained, but only one record is retained in the visited queue for nodes that have pre-fetched feature vectors.

[0122] In a possible implementation, a hash table is used to store the node identifiers of the nodes in the visited queue, and the number of hash tables can be M. Taking the above-mentioned target neighbor node as an example, the implementation process of determining whether the corresponding feature vector of the target neighbor node has been pre-fetched in the historical search process can be: based on the node identifier of the target neighbor node, use a hash function to generate M position index values ​​(i.e., hash keys), based on the M position index values, query whether the node identifier of the target neighbor node exists at the position corresponding to the position index value in the M hash tables respectively, if it exists, it is determined that the feature vector of the target neighbor node has been pre-fetched in the historical search process; if it does not exist, it is determined that the feature vector of the target neighbor node has not been pre-fetched in the historical search process.

[0123] Among them, M is a positive integer greater than 0. M hash tables are used to store the node identifiers of the nodes in the visited queue. By generating M position index values ​​through a hash function, the visited queue can be quickly traversed, thereby improving the efficiency of determining whether the node has pre-fetched feature vectors during the historical search process.

[0124] If it is determined that the feature vector of the target neighbor node is not pre-fetched during the historical search process, the operation of pre-fetching the feature vector of the target neighbor node is performed. At the same time, the node identifier of the target neighbor node needs to be added to the visited queue, that is, the node identifier of the target neighbor node is inserted into any hash table.

[0125] In one possible implementation, based on the M position index values ​​(i.e., Hashkey) generated for the target neighbor node, it is determined whether the position corresponding to the position index value in the M hash tables is empty. If the position corresponding to the position index value in at least one hash table is empty, the node identifier of the target neighbor node can be stored in this position; if the positions corresponding to the position index value in the M hash tables are all occupied, the target neighbor node is discarded, that is, the target neighbor node is not temporarily inserted into the visited queue.

[0126] In this embodiment, a Hash table is used to store the visited queue, and a lossy recording method is used to record the nodes of the pre-fetched feature vectors. In this way, based on the "lossy" visited queue recording method of the visited nodes, the access to the nodes in the visited queue can be accelerated.

[0127] In some embodiments, when pre-fetching feature vectors from memory, a search starting point may correspond to one neighbor node or multiple neighbor nodes. However, a general processor or accelerator can only support a limited number of memory access requests when performing vector retrieval tasks. Therefore, in order to ensure efficient reading of feature vectors while controlling the number of memory accesses, the embodiments of the present application can schedule each search starting point in packets.

[0128] That is, for each feature vector corresponding to the search starting point, a vector request packet is generated. When pre-fetching feature vectors, the feature vectors of at least one neighbor node corresponding to each search starting point are obtained from the memory in batches in units of packets.

[0129] The vector request packet includes but is not limited to: source request, iteration round, neighbor node memory access address, neighbor node memory access address length and other information. The source request carries the retrieval information of the query vector. Based on the search starting point predicted by the same access priority queue, the iteration round in the vector request packet of the search starting point is positively correlated with the vector distance between the feature vector of the search starting point and the query vector. The vector distance between the search starting point with an earlier iteration round and the query vector is smaller than that of the search starting point with a later iteration round. Correspondingly, the pre-fetching order of the feature vectors of the neighbor nodes corresponding to the search starting point with an earlier iteration round is earlier than that of the search starting point with a later iteration round.

[0130] As an example, see Figure 3, assuming that the source request of the query vector is REQ0, three search starting points are predicted based on the access priority queue: the first search starting point, the second search starting point and the third search starting point. According to the vector between the feature vector of each search starting point and the query vector, the iteration round of the vector request package 1 corresponding to the first search starting point with the smallest vector distance is recorded as 1, the iteration round of the vector request package 2 corresponding to the second search starting point with the second smallest vector distance is recorded as 2, and the iteration round of the vector request package 3 corresponding to the third search starting point with the largest vector distance is recorded as 3. These three vector request packages are scheduled in sequence in the order of 1-2-3 to pre-fetch the feature vectors of the neighbor nodes requested in the package from the memory.

[0131] In this embodiment, after predicting multiple search starting points based on the access priority queue, a vector request packet is used to batch request to obtain the feature vector of at least one neighbor node corresponding to each search starting point, thereby improving the access efficiency to the memory when pre-fetching the feature vectors of the neighbor nodes corresponding to multiple search starting points.

[0132] In some embodiments, considering that the storage locations of feature vectors of different nodes are different, the time spent reading feature vectors from memory is also different. When it takes a long time to read the feature vectors of neighboring nodes, most of the computing power resources of the computer device are wasted on waiting for the memory access results of the feature vectors, resulting in relatively high latency of the vector search task and low data throughput.

[0133] Based on this, for the predicted multiple search starting points, when pre-fetching the feature vectors of the corresponding neighbor nodes from the memory, if it takes a long time to pre-fetch the feature vectors of the neighbor nodes corresponding to a certain search starting point, you can skip the search starting point first and pre-fetch the feature vectors of the neighbor nodes corresponding to the next search starting point.

[0134] Taking multiple search starting points including a first search starting point and a second search starting point as an example, when the feature vector of the neighbor node corresponding to the first search starting point is first pre-fetched from the memory, and then the feature vector of the neighbor node corresponding to the second search starting point is pre-fetched, there are the following two implementation methods.

[0135] In the first implementation, the pre-fetching time of the feature vector of the neighbor node corresponding to the first search starting point is estimated; if the pre-fetching time is less than or equal to the specified time, the feature vector of the neighbor node corresponding to the first search starting point is first pre-fetched from the memory, and then the feature vector of the neighbor node corresponding to the second search starting point is pre-fetched. If the pre-fetching time is greater than the specified time, the first search starting point is skipped, and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched.

[0136] The specified duration is a duration set based on the data reading rate of the processor and / or memory, and the embodiment of the present application does not limit the specific value of the specified duration.

[0137] That is, when pre-fetching the feature vector of a neighboring node corresponding to a certain search starting point, it is possible to determine whether to skip the search starting point when pre-fetching the feature vector of the neighboring node by estimating the pre-fetching time of the feature vector of the neighboring node corresponding to the search starting point.

[0138] As an example, based on the number of neighbor nodes corresponding to the first search starting point, the pre-fetching time of the feature vector of the neighbor node corresponding to the first search starting point is estimated. The more neighbor nodes there are, the longer it takes to read the feature vectors of all neighbor nodes; the fewer neighbor nodes there are, the shorter it takes to read the feature vectors of all neighbor nodes.

[0139] As another example, in the case where the neighbor nodes of the first search starting point are determined by reading the neighbor node list of the first search starting point from the memory, the pre-fetching time of the neighbor node list of the first search starting point can be estimated based on the storage location of the neighbor node list of the first search starting point in the memory. Then, based on the pre-fetching time of the neighbor node list, the pre-fetching time of the feature vector of the neighbor node corresponding to the first search starting point is estimated. Among them, since pre-fetching the neighbor node list is a prerequisite for obtaining the feature vector of the neighbor node, the longer the pre-fetching time of the neighbor node list of the first search starting point, the longer the whole process of pre-fetching the feature vector of the neighbor node corresponding to the first search starting point from the memory; the shorter the pre-fetching time of the neighbor node list of the first search starting point, the shorter the whole process of pre-fetching the feature vector of the neighbor node corresponding to the first search starting point from the memory.

[0140] Of course, the pre-fetching time of the feature vector of the neighbor node corresponding to the first search starting point can also be estimated based on the first search starting point and / or other characteristics of the neighbor node corresponding to the first search starting point. The embodiment of the present application does not limit the estimation method of the pre-fetching time.

[0141] In the second implementation, the memory includes a local memory and a remote memory. At this time, if the feature vector of the neighbor node corresponding to the first search starting point is located in the local memory, the feature vector of the neighbor node corresponding to the first search starting point is pre-fetched from the local memory, and then the feature vector of the neighbor node corresponding to the second search starting point is pre-fetched. If the feature vector of the neighbor node corresponding to the first search starting point is located in the remote memory, the first search starting point is skipped, and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched.

[0142] It should be noted that, regarding memory, the "local" and "remote" in the embodiments of the present application refer to the CPU, GPU or accelerator that executes the vector retrieval solution. In other words, local memory refers to the memory directly managed and accessed by the processing node (such as the CPU, GPU or accelerator mentioned above), such as high bandwidth memory (HBM), double data rate memory (DDR) (directly connected to processing nodes such as CPU or GPU), etc.; remote memory refers to memory managed by non-processing nodes in multiple computing node scenarios. Memory with slower processor access speed. Among them, when the processing node reads data from the memory, the reading rate of the local memory is higher than that of the remote memory.

[0143] For ease of understanding, assume that processing node A and processing node B each have local memory. For processing node A, accessing the memory of processing node B is called accessing remote memory; correspondingly, for processing node B, accessing the memory of processing node A is also called accessing remote memory.

[0144] That is, when pre-fetching the feature vector of a neighbor node corresponding to a certain search starting point, it is possible to determine whether to skip the search starting point when pre-fetching the feature vector of the neighbor node by estimating whether the feature vector of the neighbor node corresponding to the search starting point is located in the local memory.

[0145] As an example, based on the vector request packet corresponding to the first search starting point, the memory access address of the neighbor node is obtained, and then based on the memory access address of the neighbor node, it is determined whether the feature vector of the neighbor node corresponding to the first search starting point is located in the local memory or the remote memory.

[0146] Optionally, when at least one of the neighbor nodes corresponding to the first search starting point has a feature vector located in the remote memory, the search starting point can be skipped, that is, the feature vectors of all the neighbor nodes corresponding to the search starting point are not pre-fetched, and the feature vectors of the neighbor nodes corresponding to the second search starting point are directly pre-fetched.

[0147] Optionally, when the feature vectors of the neighbor nodes corresponding to the first search starting point are located both in the local memory and in the remote memory, it is possible to skip only the neighbor nodes whose feature vectors are located in the remote memory, and perform the operation of pre-fetching feature vectors for the neighbor nodes whose feature vectors are located in the local memory. After pre-fetching the feature vectors of all the neighbor nodes in the first search starting point that are located in the local memory, pre-fetch the feature vectors of the neighbor nodes corresponding to the second search starting point.

[0148] In this embodiment, when acquiring feature vectors of neighbor nodes corresponding to multiple search starting points, a certain search starting point can be selectively skipped, feature vectors of neighbor nodes corresponding to other search starting points can be pre-fetched first, and the access priority queue can be updated. That is, the present application implements pre-fetching feature vectors of neighbor nodes by skipping the search starting point, which speeds up the update speed of the access priority queue, thereby improving the vector retrieval efficiency.

[0149] In some embodiments, since the vector retrieval algorithm based on the graph index itself has behavioral differences at different stages, in the initial search stage, the area where the query node (i.e., the node corresponding to the query vector) is located is approached, and in the final search stage, the search is performed near the query node to approach the query point. At different stages of vector retrieval, when predicting the search starting point of subsequent search rounds based on the access priority queue, the difference in prediction success rate is large. In the initial search stage, the number of updates to the access priority queue is small, and the nodes in the access priority queue are far from the query node. The predicted search starting point of the next search round is most likely not the node closest to the query node in the next search round, and the probability of its prediction success is low. As the number of iterative searches increases, when the number of updates to the access priority queue is large, the nodes in the access priority queue are close to the query node, and the predicted search starting point of the next search round is most likely the node closest to the query node in the next search round, and the probability of its prediction success is high. That is, the prediction success rate when predicting the search starting point increases with the number of updates to the access priority queue.

[0150] As an example, see Figure 4 , taking the public datasets DEEP10M and SIFT10M as examples, Figure 4 The corresponding relationship between the number of updates of the access priority queue and the success rate of predicting the search starting point is shown. When the number of updates of the access priority queue is less than 30, the predicted success rate of the search starting point is less than 0.8; when the number of updates of the access priority queue is greater than 35, the predicted success rate of the search starting point is greater than 0.8, and as the number of updates of the access priority queue increases, the predicted success rate of the search starting point can be stabilized at around 0.9.

[0151] Based on this, since the prediction success rate is low when predicting the search starting point at the initial search node, in order to ensure the accuracy of the vector retrieval result, when skipping the search starting point, the search starting point far from the query vector can be skipped, but the search starting point closest to the query vector cannot be skipped. Therefore, in the case of skipping the search starting point, the number of search starting points allowed to be skipped must be less than the first threshold.

[0152] The first threshold is the number of search starting points that can be skipped when pre-fetching feature vectors of neighboring nodes without affecting the accuracy of the vector search result. For example, the first threshold can be 3, 5, 8, etc.

[0153] That is, in the case of skipping the first search starting point, whether to continue pre-fetching the feature vector of the neighboring node corresponding to the second search starting point needs to be determined whether the number of skipped search starting points is less than the first threshold.

[0154] In a possible implementation, the implementation process of skipping the first search starting point and directly pre-fetching the feature vector of the neighbor node corresponding to the second search starting point is: skipping the first search starting point, and determining the number of skipped search starting points among multiple search starting points; if the number of skipped search starting points is less than the first threshold, pre-fetching the feature vector of the neighbor node corresponding to the second search starting point. If the number of skipped search starting points is equal to the first threshold, pre-fetching the feature vector of the neighbor node corresponding to the skipped search starting point, and suspending the update of the access priority queue.

[0155] That is, when the number of skipped search starting points is equal to the first threshold, in order to avoid skipping the search starting point with the smallest vector distance between the feature vector and the query vector, it is necessary to first obtain the feature vector of the neighbor node corresponding to the skipped search starting point to update the access priority queue, and then readjust the search direction based on the updated access priority queue to predict the new search starting point.

[0156] It should be noted that the embodiment of the present application does not impose any restrictions on the access priority queue corresponding to the skipped search starting point, that is, the skipped search starting point can be predicted based on the same access priority queue or based on different access priority queues.

[0157] Optionally, after updating the access priority queue based on the feature vector of the neighbor node corresponding to the skipped search starting point, the second search starting point can be directly discarded, and the above steps 201 and 202 can be performed based on the updated access priority queue; or the feature vector of the neighbor node corresponding to the second search starting point can be pre-fetched to update the access priority queue. The embodiment of the present application does not limit this.

[0158] In this embodiment, when the number of skipped search starting points is equal to the first threshold, the access priority queue is stopped from being updated based on the feature vectors of the neighboring nodes corresponding to the subsequent search starting points, and the access priority queue needs to be updated once based on the feature vectors of the neighboring nodes corresponding to the skipped search starting points before the subsequent search operation can be performed. In this way, it is possible to avoid skipping the search starting points that are close to the query vector, which causes the retrieval direction to deviate from the query vector, thereby ensuring the accuracy of the vector retrieval.

[0159] In some embodiments, since the search starting point is predicted based on the access priority queue, the feature vector of the neighbor node corresponding to the pre-fetched search starting point is decoupled. Therefore, when pre-fetching the feature vector from the memory, the search starting point corresponding to the multiple vector request packets to be scheduled may include the search starting point predicted by the previous access priority queue, and may also include the search starting point predicted by the current access priority queue. As described above, as the number of updates of the access priority queue increases, the prediction success rate when predicting the search starting point also increases. Therefore, if the search starting points corresponding to the multiple vector request packets to be scheduled include multiple search starting points predicted based on different access priority queues, the scheduling order of the vector request packets corresponding to each search starting point can be adjusted according to the number of updates of the access priority queue.

[0160] In one possible implementation, the implementation process of pre-fetching feature vectors of neighbor nodes corresponding to multiple search starting points from the memory is as follows: if the number of updates of the access priority queue is equal to the second threshold, and there is a second type of search starting point in the last predicted search starting point, then the feature vectors of neighbor nodes corresponding to the multiple search starting points are first pre-fetched from the memory, and then the feature vectors of neighbor nodes corresponding to the second type of search starting point are pre-fetched. The second type of search starting point is the search starting point for which the feature vectors of neighbor nodes in the last predicted search starting point were not pre-fetched.

[0161] In another possible implementation, the process of pre-fetching feature vectors of neighbor nodes corresponding to multiple search starting points from the memory is as follows: if the number of updates of the access priority queue is equal to the second threshold, and there is a second type of search starting point in the last predicted search starting point, then the second type of search starting point is discarded, and only the feature vectors of neighbor nodes corresponding to the multiple search starting points are pre-fetched from the memory.

[0162] That is, when the number of updates of the access priority queue is less than the second threshold, the vector request packets corresponding to the search starting points predicted by each access priority queue are scheduled in turn according to the update status of the access priority queue, and the feature vectors of the neighboring nodes corresponding to each search starting point are read from the memory in turn. When the number of updates of the access priority queue is equal to the second threshold, the vector request packet corresponding to the search starting point predicted by the access priority queue can be scheduled first, and the feature vectors of the neighboring nodes corresponding to the search starting point can be read from the memory first; and for the vector request packets corresponding to the second type of search starting points to be scheduled, the scheduling operation is performed later, or the scheduling operation is not performed.

[0163] The second threshold is the number of updates set based on the correspondence between the number of updates of the access priority queue and the prediction success rate of the search starting point and combined with the vector search experience. For example, the second threshold may be 30, 60, and so on.

[0164] As an example, assuming that the second threshold is 30, the search starting points of the feature vectors of the neighbor nodes to be pre-fetched include the search starting point M predicted by the access priority queue updated in the 29th round, the search starting point N and the search starting point P predicted by the access priority queue updated in the 30th round, and the vector distance between the search starting point N and the query vector is less than the vector distance between the search starting point P and the query vector. When pre-fetching the feature vectors of the neighbor nodes, the vector request packets corresponding to the search starting point N and the search starting point P are first scheduled to read the feature vectors of the neighbor nodes corresponding to the search starting point N and the search starting point P from the memory in sequence, and then the vector request packet corresponding to the search starting point M is scheduled to read the feature vector of the neighbor node corresponding to the search starting point M from the memory.

[0165] Optionally, only the vector request packets corresponding to the search starting point N and the search starting point P may be scheduled to sequentially read the feature vectors of the neighboring nodes corresponding to the search starting point N and the search starting point P from the memory, without performing the operation of scheduling the vector request packet corresponding to the search starting point M. The embodiment of the present application does not limit this.

[0166] It should be understood that for the search starting point predicted by the access priority queue that is less than the second threshold value, or greater than the second threshold value, the pre-fetching order is determined by the vector distance between each search starting point and the query vector, and the vector with a smaller distance is pre-fetched first, and the vector with a larger distance is pre-fetched later. Therefore, if the search starting point of the feature vector of the neighbor node to be pre-fetched also includes the search starting point Q predicted by the access priority queue updated in the 31st round, the vector request packet corresponding to the search starting point N is first scheduled to read the feature vector of the neighbor node corresponding to the search starting point N from the memory, and then the vector request packet corresponding to the search starting point P is scheduled to read the feature vector of the neighbor node corresponding to the search starting point P from the memory, and then the vector request packet corresponding to the search starting point Q is scheduled to read the feature vector of the neighbor node corresponding to the search starting point Q from the memory, and finally, the vector request packet corresponding to the search starting point M is scheduled to read the feature vector of the neighbor node corresponding to the search starting point M from the memory. In this process, the above-mentioned scheme of skipping the search starting point is also applicable.

[0167] Optionally, considering that the vector request packets to be scheduled may be generated based on the search starting points predicted by different access priority queues, the prefetch levels of the search starting points predicted by multiple access priority queues can be determined based on the number of updates of the access priority queues, thereby determining the order of scheduling the vector request packets corresponding to each search starting point according to the prefetch level of each search starting point.

[0168] When determining the pre-fetch level of the search starting point, only the second threshold mentioned above can be used to divide the pre-fetch levels into two levels; more thresholds can also be set to divide more pre-fetch levels, which is not limited in the embodiment of the present application.

[0169] As an example, the second threshold is set to 30 and the fourth threshold is set to 60. When the number of updates of the access priority queue is less than the second threshold, the prefetch level of the search starting point predicted by the access priority queue is set to the first priority; when the number of updates of the access priority queue is equal to or greater than the second threshold and less than the fourth threshold, the prefetch level of the search starting point predicted by the access priority queue is set to the second priority; when the number of updates of the access priority queue is equal to or greater than the fourth threshold, the prefetch level of the search starting point predicted by the access priority queue is set to the third priority.

[0170] If the search starting points include third-category search starting points, fourth-category search starting points, and fifth-category search starting points, and the prefetch level of the third-category search starting points is the first priority, the prefetch level of the fourth-category search starting points is the second priority, and the prefetch level of the fifth-category search starting points is the third priority, then in the order of third priority - second priority - first priority, first prefetch the feature vectors of the neighbor nodes corresponding to the fifth-category search starting points from the memory, then prefetch the feature vectors of the neighbor nodes corresponding to the fourth-category search starting points from the memory, and finally prefetch the feature vectors of the neighbor nodes corresponding to the third-category search starting points from the memory.

[0171] Optionally, the search starting point with the lowest pre-fetching level, i.e., the third search starting point mentioned above, may be deleted, and only the feature vectors of the neighboring nodes corresponding to the fifth category search starting point and the feature vectors of the neighboring nodes corresponding to the fourth category search starting point may be pre-fetched from the memory. This embodiment of the present application does not impose any restrictions on this.

[0172] In this embodiment, as the number of updates of the access priority queue increases, the neighbor nodes of the predicted search starting point are closer to the query node corresponding to the query vector. Therefore, when the number of updates of the access priority queue is equal to the second threshold, the feature vectors of the neighbor nodes corresponding to the search starting point predicted by the access priority queue can be obtained preferentially, and then the search starting point predicted by the access priority queue whose update number is less than the second threshold is pre-fetched The operation of the feature vector of the corresponding neighbor node is performed, thereby avoiding the problem of slow retrieval progress due to pre-fetching a large number of feature vectors of temporarily unused neighbor nodes, thereby improving the vector retrieval performance.

[0173] Step 203: updating the access priority queue based on the feature vectors of neighbor nodes corresponding to the first type of search starting point, where the first type of search starting point is a search starting point for which the feature vectors of neighbor nodes have been pre-fetched among multiple search starting points.

[0174] Since multiple search starting points are predicted for the same access priority queue and operations of searching neighbor nodes are performed in multiple directions, when the feature vectors of all neighbor nodes corresponding to any search starting point are pre-fetched, the access priority queue can be updated based on the feature vectors of the neighbor nodes corresponding to the search starting point, so that the updated access priority queue can be used to continue predicting the search starting point and performing operations of searching neighbor nodes.

[0175] It should be noted that for the same access priority queue, if the predicted multiple search starting points all pre-fetch the feature vectors of the corresponding neighbor nodes in sequence, the access priority queue can be updated multiple times based on the feature vectors of the neighbor nodes corresponding to each search starting point.

[0176] It can be seen that after predicting multiple search starting points based on the access priority queue and pre-fetching the feature vectors of neighbor nodes corresponding to the multiple search starting points, since the time lengths for pre-fetching feature vectors for different search starting points are different, the first type of search starting points used when updating the access priority queue are also different.

[0177] Next, a process of updating the access priority queue based on feature vectors of neighbor nodes corresponding to the first type of search starting points is introduced with multiple search starting points including a first search starting point and a second search starting point.

[0178] In the first update mode, the first type of search starting point is the first search starting point mentioned above. In this case, the feature vector of the neighbor node corresponding to the first search starting point is used to calculate the vector distance between the feature vector of each neighbor node and the query vector, and according to the vector distance, the neighbor node corresponding to the first search starting point is inserted into the access priority queue to update the access priority queue. For ease of description, the access priority queue containing the neighbor node of the first search starting point after the update is recorded as the first priority queue.

[0179] If the feature vector of the neighbor node corresponding to the second search starting point is pre-fetched, the feature vector of the neighbor node corresponding to the second search starting point is used to calculate the vector distance between the feature vector of each neighbor node and the query vector, and the neighbor node corresponding to the second search starting point is inserted into the first priority queue according to the vector distance to update the first priority queue. For ease of description, the updated first priority queue containing the neighbor node of the second search starting point is recorded as the second priority queue.

[0180] That is, for access priority queues, the first priority queue has newly added neighbor nodes corresponding to the first search starting point, and the second priority queue has newly added neighbor nodes corresponding to the first search starting point and neighbor nodes corresponding to the second search starting point.

[0181] In this update method, after pre-fetching the feature vectors of neighbor nodes corresponding to multiple search starting points, the access priority queue is updated multiple times, thereby improving the update frequency of the access priority queue; at the same time, based on the updated access priority queue, the search starting point in the next queue update round that is closer to the query vector can be accurately predicted, which, to a certain extent, also improves the prediction accuracy of the search starting point.

[0182] In the second update method, the first type of search starting point is the above-mentioned second search starting point. That is, when pre-fetching the feature vector of the neighbor node, the first search starting point is skipped, and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched. In this case, the feature vector of the neighbor node corresponding to the second search starting point is used to calculate the vector distance between the feature vector of each neighbor node and the query vector, and according to the vector distance, the neighbor node corresponding to the second search starting point is inserted into the access priority queue to update the access priority queue. For ease of description, the access priority queue containing the neighbor node of the second search starting point after the update is recorded as the third priority queue.

[0183] That is, for the access priority queue, a neighbor node corresponding to the second search starting point is newly added to the third priority queue.

[0184] In this update method, multiple search starting points are predicted based on an access priority queue. Therefore, nodes closer to the query vector are searched in different directions based on multiple search starting points. When updating the access priority queue, the access priority queue can be updated once according to the feature vector of the neighboring node corresponding to any search starting point. In this way, the update frequency of the access priority queue is improved; at the same time, after updating the access priority queue, multiple search starting points can be re-predicted to continue the search operation, which also improves the speed of vector retrieval to a certain extent.

[0185] In the third updating method, the first type of search starting point is the skipped search starting point. That is, when the number of skipped search starting points is equal to the first threshold, the feature vectors of the neighboring nodes corresponding to the skipped search starting points are pre-fetched, and the access priority queue is updated based on the feature vectors of the neighboring nodes corresponding to the skipped search starting points.

[0186] In this case, the feature vectors of the neighbor nodes corresponding to the skipped search starting points are used to calculate the vector distance between the feature vectors of each neighbor node and the query vector, and according to the vector distance, the neighbor nodes corresponding to all the skipped search starting points are inserted into the access priority queue to update the access priority queue. For ease of description, the access priority queue containing the neighbor nodes of all the skipped search starting points after the update is recorded as the fourth priority queue.

[0187] That is, for the access priority queue, the neighbor nodes corresponding to all skipped search starting points are newly added to the fourth priority queue.

[0188] Step 204: If the updated access priority queue meets the retrieval end condition, then based on the updated access priority queue, the vector retrieval result of the query vector is output.

[0189] The search end conditions include but are not limited to the following three:

[0190] (1) The nodes in the updated access priority queue no longer change.

[0191] That is, when the nodes in the updated access priority queue are the same as the nodes before the update, it means that after multiple rounds of searching, the query vector has been approached and a search starting point with a vector distance closer to the query vector can no longer be predicted. At this time, the retrieval can be terminated.

[0192] (2) The number of updates to the priority queue reaches the total number of iterative updates.

[0193] The total number of iterative updates may be a value set based on vector retrieval experience, such as 50 times, 50 times, etc.

[0194] When the number of updates to the access priority queue reaches the total number of iterative updates, it means that the search process converges and the nodes in the access priority queue tend to be stable. At this time, the retrieval can be ended.

[0195] (3) The vector distance between the feature vectors of the top-K nodes in the updated access priority queue and the query vector is less than the distance threshold.

[0196] That is, when the vector distance between the feature vectors of the top-K nodes in the updated access priority queue and the query vector is less than the distance threshold, the top-K nodes in the access priority queue are very likely to be located around the nodes of the query vector, and may even include the nodes of the query vector. At this time, the retrieval can be terminated.

[0197] It should be noted that the search end condition of the vector search may also be other conditions, which is not limited in the embodiment of the present application.

[0198] In some embodiments, each time the access priority queue is updated, a judgment is performed according to the above retrieval end condition. If the updated access priority queue meets the retrieval end condition, the vector retrieval result of the query vector is output based on the updated access priority queue.

[0199] In a possible implementation, according to the retrieval quantity threshold, the top-K nodes are selected from the nodes included in the updated access priority queue, and the feature vectors corresponding to the top-K nodes are output as the vector retrieval result of the query vector.

[0200] The retrieval quantity threshold is K, and K is a positive integer greater than 0. That is, the number of feature vectors included in the output vector retrieval result is equal to the retrieval quantity threshold.

[0201] It should be understood that when the number of nodes included in the updated access priority queue is less than or equal to the above retrieval quantity threshold, the feature vectors of all nodes in the updated access priority queue are directly output as the vector retrieval result of the query vector.

[0202] In some embodiments, if the updated access priority queue does not satisfy the retrieval end condition, it is necessary to loop through steps 201 to 204 based on the updated access priority queue until the updated access priority queue satisfies the retrieval end condition.

[0203] In the process of cyclically executing the above steps 201 to 204 to update the access priority queue, when the number of updates is large enough, the nodes in the updated access priority queue may tend to a stable state. At this time, in order to improve the pre-fetching efficiency of feature vectors and speed up the retrieval progress, the nodes in the access priority queue that have not traversed neighboring nodes can be batch processed.

[0204] In one possible implementation, if the number of times the access priority queue has been updated is less than the third threshold, the step of predicting multiple search starting points based on the access priority queue is executed, that is, the above steps 201-204 are looped to update the access priority queue until the updated access priority queue reaches the retrieval end condition.

[0205] The third threshold is the number of queue updates set based on the node stability of the access priority queue during the iterative update process and the vector search experience. The third threshold is greater than the second threshold. For example, when the total number of iterative updates is 100, the third threshold can be 80, 90, etc.

[0206] In other words, when the number of updates to the access priority queue is less than the third threshold, the entire search process may not yet be close to the area where the query node corresponding to the query vector is located. A larger number of nodes may need to be inserted each time the access priority queue is updated. The nodes in the access priority queue that have not traversed neighboring nodes are also in a state of change. At this time, in order to ensure the retrieval accuracy, it is necessary to continue to use the above-mentioned method of predicting multiple search starting points and continue to search for nodes closer to the query vector along at least one predicted direction. When the number of updates to the access priority queue is greater than or equal to the third threshold, the entire search process may have been searching near the query node corresponding to the query vector. A smaller number of nodes only need to be inserted each time the access priority queue is updated. The nodes in the access priority queue that have not traversed neighboring nodes tend to be in a stable state. At this time, the operation of pre-fetching the feature vectors of neighboring nodes can be performed on the nodes in the access priority queue that have not traversed neighboring nodes to improve the pre-fetching efficiency of feature vectors and speed up the retrieval progress.

[0207] In one possible implementation, if the number of times the access priority queue has been updated is greater than or equal to a third threshold, multiple target nodes in the access priority queue that have not traversed neighbor nodes are determined; feature vectors of neighbor nodes corresponding to the multiple target nodes are obtained; based on the feature vectors of neighbor nodes corresponding to the multiple target nodes, the access priority queue is updated; based on the updated access priority queue, the vector retrieval result of the query vector is output.

[0208] As an example, the multiple target nodes include a first node and a second node, and the vector distance between the feature vector of the first node and the query vector is smaller than the vector distance between the feature vector of the second node and the query vector. Then, the implementation process of obtaining the feature vectors of the neighbor nodes corresponding to the multiple target nodes is as follows: first, pre-fetch the feature vectors of the neighbor nodes corresponding to the first node from the memory, and then pre-fetch the feature vectors of the neighbor nodes corresponding to the second node.

[0209] Correspondingly, the implementation process of updating the access priority queue based on the feature vectors of the neighbor nodes corresponding to the multiple target nodes can be: based on the feature vectors of the neighbor nodes corresponding to the first node, the distance between the feature vectors of each neighbor node and the query vector is calculated, and the access priority queue is updated for the first time. Then, based on the feature vectors of the neighbor nodes corresponding to the second node, the distance between the feature vectors of each neighbor node and the query vector is calculated, and the access priority queue is updated for the second time. In this way, based on the access priority queue after the second update, the vector retrieval result of the query vector is output.

[0210] Optionally, the implementation process of updating the access priority queue based on the feature vectors of neighbor nodes corresponding to multiple target nodes can be: for the feature vectors of the neighbor nodes corresponding to the first node, and the feature vectors of the neighbor nodes corresponding to the second node, calculate the distance between the feature vector of each neighbor node and the query vector, update the access priority queue once, and output the vector retrieval result of the query vector based on the updated access priority queue.

[0211] That is, when the access priority queue is updated by using the feature vectors of the neighbor nodes corresponding to multiple target nodes, the feature vectors of the neighbor nodes corresponding to each target node can be used in turn to update the access priority queue multiple times. The access priority queue can also be updated once by using the feature vectors of the neighbor nodes corresponding to multiple target nodes, which is not limited in the embodiments of the present application.

[0212] As another example, the implementation process of obtaining feature vectors of neighbor nodes corresponding to multiple target nodes is: determine at least one neighbor node from the neighbor nodes corresponding to the multiple target nodes, and the feature vector of at least one neighbor node is located in the same remote memory; obtain the feature vector of at least one neighbor node from the remote memory.

[0213] Since the feature vector of each node may be located in the local memory or in the remote memory, the corresponding pre-fetch duration of the feature vector is also different. Based on this, after determining the neighbor nodes corresponding to multiple target nodes, the neighbor nodes corresponding to the multiple target nodes can be classified according to the storage location of the feature vector of each neighbor node. For at least one neighbor node whose feature vector is stored in the same remote memory, the feature vector of the at least one neighbor node is batch obtained from the remote memory to improve the reading efficiency of the feature vector.

[0214] Similarly, when the neighbor nodes corresponding to each target node are determined by the neighbor node list stored in the memory, multiple target nodes can also be classified according to the storage location of the neighbor node list of each target node. For at least one target node whose neighbor node list is stored in the same remote memory, the neighbor node list of the at least one target node can be batch obtained from the remote memory to improve the node search efficiency when determining the neighbor nodes corresponding to the target node.

[0215] In addition, when the number of updates of the access priority queue is greater than the third threshold, the feature vector of the neighbor node corresponding to the target node in the access priority queue whose neighbor nodes have not been traversed may have been pre-fetched in a previous search round. Therefore, in order to avoid repeatedly reading the feature vector of the same node from the memory, for the target node in the access priority queue whose neighbor nodes have not been traversed, after determining the neighbor nodes corresponding to multiple target nodes, it is necessary to first check for duplication of the neighbor node to determine whether the feature vector of the neighbor node has been pre-fetched in the historical search process.

[0216] The specific implementation process of determining whether the feature vectors of the neighbor nodes corresponding to the target node have been pre-fetched during the historical search process can be found in the relevant description of the visited queue under step 202 above, which will not be repeated here.

[0217] In an embodiment of the present application, when a computer device performs a vector retrieval task, it can predict multiple search starting points for an access priority queue, and increase the concurrency of memory access when pre-fetching feature vectors by increasing the number of search starting points. Since multiple search starting points are predicted based on an access priority queue, after pre-fetching the feature vector of the neighboring node corresponding to the first type of search starting point, the feature vector of the neighboring node corresponding to the first type of search starting point can be used to update the access priority queue. That is, when updating the access priority queue, the access priority queue can be updated by skipping at least one search starting point among multiple search starting points in the order of pre-fetching feature vectors from the memory to predict a new search starting point. In this way, the update frequency of the access priority queue is increased, thereby improving the vector retrieval performance.

[0218] It should be noted that when introducing the vector retrieval method provided in the embodiments of the present application, different embodiments are used to illustrate different technical features. In actual implementation, the above embodiments can be combined with each other, and the present application does not impose any restrictions on this.

[0219] Figure 5 is a schematic diagram of the structure of a vector search device provided in an embodiment of the present application. The vector search device can be implemented by software, hardware, or a combination of both to form a part or all of a device including a CPU, a GPU, or an accelerator. Figure 5 The vector retrieval device includes: a prediction module 501, a feature reading module 502, a queue updating module 503 and an output module 504.

[0220] Prediction module 501, used to predict multiple search starting points according to the access priority queue, the access priority queue includes multiple nodes, and the multiple nodes are arranged in sequence according to the vector distance between the feature vectors of the multiple nodes and the query vector, and the search starting point is a node in the access priority queue that has not traversed neighbor nodes;

[0221] A feature reading module 502 is used to pre-fetch feature vectors of neighbor nodes corresponding to a plurality of search starting points from a memory;

[0222] A queue updating module 503 is used to update the access priority queue based on the feature vector of the neighbor node corresponding to the first type of search starting point, where the first type of search starting point is a search starting point for which the feature vector of the neighbor node has been pre-fetched among the multiple search starting points;

[0223] The output module 504 is configured to output the vector search result of the query vector based on the updated access priority queue if the updated access priority queue meets the search end condition.

[0224] Optionally, the multiple search starting points include a first search starting point and a second search starting point, and a vector distance between a feature vector of the first search starting point and a query vector is smaller than a vector distance between a feature vector of the second search starting point and a query vector;

[0225] The feature reading module 502 is specifically used for:

[0226] The feature vectors of the neighboring nodes corresponding to the first search starting point are first pre-fetched from the memory, and then the feature vectors of the neighboring nodes corresponding to the second search starting point are pre-fetched.

[0227] Optionally, the feature reading module 502 includes:

[0228] A duration estimation unit, used to estimate the pre-fetch duration of the feature vector of the neighboring node corresponding to the first search starting point;

[0229] The first reading unit is used to pre-fetch the feature vector of the neighbor node corresponding to the first search starting point from the memory if the pre-fetching duration is less than or equal to the specified duration, and then pre-fetch the feature vector of the neighbor node corresponding to the second search starting point.

[0230] Optionally, the first reading unit is further used for:

[0231] If the pre-fetch duration is longer than the specified duration, the first search starting point is skipped and the feature vectors of the neighboring nodes corresponding to the second search starting point are directly pre-fetched.

[0232] Optionally, the memory includes a local memory and a remote memory; the feature reading module 502 includes:

[0233] The second reading unit is used to pre-fetch the feature vector of the neighbor node corresponding to the first search starting point from the local memory if the feature vector of the neighbor node corresponding to the first search starting point is located in the local memory, and then pre-fetch the feature vector of the neighbor node corresponding to the second search starting point.

[0234] Optionally, the second reading unit is further used for:

[0235] If the feature vector of the neighbor node corresponding to the first search starting point is located in the remote memory, the first search starting point is skipped and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched.

[0236] Optionally, the feature reading module 502 further includes:

[0237] A skip point counting unit, used for skipping the first search starting point and determining the number of skipped search starting points among the multiple search starting points;

[0238] The third reading unit is used to pre-fetch the feature vector of the neighbor node corresponding to the second search starting point if the number of skipped search starting points is less than the first threshold.

[0239] Optionally, the third reading unit is further used for:

[0240] If the number of skipped search starting points is equal to the first threshold, pre-fetching feature vectors of neighboring nodes corresponding to the skipped search starting points, and suspending updating of the access priority queue;

[0241] The queue updating module 503 is further used for:

[0242] The access priority queue is updated based on the feature vectors of the neighbor nodes corresponding to the skipped search starting point.

[0243] Optionally, the feature reading module 502 is further configured to:

[0244] If the number of updates of the access priority queue is equal to the second threshold, and there is a second type of search starting point in the last predicted search starting point, the feature vectors of the neighbor nodes corresponding to the multiple search starting points are first pre-fetched from the memory, and then the feature vectors of the neighbor nodes corresponding to the second type of search starting point are pre-fetched. The second type of search starting point is the search starting point for which the feature vectors of the neighbor nodes were not pre-fetched in the last predicted search starting point.

[0245] Optionally, the queue updating module 503 is further configured to:

[0246] If the number of times the access priority queue has been updated is less than the third threshold, the step of predicting multiple search starting points based on the access priority queue is executed.

[0247] Optionally, the queue updating module 503 includes:

[0248] a node determination unit, configured to determine a plurality of target nodes in the access priority queue that have not traversed neighboring nodes if the number of times the access priority queue has been updated is greater than or equal to a third threshold;

[0249] A feature reading unit, used to obtain feature vectors of neighboring nodes corresponding to multiple target nodes;

[0250] A queue updating unit, used for updating the access priority queue based on feature vectors of neighbor nodes corresponding to multiple target nodes;

[0251] The result output unit is used to output the vector retrieval result of the query vector based on the updated access priority queue.

[0252] Optionally, the feature reading unit is specifically used to:

[0253] Determine at least one neighbor node from neighbor nodes corresponding to multiple target nodes, and a feature vector of at least one neighbor node is located in the same remote memory;

[0254] Get the feature vector of at least one neighbor node from remote memory.

[0255] Optionally, the vector search device 500 further includes:

[0256] A node checking module is used to determine whether a feature vector of a target neighbor node has been pre-fetched during a historical search process, where the target neighbor node is any neighbor node determined based on an access priority queue;

[0257] The node checking module is also used to discard the target neighbor node if the feature vector of the target neighbor node has been pre-fetched during the historical search process.

[0258] In an embodiment of the present application, when executing a vector retrieval task, the vector retrieval device can predict multiple search starting points for an access priority queue, and increase the memory access concurrency when pre-fetching feature vectors by increasing the number of search starting points. Since multiple search starting points are predicted based on an access priority queue, after pre-fetching the feature vector of the neighboring node corresponding to the first type of search starting point, the feature vector of the neighboring node corresponding to the first type of search starting point can be used to update the access priority queue. That is, when updating the access priority queue, the access priority queue can be updated by skipping at least one search starting point among multiple search starting points in the order of pre-fetching feature vectors from the memory to predict a new search starting point. In this way, the update frequency of the access priority queue is increased, thereby improving the vector retrieval performance.

[0259] It should be noted that: when the vector retrieval device provided in the above embodiment performs a vector retrieval task, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the vector retrieval device provided in the above embodiment and the vector retrieval method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0260] Figure 6 Schematic diagram of the architecture of a processing node provided in an embodiment of the present application. The processing node can be implemented by software, hardware, or a combination of both to form part or all of a device including a CPU, a GPU, or an accelerator. Figure 6When implementing the above-mentioned vector retrieval method, the processing node includes: a controller, a processing engine (PE), a memory access engine (MAE), a local memory (which may include HBM, DDR and other types of memory) and a communication module.

[0261] Among them, the controller is used to control the execution of the entire search process; PE is used to realize the calculation of vector distance and the Top-K sorting of local feature vectors; MAE is used to access the memory to read feature vectors, including accessing local memory and accessing remote memory; local memory is used to store feature vectors; and the communication module is used to realize communication between different nodes.

[0262] It should be noted that the embodiment of the present application does not limit the number of processing nodes for executing the vector search solution in parallel. Figure 6 In the example, N processing nodes communicate with each other. Similarly, the number of PE and MAE can be one or more, and the embodiment of the present application does not limit this.

[0263] In a possible implementation, PE predicts multiple search starting points based on the access priority queue and sends the multiple search starting points to MAE. Based on the multiple search starting points, MAE determines the neighbor nodes corresponding to the multiple search starting points from the graph index of the vector database, reads the feature vectors of the corresponding neighbors corresponding to the multiple search starting points from the memory, and then sends the feature vectors of the corresponding neighbors corresponding to the multiple search starting points to PE. PE calculates the vector distance between the feature vector of each neighbor node and the query vector based on the feature vectors of the corresponding neighbors corresponding to the multiple search starting points, and inserts each neighbor node into the access priority queue according to the size of the vector distance to update the access priority queue.

[0264] See also Figure 7 , the embodiment of the present application also provides a memory access engine, when executing the above-mentioned reading of the feature vectors of the neighbor nodes corresponding to each search starting point based on multiple search starting points, the MAE can command the read and write (R / W-CMD) module, the neighbor node read and write (R / W-Neighbor.id) module, the feature vector read and write (R / W-Feature) module, the output read and write (R / W-Output) module, the request allocation module, etc. Next, the specific functions of each module are introduced.

[0265] (1) R / W-CMD module, used to obtain initialization (int), start search (start) and other commands from the main CPU (responsible for the allocation and control of vector retrieval tasks) to the controller.

[0266] The initialization work includes: writing the feature vector of the node in the vector database and building the graph index of the vector database; the work of starting the search includes: inputting the query vector, initializing the visited queue, and initializing the access priority queue.

[0267] It should be noted that the embodiment of the present application stores the visited queue in the form of a hash table in RAM, namely, Hash Visited RAM, referred to as HVR herein.

[0268] (2) R / W-Neighbor.id module, used to obtain the node identifier (denoted as Vid) of the search starting point from the PE, and then determine the neighbor node list of the search starting point from the graph index based on the node identifier of the search starting point. The neighbor node list includes the node identifier (denoted as Nid) of at least one neighbor node.

[0269] After obtaining the neighbor node list of Vid, confirm in HVR whether each neighbor node has been visited in the historical search process. If it has been visited (that is, the feature vector of Nid has been visited and obtained), skip the subsequent operations on this neighbor node, that is, do not insert it into the visited queue, do not obtain the feature vector of the neighbor node, and do not obtain the feature vector of the neighbor node).

[0270] In some embodiments, the R / W-Neighbor.id module also has the function of managing the pre-fetching of feature vectors in local memory and remote memory.

[0271] (3) R / W-Feature module, which is used to obtain the feature vector of the neighbor node corresponding to the search starting point from the local memory or remote memory according to the neighbor node list, and send the obtained feature vector to PE.

[0272] After receiving the feature vector of the neighbor node, PE calculates the vector distance between the feature vector of the neighbor node and the query vector, and sorts the neighbor nodes according to the vector distance, etc. Then, PE updates the access priority queue based on the sorting result of the neighbor nodes, and predicts a new search starting point again based on the updated access priority queue.

[0273] (4) R / W-Output module, which is used to output the vector retrieval results to the main CPU, that is, the Top-K feature vectors with a close distance to the query vector.

[0274] It should be noted that the above-mentioned R / W-CMD module, R / W-Neighbor.id module, R / W-Feature module, and R / W-Output module are respectively connected to the remote node, local memory (including DDR and HBM), and main CPU through the request allocation module.

[0275] Optionally, the request distribution module can also be understood as an information routing network.

[0276] The node identifiers of visited neighbor nodes in the related art are usually stored in the form of visited queues in dynamic random access memory (DRAM), resulting in a high delay when traversing the visited queues. As described in the previous embodiments, the embodiments of the present application use a "lossy" visited queue to record nodes that have visited memory and obtained feature vectors. When judging whether the feature vector of a neighbor node has been pre-fetched in the historical search process based on the visited queue, the access speed to the visited queue can be accelerated, while the impact on the vector retrieval accuracy is low.

[0277] Figure 8 This is a schematic diagram of the structure of an HVR (i.e., Hash Visited RAM) module provided in an embodiment of the present application, see Figure 8 In a possible implementation, the scheme of using a hash table to store the visited queue is as follows: for the Nid of a neighbor node, before pre-fetching its feature vector, first confirm in the HVR module whether it has been visited. After receiving the Nid, the HVR module uses a comparison module (for example, comparator CRC-12Gen) to generate M hashkeys using a hash function, and then checks the positions corresponding to the hash keys in the M hash tables to see if there is a matching Nid. If there is a matching Nid, the visited check result is confirmed to be true; if there is no matching Nid, the visited check result is confirmed to be false.

[0278] Furthermore, if the visited verification result returned by a neighbor node Nid is false, the logic selection module attempts to insert the Nid into the Hash table. The logic selection module selects the Hash table that can be inserted according to the validity of the corresponding positions of the M Hash keys in the Hash table. Specifically, there are two situations:

[0279] (1) If there is at least one position in the M hash tables whose valid value is false, it means that the position is not occupied. Then select a hash table to insert the Nid of the neighbor node and set the valid value of the position to true.

[0280] If there are multiple unoccupied empty positions in the M hash tables, any position can be selected for insertion, and this embodiment of the present application does not impose any restrictions on this.

[0281] (2) If the positions corresponding to M hash keys in M ​​hash tables are all occupied, the Nid is discarded, that is, the Nid is not inserted into the hash table.

[0282] It should be understood that the above Figure 6 - Figure 8 This is only an exemplary structure for implementing the vector retrieval method provided in the embodiment of the present application, wherein the connection between the modules only indicates that there is a communication connection between the two modules, which can be a physical connection or a network connection, and the embodiment of the present application does not limit this. In actual application, other hardware, software or hardware and software structures can also be used to implement it, and the embodiment of the present application does not limit this.

[0283] 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 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 can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. 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. For example, the computer instructions can be transmitted from a website site, computer, server or 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, server or data center. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiment of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.

[0284] It should be understood that the "multiple" mentioned herein refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit them to be necessarily different.

[0285] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of the present application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0286] The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A vector retrieval method, characterized in that: The method comprises: Predicting multiple search starting points according to an access priority queue, the access priority queue comprising multiple nodes, and the multiple nodes are arranged in sequence according to the magnitude of the vector distance between the feature vectors of the multiple nodes and the query vector, and the search starting point is a node in the access priority queue whose neighbor nodes have not been traversed; Pre-fetching feature vectors of neighbor nodes corresponding to the multiple search starting points from the memory; The access priority queue is updated based on feature vectors of neighbor nodes corresponding to a first type of search starting point, wherein the first type of search starting point is a search starting point for which feature vectors of neighbor nodes have been pre-fetched among the multiple search starting points; If the updated access priority queue meets the retrieval end condition, the vector retrieval result of the query vector is output based on the updated access priority queue.

2. The method according to claim 1, characterized in that The multiple search starting points include a first search starting point and a second search starting point, and a vector distance between a feature vector of the first search starting point and the query vector is smaller than a vector distance between a feature vector of the second search starting point and the query vector; The step of pre-fetching feature vectors of neighbor nodes corresponding to the plurality of search starting points from the memory includes: The feature vectors of the neighboring nodes corresponding to the first search starting point are first pre-fetched from the memory, and then the feature vectors of the neighboring nodes corresponding to the second search starting point are pre-fetched.

3. The method according to claim 2, characterized in that The step of first pre-fetching the feature vector of the neighboring node corresponding to the first search starting point from the memory, and then pre-fetching the feature vector of the neighboring node corresponding to the second search starting point, comprises: estimating a pre-fetching duration of a feature vector of a neighboring node corresponding to the first search starting point; If the pre-fetch duration is less than or equal to the specified duration, the feature vectors of the neighboring nodes corresponding to the first search starting point are first pre-fetched from the memory, and then the feature vectors of the neighboring nodes corresponding to the second search starting point are pre-fetched.

4. The method according to claim 3, characterized in that After estimating the pre-fetching duration of the feature vector of the neighboring node corresponding to the first search starting point, the method further includes: If the pre-fetching duration is greater than the specified duration, the first search starting point is skipped, and the feature vector of the neighboring node corresponding to the second search starting point is directly pre-fetched.

5. The method according to claim 2, characterized in that The memory includes local memory and remote memory; The step of first pre-fetching the feature vector of the neighboring node corresponding to the first search starting point from the memory, and then pre-fetching the feature vector of the neighboring node corresponding to the second search starting point, comprises: If the feature vector of the neighbor node corresponding to the first search starting point is located in the local memory, the feature vector of the neighbor node corresponding to the first search starting point is pre-fetched from the local memory, and then the feature vector of the neighbor node corresponding to the second search starting point is pre-fetched.

6. The method according to claim 5, characterized in that The method further comprises: If the feature vector of the neighbor node corresponding to the first search starting point is located in the remote memory, the first search starting point is skipped and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched.

7. The method according to claim 4 or 6, characterized in that The step of skipping the first search starting point and directly pre-fetching a feature vector of a neighboring node corresponding to the second search starting point includes: skipping the first search starting point, and determining the number of skipped search starting points among the plurality of search starting points; If the number of the skipped search starting points is less than a first threshold, the feature vectors of the neighboring nodes corresponding to the second search starting point are pre-fetched.

8. The method according to claim 7, characterized in that After determining the number of skipped search starting points among the multiple search starting points, the method further includes: If the number of the skipped search starting points is equal to the first threshold, pre-fetching feature vectors of neighboring nodes corresponding to the skipped search starting points, and suspending updating of the access priority queue; The updating of the access priority queue based on the feature vector of the neighbor node corresponding to the first type of search starting point includes: The access priority queue is updated based on the feature vectors of the neighbor nodes corresponding to the skipped search starting point.

9. The method according to any one of claims 1 to 8, characterized in that The step of pre-fetching feature vectors of neighbor nodes corresponding to the plurality of search starting points from the memory includes: If the number of updates of the access priority queue is equal to the second threshold, and there is a second type of search starting point in the last predicted search starting point, the feature vectors of the neighbor nodes corresponding to the multiple search starting points are first pre-fetched from the memory, and then the feature vectors of the neighbor nodes corresponding to the second type of search starting point are pre-fetched. The second type of search starting point is the search starting point for which the feature vectors of the neighbor nodes were not pre-fetched in the last predicted search starting point.

10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: If the number of times the access priority queue has been updated is less than the third threshold, the step of predicting multiple search starting points based on the access priority queue is performed.

11. The method according to claim 10, characterized in that The method further comprises: If the number of times the access priority queue has been updated is greater than or equal to the third threshold, determining a plurality of target nodes in the access priority queue that have not traversed neighbor nodes; Obtaining feature vectors of neighbor nodes corresponding to the multiple target nodes; Based on the feature vectors of neighbor nodes corresponding to the multiple target nodes, the access priority queue is updated; Based on the updated access priority queue, a vector retrieval result of the query vector is output.

12. The method according to claim 11, characterized in that The obtaining feature vectors of neighbor nodes corresponding to the multiple target nodes includes: Determine at least one neighbor node from the neighbor nodes corresponding to the multiple target nodes, wherein the feature vector of the at least one neighbor node is located in the same remote memory; A feature vector of the at least one neighbor node is obtained from the remote memory.

13. The method according to any one of claims 1 to 12, characterized in that: Before obtaining the feature vector of the neighbor node, the method further includes: Determining whether a feature vector of a target neighbor node has been pre-fetched during a historical search process, the target neighbor node being any neighbor node determined based on the access priority queue; If the feature vector of the target neighbor node has been pre-fetched during the historical search process, the target neighbor node is discarded.

14. A vector search device, characterized in that: The device comprises: A prediction module, used to predict multiple search starting points according to an access priority queue, wherein the access priority queue includes multiple nodes, and the multiple nodes are arranged in sequence according to the magnitude of the vector distance between the feature vectors of the multiple nodes and the query vector, and the search starting point is a node in the access priority queue that has not traversed neighboring nodes; A feature reading module, used for pre-fetching feature vectors of neighbor nodes corresponding to the multiple search starting points from a memory; A queue updating module, configured to update the access priority queue based on a feature vector of a neighboring node corresponding to a first type of search starting point, wherein the first type of search starting point is a search starting point for which a feature vector of a neighboring node has been pre-fetched among the multiple search starting points; The output module is configured to output the vector search result of the query vector based on the updated access priority queue if the updated access priority queue satisfies the search end condition.

15. The device according to claim 14, characterized in that The multiple search starting points include a first search starting point and a second search starting point, and a vector distance between a feature vector of the first search starting point and the query vector is smaller than a vector distance between a feature vector of the second search starting point and the query vector; The feature reading module is specifically used for: The feature vectors of the neighboring nodes corresponding to the first search starting point are first pre-fetched from the memory, and then the feature vectors of the neighboring nodes corresponding to the second search starting point are pre-fetched.

16. The device according to claim 15, characterized in that The feature reading module comprises: A duration estimation unit, used to estimate the pre-fetch duration of the feature vector of the neighboring node corresponding to the first search starting point; The first reading unit is used to pre-fetch the feature vector of the neighbor node corresponding to the first search starting point from the memory first, and then pre-fetch the feature vector of the neighbor node corresponding to the second search starting point if the pre-fetch duration is less than or equal to the specified duration.

17. The device according to claim 16, characterized in that The first reading unit is further used for: If the pre-fetching duration is greater than the specified duration, the first search starting point is skipped, and the feature vector of the neighboring node corresponding to the second search starting point is directly pre-fetched.

18. The device according to claim 15, characterized in that The memory includes local memory and remote memory; The feature reading module comprises: The second reading unit is used to pre-fetch the feature vector of the neighbor node corresponding to the first search starting point from the local memory if the feature vector of the neighbor node corresponding to the first search starting point is located in the local memory, and then pre-fetch the feature vector of the neighbor node corresponding to the second search starting point.

19. The device according to claim 18, characterized in that The second reading unit is further used for: If the feature vector of the neighbor node corresponding to the first search starting point is located in the remote memory, the first search starting point is skipped and the feature vector of the neighbor node corresponding to the second search starting point is directly pre-fetched.

20. The device according to claim 17 or 19, characterized in that The feature reading module further includes: a skip point counting unit, configured to skip the first search starting point and determine the number of skipped search starting points among the multiple search starting points; The third reading unit is used to pre-fetch the feature vector of the neighboring node corresponding to the second search starting point if the number of the skipped search starting points is less than the first threshold.

21. The device according to claim 20, characterized in that The third reading unit is further used for: If the number of the skipped search starting points is equal to the first threshold, pre-fetching feature vectors of neighboring nodes corresponding to the skipped search starting points, and suspending updating of the access priority queue; The queue updating module is further used for: The access priority queue is updated based on the feature vectors of the neighbor nodes corresponding to the skipped search starting point.

22. The device according to any one of claims 14 to 21, characterized in that The feature reading module is further used for: If the number of updates of the access priority queue is equal to the second threshold, and there is a second type of search starting point in the last predicted search starting point, the feature vectors of the neighbor nodes corresponding to the multiple search starting points are first pre-fetched from the memory, and then the feature vectors of the neighbor nodes corresponding to the second type of search starting point are pre-fetched. The second type of search starting point is the search starting point for which the feature vectors of the neighbor nodes were not pre-fetched in the last predicted search starting point.

23. The device according to any one of claims 14 to 22, characterized in that The queue updating module is also used for: If the number of times the access priority queue has been updated is less than the third threshold, the step of predicting multiple search starting points based on the access priority queue is performed.

24. The device according to claim 23, characterized in that The queue updating module comprises: a node determination unit, configured to determine a plurality of target nodes in the access priority queue that have not traversed neighbor nodes if the number of times the access priority queue has been updated is greater than or equal to the third threshold; A feature reading unit, used to obtain feature vectors of neighbor nodes corresponding to the multiple target nodes; A queue updating unit, configured to update the access priority queue based on feature vectors of neighbor nodes corresponding to the multiple target nodes; A result output unit is used to output the vector retrieval result of the query vector based on the updated access priority queue.

25. The device according to claim 24, characterized in that The feature reading unit is specifically used for: Determine at least one neighbor node from the neighbor nodes corresponding to the multiple target nodes, wherein the feature vector of the at least one neighbor node is located in the same remote memory; A feature vector of the at least one neighbor node is obtained from the remote memory.

26. The device according to any one of claims 14 to 25, characterized in that The device also includes: A node checking module, used to determine whether a feature vector of a target neighbor node has been pre-fetched during a historical search process, wherein the target neighbor node is any neighbor node determined based on the access priority queue; The node checking module is further configured to discard the target neighboring node if the feature vector of the target neighboring node has been pre-fetched during the historical search process.

27. A computer device, characterized in that: The computer device includes a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method according to any one of claims 1 to 13.

28. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 13 are implemented.

Citation Information

Cited By

  • Parallel construction algorithm for in-memory hierarchical navigable small world vector index in a relational database management system

    US12613848B2

  • Parallel construction algorithm for in-memory hierarchical navigable small world vector index in a relational database management system

    US20250335410A1