Query method and device for vector

By processing subtrees of the index tree in parallel in a low-dimensional projection space, the problem of insufficient utilization of multiple processing units in existing technologies is solved, thereby improving the speed and efficiency of vector queries.

CN122019538APending Publication Date: 2026-05-12BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING OCEANBASE TECHNOLOGY CO LTD
Filing Date
2026-01-20
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing approximate nearest neighbor search schemes based on locality-sensitive hashing fail to fully utilize the multi-processor characteristics of modern computer systems, resulting in the inability to achieve higher vector query performance in parallelized hardware environments.

Method used

By mapping the query vector to a low-dimensional projection space, multiple processing units are used to process the subtrees of the index tree in parallel, range queries are performed, invalid nodes are pruned, and candidate sets are merged to determine the query results.

Benefits of technology

It improves the response speed and query efficiency of vector queries, makes full use of the parallel processing capabilities of modern computer systems, and enhances the speed of index tree construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122019538A_ABST
    Figure CN122019538A_ABST
Patent Text Reader

Abstract

The invention discloses a vector query method and device, and the method comprises the steps: mapping a received query vector to a low-dimensional projection space, and obtaining a projection query point; a root node of the pre-constructed index tree is provided with a plurality of sub-trees, leaf nodes of the pre-constructed index tree are used for storing data points in the low-dimensional projection space, each node of the index tree corresponds to an area in the low-dimensional projection space, and the area corresponding to the sub-nodes in the index tree is included in the area corresponding to the father node; distributing the plurality of sub-trees to a plurality of processing units, and executing range query on the distributed sub-trees by each processing unit: traversing nodes of the sub-trees, and for non-leaf nodes in the sub-trees, if the lower bound of the distance between a corresponding region of the non-leaf nodes and a projection query point is greater than a preset search radius, pruning the sub-trees of the non-leaf nodes; and for a first leaf node in the sub-tree, if the lower bound of the distance between the corresponding region and the projection query point is greater than the search radius, adding data points contained in the first leaf node into a local candidate set for determining a query result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the fields of code compilation and trusted computing technology, and more particularly to a method and apparatus for querying vectors. Background Technology

[0002] Retrieval of vectorized data is a key technology in the field of artificial intelligence, widely used in AI applications such as intelligent search, question answering systems, retrieval enhancement and generation, and multimodal search. Among these, Approximate Nearest Neighbor Search (LSH) is a commonly used vectorized data retrieval scheme due to its high search efficiency and low computational cost. However, existing LSH-based LSH schemes also suffer from the following problems: they cannot fully utilize the parallel computing capabilities of modern hardware during the indexing and retrieval processes of vector data, thus failing to achieve higher performance in parallelized hardware execution environments. Summary of the Invention

[0003] The embodiments in this specification aim to provide a vector query method and apparatus that, by leveraging the parallel processing capabilities of multiple processing units in modern computer systems, performs multi-way parallel queries on the index tree of the vector projection space, greatly improving the speed of vector queries and overcoming the shortcomings of existing technologies.

[0004] Based on the first aspect, a vector query method is provided, including: Receive a query vector, map the query vector to a low-dimensional projection space to obtain a projection query point; obtain a pre-constructed index tree, where each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node. The leaf nodes of the index tree are used to store data points in the low-dimensional projection space, and the root node of the index tree has multiple subtrees. The multiple subtrees are assigned to multiple processing units. Each processing unit performs a range query on its assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projected query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

[0005] In one possible implementation, the method further includes: Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set; determine the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space; sort the data points in the total candidate set according to the actual distance; and determine at least one data point as the query result based on the sorting result.

[0006] In one possible implementation, obtaining a pre-built index tree, the root node of which corresponds to a low-dimensional projection space, includes: obtaining L pre-built index trees, where L is an integer greater than or equal to 2, the root node of each index tree corresponds to a low-dimensional projection space, each index tree has multiple subtrees, and each subtree corresponds to an axis-aligned hyperrectangular region in the low-dimensional projection space. The plurality of subtrees are assigned to the plurality of processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projection query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree, including: For any one of the index trees, multiple subtrees of the index tree are assigned to the multiple processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projection query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree. Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set; determine the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space, and determine at least one data point in the merged candidate set as the query result based on the actual distance, including: Merge the local candidate sets corresponding to all subtrees of all index trees to obtain the total candidate set; determine the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space; and determine at least one data point in the total candidate set as the query result based on the actual distance.

