Vector retrieval method, apparatus, device and readable storage medium
By converting the vector dataset into a vector node graph and storing it in a distributed manner, and utilizing a collaborative retrieval method involving navigation nodes and adjacent nodes, the problems of low accuracy and efficiency in distributed vector retrieval are solved, achieving a highly efficient vector retrieval effect.
Patent Information
- Application Number
- CN202410471011.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-18
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2044-04-18
AI Technical Summary
In existing technologies, distributed vector retrieval scenarios suffer from problems such as communication overhead, insufficient local data, and unbalanced load, resulting in low retrieval accuracy and efficiency.
The vector dataset is converted into a vector node graph and stored in a distributed manner. Navigation nodes are used as starting exploration nodes, and the search range is expanded through adjacent nodes to achieve collaborative retrieval between distributed servers. The node closest to the target vector in the candidate vector pool is selected as the new starting exploration node for iterative retrieval.
It improves the accuracy and efficiency of vector retrieval, expands the retrieval coverage, and makes full use of system resources, enabling multiple servers to collaborate in completing retrieval tasks.
Smart Images

Figure CN118170825B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data retrieval technology, and in particular to a vector retrieval method, apparatus, device, and readable storage medium. Background Technology
[0002] Vector retrieval refers to finding vectors similar to a given query vector within a given vector dataset. It is used in fields such as information retrieval and machine learning to find similar documents, images, audio, or other types of data. For large vector datasets, such as those containing billions of vectors, the dataset is typically distributed across multiple machines for distributed vector retrieval.
[0003] In related technologies, for distributed vector retrieval scenarios, the existing hierarchical navigable small-world algorithm is used to retrieve the vector data stored on one or more machines. The vector data stored on each machine is constructed into a multi-level small-world graph and then searched separately.
[0004] However, the above retrieval methods are affected by issues such as communication overhead, insufficient local data, and unbalanced load, resulting in low retrieval accuracy and efficiency. Summary of the Invention
[0005] In view of this, in order to solve the above-mentioned technical problems, this application provides a vector retrieval method, apparatus, device and readable storage medium.
[0006] Specifically, this application is implemented through the following technical solution:
[0007] According to a first aspect of the embodiments of this application, a vector retrieval method is provided. This method is applied to any server in a distributed system, the distributed system being used to store a vector node graph corresponding to a vector dataset; each server in the distributed system stores a preset navigation node in the vector node graph, and adjacent nodes of the navigation node; the method includes:
[0008] In response to receiving a retrieval request for a target vector, the node distance pairs between the navigation node and the target vector are obtained and stored in the candidate vector pool; the node distance pairs include the node identifier and the distance between the node and the target vector;
[0009] The retrieval process, starting with the navigation node, includes: determining the node distance pairs of each neighboring node of the starting node to the target vector, deduplicating the node distance pairs with those in the candidate vector pool, sorting them in ascending order of distance, and storing a predetermined number of the top-ranked node distance pairs in the candidate vector pool; updating the starting node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting node is located repeats the retrieval process until all nodes in the candidate vector pool have been explored;
[0010] Based on the node distance pairs stored in the candidate vector pool after the retrieval process is completed, the retrieval result of the target vector is determined.
[0011] Optionally, determining the node distance pairs of each adjacent node of the starting exploration node to the target vector includes:
[0012] Get the node server where each neighboring node is located;
[0013] The node distance pair between the first adjacent node and the target vector is calculated locally; the first adjacent node refers to the adjacent node of the node server that is currently performing the retrieval process.
[0014] Distance calculation requests are sent in parallel to the node servers of all neighboring nodes except the first neighboring node; the distance calculation requests are used to instruct the node servers to return the node distance pairs of the other neighboring nodes to the target vector.
[0015] Optionally, each server also stores a first node that can be connected to the navigation node via no more than N edges; after the starting exploration node is updated, the retrieval process further includes:
[0016] If the starting exploration node is the first node, the server that is performing the retrieval process continues to perform the retrieval process;
[0017] If the starting exploration node is not the first node, and the server where the starting exploration node is located is a server that is currently performing retrieval processing, then the retrieval processing continues; otherwise, it is determined that the server where the starting exploration node is located continues to perform the retrieval request.
[0018] Optionally, the retrieval process further includes:
[0019] Traverse the identifier pairs in the preset server set to determine the target identifier pairs whose node identifiers are the same as the node identifiers of the updated starting exploration node; the server set is used to store the identifier pairs of each node indicated by a set number of node distance pairs stored in the candidate vector pool by the retrieval process; the identifier pair includes the node identifier and the identifier of the server where the node is located;
[0020] The server where the starting exploration node is located is determined based on the server identifier in the target identifier pair.
[0021] Optionally, the candidate vector pool is stored on the server that is performing the retrieval process; the retrieval process further includes: if the server where the starting exploration node is located is not the server that is performing the retrieval process, sending the candidate vector pool to the server where the starting exploration node is located.
[0022] Optionally, if the candidate vector pool is stored on the server performing the retrieval process, after the retrieval process is completed, the method further includes: if the server storing the candidate vector pool is another server besides the server receiving the retrieval request, receiving the candidate vector pool sent by the other server and storing it on the server receiving the retrieval request.
[0023] Optionally, determining the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval process includes:
[0024] The vector values of the distances from the first k nodes of the candidate vector pool to the midpoint node are used as the retrieval results of the target vector; where k is less than or equal to the set number, and k is a positive integer.
[0025] Optionally, the method further includes a server pre-storage step, the step comprising:
[0026] Obtain the vector node graph of the vector dataset, and determine the navigation node and its adjacent nodes; each node in the vector node graph includes a node identifier and a vector value;
[0027] The navigation node and its adjacent nodes are stored on each server in the distributed system, and the server where the navigation node is located is set as a preset identifier; the preset identifier is used to indicate that the navigation node is stored on each server.
[0028] Cluster all nodes in the vector node graph except the navigation node and divide them into different servers.
[0029] Optionally, the step of clustering and dividing the nodes other than the navigation node in the vector node graph and storing them on various servers includes:
[0030] The other nodes are clustered into multiple node categories, the same number as the number of servers in the distributed system; based on the centroid of each node category, the node categories are divided and stored on the server closest to the centroid.
[0031] According to a second aspect of the embodiments of this application, a vector retrieval apparatus is provided. The apparatus is applied to any server of a distributed system, the distributed system being used to store a vector node graph corresponding to a vector dataset; each server in the distributed system stores a preset navigation node in the vector node graph, and adjacent nodes of the navigation node; the apparatus includes:
[0032] The navigation node distance pair storage module is used to, in response to receiving a retrieval request for a target vector, obtain the node distance pair between the navigation node and the target vector and store it in the candidate vector pool; the node distance pair includes a node identifier and the distance between the node and the target vector;
[0033] The retrieval processing module is used to perform retrieval processing with the navigation node as the starting exploration node, including: determining the node distance pairs of each adjacent node of the starting exploration node to the target vector, deduplicating the node distance pairs with the node distance pairs in the candidate vector pool, sorting them in ascending order of distance, and storing a set number of the top-ranked node distance pairs in the candidate vector pool; updating the starting exploration node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting exploration node is located repeats the retrieval processing until all nodes in the candidate vector pool have been explored;
[0034] The retrieval result determination module is used to determine the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval processing is completed.
[0035] Optionally, the retrieval processing module further includes:
[0036] Get the node server where each neighboring node is located;
[0037] The node distance pair between the first adjacent node and the target vector is calculated locally; the first adjacent node refers to the adjacent node of the node server that is currently performing the retrieval process.
[0038] Distance calculation requests are sent in parallel to the node servers of all neighboring nodes except the first neighboring node; the distance calculation requests are used to instruct the node servers to return the node distance pairs of the other neighboring nodes to the target vector.
[0039] Optionally, each server also stores a first node that can be connected to the navigation node via no more than N edges; after the starting exploration node is updated, the retrieval processing module further includes:
[0040] If the starting exploration node is the first node, the server currently performing the retrieval process continues to perform the retrieval process; if the starting exploration node is not the first node, if the server where the starting exploration node is located is the server currently performing the retrieval process, then the retrieval process continues to perform; otherwise, it is determined that the server where the starting exploration node is located continues to perform the retrieval request.
[0041] Optionally, the retrieval processing module further includes:
[0042] Traverse the identifier pairs in the preset server set to determine the target identifier pairs whose node identifiers are the same as the node identifiers of the updated starting exploration node; the server set is used to store the identifier pairs of each node indicated by a set number of node distance pairs stored in the candidate vector pool by the retrieval process; the identifier pair includes the node identifier and the server identifier where the node is located; determine the server where the starting exploration node is located based on the server identifier in the target identifier pair.
[0043] Optionally, the candidate vector pool is stored on the server that is performing the retrieval process; the retrieval process module further includes: if the server where the starting exploration node is located is not the server that is performing the retrieval process, sending the candidate vector pool to the server where the starting exploration node is located for storage.
[0044] Optionally, the candidate vector pool is stored on the server performing the retrieval process; after the retrieval process is completed, the method further includes: if the server storing the candidate vector pool is another server besides the server receiving the retrieval request, receiving the candidate vector pool sent by the other server and storing it on the server receiving the retrieval request.
[0045] Optionally, the retrieval result determination module is specifically used for:
[0046] The vector values of the distances from the first k nodes of the candidate vector pool to the midpoint node are used as the retrieval results of the target vector; where k is less than or equal to the set number, and k is a positive integer.
[0047] Optionally, the device further includes a server pre-storage module, specifically used for:
[0048] Obtain the vector node graph of the vector dataset, and determine the navigation node and its adjacent nodes; each node in the vector node graph includes a node identifier and a vector value;
[0049] The navigation node and its adjacent nodes are stored on each server in the distributed system, and the server where the navigation node is located is set as a preset identifier; the preset identifier is used to indicate that the navigation node is stored on each server.
[0050] Cluster all nodes in the vector node graph except the navigation node and divide them into different servers.
[0051] Optionally, the server pre-storage module, when clustering and partitioning nodes other than the navigation node in the vector node graph and storing them on various servers, includes:
[0052] The other nodes are clustered into multiple node categories, the same number as the number of servers in the distributed system; based on the centroid of each node category, the node categories are divided and stored on the server closest to the centroid.
[0053] According to a third aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a memory and a processor; the memory being used to store a computer program; and the processor being used to execute the above-described method by invoking the computer program.
[0054] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the above-described method.
[0055] The technical solutions provided in this application embodiment may include the following beneficial effects:
[0056] In the technical solution provided in this application, the vector dataset is converted into a vector node graph and the vector node graph is distributed and stored. Based on the distributed storage of the vector node graph, any server in the distributed system can use the navigation node as the starting exploration node and continuously expand the search range by using the adjacent nodes of the starting exploration node. By selecting the node closest to the target vector in the candidate vector pool as the new starting exploration node for retrieval processing, the algorithm iterates among the distributed servers. This efficiently extends the graph-based vector approximation retrieval algorithm to the distributed system scenario, realizing the collaboration between multiple distributed servers in the distributed system. Each server, based on the node information it is responsible for storing, the candidate vector pool, and communication with other servers, jointly completes the vector retrieval task, improving the vector retrieval coverage and effectively focusing on nodes closer to the target vector, thereby improving the accuracy and performance of vector retrieval.
[0057] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Furthermore, no embodiment in this application needs to achieve all the effects described above. Attached Figure Description
[0058] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0059] Figure 1 This is a schematic diagram illustrating a vector retrieval method flow according to an exemplary embodiment of this application;
[0060] Figure 2 This is a schematic flowchart illustrating a method for obtaining node distance pairs of nodes according to an exemplary embodiment of this application;
[0061] Figure 3 This is a flowchart illustrating the steps for determining the server where the initial exploration node is located, as shown in an exemplary embodiment of this application.
[0062] Figure 4 This is a flowchart illustrating the steps of storing a vector dataset in a distributed system according to an exemplary embodiment of this application;
[0063] Figure 5 This is a schematic diagram of a vector node graph distributed storage structure shown in an exemplary embodiment of this application;
[0064] Figure 6 This is a schematic diagram of the structure of a vector retrieval device shown in an exemplary embodiment of this application;
[0065] Figure 7 This is a hardware schematic diagram of an electronic device illustrated in an exemplary embodiment of this application. Detailed Implementation
[0066] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0067] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0068] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, a first classification threshold may also be referred to as a second classification threshold, and similarly, a second classification threshold may also be referred to as a first classification threshold. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."
[0069] A vector dataset refers to a dataset composed of vectors, where each vector is used to represent a feature or attribute of unstructured data such as text, images, and videos. The closer the distance between two vectors, such as the inner product or Manhattan distance, the more similar the two data points are. Vector approximate retrieval utilizes this property to approximate the nearest vectors to a given query vector within a given vector dataset. It is widely used in local knowledge base retrieval in large language models and user preference recommendation in recommendation scenarios.
[0070] In many applications, the size of the retrieval dataset often exceeds one billion vectors, which is difficult for a single machine to handle. Therefore, it is necessary to distribute the dataset across multiple machines for distributed vector approximation retrieval. In related technologies, for distributed storage of vector datasets, one or more machines that are close to the given query vector are selected. A hierarchical navigable small-world algorithm is applied to each machine, constructing a multi-level small-world graph for the vector data stored on each machine and performing the retrieval. The retrieval results from these one or more machines are then used as the distributed retrieval results.
[0071] However, this distributed retrieval method has shortcomings in accuracy and performance. Its retrieval process is susceptible to problems such as cross-machine communication, load imbalance, and insufficient local data information within machines, resulting in low accuracy and efficiency. Furthermore, because each machine constructs its own small world graph and performs the retrieval separately, the computational resources required are significant. For example, taking the NSG (Navigable Small World Graph) algorithm as an example, compared to storing the entire dataset on a single machine, the performance of the aforementioned distributed retrieval method based on memory pooling is only 1 / 18th of that of a single-machine retrieval. Moreover, compared to a single-machine query for the 100 closest vectors to a given query vector, randomly dividing the dataset across 10 nodes for distributed storage and querying the 10 closest vectors to the target vector on each node reduces the accuracy by 16%.
[0072] To address the aforementioned technical problems, this application provides a vector retrieval method that can be used in various vector retrieval scenarios such as text document retrieval, image search, audio retrieval, video retrieval, and recommendation systems. This application does not impose specific limitations on any particular application scenario.
[0073] This vector retrieval method is applied to distributed vector retrieval. Before executing the method, the vector dataset required for retrieval is pre-converted into a vector node graph. Each node in the graph corresponds to a vector data point, including a node identifier and a vector value. The vector node graph is stored in a distributed storage manner in a distributed system comprising multiple servers. Each server stores a subset of nodes in the graph and information about the neighboring nodes of each of these nodes. This neighboring node information includes at least the neighboring node identifier and information about the server where the neighboring node resides, such as the server identifier, and may also include other attribute information of the neighboring node. Furthermore, a node in the vector node graph is designated as a navigation node, and copies of this navigation node and its neighboring nodes are stored on each server in the distributed system. The navigation node acts as an important locating point or reference point in the vector node graph to quickly locate the target vector or related vectors. The navigation node can be a manually designated node in the graph, or it can be automatically generated using the graph construction algorithm, or it can be the node closest to the center of the graph.
[0074] Based on the vector node information stored on each server in this distributed system, the vector retrieval method provided in this application can be executed by any server in the distributed system. See [link to relevant documentation]. Figure 1 As shown, this vector retrieval method may include at least the following steps:
[0075] S101, in response to receiving a retrieval request for a target vector, obtain the node distance pair between the navigation node and the target vector and store it in the candidate vector pool; the node distance pair includes the node identifier and the distance between the node and the target vector;
[0076] The target vector refers to a vector representing a user's query needs or interests, and is associated with a specific retrieval scenario and user needs. For example, in a text document retrieval scenario, the target vector can be a feature vector representing the text the user wants to query; in a recommendation system scenario, the target vector can be a feature vector representing user preferences or interests.
[0077] The node distance pair consists of a node identifier and the distance between the node indicated by the node identifier and the target vector. The node identifier is the identifier of the node whose distance pair needs to be calculated in the vector node graph, uniquely representing that node in the graph. The distance between this node and the target vector indicates the similarity between the node and the target vector, and can be obtained using vector distance calculation methods such as inner product or Manhattan distance. Since the nodes in the vector node graph include node identifiers and vector values, when obtaining node distance pairs, the distance between the node and the target vector can be determined based on the node's vector value. The node distance pair between the navigation node and the target vector includes the navigation node's node identifier and the distance between the navigation node and the target vector.
[0078] The candidate vector pool stores candidate nodes and their distances to the target vector during vector retrieval. Initially, the pool is empty. During the retrieval process, the stored candidate nodes are dynamically updated based on the distances between the adjacent nodes of the starting node and the target vector in each round of retrieval. The candidate vector pool can be represented as a list or array, with each element including a node identifier and the distance between that node and the target vector. The candidate vector pool can be stored in shared storage, such as database storage or network file system storage, for access by servers in the distributed system during the retrieval process targeting the target vector.
[0079] The distributed system comprises multiple servers. Upon receiving a retrieval request for the target vector, any server, based on its locally stored information about the navigation node in the vector node graph and its adjacent nodes, can begin the vector retrieval process according to the navigation node. For a server receiving a retrieval request, the server first determines the first distance between the navigation node stored on its server and the target vector, combines this first distance with the node identifier of the navigation node to form a node distance pair for the navigation node, and stores it in a preset candidate vector pool.
[0080] S102, performing a retrieval process with the navigation node as the starting exploration node, wherein the retrieval process includes: determining the node distance pairs of each neighboring node of the starting exploration node to the target vector, deduplicating the node distance pairs with the node distance pairs in the candidate vector pool, sorting them in ascending order of distance, and storing a predetermined number of the sorted node distance pairs in the candidate vector pool; updating the starting exploration node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting exploration node is located repeats the retrieval process until all nodes in the candidate vector pool have been explored;
[0081] The starting exploration node refers to the node with the smallest distance among the unexplored nodes in the candidate vector pool. It serves as the starting node for each round of retrieval. Each round of retrieval will start from this starting node and search outwards from it, and will be continuously updated with each round of retrieval.
[0082] To determine whether a node in the candidate vector pool is an unexplored node, before updating the initial exploration node, the initial exploration node used by the server currently performing the retrieval process (i.e., the initial exploration node before the update) can be identified as an explored node. This can be achieved by setting an explored identifier in the node attribute information of the initial exploration node. For example, all nodes in the node attribute information can be set to 0 by default to indicate that they have not been explored, and explored nodes can be set to -1 to indicate that they have been explored. When determining a new initial exploration node, this attribute identifier can be used to determine whether it is an unexplored node. Alternatively, the explored nodes before the update can be stored in an explored node list. This explored list can be updated before updating the initial exploration node in each round of retrieval processing. By comparing it with this explored list, the unexplored node with the smallest distance can be identified as the new initial exploration node.
[0083] After the starting exploration node is determined, the search process begins, which includes at least the following steps:
[0084] (1) First, obtain all the adjacent nodes of the starting exploration node, and calculate the distance between each adjacent node and the target vector to obtain the node distance pair of the adjacent node.
[0085] For example, if the initial exploration node is node A, and its adjacent nodes include nodes B, C, and D, then the distances between the vector values of nodes B, C, and D and the target vector are calculated as 2, 4, and 5, respectively, to obtain the node distance pairs.<B,2> ,<C,4> ,<D,7> .
[0086] (2) After that, put all the node distance pairs of the adjacent nodes of the starting exploration node and the node distance pairs stored in the candidate vector pool together, and perform deduplication according to the node identifier in the node distance pair to ensure the uniqueness of each node distance pair. The specific deduplication process can be implemented by data nodes such as hash tables or sets. After the deduplication process is completed, sort all the deduplicated node distance pairs according to the distance in the node distance pair from smallest to largest (i.e., ascending order). During the sorting process, for two node distance pairs with the same distance, the unexplored node is sorted before the explored node that has been used as the starting exploration node.
[0087] For example, the candidate vector pool already stores<A,5> ,<E,5> ,<D,7> If A and D have already been explored, then the node distance pairs of the adjacent nodes B, C, and D of the initial exploration node A are combined with the node distance pairs stored in the candidate vector pool to remove duplicates, resulting in the deduplicated node distance pairs.<B,2> ,<C,4> ,<D,7> ,<A,5> ,<E,5> When sorting by distance in ascending order, unexplored nodes are placed before explored nodes, resulting in the sorted order.<B,2> ,<C,4> ,<E,5> ,<A,5> ,<D,7> .
[0088] (3) Next, for node distance pairs sorted in ascending order of distance, a predetermined number of node distance pairs, such as the first four, are stored as the content of the candidate vector. That is, all node distance pairs stored in the candidate vector pool are updated with the predetermined number of node distance pairs sorted first. This predetermined number can be set according to the storage limitations of the candidate vector pool or retrieval performance considerations.
[0089] For example, for the sorting above<B,2> ,<C,4> ,<E,5> ,<A,5> ,<D,7> If the first four are taken as the storage content of the candidate vector pool, then the candidate vector pool will already contain...<A,5> ,<E,5> ,<D,7> Updated to<B,2> ,<C,4> ,<E,5> ,<A,5> .
[0090] (4) For the candidate vector pool after the storage content is updated, a new starting exploration node is determined from the candidate vector pool, that is, the starting exploration node is updated to the node with the smallest distance among the unexplored nodes in the candidate vector pool. That is, the node distance pairs stored in the candidate vector pool are traversed in ascending order of distance, and the first unexplored node traversed is determined as the starting exploration node.
[0091] For example, for the updated candidate vector pool storage mentioned above<B,2> ,<C,4> ,<E,5> ,<A,5> When traversing in ascending order of distance, if node B has not been explored, the starting exploration node is updated to node B. If node B has already been used as the starting exploration node, the search continues to find the next node C. If C has not been explored, the starting exploration node is updated to node C. Otherwise, the search continues to find the next node E until an unexplored node is found or all nodes stored in the candidate vector pool are explored nodes.
[0092] (5) If the starting exploration node is not updated, then all nodes in the candidate vector pool are determined to be explored nodes, and the retrieval process ends. Otherwise, after the starting exploration node is updated, the server where the starting exploration node is located will execute steps (1)-(5) in a loop according to the starting exploration node.
[0093] Since the vector node graph is distributed across multiple servers in a distributed system, after server 1 performs retrieval processing and updates the starting retrieval node, the updated starting retrieval node may be located on server 1 or stored on other servers in the distributed system, such as server 2. If the updated starting exploration node is still located on server 1, server 1 continues to perform retrieval processing; otherwise, if it is located on server 2, server 2 will perform retrieval processing based on the updated starting exploration node, and retrieval processing on server 1 will be temporarily suspended. Therefore, after each round of retrieval processing updates the starting exploration node, the new round of retrieval processing must be performed by the server where the updated starting exploration node is located.
[0094] Each round of retrieval selects the node closest to the target vector as the starting node, calculates node distance pairs based on its neighboring nodes, and stores a certain number of node distance pairs closest to the target vector in the candidate vector pool. This process continuously expands the search range. When all nodes in the candidate vector pool have been explored, node distance pairs of multiple vectors most similar to the target vector are obtained.
[0095] Based on the above description of the retrieval process, for the server that receives the retrieval request, the node distance pairs stored in the candidate vector pool are <navigation node, distance d1>. Since the navigation node has not been explored and meets the minimum distance requirement, the server takes the navigation node as the starting exploration node, that is, it starts from the navigation node in the vector node graph to search for at least one vector similar to the target vector.
[0096] In a distributed system, each server stores information about the neighboring nodes of the navigation node. When a server receives a retrieval request, it first retrieves the neighboring nodes of the navigation node, then calculates the node distance pairs between these neighboring nodes and the target vector. This node distance pair is then deduplicated and sorted in ascending order against the <navigation node, distance d1> stored in the candidate vector pool. The candidate vector pool is then updated, and a new starting exploration node is selected. For this new starting exploration node: if the server containing the new starting exploration node is the server that received the retrieval request, then the server receiving the retrieval request continues to perform the retrieval process based on the new starting exploration node; otherwise, the server receiving the retrieval request suspends the retrieval process, and the server containing the new starting exploration node takes over. If, during the retrieval process on another server, another server obtains an updated starting exploration node, and that server is the server that received the retrieval request, then the server receiving the retrieval request again performs the retrieval process based on the updated starting exploration node.
[0097] S103, determine the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval process is completed.
[0098] For a server that receives the retrieval request, after the retrieval process is completed, if the node distance pairs stored in the current candidate vector pool are sorted in ascending order of distance, the vector values of the nodes in the top k node distance pairs are used as the retrieval result of the target vector, and the retrieval result is returned; wherein, k is less than or equal to the total number of node distance pairs stored in the candidate vector pool, and k takes the value of a positive integer.
[0099] For example, the node distance pairs stored in the candidate vector pool include<H,1> ,<B,2> ,<F,3> ,<C,4> Then, the node distance pair with the smallest distance stored in the candidate vector pool can be directly selected.<H,1> The vector value of node H can be used as the retrieval result of the target vector, or the vector values of the first three nodes H, B, and F can be used as the retrieval result of the target vector.
[0100] In this embodiment, by converting the vector dataset into a vector node graph and distributing the graph, any server in the distributed system can use a navigation node as the starting exploration node upon receiving a retrieval request. The candidate vector pool is continuously updated using the adjacent nodes of the starting exploration node to expand the search range. Each round of retrieval selects the node in the candidate vector pool closest to the target vector as the new starting exploration node, which is then executed by the server containing this updated starting exploration node. This improves the vector retrieval coverage and effectively focuses on nodes closer to the target vector, thus enhancing the accuracy of vector retrieval. Furthermore, this method enables collaboration among multiple distributed servers in the distributed system. Each server, based on the node information it stores, the candidate vector pool, and communication with other servers, jointly completes the vector retrieval task. This allows multiple servers to participate in vector retrieval in a distributed vector retrieval scenario, fully utilizing the system's computing and storage resources and improving retrieval efficiency and scalability.
[0101] In some embodiments, regarding the determination of the node distance pairs of each neighboring node of the starting exploration node to the target vector in step S102, based on the distributed storage of the vector node graph across various servers, the neighboring nodes of the starting exploration node may be stored on the server currently performing the retrieval process, i.e., the server where the current starting exploration node resides, or they may be stored on other servers besides the server currently performing the retrieval process. For the neighboring nodes of the starting exploration node located on these other servers, the node distance pairs of these neighboring nodes to the target vector are calculated on these other servers, and the calculation results are returned to the server currently performing the retrieval process. Based on this, as... Figure 2 As shown, the node distance pairs of each neighboring node of the starting exploration node to the target vector can be obtained in the following way:
[0102] S201, Obtain the node server where each adjacent node is located;
[0103] For a server that is performing a retrieval process, the starting exploration node is located on that server. Based on the fact that the server locally stores relevant information about the neighboring nodes of each node located on the server, the node servers where each neighboring node of the starting exploration node is located can be obtained from the server storage, such as obtaining the server identifier of the node server.
[0104] S202, locally calculate the node distance pairs of the first adjacent node to the target vector; the first adjacent node refers to the adjacent node of the node server that is performing the retrieval process;
[0105] S203, in parallel, send distance calculation requests to the node servers of the other neighboring nodes besides the first neighboring node; the distance calculation requests are used to instruct the node servers to return the node distance pairs of the other neighboring nodes to the target vector.
[0106] For each neighboring node of the starting exploration node, the neighboring nodes can be divided into two categories according to the node server they belong to. If the node server is the same as the server where the starting exploration node is located, that is, the node server is the server that is performing the retrieval process, the node of this category is determined as the first neighboring node, and the other neighboring nodes are the second category nodes.
[0107] For the first neighboring node, since this node and the starting exploration node are located on the same server, the node distance pair calculation for the first neighboring node is performed by the server currently executing the retrieval process, i.e., local calculation. Conversely, if other neighboring nodes besides the first neighboring node are not on the server currently executing the retrieval process, then the node server where the other neighboring node is located needs to calculate the node distance pair. When calculating the node distance pair for the first neighboring node locally, based on the node server obtained in S201, distance calculation requests are simultaneously sent in parallel to the servers of each other neighboring node. This allows the servers where the other neighboring nodes are located to respond to the distance calculation request by calculating the distance to the target vector based on the stored vector values of the other neighboring nodes, generating the node distance pair for the other neighboring node, and returning it to the server that sent the distance calculation request.
[0108] In this embodiment of the disclosure, by sending distance calculation requests in parallel to the adjacent nodes of the server that is not currently performing retrieval processing, distributed computing resources are fully utilized. This allows for the simultaneous processing of node distance pair calculations for multiple nodes, accelerating the node distance pair calculation process and improving response speed and performance.
[0109] In some embodiments, the retrieval process in step S102, which involves deduplicating the node distance pairs of adjacent nodes and sorting them in ascending order of distance, and storing the first set number of sorted node distance pairs in the candidate vector pool, can be implemented in any of the following ways:
[0110] The node distance pairs of the adjacent nodes can be stored in the candidate vector pool. All node distance pairs stored in the candidate vector pool are deduplicated and sorted in ascending order of distance. For node distance pairs with the same distance, the unexplored nodes are sorted before the explored nodes. A set number of node distance pairs with the highest sorting are used as the storage content of the candidate vector pool. All other node distance pairs are deleted from the candidate vector pool to complete the update of the candidate vector pool.
[0111] Alternatively, all node distance pairs in the candidate vector pool can be retrieved, their distance pairs can be deduplicated and sorted by distance with the distance pairs of their neighboring nodes, and the top-ranked node distance pairs can be stored in the candidate vector pool to complete the update of the candidate vector pool.
[0112] Based on the content described in the foregoing embodiments, when the vector node graph is distributed and stored in a distributed system, the content stored in each server includes at least: information about some nodes of the vector node graph and their adjacent nodes, information about the navigation node of the vector node graph and its adjacent nodes. In this embodiment, each server also stores information about a first node that can be connected to the navigation node through no more than N edges and its adjacent nodes, where N is a positive integer. Based on this, in the aforementioned retrieval process, after updating the starting exploration node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, the retrieval process may further include the following steps:
[0113] If the starting exploration node is the first node, the server that is performing the retrieval process continues to perform the retrieval process;
[0114] If the starting exploration node is not the first node, and the server where the starting exploration node is located is a server that is currently performing retrieval processing, then the retrieval processing continues; otherwise, it is determined that the server where the starting exploration node is located continues to perform the retrieval request.
[0115] In other words, since each server stores the first node, after the initial exploration node is updated, the updated initial exploration node is compared with the first node stored locally on the server. If it is the first node, the server performing the retrieval process remains unchanged, and the server where the original initial exploration node was located (i.e., the server currently performing the retrieval process) continues to perform the retrieval process with the updated initial exploration node. Conversely, if the updated initial exploration node is not the first node, it is necessary to further obtain the server where the initial exploration node is located. If the server where the initial exploration node is located is the server currently performing the retrieval process, it means that the initial exploration nodes before and after the update are located on the same server, and the server performing the retrieval process remains unchanged. Otherwise, a change in the server performing the retrieval process is required, and the retrieval process steps based on the updated initial exploration node are handed over to the server where the updated initial exploration node is located for execution.
[0116] For example, each server stores a first node M, N, P, Q. Server 1 is performing a search process. After server 1 updates the initial exploration node, assuming the initial exploration node is M, the updated initial exploration node is the first node. Therefore, server 1 continues to perform the search process based on the initial exploration node M. Assuming the initial exploration node is H, if the server where H is located is still server 1, then server 1 continues to perform the search process based on the initial exploration node H. Otherwise, the search process is performed by the server where the initial exploration node H is located, such as server 2.
[0117] In this embodiment of the disclosure, by backing up and storing multiple nodes close to the navigation node on each distributed server, the server receiving the retrieval request can handle part of the retrieval processing, avoiding all retrieval requests being sent to the server where the navigation node is located for processing. This effectively reduces the load pressure on the navigation node server, prevents a single server from being overloaded, balances the server load, and improves the stability and performance of the system. Furthermore, based on this node storage method, the execution server for the retrieval processing of the initial exploration node update can be quickly determined by comparing whether the node is stored locally on the server, thus improving the system response speed.
[0118] In some embodiments, each server stores the neighboring nodes of the nodes stored on the server, as well as the relevant information of the neighboring nodes. The neighboring nodes and their relevant information can be stored in the form of an adjacency set. Each node corresponds to an adjacency set, which includes multiple identifier pairs. Each identifier pair corresponds to one of the neighboring nodes of the node. Each identifier pair includes the identifier of the neighboring node and the identifier of the server where the neighboring node is located. The identifier of the neighboring node and the identifier of the server are used to uniquely identify the neighboring node and the server where the node is located.
[0119] Based on this adjacency set, a server set can be pre-configured. This server set stores the server identifiers of candidate nodes stored in the candidate vector pool during each round of retrieval processing, in the form of identifier pairs. Specifically, when storing a predetermined number of node distance pairs in the candidate vector pool, the identifier pairs of the nodes indicated by the predetermined number of node distance pairs are simultaneously retrieved from the adjacency set of the starting exploration node stored by the server currently performing the retrieval processing, as well as from the server set itself. These identifier pairs are then used as the storage content of the server set, and all content stored in the server set is updated to these identifier pairs. Regarding the server where the starting exploration node is located in the steps of the retrieval processing in the aforementioned embodiment, see [link to documentation]. Figure 3 As shown, it can be obtained in the following ways:
[0120] S301, Traverse the identifier pairs stored in the preset server set, and determine the target identifier pairs whose node identifiers are the same as the node identifiers of the updated starting exploration node;
[0121] The server set is initially empty. When adding the node distance pairs of navigation nodes to the candidate vector pool, the identifier pairs of the navigation nodes and their respective servers are stored in the server set. In each round of retrieval processing, based on the identifier pairs stored in the server set and the adjacency set of the starting exploration node that is currently performing the retrieval processing, the server set is updated synchronously after the candidate vector pool is updated, so that the same nodes are always stored synchronously in the server set as in the candidate vector pool.
[0122] The set of servers can be stored in shared storage for access by all servers in the distributed system; or, it can be stored separately in the server currently performing the retrieval process, and when the server performing the retrieval process changes, the set of servers can be sent to the new server performing the retrieval process for storage through data interaction.
[0123] S302, determine the server where the starting exploration node is located based on the server identifier in the target identifier pair.
[0124] After updating the starting exploration node, the system iterates through the corresponding server set to find target identifier pairs that match the node identifier of the starting exploration node. The server indicated by the server identifier in the identifier pair is the server where the starting exploration node resides. Furthermore, if the server identifier is the same as the server identifier currently performing the retrieval process, or indicates that the starting exploration node exists on every server, then the updated starting exploration node is on the same server as the original starting exploration node, and the server for retrieval processing remains unchanged.
[0125] For example, a distributed system has three servers with server identifiers A1, A2, and A3. The server identifier of the navigation node, which is stored on all servers or is the first node connected to the navigation node via no more than N edges, corresponds to -1, used to represent each server in the distributed system. Assume the initial exploration node is node X located on server A1, and its adjacency set is {<G,A1> ,<J,A2> ,<K,-1> The candidate vector pool stores the node distance pairs between node L and the target vector.<X,4> The server set corresponding to this candidate vector pool includes pairs of identifiers representing that node X is located on server A1.<X,A1>}, when the distance pairs of the first 3 nodes stored in the candidate vector pool are determined<G,2> ,<K,3> ,<X,4> Then, based on the adjacency set of the initial exploration node and the identifier pairs in the server set, the identifier pairs of nodes G, K, and X are obtained, and the {...} stored in the server set are...<X,A1>} updated to {<G,A1> ,<K,-1> ,<X,A1> Therefore, based on this set of servers, after determining a new starting exploration node from the updated candidate vector pool, the server where the new starting exploration node resides is determined from this set of servers.
[0126] In this embodiment of the disclosure, by using a server set to store the server identifiers of each node in the updated candidate vector pool during each round of retrieval processing, the server where the starting exploration node is located can be directly found from the server set after the initial exploration node is updated without additional searching or calculation. This reduces the operational complexity of traversing the candidate vector pool to determine the new starting exploration node and then determining its server after the execution server of the retrieval process changes, making the logical structure of the system clearer and simpler, reducing the complexity of the system, and improving the understandability of the system.
[0127] In some embodiments, the candidate vector pool described in the foregoing embodiments can be stored in shared memory in a shared storage manner, so that each server in the distributed system can access it. Alternatively, the candidate vector pool can also be stored on the server that is performing the retrieval process. For example, if the retrieval process is initially performed by the server that received the retrieval request, then the candidate vector pool is stored on that server. Based on the storage method of the candidate vector pool, after updating the initial exploration node, the retrieval process may further include the following steps:
[0128] If the server where the starting exploration node is located is not the server that is performing the retrieval process, the candidate vector pool is sent and stored to the server where the starting exploration node is located.
[0129] That is, when the server where the updated starting exploration node is located is not the same server as the server where the original starting exploration node was located, the data exchange of the candidate vector pool will occur because the server performing the retrieval process has changed. The candidate vector pool will be sent to the server where the updated starting exploration node is located so that the server can perform the retrieval process with the starting exploration node based on the received candidate vector pool.
[0130] For example, if the candidate vector pool is stored on the server that receives the retrieval request, and the server where the starting exploration node of the current retrieval process ends is not the server that received the retrieval request, then if the starting exploration node of the update is on server A2, the server that received the retrieval request should send the candidate vector pool to server A2. After receiving the candidate vector pool, server A2 stores it locally and performs the retrieval process based on the candidate vector pool and the updated starting exploration node.
[0131] Based on the candidate vector pool stored in the server currently performing the retrieval process, after the retrieval process is completed, the method further includes:
[0132] If the server storing the candidate vector pool is a server other than the server receiving the retrieval request, the server receives the candidate vector pool sent by the other server and stores it on the server receiving the retrieval request.
[0133] In other words, if the candidate vector pool consists of all explored nodes, and if the candidate vector pool is not stored in the server that received the retrieval request, the server that completed the last round of retrieval processing needs to send the candidate vector pool to the server that received the retrieval request so that the server that received the retrieval request can respond to the retrieval request based on the node distances stored in the candidate vector pool.
[0134] In this embodiment of the disclosure, by binding the candidate vector pool to the server that performs the retrieval process and dynamically exchanging candidate vector pool data during the retrieval process, a distributed storage of a vector node graph is realized, after which multiple distributed servers cooperate to participate in the retrieval process for the target vector and continuously expand the search range. This makes full use of distributed resources, which not only simplifies the complexity of system design and implementation and reduces the system maintenance cost and management difficulty, but also improves the efficiency of vector retrieval.
[0135] In some embodiments, for the distributed storage of the vector node graph corresponding to the vector dataset to the distributed system, the aforementioned vector retrieval method may further include a server pre-storage step of distributively storing the vector dataset to the distributed system, see [link to relevant documentation]. Figure 4 As shown, this step may include at least the following:
[0136] S401, Obtain the vector node graph of the vector dataset, and determine the navigation node and its adjacent nodes; each node in the vector node graph includes a node identifier and a vector value;
[0137] Graph construction algorithms refer to algorithms used in data analysis and machine learning to construct graph structures. These graph structures can be used to represent relationships between data, network topology, influence propagation, etc., such as nearest neighbor algorithm, minimum spanning tree algorithm, spectral clustering algorithm, PageRank algorithm, graph neural network, etc.
[0138] The vector node graph of the vector dataset can be obtained through a graph construction algorithm. This algorithm represents each vector data point as a node in the graph and determines connections based on similarity or distance between vectors, resulting in a node graph representing the dataset relationships and vector values. For undirected graphs, each vector node can be connected to its similar vector nodes, forming a fully connected graph. For directed graphs, nodes can be connected based on specific relationships or attributes.
[0139] The navigation nodes can be determined in any of the following ways: They can be determined based on the degree centrality of the node, which refers to the number of edges a node connects to in the graph. Nodes with high degree centrality are potential navigation nodes because they connect to more other nodes and may be key pathways to different regions. Alternatively, they can be determined based on betweenness centrality, which measures the frequency with which a node acts as an intermediate node in the shortest path in the graph. Alternatively, they can be determined based on compact centrality, which measures the average distance between a node and other nodes. Alternatively, they can be determined based on clustering coefficients, which measure the density of connections between a node's neighbors, i.e., the formation of closed triangles. Nodes with high clustering coefficients may be important connection points between different regions.
[0140] S402, the navigation node and its adjacent nodes are stored on each server of the distributed system, and the server where the navigation node is located is set as a preset identifier; the preset identifier is used to indicate that the navigation node is stored on each server;
[0141] In other words, for the navigation node in the above vector node graph, the navigation node, its adjacent nodes, and node-related information can be copied and stored on each server in the distributed system, so that when any server in the system receives a retrieval request, it can start the retrieval process based on the navigation node stored on its own server.
[0142] Furthermore, for navigation nodes that are replicated and stored on each server, the server identifier of the server where the navigation node is located can be set to a preset identifier, such as setting the server where the navigation node is located to -1, to indicate that the navigation node is located on each server. This means that when the server identifier of the server where the starting exploration node is located is -1 during the retrieval process, it indicates that the starting exploration node is stored in the server currently performing the retrieval process, and the server performing the retrieval process does not change.
[0143] The first node, which can be connected to the navigation node via no more than N edges as described in the foregoing embodiments, is also stored in a duplicate on each server, and the server identifier of the server where the first node resides is the same as the server identifier of the server where the navigation node resides. Alternatively, the first node can be stored together with the navigation node on each server in step S402.
[0144] S403, cluster the nodes other than the navigation node in the vector node graph and divide and store them on various servers.
[0145] For nodes in the vector node graph other than those replicated on each server, clustering is performed on these nodes. This clustering can be implemented using the global k-Means algorithm or other clustering methods, and then distributed across the servers. Each server stores not only the nodes in its assigned cluster but also information about their neighboring nodes, which can be stored with each node corresponding to a set of neighboring nodes. Furthermore, the other nodes can be clustered into multiple node categories, the same number as the number of servers in the distributed system.
[0146] After the clustering process is completed, the node categories can be divided and stored on the server closest to the centroid of each node category, or the multiple node categories obtained by clustering can be randomly assigned. This application does not limit this.
[0147] In this embodiment of the disclosure, by using a graph structure and a replica storage strategy, the vector dataset is organized into a graph and the data is stored on multiple servers as required. This can optimize query efficiency and system response speed, and is suitable for searching and querying large-scale vector datasets, thereby improving system performance and scalability.
[0148] Based on the content described in the foregoing embodiments, in order to enable those skilled in the art to better understand the vector retrieval method provided in this application, the method will be described below using an example vector node graph.
[0149] Based on the characteristics of graph search algorithms, this application utilizes the monotonicity of the search process of graph algorithms, where the distance between the vector node set to be explored and the target point decreases monotonically during the search process. The vector dataset is constructed into a vector node graph for distributed storage, including: (1) organizing the vector dataset into a vector node graph using a graph construction algorithm; (2) replicating the preset navigation node and its adjacent vector nodes and their adjacency sets on all servers. The adjacent vector refers to a vector node that can be connected to the navigation node through ≤n edges, where n is an adjustable positive integer; the adjacency set is the set of <adjacent node number, adjacent node server>; (3) clustering other vector nodes except the navigation node and its adjacent vector nodes and their adjacency sets and assigning them to all servers.
[0150] Based on the storage method of this vector node graph, the vector retrieval request can start from any server. The server uses the navigation node as the starting exploration node and performs retrieval processing according to the handover-based distributed graph search algorithm. The retrieval processing includes: retrieval processing input: starting exploration node p, target vector q, upper limit of candidate vector pool size L, and the number of vectors returned by the retrieval result k (limited to k<=L).
[0151] The retrieval process outputs the k closest vectors to the target vector q.
[0152] Search process description: In the initial state, the candidate vector pool only contains navigation nodes.
[0153] In each iteration of the retrieval process, after the candidate vector pool is updated, the vector node that is closest to the target vector q and has not been explored is selected as the starting exploration node for the new round of retrieval. If the starting exploration node for the new round of retrieval is different from the server currently executing the retrieval process, the current candidate vector pool is sent to the server where the starting exploration node for the new round of retrieval is located, and that server continues to execute the retrieval process.
[0154] In the retrieval process, firstly, the starting exploration node of this round of retrieval is marked as explored. Then, it is determined whether its neighboring nodes should be added to the candidate vector pool. Requests can be sent in parallel to the servers where neighboring nodes not currently located reside. The distance between the target node and the neighboring node is calculated on the corresponding server, and <number, distance> pairs are returned. The same operation is performed on the neighboring nodes on the current server. Subsequently, all <number, distance> pairs are added to the candidate vector pool and deduplicated. After sorting by distance, the top L elements are selected as the storage content of the candidate vector pool.
[0155] Repeat the above process until all vectors in the candidate vector pool have been explored. Then return the first k vectors in the candidate vector pool, and the retrieval process ends.
[0156] For details on the above methods and steps, please refer to [link / reference]. Figure 5 The graph storage example of the vector node graph shown further illustrates the above method. It should be noted that... Figure 5 This is just an example; the number of vector nodes, graph size, number of servers, number of edges, graph connection method, and replicated nodes in the actual dataset can all be adjusted according to the actual dataset.
[0157] Figure 5 Each labeled node (numbered 0-10) represents a vector node, with node 0 designated as a navigation node. Each vector node contains both a label and a vector value; only the label is shown in the diagram, omitting the vector value. All solid black lines connecting two vector nodes indicate an edge between them, and these edges are stored on three servers.
[0158] First, the navigation node and its nearest vector nodes are replicated. In this example, vectors (i.e., 1, 2, 3) that can be connected to navigation vector 0 through ≤1 edge are identified as its nearest vector nodes. Navigation node 0 and its nearest vector nodes 1, 2, and 3 are replicated and stored on each server. Therefore, vectors 0, 1, 2, and 3 and their <adjacent node numbers, servers where adjacent nodes reside> are replicated and stored on 3 servers. The 4 nodes included within the circle are the nodes replicated and stored on each server.
[0159] Then, the vectors other than those whose replicas are stored on each server (i.e., nodes 4-10) and their <adjacent node numbers, servers where adjacent nodes reside> sets are clustered and assigned to all servers. The black dashed line in the figure represents one partitioning method. After clustering, the other vectors are divided into three classes: vectors {4, 6, 7, 9}, vectors {5, 8}, and vector {10}, which are then assigned to server 1, server 2, and server 3, respectively.
[0160] To further clarify, an example of a set of <adjacent node numbers, servers where adjacent nodes reside> is given. In this embodiment, for nodes whose replicas are stored on each server, the server identifier of the server they reside on is set to -1, and other nodes are marked normally according to their server identifiers. Therefore, for node 1, its adjacent nodes are 0 (replicated, represented by -1 on the server) and 4 (located on server 1), so its corresponding set is {<0,-1>,<4,1>}, and this adjacent set is stored on 3 servers along with node 1.
[0161] Based on the vector node graph storage method illustrated in the diagram, assuming the target vector q is located at the black dot, the upper limit of the candidate vector pool size L = 4, the number of vectors returned k = 3, and the distances between the target vector q and all vector nodes in the dataset are shown in Table 1 below:
[0162] 0 8 6 4 1 6 7 2 2 7 8 5 3 8 9 1 4 3 10 9 5 6
[0163] Table 1 illustrates the distance between vector nodes and the target vector.
[0164] After receiving a retrieval request, any server in the distributed system designates navigation node 0 as the starting exploration node p. Assume the retrieval request is sent to server 3:
[0165] Store the node distance pairs {<0,8>} of the navigation nodes into the candidate vector pool. Each node distance pair includes <navigation node identifier, distance of the navigation node to the target vector>.
[0166] Step 1: The adjacency set of the initial exploration node 0 is {<1,-1>,<2,-1>,<3,-1>}. All adjacent nodes are located locally. Server 3 calculates the <number, distance> pairs for each node locally, adds them to the candidate vector pool, removes duplicates, and sorts them by distance, resulting in {<1,6>,<2,7>,<3,8>,<0,8>}, with a number of elements <= 4. All of these are retained. The node with the smallest distance that has not been explored is found in the candidate vector pool and designated as the new initial exploration node, i.e., node 1. This initial exploration node is located on the current server 3, and server 3 continues the retrieval process.
[0167] Step 2: The adjacency set of node 1 is {<4,1>,<0,-1>}. Adjacent node 4 is located on server 1, not server 3. A request is sent to server 1 to calculate the <number, distance> pair and return it. Node 0 is located on server 3, and server 3 directly calculates the <number, distance> pair for it locally. Then, it is added to the candidate vector pool, deduplicated, and sorted by distance, resulting in {<4,3>,<1,6>,<2,7>,<3,8>,<0,8>}. The first four are truncated to obtain {<4,3>,<1,6>,<2,7>,<3,8>}. A new starting exploration node 4 is determined, which is located on server 1. Server 3 sends the candidate vector pool to server 1, and server 1 continues the retrieval process.
[0168] Step 3: The adjacency set of the initial exploration node 4 is {<6,1>,<7,1>,<8,2>,<1,-1>}. A request is sent to server 2 to calculate the <number, distance> pair of node 8. The <number, distance> pair of nodes 6, 7, and 1 is calculated locally on server 1. After the same processing, the candidate vector pool {<7,2>,<4,3>,<6,4>,<8,5>} is obtained. The new initial exploration node 7 is determined. This node 7 is still located on server 1, and server 1 continues to perform the retrieval process.
[0169] Step 4: The adjacency set of the starting exploration node 7 is {<9,1>,<4,1>}. The <number, distance> pairs between the two are calculated locally. After processing as above, the candidate vector pool {<9,1>,<7,2>,<4,3>,<6,4>} is obtained. The new starting exploration node 9 is determined, and the server 1 continues to perform the retrieval process.
[0170] Step 5: The adjacency set of the starting exploration node 9 is {<7,1>}. After processing as above, the candidate vector pool is obtained as {<9,1>,<7,2>,<4,3>,<6,4>}. Since nodes 9, 7, and 4 have been explored, the new starting exploration node 6 is determined, and server 1 continues to perform the retrieval process.
[0171] Step 6: The adjacency set of the initial exploration node 6 is {<4,1>}. After processing as above, the candidate vector pool is obtained as {<9,1>,<7,2>,<4,3>,<6,4>}.
[0172] All nodes in the candidate vector pool are explored nodes. The search is complete, and the three vectors closest to the target vector are returned. Their corresponding node numbers in the graph are 9, 7, and 4, respectively. The vector values corresponding to the three nodes with node numbers 9, 7, and 4 are used as the search results for the target vector q. Since the final round of search processing is completed by server 1, server 1 sends the candidate vector pool to server 3, which received the search request, and server 3 responds to the search request.
[0173] Next, corresponding to the embodiments of the aforementioned vector retrieval method, see... Figure 6 As shown, this application also provides an embodiment of a vector retrieval device, which is applied to any server in a distributed system. The distributed system is used to store a vector node graph corresponding to a vector dataset. Each server in the distributed system stores a preset navigation node in the vector node graph and the adjacent nodes of the navigation node. The device includes:
[0174] The navigation node distance pair storage module 601 is used to, in response to receiving a retrieval request for a target vector, obtain the node distance pair between the navigation node and the target vector and store it in the candidate vector pool; the node distance pair includes a node identifier and the distance between the node and the target vector;
[0175] The retrieval processing module 602 is used to perform retrieval processing with the navigation node as the starting exploration node, including: determining the node distance pairs of each adjacent node of the starting exploration node to the target vector, deduplicating the node distance pairs with the node distance pairs in the candidate vector pool, sorting them in ascending order of distance, and storing a set number of the sorted node distance pairs in the candidate vector pool; updating the starting exploration node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting exploration node is located repeats the retrieval processing until all nodes in the candidate vector pool have been explored;
[0176] The retrieval result determination module 603 is used to determine the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval processing is completed.
[0177] In some embodiments, the retrieval processing module further includes:
[0178] Get the node server where each neighboring node is located;
[0179] The node distance pair between the first adjacent node and the target vector is calculated locally; the first adjacent node refers to the adjacent node of the node server that is currently performing the retrieval process.
[0180] Distance calculation requests are sent in parallel to the node servers of all neighboring nodes except the first neighboring node; the distance calculation requests are used to instruct the node servers to return the node distance pairs of the other neighboring nodes to the target vector.
[0181] In some embodiments, each server further stores a first node that can be connected to the navigation node via no more than N edges; after the starting exploration node is updated, the retrieval processing module further includes:
[0182] If the starting exploration node is the first node, the server currently performing the retrieval process continues to perform the retrieval process; if the starting exploration node is not the first node, if the server where the starting exploration node is located is the server currently performing the retrieval process, then the retrieval process continues to perform; otherwise, it is determined that the server where the starting exploration node is located continues to perform the retrieval request.
[0183] In some embodiments, the retrieval processing module further includes:
[0184] Traverse the identifier pairs in the preset server set to determine the target identifier pairs whose node identifiers are the same as the node identifiers of the updated starting exploration node; the server set is used to store the identifier pairs of each node indicated by a set number of node distance pairs stored in the candidate vector pool by the retrieval process; the identifier pair includes the node identifier and the server identifier where the node is located; determine the server where the starting exploration node is located based on the server identifier in the target identifier pair.
[0185] In some embodiments, the candidate vector pool is stored on the server that is performing the retrieval process; the retrieval process module further includes: if the server where the starting exploration node is located is not the server that is performing the retrieval process, sending the candidate vector pool to the server where the starting exploration node is located.
[0186] In some embodiments, the candidate vector pool is stored on the server performing the retrieval process; after the retrieval process is completed, the method further includes: if the server storing the candidate vector pool is another server besides the server receiving the retrieval request, receiving the candidate vector pool sent by the other server and storing it on the server receiving the retrieval request.
[0187] In some embodiments, the retrieval result determination module is specifically used for:
[0188] The vector values of the distances from the first k nodes of the candidate vector pool to the midpoint node are used as the retrieval results of the target vector; where k is less than or equal to the set number, and k is a positive integer.
[0189] In some embodiments, the apparatus further includes a server pre-storage module, specifically used for:
[0190] Obtain the vector node graph of the vector dataset, and determine the navigation node and its adjacent nodes; each node in the vector node graph includes a node identifier and a vector value;
[0191] The navigation node and its adjacent nodes are stored on each server in the distributed system, and the server where the navigation node is located is set as a preset identifier; the preset identifier is used to indicate that the navigation node is stored on each server.
[0192] Cluster all nodes in the vector node graph except the navigation node and divide them into different servers.
[0193] In some embodiments, the server pre-storage module, when clustering and partitioning nodes other than the navigation nodes in the vector node graph and storing them on various servers, includes:
[0194] The other nodes are clustered into multiple node categories, the same number as the number of servers in the distributed system; based on the centroid of each node category, the node categories are divided and stored on the server closest to the centroid.
[0195] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0196] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0197] This application also provides an electronic device, the structural schematic diagram of which is shown below. Figure 7 As shown, the electronic device 700 includes at least one processor 701, a memory 702, and a bus 703. At least one processor 701 is electrically connected to the memory 702. The memory 702 is configured to store at least one computer-executable instruction, and the processor 701 is configured to execute the at least one computer-executable instruction to perform the steps of any vector retrieval method provided in any embodiment or optional implementation of this application.
[0198] Furthermore, the processor 701 can be an FPGA (Field-Programmable Gate Array) or other devices with logic processing capabilities, such as an MCU (Microcontroller Unit) or a CPU (Central Processing Unit).
[0199] This application also provides another readable storage medium storing a computer program that, when executed by a processor, implements the steps of any vector retrieval method provided in any embodiment or optional implementation of this application.
[0200] The readable storage media provided in this application include, but are not limited to, any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic cards, or optical cards. In other words, the readable storage media includes any medium by which a device (e.g., a computer) stores or transmits information in a readable form.
[0201] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0202] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0203] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A vector retrieval method, characterized in that, The method is applied to any server in a distributed system, wherein the distributed system stores a vector node graph corresponding to a vector dataset; each server in the distributed system stores a preset navigation node in the vector node graph, and the adjacent nodes of the navigation node; the method includes: In response to receiving a retrieval request for a target vector, the node distance pairs between the navigation node and the target vector are obtained and stored in the candidate vector pool; the node distance pairs include the node identifier and the distance between the node and the target vector; The retrieval process, starting with the navigation node, includes: determining the node distance pairs of each neighboring node of the starting node to the target vector, deduplicating the node distance pairs with those in the candidate vector pool, sorting them in ascending order of distance, and storing a predetermined number of the top-ranked node distance pairs in the candidate vector pool; updating the starting node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting node is located repeats the retrieval process until all nodes in the candidate vector pool have been explored; Based on the node distance pairs stored in the candidate vector pool after the retrieval process is completed, the retrieval result of the target vector is determined.
2. The method according to claim 1, characterized in that, Determining the node distance pairs of each adjacent node of the starting exploration node to the target vector includes: Get the node server where each neighboring node is located; The node distance pair between the first adjacent node and the target vector is calculated locally; the first adjacent node refers to the adjacent node of the node server that is currently performing the retrieval process. Distance calculation requests are sent in parallel to the node servers of all neighboring nodes except the first neighboring node; the distance calculation requests are used to instruct the node servers to return the node distance pairs of the other neighboring nodes to the target vector.
3. The method according to claim 1, characterized in that, Each server also stores the first node that can be connected to the navigation node via no more than N edges; After the initial exploration node is updated, the retrieval process further includes: If the starting exploration node is the first node, the server that is performing the retrieval process continues to perform the retrieval process; If the starting exploration node is not the first node, and the server where the starting exploration node is located is a server that is currently performing retrieval processing, then the retrieval processing continues; otherwise, it is determined that the server where the starting exploration node is located continues to perform the retrieval request.
4. The method according to claim 1 or 3, characterized in that, The retrieval process also includes: Traverse the identifier pairs in the preset server set to determine the target identifier pairs whose node identifiers are the same as the node identifiers of the updated starting exploration node; the server set is used to store the identifier pairs of each node indicated by a set number of node distance pairs stored in the candidate vector pool by the retrieval process; the identifier pair includes the node identifier and the identifier of the server where the node is located; The server where the starting exploration node is located is determined based on the server identifier in the target identifier pair.
5. The method according to claim 1, characterized in that, The candidate vector pool is stored in the server that is performing the retrieval process; the retrieval process further includes: If the server where the starting exploration node is located is not the server that is performing the retrieval process, the candidate vector pool is sent and stored to the server where the starting exploration node is located.
6. The method according to claim 5, characterized in that, After the retrieval process is completed, the method further includes: If the server storing the candidate vector pool is a server other than the server receiving the retrieval request, the server receives the candidate vector pool sent by the other server and stores it on the server receiving the retrieval request.
7. The method according to claim 1, characterized in that, The step of determining the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval process includes: The vector values of the distances from the first k nodes of the candidate vector pool to the midpoint node are used as the retrieval results of the target vector; where k is less than or equal to the set number, and k is a positive integer.
8. The method according to claim 1, characterized in that, The method further includes a server pre-storage step, which includes: Obtain the vector node graph of the vector dataset, and determine the navigation node and its adjacent nodes; each node in the vector node graph includes a node identifier and a vector value; The navigation node and its adjacent nodes are stored on each server in the distributed system, and the server where the navigation node is located is set as a preset identifier; the preset identifier is used to indicate that the navigation node is stored on each server. Cluster all nodes in the vector node graph except for the navigation node and divide them into different servers.
9. The method according to claim 8, characterized in that, The step of clustering and dividing nodes other than the navigation node in the vector node graph and storing them on various servers includes: The other nodes are clustered into multiple node categories, the same number as the number of servers in the distributed system. Based on the centroid of each node category, the node categories are divided and stored in the server closest to the centroid.
10. A vector retrieval device, characterized in that, An apparatus is applied to any server in a distributed system, wherein the distributed system stores a vector node graph corresponding to a vector dataset; each server in the distributed system stores a preset navigation node in the vector node graph, and the adjacent nodes of the navigation node; the apparatus includes: The navigation node distance pair storage module is used to, in response to receiving a retrieval request for a target vector, obtain the node distance pair between the navigation node and the target vector and store it in the candidate vector pool; the node distance pair includes a node identifier and the distance between the node and the target vector; The retrieval processing module is used to perform retrieval processing with the navigation node as the starting exploration node. The module includes: determining the node distance pairs of each adjacent node of the starting exploration node to the target vector, deduplicating these pairs with the node distance pairs in the candidate vector pool, sorting them in ascending order of distance, and storing a predetermined number of the top-ranked node distance pairs in the candidate vector pool; updating the starting exploration node to the node with the smallest distance among the unexplored nodes in the candidate vector pool, so that the server where the starting exploration node is located repeatedly performs the retrieval processing until all nodes in the candidate vector pool have been explored. The retrieval result determination module is used to determine the retrieval result of the target vector based on the node distance pairs stored in the candidate vector pool after the retrieval processing is completed.
11. An electronic device, characterized in that, include: Memory, processor; The memory is used to store computer programs; The processor is configured to invoke the computer program to implement the method as described in any one of claims 1-9.
12. A readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-9.
Citation Information
Patent Citations
Methods and systems for storing and querying database entries with neuromorphic computers
CA3090985A1
Vector retrieval method, system and equipment and storage medium
CN115129939A