An approximate nearest neighbor search method, system, device and storage medium
By constructing a K-nearest neighbor graph with filtered navigation points and combining it with tag library information, a combination of greedy and breadth-first search methods is used to solve the approximate nearest neighbor retrieval problem with conditional filtering. This improves search efficiency and recall, reduces computational overhead, and is applicable to fields such as image and video retrieval, text semantic retrieval, and anomaly detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENGDU UNION BIG DATA TECH CO LTD
- Filing Date
- 2023-05-10
- Publication Date
- 2026-08-04
AI Technical Summary
Existing condition-filtered approximate nearest neighbor retrieval methods suffer from high computational overhead, low query efficiency, and lack of feasibility, especially when dealing with large datasets.
By constructing a K-nearest neighbor graph with filtering navigation points and combining it with tag library information, a combination of greedy search and breadth-first search is used to quickly filter out nodes that do not meet the tag query, thereby improving search efficiency and reducing computational overhead.
It improves the search recall rate of nearest neighbor vectors that meet the filtering conditions, reduces the search budget and time, improves query efficiency, and has good adaptability and feasibility.
Smart Images

Figure CN116521724B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of near nearest neighbor retrieval technology, and more specifically, to a near nearest neighbor retrieval method, system, device, and storage medium. Background Technology
[0002] Approximate Nearest Neighbor Search (ANNS) is a widely used retrieval technique. Unlike traditional exact search and text matching search, the ANNS problem involves indexing a set of vectors in a metric space and finding the k vectors in the index that are closest to a query vector in the same space. Typically, the vector database used to build the index is large and high-dimensional. While an exhaustive search of the vector database can guarantee 100% recall, the time and computational costs are too high. Therefore, the core of ANNS technology is to build an index structure with high recall and short retrieval time. This technique is widely used in problems such as image and video retrieval, text semantic retrieval, and anomaly detection.
[0003] For the conditionally filtered approximate nearest neighbor retrieval problem, the retrieved k nearest neighbor vectors must not only be close to the query vector but also satisfy the filtering conditions. For example, in face recognition applications, each feature vector in a face image feature library is often related to a person's attributes, such as name, gender, age, and place of residence. In this application scenario, the general approximate nearest neighbor retrieval problem only retrieves the k nearest neighbor vectors of the face image features to be identified, searching for the face image features closest to the query target. However, conditionally filtered approximate nearest neighbor retrieval may require querying the k records closest to the query vector among records of gender, detailed place of residence, and actual age. This problem is widespread in various practical applications of approximate nearest neighbor retrieval and is considered a research direction worthy of attention and breakthroughs in both academia and industry. However, existing solutions to the approximate nearest neighbor retrieval problem based on conditional filtering mainly rely on filtering the vector library to obtain vectors that meet the conditions; then, they iterate through all the filtered library vectors and calculate the similarity with the query vector, selecting the k library vectors with the smallest distance; however, when there are too many vectors to filter, iterating through and calculating the similarity with the query vector will bring too high computational overhead and low query efficiency, which is not feasible when the amount of data is large. Summary of the Invention
[0004] This invention provides an approximate nearest neighbor retrieval method, system, device, and storage medium, which solves the problems of high computational overhead, low query efficiency, and lack of feasibility in existing solutions to the approximate nearest neighbor retrieval problem based on conditional filtering.
[0005] In a first aspect, embodiments of the present invention provide an approximate nearest neighbor retrieval method, the method comprising an index construction process and a retrieval process;
[0006] The index building process is as follows:
[0007] A K-nearest neighbor graph is constructed based on a preset vector library, and a filter navigation point is set in combination with a preset label library to obtain a K-nearest neighbor graph with filter navigation points.
[0008] The search process is as follows:
[0009] A greedy search is performed on the query vector based on the K-nearest neighbor graph with filtered navigation points to obtain a list of unfiltered nearest neighbors;
[0010] A breadth-first search is performed on the filtered navigation points based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list.
[0011] In the above embodiments, the present invention adds tag library information to the conventional index structure of approximate nearest neighbor retrieval based on K-nearest neighbor graph, thereby enabling conditional filtering and having better adaptability; and because a filtering navigation point is set, nodes near a node that do not meet the tag query can be quickly filtered out during the search process, thereby avoiding local exhaustive search, improving search efficiency, search recall of nearest neighbor vectors that meet the filtering conditions, and reducing search budget overhead and time.
[0012] As some optional implementations of this application, the process of constructing a K-nearest neighbor graph based on a preset vector library is as follows:
[0013] The K-nearest neighbor algorithm is used to construct a K-nearest neighbor graph, and each vector in the vector library is added to the K-nearest neighbor graph as a node;
[0014] Connect the newly added node to the existing neighbor nodes in the K-nearest neighbor graph.
[0015] As some optional implementations of this application, the process of obtaining a K-nearest neighbor graph with filtered navigation points by setting filter navigation points in conjunction with a preset tag library is as follows:
[0016] Randomly sample several nodes from the K-nearest neighbor graph as filtering navigation points;
[0017] Calculate the label set of neighboring nodes of each filtering navigation point that meet the filtering conditions and are within the navigation range, and store the label set in the Bloom filter where the filtering navigation point is located.
[0018] As one of the optional implementations of this application, the process of performing a greedy search on the query vector based on a K-nearest neighbor graph with filtered navigation points to obtain an unfiltered list of nearest neighbors is as follows:
[0019] Obtain the query vector and the Euclidean distances of all nodes in the K-nearest neighbor graph with filtered navigation points;
[0020] Select k nodes with the smallest Euclidean distance to form an unfiltered list of nearest neighbors; where k is the preset number of nearest neighbor nodes.
[0021] As some optional implementations of this application, the process of performing a breadth-first search on the filtering navigation points based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list is as follows:
[0022] Starting with the node corresponding to the unfiltered nearest neighbor list, perform a breadth-first search for nodes that meet the filtering conditions.
[0023] During the query process, if a filtering navigation point exists, the Bloom filter of the filtering navigation point is used to determine whether the neighbor nodes of the filtering navigation point within the navigation range meet the filtering conditions. If they do, the breadth-first search continues; otherwise, the neighbor nodes within the navigation range corresponding to the filtering navigation point are excluded from the search range. Finally, k nodes that meet the filtering conditions are retained to form a list of nearest neighbors for conditional filtering, where k is the preset number of nearest neighbors.
[0024] In the above embodiments, unlike general breadth-first search, during the search process, filtering navigation points set during index construction are used to exclude nodes that do not meet the filtering conditions, thereby improving search efficiency.
[0025] As some optional embodiments of this application, the navigation range of the filtered navigation point is set as follows:
[0026]
[0027] Where R represents the order of the neighbor nodes of the filtered navigation point, m represents the number of existing neighbor nodes defined in the K-nearest neighbor graph, ρ represents the proportion of the filtered navigation points sampled in the K-nearest neighbor graph, and N represents the total number of nodes in the K-nearest neighbor graph.
[0028] As some optional embodiments of this application, the number of filtered navigation points is ρN, where ρ is a decimal in the interval [0,1].
[0029] In the above embodiments, in a second aspect, the present invention provides an approximate nearest neighbor retrieval system, the system comprising:
[0030] An index building unit is used to build a K-nearest neighbor graph based on a preset vector library and to set filter navigation points in combination with a preset tag library to obtain a K-nearest neighbor graph with filter navigation points.
[0031] The retrieval unit first performs a greedy search on the query vector based on the K-nearest neighbor graph with filtered navigation points to obtain an unfiltered nearest neighbor list; then, it performs a breadth-first search on the filtered navigation points based on the unfiltered nearest neighbor list to obtain a filtered nearest neighbor list.
[0032] In a third aspect, the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the approximate nearest neighbor retrieval method.
[0033] In a fourth aspect, the present invention provides a computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the approximate nearest neighbor retrieval method.
[0034] The beneficial effects of this invention are as follows: Based on the conventional index structure of approximate nearest neighbor retrieval based on K-nearest neighbor graphs, this invention adds information from the tag library, thereby enabling conditional filtering and exhibiting better adaptability; furthermore, due to the setting of filtering navigation points, it can quickly filter out nodes near a node that do not meet the tag query during the search process, thereby avoiding local exhaustive search, improving search efficiency, increasing the search recall rate of nearest neighbor vectors that meet the filtering conditions, and reducing search budget overhead and time. Attached Figure Description
[0035] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a flowchart of the approximate nearest neighbor retrieval method according to an embodiment of the present invention;
[0037] Figure 2 This is a schematic diagram of a breadth-first search for filtering navigation points according to an embodiment of the present invention. Detailed Implementation
[0038] To better understand the above technical solutions, the technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments and specific features in the embodiments are detailed descriptions of the technical solutions of the present invention, rather than limitations thereof. In the absence of conflict, the technical features in the embodiments and embodiments can be combined with each other.
[0039] It should also be understood that, in order to simplify the description of the invention and thus aid in the understanding of at least one embodiment, multiple features may sometimes be grouped into a single embodiment, drawing, or description thereof in the foregoing description of the embodiments of the invention. However, this method of disclosure does not imply that the subject matter of the invention requires more features than those mentioned in the claims. In fact, the embodiments contain fewer features than all the features of the single embodiment disclosed above.
[0040] Example 1
[0041] This invention provides an approximate nearest neighbor retrieval method, the technical problem to be solved by the method is defined as follows:
[0042] There exists a vector library (set) X = {x1, x2, ..., x...} N}, where each vector is a D-dimensional real vector x. i ∈R D Meanwhile, there exists a tag library (set) A = {a1, a2, ..., a...} N}, where each label is an integer a. i ∈Z; for any query vector x q ∈R D Query tag a q Given ∈Z and the number of nearest neighbor nodes k, query the vector library X whose corresponding label is equal to the query label a. q And with the query vector x q The k vectors with the smallest Euclidean distance (L2 distance) are:
[0043]
[0044] The proposed method can improve the search recall rate of nearest neighbor vectors that meet the filtering conditions and reduce the search budget and time. It also has high query efficiency and is highly feasible.
[0045] Please see Figure 1 The method includes an index building process and a retrieval process;
[0046] (1) The index building process is as follows:
[0047] (1.1) Based on the pre-defined vector library X = {x1, x2, ..., x...} N Construct a K-nearest neighbor graph and combine it with a pre-defined label library A = {a1, a2, ..., a...} N Set up filtered navigation points to obtain a K-nearest neighbor graph with filtered navigation points;
[0048] In this embodiment of the invention, based on a preset vector library X = {x1, x2, ..., x...} NThe process of constructing a K-nearest neighbor graph is as follows:
[0049] (1.11) The K-nearest neighbor algorithm is used to construct the K-nearest neighbor graph, and the vector library X = {x1, x2, ..., x} is used. N Each vector x in} i Add it as a node to the K-nearest neighbor graph;
[0050] (1.12) Connect the newly added node to no more than m existing neighbor nodes in the K-nearest neighbor graph. The larger m is, the greater the memory overhead of retrieval, but the higher the query efficiency and recall rate.
[0051] Specifically, the K-nearest neighbor graph is a commonly used Approximate Nearest Neighbor Search (ANNS) index structure, which is an undirected graph that approximates a Delaunay graph. The Delaunay graph refers to a graph that, for a vector library X = {x1, x2, ..., x...},... N Given two vectors x1 and x2 in}, the Euclidean distance between them is: if or Then in the vector library X = {x1, x2, ..., x...} N In the corresponding undirected graph, vectors x1 and x2 share an edge. A greedy search can guarantee finding an edge that matches the query vector x. q The node corresponding to the nearest neighbor vector; since the computational cost of constructing a Delaunay graph is very high, a K-nearest neighbor graph is generally used to construct an approximate Delaunay graph, thereby obtaining an undirected graph with properties similar to the Delaunay graph.
[0052] Currently, there are many mature K-nearest neighbor graph construction algorithms for Approximate Nearest Neighbor Search (ANNS). Although the final results and search performance differ, they share similar properties: they can all obtain k nearest neighbor nodes with a relatively high probability after performing a greedy search. In this embodiment of the invention, any existing K-nearest neighbor graph construction algorithm can be used. Specifically, the following describes a computer algorithm for constructing a K-nearest neighbor graph:
[0053]
[0054] In this embodiment of the invention, the process of setting filter navigation points in conjunction with a preset tag library to obtain a K-nearest neighbor graph with filter navigation points is as follows:
[0055] (1.13) Randomly sample ρN nodes from the K-nearest neighbor graph as filtering navigation points, where ρ is a decimal in the interval [0, 1];
[0056] (1.14) Calculate the label set of neighboring nodes of each filtering navigation point that meet the filtering conditions and are within the navigation range, and store the label set in the Bloom filter where the filtering navigation point is located. The neighboring nodes within the navigation range include all neighboring nodes of order no greater than R.
[0057] In this embodiment of the invention, setting a filtering navigation point is the main innovation. In the conventional index structure of approximate nearest neighbor retrieval based on K-nearest neighbor graphs, regardless of where the search starts or in what order, the search for the query label a is satisfied. q For any given node, exhaustive search is difficult to avoid. This is because the index structure of a conventional approximate nearest neighbor search does not include the tag library A = {a1, a2, ..., a...}. N The information in the context of the search is that the purpose of setting filter navigation points is to quickly check whether there are any nodes near a given node that satisfy the query tag 'a'. q This allows for the identification of nodes, thus locally avoiding exhaustive searches.
[0058] Specifically, the fundamental technology for setting up filtering navigation points is the Bloom filter. A Bloom filter is a classic data structure that can be used to quickly approximate the existence of elements. That is, for a tag library A = {a1, a2, ..., a...}, ..., ..., ..., ..., ... N Bloom filters can determine whether 'a' is true or false in constant time complexity. q Since this invention does not have any special features in the use of Bloom filters, the algorithm flow will not be described in detail in the embodiments of this invention. It is only necessary to explain that a Bloom filter can be built on a tag library, and then a query can be performed quickly (constant time complexity) to check whether a certain tag exists in the tag library. Bloom filters can guarantee no missed detections, that is, if the queried tag exists in the set, it can definitely be judged as existing; however, there is a certain false positive rate, that is, if the queried tag does not exist in the tag library, there is a small probability of falsely reporting its existence. Theoretically, the Bloom filter used here can be replaced by data structures with the same function, such as the Cuckoo filter; specifically, the following describes a computer algorithm for setting filter navigation points:
[0059]
[0060] Here, the proportion ρ of the filtering navigation points is a decimal in the interval [0,1]. The higher ρ is, the faster the breadth-first search is, but the greater the memory overhead. The navigation range R (positive integer) of the filtering navigation points refers to the neighboring nodes (neighboring nodes with an order not greater than R) contained in a filtering navigation point. Its impact on retrieval performance is related to the query tag a during retrieval. q The ratio is relevant and can be set as follows:
[0061]
[0062] In the filtering navigation point setting algorithm, the distance function is the Euclidean distance (L2 distance) calculation function, and the neighbor(G,v,r) function extracts all neighbor nodes of order no greater than R from the graph G for the filtering navigation point v.
[0063] (2) The retrieval process is as follows:
[0064] (2.1) Query vector x is based on a K-nearest neighbor graph with filtered navigation points. q Perform a greedy search to obtain a list of unfiltered nearest neighbors;
[0065] In this embodiment of the invention, the query vector x is based on a K-nearest neighbor graph with filtered navigation points. q The process of performing a greedy search to obtain a list of unfiltered nearest neighbors is as follows:
[0066] (2.11) Obtain the Euclidean distance between the query vector and all nodes in the K nearest neighbor graph with filtered navigation points;
[0067] (2.12) Select k nodes with the smallest Euclidean distance to form an unfiltered list of nearest neighbors; where k is the preset number of nearest neighbors. Specifically, a greedy search computer algorithm is introduced below:
[0068]
[0069]
[0070] The sampling greedy search strategy for finding the k nearest neighbors does not involve labels or filtering navigation points. H is a priority queue data structure that stores node indices and distances between nodes and the query vector. The priority queue supports addition operations; if the number of nodes in H exceeds its capacity after adding a new node, the node with the largest distance is automatically deleted. The greedy search process maintains: a set C storing nodes to be explored and a set W storing visited nodes; and a priority queue H storing the k nearest neighbors among the currently explored nodes. The search process continuously retrieves the nearest node c from the candidate set C and visits c's neighbors, thus expanding the search range and updating H; the search stops when no closer nodes can be found (C is empty), and H is output.
[0071] (2.2) Perform a breadth-first search based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list;
[0072] In this embodiment of the invention, the process of performing a breadth-first search based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list is as follows:
[0073] (2.21) Starting from the node corresponding to the unfiltered nearest neighbor list, perform a breadth-first search for nodes that meet the filtering conditions;
[0074] (2.22) During the query process, if a filtering navigation point exists, the Bloom filter of the filtering navigation point is used to determine whether the nearest neighbor node of the filtering navigation point meets the filtering conditions. If it does, the breadth-first search continues; otherwise, all nearest neighbor nodes within the navigation range corresponding to the filtering navigation point are excluded from the search range. Finally, k nodes that meet the filtering conditions are retained to form a list of nearest neighbors for conditional filtering, where k is the preset number of nearest neighbors. Specifically, a computer algorithm for breadth-first search is introduced below:
[0075]
[0076]
[0077] Here, BF.exists is the query function of the Bloom filter that filters navigation points, checking if a label exists. This algorithm is based on breadth-first search, updating the candidate set C (storing candidate nodes) and the set L (storing nodes that meet the filtering criteria) in a loop. q The index contains nodes and a set W (which stores visited nodes). Unlike a typical breadth-first search, this method uses filtering navigation points set during index building to exclude nodes that do not meet the query label 'a'. q This improves search efficiency by identifying nodes.
[0078] Specifically, the principle of breadth-first search for filtering navigation points is illustrated using examples. The result of greedy search (k=2) is... Figure 2 In the context of nodes C1 and C2, after starting the breadth-first search, when a filtered navigation point a1 (navigation range R=1) is found, a Bloom filter for that navigation point is used to determine that there are no matching nodes nearby. Therefore, all first-order neighbors of the filtered navigation point can be directly added to set W instead of adding them to candidate set C, thus reducing the search range. Subsequently, since neighboring nodes outside the navigation range are added to candidate set C, nodes that meet the requirements a1... q The required nodes were directly entered into candidate set C. Please refer to [link / reference]. Figure 2 .
[0079] In summary, the embodiments of the present invention can solve the problem of approximate nearest neighbor search based on filtering conditions, dynamically reduce the search range during the search process, improve search efficiency, increase the search recall rate of nearest neighbor vectors that meet the filtering conditions, and reduce the search budget and time; and have good adaptability, any approximate nearest neighbor search scheme based on K-nearest neighbor graphs can be modified using the method described in the present invention.
[0080] Example 2
[0081] This invention provides an approximate nearest neighbor retrieval system, which corresponds one-to-one with the method described in Embodiment 1. The system includes:
[0082] An index building unit is used to build a K-nearest neighbor graph based on a preset vector library and to set filter navigation points in combination with a preset tag library to obtain a K-nearest neighbor graph with filter navigation points.
[0083] The retrieval unit first performs a greedy search on the query vector based on the K-nearest neighbor graph with filtered navigation points to obtain an unfiltered nearest neighbor list; then, it performs a breadth-first search on the filtered navigation points based on the unfiltered nearest neighbor list to obtain a filtered nearest neighbor list.
[0084] Example 3
[0085] The present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the approximate nearest neighbor retrieval method described in Embodiment 1.
[0086] The computer device provided in this embodiment can implement the method described in Embodiment 1. To avoid repetition, it will not be described again here.
[0087] Example 4
[0088] The present invention provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the approximate nearest neighbor retrieval method described in Embodiment 1.
[0089] The computer-readable storage medium provided in this embodiment can implement the method described in Embodiment 1. To avoid repetition, it will not be described again here.
[0090] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0091] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
Claims
1. A method of approximate nearest neighbor search, applied in a face recognition application, characterized in that, The method includes an index building process and a retrieval process; The index building process is as follows: A K-nearest neighbor graph is constructed based on a preset vector library, wherein the vectors in the vector library are stored face image feature vectors; The process of constructing a K-nearest neighbor graph based on a pre-defined vector library is as follows: The K-nearest neighbor algorithm is used to construct a K-nearest neighbor graph, and each vector in the vector library is added to the K-nearest neighbor graph as a node; Connect the newly added node to the existing neighbor nodes in the K-nearest neighbor graph; By combining a preset tag library with filter navigation points, a K-nearest neighbor graph with filter navigation points is obtained; the tags in the tag library correspond one-to-one with the vectors in the vector library, and the tags in the tag library are attributes corresponding to the face image feature vectors, including name, gender, age and place of residence. The process of setting filtered navigation points based on a pre-defined tag library to obtain a K-nearest neighbor graph with filtered navigation points is as follows: Randomly sample several nodes from the K-nearest neighbor graph as filtering navigation points; The label set of neighboring nodes of each filtering navigation point that meet the filtering conditions and are within the navigation range is counted, and the label set is stored in the Bloom filter where the filtering navigation point is located; the filtering conditions are attribute constraint rules, including constraints such as name, gender, age or place of residence. The search process is as follows: A greedy search is performed on the query vector based on a K-nearest neighbor graph with filtered navigation points to obtain an unfiltered list of nearest neighbors; the query vector is the feature vector of the face image to be retrieved. A breadth-first search is performed on the filtered navigation point based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list. The process of performing a breadth-first search on the filtered navigation points based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list is as follows: Starting with the node corresponding to the unfiltered nearest neighbor list, perform a breadth-first search for nodes that meet the filtering conditions. During the query process, if a filtering navigation point exists, a Bloom filter for the filtering navigation point is used to determine whether the neighboring nodes of the filtering navigation point within the navigation range meet the filtering conditions. If they do, breadth-first search continues; otherwise, the neighboring nodes within the navigation range corresponding to the filtering navigation point are excluded from the search range. Finally, k nodes that meet the filtering conditions are retained to form a conditionally filtered nearest neighbor list. The nearest neighbor list corresponds to the face image feature vector of the conditionally filtered face, where k is the preset number of nearest neighbors.
2. The approximate nearest neighbor search method according to claim 1, wherein, The process of performing a greedy search on the query vector based on a K-nearest neighbor graph with filtered navigation points to obtain an unfiltered list of nearest neighbors is as follows: Obtain the query vector and the Euclidean distances of all nodes in the K-nearest neighbor graph with filtered navigation points; Select k nodes with the smallest Euclidean distance to form an unfiltered list of nearest neighbors; where k is the preset number of nearest neighbor nodes.
3. The approximate nearest neighbor search method according to claim 1, wherein, The navigation range for the filtered navigation points is set as follows: ; Where R represents the order of the neighbor nodes of the filtering navigation point, and m represents the number of existing neighbor nodes defined in the K-nearest neighbor graph. The percentage of filtered navigation points sampled in the K-nearest neighbor graph is represented by N, and N represents the total number of nodes in the K-nearest neighbor graph.
4. The approximate nearest neighbor retrieval method according to claim 3, characterized in that, The number of filtered navigation points is wherein, is a number in the interval .
5. An approximate nearest neighbor retrieval system, applied to face recognition applications, characterized in that, The system includes: An index building unit constructs a K-nearest neighbor graph based on a preset vector library, wherein the vectors in the vector library are stored face image feature vectors. The process of constructing a K-nearest neighbor graph based on a pre-defined vector library is as follows: The K-nearest neighbor algorithm is used to construct a K-nearest neighbor graph, and each vector in the vector library is added to the K-nearest neighbor graph as a node; Connect the newly added node to the existing neighbor nodes in the K-nearest neighbor graph; By combining a preset tag library with filter navigation points, a K-nearest neighbor graph with filter navigation points is obtained; the tags in the tag library correspond one-to-one with the vectors in the vector library, and the tags in the tag library are attributes corresponding to the face image feature vectors, including name, gender, age and place of residence. The process of setting filtered navigation points based on a pre-defined tag library to obtain a K-nearest neighbor graph with filtered navigation points is as follows: Randomly sample several nodes from the K-nearest neighbor graph as filtering navigation points; The label set of neighboring nodes of each filtering navigation point that meet the filtering conditions and are within the navigation range is counted, and the label set is stored in the Bloom filter where the filtering navigation point is located; the filtering conditions are attribute constraint rules, including constraints such as name, gender, age or place of residence. The retrieval unit performs a greedy search on the query vector based on a K-nearest neighbor graph with filtered navigation points to obtain an unfiltered list of nearest neighbors; the query vector is the feature vector of the face image to be retrieved. A breadth-first search is performed on the filtered navigation points based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list. The process of performing a breadth-first search on the filtered navigation points based on the unconditionally filtered nearest neighbor list to obtain the conditionally filtered nearest neighbor list is as follows: Starting with the node corresponding to the unfiltered nearest neighbor list, perform a breadth-first search for nodes that meet the filtering conditions. During the query process, if a filtering navigation point exists, a Bloom filter for the filtering navigation point is used to determine whether the neighboring nodes of the filtering navigation point within the navigation range meet the filtering conditions. If they do, breadth-first search continues; otherwise, the neighboring nodes within the navigation range corresponding to the filtering navigation point are excluded from the search range. Finally, k nodes that meet the filtering conditions are retained to form a conditionally filtered nearest neighbor list. The nearest neighbor list corresponds to the face image feature vector of the conditionally filtered face, where k is the preset number of nearest neighbors.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes a computer program, it implements an approximate nearest neighbor retrieval method according to any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements an approximate nearest neighbor retrieval method according to any one of claims 1-4.