[0007] In one possible implementation, the data points contained in the first leaf node are added to the local candidate set corresponding to the subtree, including: The first leaf node is randomly inserted into one of a plurality of pre-constructed node storage queues, and the data points contained in the nodes in the node storage queue are used to determine the query result corresponding to the query vector. Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set, including: The total candidate set is obtained based on the data points contained in the nodes of the multiple node storage queues.

[0008] In one possible implementation, the number of subtrees of the root node of the index tree is greater than or equal to 2 and less than or equal to 2 to the power of K, where K is the dimension of the low-dimensional projection space.

[0009] In one possible implementation, mapping the query vector to a low-dimensional projection space to obtain the projected query point includes: The query vector in the original high-dimensional space is mapped to the low-dimensional projection space through a preset hash projection matrix to obtain the projected query point.

[0010] In one possible implementation, the region is an axis-aligned superrectangular region; The lower bound of the distance between the region corresponding to the non-leaf node and the projection query point includes: the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the non-leaf node and the projection query point; The lower bound of the distance between the region corresponding to the first leaf node and the projection query point includes: the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the first leaf node and the projection query point.

[0011] In one possible implementation, the index tree is constructed through the following process: Acquire multiple high-dimensional data points and map them to a low-dimensional projection space to obtain multiple projection points. For each dimension of the low-dimensional projection space, based on the coordinate distribution of all projection points in the dimension, multiple breakpoints of the dimension are determined, and the dimension is divided into multiple non-overlapping intervals according to the multiple breakpoints; the symbol corresponding to each interval of each dimension is determined; for each projection point among the multiple projection points, the code of the projection point is generated according to the symbol corresponding to the interval to which the projection point belongs in each dimension. An index tree is constructed, and 2^K first-level nodes are generated under the root node of the index tree as initial leaf nodes, where K is the number of dimensions of the low-dimensional projection space. For each projection point among the plurality of projection points, the target leaf node corresponding to the projection point in the index tree is determined according to the encoding of the projection point, and the projection point is inserted into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space.

[0012] In one possible implementation, for each dimension of the low-dimensional projection space, based on the coordinate distribution of all projected points in that dimension, multiple breakpoints of the dimension are determined, including: The low-dimensional projection space is divided into multiple dimensional subsets, each containing multiple dimensions. These multiple dimensional subsets are then assigned to multiple processing units, each of which is used to determine the breakpoints of the dimensions contained in its assigned dimensional subset.

[0013] In one possible implementation, for each of the plurality of projection points, its target leaf node in the index tree is determined according to the encoding of the projection point, and the target leaf node is inserted; if the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from K dimensions of the low-dimensional projection space, including: All projection points are divided into multiple subsets of projection points, each containing multiple projection points. For each projection point in the assigned subset, each processing unit determines the target leaf node corresponding to the projection point in the index tree according to the encoding of the projection point, and inserts the projection point into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space.

[0014] In one possible implementation, determining multiple breakpoints in a dimension based on the coordinate distribution of all projected points in that dimension includes: determining multiple breakpoints in a dimension using a fast selection algorithm based on the coordinate distribution of all projected points in that dimension.

[0015] According to the second aspect, a vector query apparatus is provided, comprising: The acquisition unit is configured to receive a query vector, map the query vector to a low-dimensional projection space to obtain a projection query point; acquire a pre-constructed index tree, wherein each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node; the leaf nodes of the index tree are used to store data points in the low-dimensional projection space; and the root node of the index tree has multiple subtrees. The processing unit is configured to assign the plurality of subtrees to the plurality of processing units, each processing unit performing a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projected query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

[0016] According to a third aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method described in the first aspect.

[0017] According to a fourth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method described in the first aspect.

[0018] By utilizing one or more of the methods, apparatuses, computing devices, and storage media mentioned above, the parallel processing characteristics of the multiprocessing units in modern computer systems can be used to perform multi-way parallel queries on the index tree of the projection space, greatly improving the response speed of vector queries. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A schematic diagram of a vector query method according to an embodiment of this specification is shown; Figure 2 A flowchart illustrating a vector query method according to an embodiment of this specification is shown; Figure 3 A schematic diagram illustrating the construction of an index tree according to an embodiment of this specification is shown; Figure 4 A schematic diagram illustrating the construction of a parallelized index tree according to an embodiment of this specification is shown; Figure 5 A structural diagram of a vector query apparatus according to an embodiment of this specification is shown. Detailed Implementation

[0021] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0022] As mentioned earlier, retrieval of vectorized data is a key technology in the field of artificial intelligence, widely used in AI applications such as intelligent search, question answering systems, retrieval enhancement generation, and multimodal search. Approximate Nearest Neighbor Search (ANN) is a commonly used retrieval scheme for vectorized data. Its main idea is to find several data points (vectors) in a high-dimensional space that are close to the query data point (query vector), and use these as the query results that match the query data point. Unlike another commonly used vectorized data retrieval scheme, Nearest Neighbor Search (NN), Approximate Nearest Neighbor Search, at the cost of a certain degree of query accuracy error, achieves higher query efficiency and lower computational cost.

[0023] Approximate nearest neighbor search based on Locality-Sensitive Hashing (LSH) is an approximate nearest neighbor search scheme that optimizes the performance of vector queries in high-dimensional spaces. LSH is a probabilistic hashing technique that uses a specific hash function to ensure that similar data points that are close together in a multi-dimensional space have a high probability of collision and are mapped to the same hash bucket, while dissimilar data points that are far apart have a low probability of collision and are mapped to different hash buckets. The basic idea of ​​LSH-based approximate nearest neighbor search is to use random projection to project the data points from the original high-dimensional space to a low-dimensional space, and then use LSH to distribute the projected data into multiple hash buckets, so that data points that are close together have a higher probability of being assigned to the same hash bucket. Then, by comparing the query data point (query vector) with the data points in the same hash bucket, the approximate nearest neighbor data points are quickly selected as the query results that match the query data point. However, existing approximate nearest neighbor search schemes based on locality-sensitive hashing also have the following problems: In current real-world production environments, computing devices often possess parallel computing capabilities. Parallel computing refers to computing techniques that utilize multiple processing units (e.g., multiple processing cores or multiple threads) in a computer system to execute tasks simultaneously, thereby improving computational efficiency. Existing approximate nearest neighbor search schemes based on locality-sensitive hashing do not fully leverage the multi-processing unit characteristics of modern computer systems to improve computational efficiency during the organization of vector data (e.g., building an index of vector data) and the retrieval of vector data based on the organized vector data (e.g., based on the index). Therefore, they cannot fully utilize the parallel computing potential of the hardware in current parallelizable hardware execution environments to achieve higher query performance.

[0024] To address the aforementioned technical problems, this specification provides a vector query method. Figure 1 A schematic diagram of a vector query method according to an embodiment of this specification is shown. Figure 1 As shown, the original high-dimensional query point (vector) P can be obtained, and through multiple hash projection matrices (also known as random projection matrices), the projected query points corresponding to query point P in multiple low-dimensional projection spaces can be obtained, such as projected query point P1, projected query point P2, ..., projected query point Pn. For each low-dimensional projection space, according to the pre-constructed index tree used to organize data points in that projection space, the index tree in this specification can be a tree-structured spatial index. A spatial index is a data structure used for efficiently organizing and querying multi-dimensional spatial data, used to accelerate spatial query operations. In different examples, these spatial queries can be, for example, range queries, nearest neighbor searches, and spatial joins. In one example, each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the tree is contained within the region corresponding to the parent node. The data points in the low-dimensional projection space are stored in the leaf nodes of the index tree.

[0025] Furthermore, parallel range queries can be performed using multiple processing units to obtain candidate point sets in each low-dimensional projection space. These candidate point sets include data points in the low-dimensional projection space that are approximately similar to the query point. Specifically, the index tree of each low-dimensional projection space can include multiple subtrees (e.g., greater than or equal to 2 and less than or equal to 2^K), with data points in each low-dimensional projection space distributed and stored in the leaf nodes of these subtrees. Range queries targeting these subtrees can be processed in parallel using multiple processing units (e.g., finding leaf nodes in a subtree whose corresponding regions are close to the projection query point, and adding the data points in these leaf nodes to the candidate point set). Different processing units are used to process range queries for different subtrees. If the number of subtrees exceeds the number of processing units, each processing unit can be allocated multiple times to process range queries targeting different subtrees, until all subtree range queries are processed without repetition by multiple processing units. After obtaining the candidate point sets corresponding to each low-dimensional projection space, these sets can be merged, and all data points in the merged set can be reordered. The query result corresponding to the query point is determined based on the sorting result.

[0026] The advantages of this method are as follows: First, by leveraging the parallel processing capabilities of multiple processing units in modern computer systems, multi-path parallel queries are performed on the index tree of the projection space, significantly improving the response speed of vector queries. Second, in some instances, during range queries on subtrees of the index tree, leaf nodes containing approximate data points can be compared based on Euclidean distance. This query method, essentially using a hypersphere as a hash table, is more efficient than existing approximate nearest neighbor search schemes, which typically require comparisons in every dimension of the projection space during range queries. Third, in some embodiments, the index tree can be a Dynamic Encoding Tree (DET) constructed based on data point encoding. The processes of constructing dimensional breakpoints, encoding data points, and constructing subtrees can also be processed in parallel by multiple processing units, thereby greatly improving the construction speed of the index tree.

[0027] The following section further elaborates on the detailed process of this method. Figure 2 A flowchart illustrating a vector query method according to an embodiment of this specification is shown. Figure 2 The method includes at least the following steps: Step S201: Receive a query vector, map the query vector to a low-dimensional projection space to obtain a projection query point; obtain a pre-constructed index tree, where each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node. The leaf nodes of the index tree are used to store data points in the low-dimensional projection space, and the root node of the index tree has multiple subtrees. Step S203: Assign the multiple subtrees to multiple processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projected query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

[0028] First, in step S201, a query vector can be received and mapped to a low-dimensional projection space to obtain a projected query point. Then, a pre-constructed index tree is obtained. Each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node. The leaf nodes of the index tree can be used to store data points in the low-dimensional projection space, and the root node of the index tree can have multiple subtrees. In different embodiments, the number of subtrees of the root node of the index tree can be different. In one embodiment, the number of subtrees of the root node of the index tree can be greater than or equal to 2 and less than or equal to 2^K. In different embodiments, the type of region corresponding to the node in the index tree can be different. In one embodiment, the region can be an axis-aligned hyperrectangular region.

[0029] In this step, a query vector and a pre-constructed index tree of the low-dimensional projection space can be obtained. The specific method for obtaining the query vector may differ in different embodiments, and this specification does not limit this. After obtaining the query vector, the received query vector can be mapped to the low-dimensional projection space. In one embodiment, the query vector in the original high-dimensional space can be mapped to the low-dimensional projection space through a preset hash projection matrix to obtain the projected query point.

[0030] In different embodiments, the index tree obtained in this step can be of different specific types of tree-like spatial indexes, and its construction steps can also differ. In one embodiment, the index tree can be constructed through the following process: acquiring multiple high-dimensional data, mapping the multiple high-dimensional data to a low-dimensional projection space to obtain multiple projection points; for each dimension of the low-dimensional projection space, determining multiple breakpoints of the dimension based on the coordinate distribution of all projection points on the dimension, and dividing the dimension into multiple non-overlapping intervals according to the multiple breakpoints. In different specific embodiments, the specific methods for determining the breakpoints of each dimension can differ. In one specific embodiment, a fast selection algorithm can be used to determine multiple breakpoints of the dimension based on the coordinate distribution of all projection points on the dimension. Furthermore, the symbol corresponding to each interval of each dimension can be determined; for each projection point among the multiple projection points, the code of the projection point is generated according to the symbol corresponding to the interval to which the projection point belongs in each dimension. Subsequently, an index tree can be constructed, generating 2^K first-level nodes as initial leaf nodes under the root node of the index tree, where K is the dimension of the low-dimensional projection space. For each projection point, the target leaf node corresponding to the projection point in the index tree is determined according to the encoding of the projection point, and the projection point is inserted into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary-split based on the target dimension determined from the K dimensions of the low-dimensional projection space. Binary split refers to generating two child nodes of the target leaf node. The regions corresponding to the two child nodes can be obtained by dividing the regions corresponding to the target leaf node according to the target dimension. Based on the position of the data points in the target leaf node and the regions corresponding to the two child nodes of the target leaf node, the data points in the target leaf node are divided into the two child nodes of the target leaf node.

[0031] The index tree constructed in this way is also known as a dynamic encoding tree (DE-Tree), a spatial index structure. Its core is to generate a symbolic path code for each data point based on the data distribution, and then construct a tree-like index structure accordingly, ensuring that similar data points have similar paths within the index. Through dynamic index trees, fast range queries and pruning can be performed on the index based on the lower bound of Euclidean distance, preventing the performance degradation of conventional spatial indexes in high-dimensional environments and improving the speed of vector queries.

[0032] In different specific embodiments, the process of constructing the index tree can also be processed in parallel by multiple processing units, thereby accelerating the efficiency of index tree construction. Specifically, for example, multiple processing units can handle one or more of the following: determining dimension breakpoints, data point encoding, and subtree construction. Therefore, in one specific embodiment, all dimensions of the low-dimensional projection space can be divided into multiple dimension subsets, each containing multiple dimensions, and these multiple dimension subsets can be assigned to multiple processing units. Each processing unit is used to determine the breakpoints of the dimensions contained in the assigned dimension subset. In another specific embodiment, all projection points are further divided into multiple projection point subsets, each containing multiple projection points. For each projection point in the assigned projection point subset, each processing unit generates an encoding for the projection point based on the sign corresponding to the interval to which the projection point belongs in each dimension. In another specific embodiment, all projection points are further divided into multiple projection point subsets, each containing multiple projection points. For each projection point in the assigned projection point subset, each processing unit determines the target leaf node corresponding to the projection point in the index tree according to the encoding of the projection point, and inserts the projection point into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space.

[0033] After obtaining the projection query point and the index tree, in step S203, multiple subtrees of the index tree can be assigned to multiple processing units. Each processing unit performs a range query on its assigned subtree. The range query may include: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node. For leaf nodes (first leaf nodes) in the subtree, if the lower bound of the distance between the region corresponding to the leaf node and the projection query point is greater than the search radius, adding the data points contained in the leaf node to the local candidate set corresponding to the subtree. This local candidate set is used to determine the query result corresponding to the query vector.

[0034] In this step, during the traversal of nodes in the assigned subtree by any processing unit, for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projected query point is greater than a preset search radius, the subtree of the non-leaf node can be pruned. Pruning refers to skipping branches or regions that do not contain valid results during the query or traversal process. This avoids useless calculations and improves query efficiency. For leaf nodes (e.g., the first leaf node) in the subtree, if the lower bound of the distance between the region corresponding to the leaf node and the projected query point is greater than the search radius, the data points contained in the leaf node are added to the local candidate set corresponding to the subtree. In different embodiments, the size of the preset search radius may be different, and this specification does not limit it.

[0035] In different embodiments, the specific method for determining the lower bound of the distance between the region corresponding to a node and the projection query point can differ. In the embodiment where the region corresponding to the index tree node is an axis-aligned hyperrectangular region, the lower bound of the distance between the region corresponding to a non-leaf node and the projection query point can be the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the non-leaf node and the projection query point. The lower bound of the distance between the region corresponding to the first leaf node and the projection query point can be the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the first leaf node and the projection query point.

[0036] In scenarios where multiple processing units perform range queries in parallel, if all processing units store the range query results in the same storage area, it can lead to a decrease in the storage response speed of that storage area and a longer storage wait time for some processing units. To prevent this problem, in one embodiment, the first leaf node is randomly inserted into one of a pre-constructed node storage queues. The data points contained in the nodes of the node storage queue are used to determine the query result corresponding to the query vector.

[0037] In one embodiment, after step S203, the local candidate sets corresponding to all subtrees can be merged to obtain a total candidate set. In the embodiment where leaf nodes are inserted into the node storage queue, the total candidate set can be obtained based on the data points contained in the nodes of multiple node storage queues. Then, the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space can be determined, and the data points in the total candidate set can be sorted according to the actual distance. At least one data point can be determined as the query result based on the sorting result. In a specific example, for instance, in a sorting result where the sorting order of data points is negatively correlated with the actual distance, a preset number of data points with the highest sorting order can be used as the query result.

[0038] According to yet another embodiment, a vector query apparatus is also provided. Figure 5 This diagram illustrates a structural diagram of a vector query apparatus according to an embodiment of this specification, such as... Figure 5 As shown, the device 500 includes: The acquisition unit 501 is configured to receive a query vector, map the query vector to a low-dimensional projection space to obtain a projection query point; acquire a pre-constructed index tree, wherein each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node; the leaf nodes of the index tree are used to store data points in the low-dimensional projection space; and the root node of the index tree has multiple subtrees. Processing unit 502 is configured to assign the plurality of subtrees to a plurality of processing units, each processing unit performing a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projected query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

[0039] In another aspect, embodiments of this specification provide a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform any of the methods described above.

[0040] In another aspect, embodiments of this specification provide a computing device, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement any of the methods described above.

[0041] It should be understood that the descriptions such as "first" and "second" in this article are merely for the sake of simplicity in description and to distinguish similar concepts, and do not have any other limiting function.

[0042] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0043] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0044] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0045] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes said elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.

[0046] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.

[0047] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0048] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0049] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0050] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0051] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0052] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0053] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0054] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0055] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0056] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.

Claims

1. A vector query method, comprising: Receive the query vector, map the query vector to a low-dimensional projection space, and obtain the projected query point; Obtain a pre-constructed index tree, where each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node. The leaf nodes of the index tree are used to store data points in the low-dimensional projection space, and the root node of the index tree has multiple subtrees. The multiple subtrees are assigned to multiple processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree. For non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then the subtree of the non-leaf node is pruned. For the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, the data points contained in the first leaf node are added to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

2. The method according to claim 1, further comprising: Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set; The actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space is determined. The data points in the total candidate set are sorted according to the actual distance. At least one data point is determined as the query result based on the sorting result.

3. The method according to claim 2, wherein, Obtaining a pre-built index tree, the root node of which corresponds to a low-dimensional projection space, includes: obtaining L pre-built index trees, where L is an integer greater than or equal to 2, the root node of each index tree corresponds to a low-dimensional projection space, each index tree has multiple subtrees, and each subtree corresponds to an axis-aligned hyperrectangular region in the low-dimensional projection space; The plurality of subtrees are assigned to the plurality of processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projection query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree, including: For any one of the index trees, multiple subtrees of the index tree are assigned to the multiple processing units. Each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree; for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node; for the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projection query point is greater than the search radius, adding the data points contained in the first leaf node to the local candidate set corresponding to the subtree. Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set; determine the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space, and determine at least one data point in the merged candidate set as the query result based on the actual distance, including: Merge the local candidate sets corresponding to all subtrees of all index trees to obtain the total candidate set; determine the actual distance between each data point in the total candidate set and the query vector in the original high-dimensional space; and determine at least one data point in the total candidate set as the query result based on the actual distance.

4. The method according to claim 2, wherein, Add the data points contained in the first leaf node to the local candidate set corresponding to the subtree, including: The first leaf node is randomly inserted into one of a plurality of pre-constructed node storage queues, and the data points contained in the nodes in the node storage queue are used to determine the query result corresponding to the query vector. Merge the local candidate sets corresponding to all subtrees to obtain the total candidate set, including: The total candidate set is obtained based on the data points contained in the nodes of the multiple node storage queues.

5. The method according to claim 1, wherein, The number of subtrees of the root node of the index tree is greater than or equal to 2 and less than or equal to 2 to the power of K, where K is the dimension of the low-dimensional projection space.

6. The method according to claim 1, wherein, Mapping the query vector to a low-dimensional projection space yields the projected query points, including: The query vector in the original high-dimensional space is mapped to the low-dimensional projection space through a preset hash projection matrix to obtain the projected query point.

7. The method according to claim 1, wherein, The region is an axis-aligned super-rectangular region; The lower bound of the distance between the region corresponding to the non-leaf node and the projection query point includes: the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the non-leaf node and the projection query point; The lower bound of the distance between the region corresponding to the first leaf node and the projection query point includes: the lower bound of the Euclidean distance between the axis-aligned hyperrectangular region corresponding to the first leaf node and the projection query point.

8. The method according to claim 1, wherein, The index tree is constructed through the following process: Acquire multiple high-dimensional data points and map them to a low-dimensional projection space to obtain multiple projection points. For each dimension of the low-dimensional projection space, based on the coordinate distribution of all projection points in the dimension, multiple breakpoints of the dimension are determined, and the dimension is divided into multiple non-overlapping intervals according to the multiple breakpoints. Determine the symbol corresponding to each interval of each dimension; for each of the multiple projection points, generate the code of the projection point according to the symbol corresponding to the interval to which the projection point belongs in each dimension; An index tree is constructed, and 2^K first-level nodes are generated under the root node of the index tree as initial leaf nodes, where K is the number of dimensions of the low-dimensional projection space. For each projection point among the plurality of projection points, the target leaf node corresponding to the projection point in the index tree is determined according to the encoding of the projection point, and the projection point is inserted into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space.

9. The method according to claim 8, wherein, For each dimension of the low-dimensional projection space, based on the coordinate distribution of all projected points in that dimension, multiple breakpoints of that dimension are determined, including: The low-dimensional projection space is divided into multiple dimensional subsets, each containing multiple dimensions. These multiple dimensional subsets are then assigned to multiple processing units, each of which is used to determine the breakpoints of the dimensions contained in its assigned dimensional subset.

10. The method according to claim 8, wherein, For each of the plurality of projection points, its target leaf node in the index tree is determined according to the encoding of the projection point, and the target leaf node is inserted; if the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space, including: All projection points are divided into multiple subsets of projection points, each containing multiple projection points. For each projection point in the assigned subset, each processing unit determines the target leaf node corresponding to the projection point in the index tree according to the encoding of the projection point, and inserts the projection point into the target leaf node. If the number of projection points of the target leaf node reaches a preset leaf node size threshold, the target leaf node is binary split based on the target dimension determined from the K dimensions of the low-dimensional projection space.

11. The method according to claim 1, wherein, Based on the coordinate distribution of all projected points in the dimension, multiple breakpoints of the dimension are determined, including: using a fast selection algorithm to determine multiple breakpoints of the dimension based on the coordinate distribution of all projected points in the dimension.

12. A vector query device, comprising: The acquisition unit is configured to receive a query vector, map the query vector to a low-dimensional projection space, and obtain the projected query point. Obtain a pre-constructed index tree, where each node of the index tree corresponds to a region in the low-dimensional projection space, and the region corresponding to the child node of any parent node in the index tree is contained within the region corresponding to the parent node. The leaf nodes of the index tree are used to store data points in the low-dimensional projection space, and the root node of the index tree has multiple subtrees. The processing unit is configured to assign the plurality of subtrees to the plurality of processing units, and each processing unit performs a range query on the assigned subtree. The range query includes: traversing the nodes of the subtree, and for non-leaf nodes in the subtree, if the lower bound of the distance between the region corresponding to the non-leaf node and the projection query point is greater than a preset search radius, then pruning the subtree of the non-leaf node. For the first leaf node in the subtree, if the lower bound of the distance between the region corresponding to the first leaf node and the projected query point is greater than the search radius, the data points contained in the first leaf node are added to the local candidate set corresponding to the subtree; the local candidate set is used to determine the query result corresponding to the query vector.

13. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-11.

14. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-11.