Index construction method, device, data system and search method
By determining the edge point in the current node as the representative point of the next node and establishing index associations in each node, the problem that the retrieval system in the existing technology fails to effectively utilize the edge points is solved, and higher retrieval accuracy is achieved.
Patent Information
- Application Number
- CN202210473409.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-04-29
AI Technical Summary
When constructing inverted indexes, existing retrieval systems fail to effectively consider edge points that are far away from the query vector, resulting in low accuracy of retrieval results.
A first preset number of edge points are determined in each cluster set of the current node as the preset representative points of the next node. Based on the preset representative points of the next node, each cluster set is obtained, and a target vector is associated with its corresponding index in each node. By comparing the distance between the query vector and the representative point of each node, the most accurate target vector is determined.
The search accuracy of the target vector in the retrieval process is improved, and the target vector in the cluster set to which the farther edge points belong is avoided from being missed due to only considering the distance to the center point, thereby ensuring the accuracy of the retrieval results.
Smart Images

Figure CN114722244B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data retrieval technology, and in particular to an index construction method, device, data system and search method. Background Art
[0002] With the rapid growth of data, data retrieval is widely used in fields such as image, video, speech, and protein molecular structure retrieval. Since various data, such as image data, can be abstracted as high-dimensional feature vectors, the similarity between data can be quantified as the distance between feature vectors in vector space. For example, the closer the distance between two feature vectors, the higher the similarity between the original data corresponding to the two feature vectors. Therefore, data retrieval can be transformed into a vector search in vector space, that is, the process of searching for several data similar to the query data in the database is transformed into the process of searching for several feature vectors in the database that are closest to the query vector corresponding to the query data.
[0003] At present, some retrieval systems will construct an inverted index for the database to facilitate user retrieval. Among them, the method of constructing the inverted index is to first cluster the feature vectors corresponding to each data in the database, such as through k-means clustering, to divide the entire vector space into several cluster sets, each cluster set has a corresponding representative point, and each feature vector is classified into the cluster set corresponding to the representative point closest to itself. In this way, when searching for a query vector, the system will determine the representative point closest to the query vector based on the distance between the query vector and multiple representative points, and search all the feature vectors in the cluster set where the representative point is located. It can be understood that searching all feature vectors is to obtain the distance between each feature vector and the query vector. Then, several feature vectors in the cluster set that are closer to the query vector are used as search results.
[0004] However, since the retrieval system determines the representative point closest to the query vector, and then only uses several feature vectors in the cluster set where this representative point is located that are closer to the query vector as search results, there may be a situation where, in the cluster set where other representative points are located, although the representative point is far from the query vector, there are several feature vectors that are closer to the query vector. As a result, the target vector of the more accurate query vector is not obtained, resulting in lower accuracy of the retrieval results. Summary of the Invention
[0005] To address the problem of low accuracy of retrieval results using vector retrieval methods, embodiments of the present application provide an index construction method, device, data system, and search method.
[0006] In a first aspect, an embodiment of the present application provides an index construction method, which is applied to an electronic system, wherein the electronic system includes multiple nodes for vector storage, and the method includes:
[0007] Determine the cluster sets of the current node;
[0008] Determining a first preset number of edge points in each cluster set of the current node as preset representative points of the next node;
[0009] Based on the preset representative point of the next node, obtaining each cluster set of the next node;
[0010] Determine a target vector and a first cluster set in each node where the target vector is located;
[0011] In each of the nodes, an index association is established between the target vector and the first cluster set where the target vector is located.
[0012] It can be understood that the index construction method provided in the embodiment of the present application determines a first preset number of edge points in each cluster set of the current node as the preset representative points of the next node, and obtains each cluster set of the next node based on the preset representative points of the next node. In this way, during the retrieval process, by obtaining the distance between the query vector and the representative point, i.e., the center point, of the cluster set within each node, and based on the distance between the obtained query vector and the representative point of each node, the target vector corresponding to the query vector in each node can be obtained. The target vectors corresponding to the query vector in each node can then be summarized and compared to search for the target vector that is closest to the query vector or the most accurate, which can effectively improve the search accuracy.
[0013] It can be understood that the target vector in the first cluster set mentioned in the embodiment of the present application can be any vector in the first cluster set.
[0014] It can be understood that the above-mentioned edge points may be edge feature vectors in the first cluster set, that is, feature vectors that are farther away from the representative points corresponding to the first cluster set.
[0015] It is understood that in the embodiment of the present application, the current node can be any node, such as the first node, the second node, and the subsequent node of the second node. Assuming that the current node is the first node, the next node is the second node.
[0016] In a possible implementation of the first aspect, determining the first cluster set to which the target vector belongs in each node includes:
[0017] Obtain the preset representative points corresponding to each cluster set;
[0018] Obtaining the distance between the target vector and the preset representative points corresponding to each cluster set in each node;
[0019] In each cluster set within each node, the cluster set with the shortest distance between the corresponding preset representative point and the target vector is used as the first cluster set where the target vector is located.
[0020] It can be understood that in the embodiment of the present application, the distance between the target vector and the preset representative points corresponding to each cluster set in each node is used, and in each cluster set in each node, the cluster set with the closest distance between the corresponding preset representative point and the target vector is used as the first cluster set where the target vector is located, which makes it easier to determine the cluster set where the target vector is located based on the distance between the representative point and the query vector, thereby finding the target vector more efficiently.
[0021] In a possible implementation of the first aspect, determining a first preset number of edge points in each cluster set of the current node includes:
[0022] Determining a second preset number of edge points of each cluster set in the current node according to the first preset number and the number of feature vectors of each cluster set in the current node;
[0023] The second preset number of corresponding edge points is determined from each cluster set within the current node.
[0024] It can be understood that in an embodiment of the present application, based on the first preset number and the number of feature vectors of each cluster set in the current node, the second preset number of edge points of each cluster set in the current node is determined, and the corresponding second preset number of edge points is determined from each cluster set in the current node, which can make the distribution of edge points of each cluster set obtained in the current node more reasonable.
[0025] In a possible implementation of the first aspect, determining the corresponding second preset number of edge points from each cluster set within the current node includes:
[0026] Determine adjacent cluster sets of each cluster set within the current node;
[0027] For each eigenvector of a corresponding cluster set, obtaining a first distance between the eigenvector and a representative point of the corresponding cluster set, and obtaining a second distance between the eigenvector and a representative point of an adjacent cluster set;
[0028] A corresponding first sequence is determined according to the first distance and the second distance, and a second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
[0029] It can be understood that the adjacent cluster sets of each cluster set in the current node are determined, and for each eigenvector of the corresponding cluster set, the first distance between each eigenvector and the representative point of the corresponding cluster set is obtained. The first distance represents the distance between each eigenvector and the center point of the corresponding cluster set, and the second distance between each eigenvector and the representative point of the adjacent cluster set is obtained. The second distance represents the distance between each eigenvector and the center point of the corresponding adjacent cluster set. Therefore, it is more reasonable and effective to determine the edge points of the corresponding cluster set based on the first distance and the second distance.
[0030] In a possible implementation of the first aspect, determining a first sequence according to the first distance and the second distance, and using a second preset number of feature vectors in the first sequence as edge points of the corresponding cluster set includes:
[0031] Obtaining the sum of the first distance and the second distance;
[0032] Sort the eigenvectors by the sum of the distances from largest to smallest to obtain the first sequence;
[0033] The first second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
[0034] It can be understood that the first sequence is obtained by sorting the sum of the first distance and the second distance from large to small. Based on the obtained first sequence, the feature vector with the largest distance sum is determined, that is, the feature vector that is farther from the representative point of the first cluster set and also farther from the representative point of the second cluster set. In other words, this feature vector may be located at an edge point in the opposite direction from the representative point of the first cluster set to the representative point of the adjacent cluster set. Once the first sequence corresponding to the adjacent cluster sets in each direction of the first cluster set is obtained, the edge points in each direction of the first cluster set can be obtained. In this way, using the edge points in each direction of the first cluster set as the preset representative points of the next node can effectively improve the search accuracy.
[0035] In a possible implementation of the first aspect, determining a first sequence according to the first distance and the second distance, and using a second preset number of feature vectors in the first sequence as edge points of the corresponding cluster set includes:
[0036] Obtaining a ratio of a difference between the second distance and the first distance to the first distance;
[0037] Sort the eigenvectors in ascending order according to the ratios to obtain the first sequence;
[0038] The first second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
[0039] It can be understood that in the embodiment of the present application, the ratio of the difference between the second distance and the first distance to the first distance is obtained. When the ratio is smaller, it indicates that the feature vector is farther away from the center point. It is more reasonable to sort the features from small to large according to the ratio and take the cluster sets of the first second preset number of distances in the sequence as the edge points of the corresponding cluster sets.
[0040] In a possible implementation of the first aspect, determining the corresponding second preset number of edge points from each cluster set within the current node includes:
[0041] Determining a first distance between each feature vector in a corresponding cluster set and a representative point of the corresponding set;
[0042] A first sequence is determined from the eigenvectors according to the first distance, and a second preset number of eigenvectors in the first sequence are used as edge points of the first cluster set.
[0043] It can be understood that in an embodiment of the present application, the first distance between each feature vector in the corresponding cluster set of the current node and the representative point of the corresponding set is determined. According to the first distance, the larger the first distance is, the farther the feature vector is from the center point. It is convenient and reasonable to use the feature vector with a larger distance in the first sequence as the edge point of the first cluster set.
[0044] In a possible implementation of the first aspect, determining the corresponding second preset number of edge points from each cluster set within the current node includes:
[0045] Determine adjacent cluster sets of each cluster set within the current node;
[0046] Determining a second distance between each feature vector in a corresponding cluster set and a representative point of an adjacent cluster set of the corresponding set;
[0047] A first sequence is determined from the eigenvectors according to the second distance, and a second preset number of eigenvectors in the first sequence are used as edge points of the first cluster set.
[0048] It can be understood that in an embodiment of the present application, the adjacent cluster sets of each cluster set in the current node are determined, and the second distance between each feature vector in the corresponding cluster set and the representative point of the adjacent cluster set of the corresponding set is determined. The smaller the second distance is, the closer the feature vector is to the adjacent cluster set, that is, the closer it is to the edge of the first cluster set. Therefore, the edge point of the first cluster set can be determined more accurately based on the second distance.
[0049] In a possible implementation of the first aspect above, the distance includes Euclidean distance, inner product distance, and Hamming distance.
[0050] It can be understood that the distances in the embodiments of the present application include Euclidean distance, inner product distance and Hamming distance, which are merely distance descriptions and can also be represented by any other feasible distance.
[0051] In a second aspect, an embodiment of the present application provides an index construction device, comprising:
[0052] A first determining unit is configured to determine a target vector and a first cluster set in which the target vector is located within a current node, wherein the first cluster set has a first representative point;
[0053] a second determining unit, configured to determine a second cluster set in which the target vector is located in the next node, the second cluster set having a corresponding representative point, the preset representative point corresponding to the second cluster set being an edge point of one of the cluster sets in the first node, wherein a feature vector in the first node is the same as a feature vector in the second node;
[0054] The association unit establishes, in each of the nodes, an index association between the target vector and the first cluster set where the target vector is located.
[0055] In a third aspect, an embodiment of the present application provides a vector search method, including:
[0056] Get the query vector;
[0057] Obtain the third distance between the representative point of each cluster set in each node and the query vector;
[0058] Determine a target representative point in each node according to the third distance, and determine a fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector;
[0059] Determining, based on the fourth distance, a first target vector corresponding to the query vector in each of the nodes;
[0060] According to the fourth distance, a second target vector corresponding to the query vector is determined from the first target vectors corresponding to the query vector in each node.
[0061] It is understandable that in an embodiment of the present application, during the retrieval process, the query vector can be compared with the representative point corresponding to each cluster set in each node, and the third distance between the representative point of each cluster set in each node and the query vector can be obtained. Based on the third distance, the target representative point in each node is determined, and the fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector is determined. This can take into account the distance between the edge points farther from the center point and the query vector, avoiding the problem in the prior art that the target vector is an edge point, and the prior art center only considers the distance from the center point, resulting in a failure to find a more accurate target vector. Furthermore, based on the fourth distance, the first target vector corresponding to the query vector in each node is determined. According to the fourth distance, the target vector of the query vector can be more comprehensively obtained from the first target vector corresponding to the query vector in each node, and then the second target vector corresponding to the query vector, i.e., the final determined target vector, is obtained based on the first target vector, so that the obtained target vector is more accurate.
[0062] In a possible implementation of the third aspect, determining, according to the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each node includes:
[0063] According to the fourth distance, the first target vectors corresponding to the query vector in each node are sorted from small to large according to the fourth distance, and the target vector in the previously set order is determined as the second target vector corresponding to the query vector.
[0064] It can be understood that the target vectors whose order is set before the distance between the query vector and the first target vector corresponding to each node is determined as the second target vector corresponding to the query vector, ie, the final target vector, can ensure the accuracy of the target vector.
[0065] In a fourth aspect, an embodiment of the present application provides a search device, applied to a data system, comprising:
[0066] A first acquisition unit, configured to acquire a query vector;
[0067] A second obtaining unit is used to obtain a third distance between the representative point of each cluster set in each node and the query vector;
[0068] a first determining unit, configured to determine a target representative point in each node according to the third distance, and determine a second distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector;
[0069] a second determining unit, configured to determine, based on the fourth distance, a first target vector corresponding to the query vector in each of the nodes;
[0070] The third determining unit is configured to determine, according to the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each of the nodes.
[0071] In a fifth aspect, an embodiment of the present application provides a retrieval system, comprising the above-mentioned index construction device and / or the above-mentioned search device.
[0072] In a sixth aspect, an embodiment of the present application provides an index structure comprising a plurality of sub-index structures, each sub-index structure comprising a plurality of representative point items and a plurality of inverted file items; the representative point items comprising representative points corresponding to respective cluster sets in a data system, and the inverted file items comprising inverted files corresponding to the representative points;
[0073] Each inverted file includes each feature vector in the cluster set corresponding to the representative point corresponding to each inverted file.
[0074] In the seventh aspect, an embodiment of the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the index construction method described in any one of the first aspects of the claim or the vector search method described in any one of the third aspects.
[0075] In an eighth aspect, an embodiment of the present application provides a readable medium, comprising instructions stored on the readable medium, which, when executed on an electronic device, enables the machine to execute the index construction method described in any one of the first aspects of the claims or the vector search method described in any one of the third aspects.
[0076] In a ninth aspect, an embodiment of the present application provides a computer program product, comprising instructions, wherein the instructions are used to implement the index construction method described in any one of the first aspects of the claims or the vector search method described in any one of the third aspects.
[0077] Based on the above solution, this application has the following beneficial effects:
[0078] The index construction method provided by the present application provides multiple ways to accurately select the edge points of each cluster set of the current node, and can realize the selection of edge points in each direction of the first cluster set of the current node, and use the first preset number of edge points of the current node as the preset representative points of the next node. According to the preset representative points of the next node, each cluster set of the next node is obtained, and an index association between the target vector and the first cluster set where the target vector is located is established in each node. In the process of searching, the distance between the query vector and the representative points corresponding to each cluster set of each node can be compared, and the target representative point can be determined based on the comparison result. In this way, the distance between the edge points farther from the center point and the query vector can be taken into account, avoiding the problem in the prior art that the target vector is an edge point and the prior art center only considers the distance between the query vector and the center point, resulting in the failure to find a more accurate target vector, and omitting the target vector in the cluster set to which the first representative point farther from the query vector belongs, thereby effectively improving the search accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] Figure 1a According to some embodiments of the present application, a schematic diagram of an image database S is shown;
[0080] Figure 1b According to some embodiments of the present application, a schematic diagram of constructing an inverted index for an image database S is shown;
[0081] Figure 2 According to some embodiments of the present application, a schematic diagram of a database corresponding to each node is shown;
[0082] Figure 3a According to some embodiments of the present application, a schematic diagram of cluster sets in a first node is shown;
[0083] Figure 3b According to some embodiments of the present application, a schematic diagram of each cluster set in a second node is shown;
[0084] Figure 3c According to some embodiments of the present application, a schematic diagram of each cluster set in a third node is shown;
[0085] Figure 3d FIG2 shows a schematic diagram of an index structure of a database S according to some embodiments of the present application;
[0086] Figure 4 According to some embodiments of the present application, a schematic diagram of determining adjacent cluster sets of cluster set S1 is shown;
[0087] Figure 5aAccording to some embodiments of the present application, a schematic diagram of obtaining edge points of a first cluster set S1 is shown;
[0088] Figure 5b According to some embodiments of the present application, a schematic diagram of obtaining edge points of a first cluster set S1 is shown;
[0089] Figure 5c According to some embodiments of the present application, a schematic diagram of obtaining edge points of a first cluster set S1 is shown;
[0090] Figure 5d According to some embodiments of the present application, a schematic diagram of obtaining edge points of a first cluster set S1 is shown;
[0091] Figure 6a According to some embodiments of the present application, a schematic diagram of obtaining a query vector and representative points in a first node is shown;
[0092] Figure 6b According to some embodiments of the present application, a schematic diagram of obtaining a query vector and representative points in a second node is shown;
[0093] Figure 6c According to some embodiments of the present application, a schematic diagram of obtaining a query vector and representative points in a third node is shown;
[0094] Figure 7a According to some embodiments of the present application, a schematic diagram of a target vector corresponding to a query vector at a first node is shown;
[0095] Figure 7b According to some embodiments of the present application, a schematic diagram of a target vector corresponding to a query vector at a second node is shown;
[0096] Figure 7c According to some embodiments of the present application, a schematic diagram of a target vector corresponding to a query vector at a third node is shown;
[0097] Figure 8 According to some embodiments of the present application, a flowchart of an index construction method is shown;
[0098] Figure 9 According to some embodiments of the present application, a sub-index structure corresponding to a first node and a second node is shown;
[0099] Figure 10 According to some embodiments of the present application, a flowchart of a search method is shown;
[0100] Figure 11 According to some embodiments of the present application, a schematic diagram of an index construction device is shown;
[0101] Figure 12 According to some embodiments of the present application, a schematic diagram of a search device is shown;
[0102] Figure 13 According to some embodiments of the present application, a schematic diagram of a retrieval system is shown;
[0103] Figure 14 According to some embodiments of the present application, a block diagram of an electronic device is shown. DETAILED DESCRIPTION
[0104] The illustrative embodiments of the present application include, but are not limited to, an index building method, apparatus, data system, and search method.
[0105] As mentioned above, the accuracy of the search results obtained by constructing an inverted index in the current database is relatively low.
[0106] For example, Figure 1a FIG. 1 is a schematic diagram of an image database S in a retrieval system, where the database S includes feature vectors corresponding to each image. Figure 1b The diagram in Figure 1 is a schematic diagram of constructing an inverted index for the image database S. Figure 1b As shown, first, each feature vector in the database S is distributed into four cluster sets through clustering processing, namely cluster set S1, cluster set S2, cluster set S3 and cluster set S4, among which cluster set S1 has a corresponding representative point C1, cluster set S2 has a corresponding representative point C2, cluster set S3 has a corresponding representative point C3, and cluster set S4 has a corresponding representative point C4.
[0107] It can be understood that the representative point mentioned in the embodiment of the present application can be the center point of the cluster set, that is, the point whose distance difference from each point is within a preset range; it can also be a point established based on other rules.
[0108] When performing vector retrieval on the query vector A corresponding to the query image based on the above database S, the retrieval system will determine the distance between each representative point and the query vector A, for example, Figure 1bAs shown, the retrieval system determines that the distance between representative point C1 and query vector A is d1, the distance between representative point C2 and query vector A is d2, the distance between representative point C3 and query vector A is d3, and the distance between representative point C4 and query vector A is d4. Assuming that d4>d3>d1>d2, the system determines that the representative point closest to query vector A among the four representative points is representative point C2, and then searches each feature vector in cluster set S2 where representative point C2 is located. It can be understood that searching each feature vector is to obtain the distance between each feature vector and query vector A. Thereafter, feature vectors Y1 and Y2 in cluster set S2 that are closer to query vector A or within a set distance range are used as target vectors for query vector A. The original image data corresponding to the target vectors is then output to the client.
[0109] However, if Figure 1b As shown, in fact, the feature vector X1 in the cluster set S1 is the feature vector closest to the query vector A in the database S. However, since the representative point C1 of the cluster set S1 is not the closest to the query vector, the system does not search the feature vectors in the cluster set S1, resulting in the failure to obtain the accurate target vector of the query vector A, resulting in the omission of the most accurate retrieval result, affecting the accuracy of the retrieval.
[0110] In order to solve the above problems, an embodiment of the present application provides an index construction method, which specifically includes: obtaining the feature vectors corresponding to each data in the database to be indexed; placing the obtained feature vectors redundantly (or called repeated) in a preset number of nodes, wherein the feature vectors in each node are the same.
[0111] It is understood that when the retrieval system is a distributed system, that is, having multiple processors and multiple corresponding memory systems, each of the above-mentioned preset number of nodes has both computing and storage capabilities and is a collection of computing resources and storage resources. Therefore, retrievals from different nodes can be processed in parallel. In some embodiments, when the retrieval system has only a single processor and a single memory, the above-mentioned node can refer to a collection of processes, threads or coroutines in a single memory and different storage areas on a single memory.
[0112] For the first node, a number of representative points are preset, and the feature vectors in the first node are clustered based on the preset representative points, and the feature vectors in the first node are assigned to corresponding cluster sets, and each cluster set has corresponding representative points; then, according to the first preset number of cluster sets of the second node, a first preset number of edge points are determined from each cluster set of the first node, as the preset representative points of each cluster set of the second node, and the feature vectors in the second node are clustered based on the preset representative points of each cluster set of the second node, and the feature vectors in the second node are assigned to corresponding cluster sets in the second node, and each corresponding cluster set in the second node has a corresponding representative point.
[0113] The feature vectors in subsequent nodes all refer to the clustering method of the second node, that is, according to the preset number of cluster sets of the current node, a preset number of edge points are obtained from the cluster sets of the previous node as the preset representative points of the cluster sets of the current node, and the feature vectors in the current node are clustered based on the preset representative points of the cluster sets of the current node to obtain corresponding cluster sets, wherein each obtained cluster set has a corresponding representative point.
[0114] If clustering has been performed on a preset number of nodes, then for each target vector, the cluster set to which each target vector belongs within each node is determined; an index association is established between the target vector and the representative point corresponding to the cluster set to which the target vector belongs within each node. That is, a sub-index structure is established for each node. For example, assuming that the target vector is assigned to the first cluster set within the first node at the first node, an index association is established between the first node and the representative point of the first cluster set in the sub-index structure of the first node; assuming that the target vector is assigned to the second cluster set within the second node at the second node, an index association is established between the second node and the representative point of the second cluster set in the sub-index structure of the second node.
[0115] It is understood that the aforementioned clustering methods for the feature vectors within each node can be clustering methods such as K-means. The K-means clustering method can obtain the distance between each feature vector in the database and the representative point corresponding to each cluster set; and assign each feature vector to the cluster set corresponding to the representative point with the closest distance.
[0116] The following is Figure 1a The index construction of the database S in the embodiment of the present application is described.
[0117] For example, Figure 1a The corresponding feature vectors in the database S in are repeatedly placed in three nodes, and the results are as follows Figure 2The first node, the second node and the third node are shown. It can be understood that the database S stored in the first node, the second node and the third node are all the same.
[0118] For the first node, cluster the feature vectors in the first node to obtain Figure 3a The four cluster sets S1, S2, S3, and S4 within the first node are shown, along with the representative points C1, C2, C3, and C4 corresponding to these four cluster sets. In the sub-index structure of the first node, the representative points C1, C2, C3, and C4 of the first node are associated with the feature vectors in the cluster sets to which the representative points belong, respectively, to establish index associations corresponding to the first node.
[0119] For the second node, assuming that the first preset number of cluster sets corresponding to the second node is 4, 4 edge points can be determined in the first node. Figure 3a As shown in FIG, the edge points selected in the first node are edge point C1' in cluster set S1, edge point C2' in cluster set S2, edge point C3' in cluster set S3, and edge point C4' in cluster set S4. The selection method will be described below and will not be repeated here. Then, as shown in FIG. Figure 3b As shown, the edge points C1', C2', C3', and C4' selected in the first node are used as the preset representative points of the second node, and all feature vectors of the second node are clustered to obtain cluster sets S1', S2', S3', and S4' corresponding to the second node. In the sub-index structure of the second node, the representative points C1', C2', C3', and C4' of the second node are respectively associated with the feature vectors in the cluster sets S1', S2', S3', and S4' to which the representative points belong, and an index association is established corresponding to the second node.
[0120] It is understood that in some embodiments, after clustering the feature vectors within a node according to the preset representative points of any node to obtain the corresponding cluster sets, the representative points of each cluster set can be recalculated. For example, the arithmetic mean of the feature vectors in each cluster set can be used as the representative point of that cluster set. It is understood that the recalculated representative points of each cluster set are generally inconsistent with the initially preset representative points. However, for ease of description, the technical solutions in the embodiments of the present application are described using the example of approximately replacing the representative points after clustering with the initial preset representative points.
[0121] For the third node, assuming that the preset number of the third node set is 3, select 3 edge points in each cluster set of the second node, and use these 3 edge points as the preset representative points of the third node. Assuming that Figure 3cThe preset number of edge points shown in FIG. 1 are specifically selected as edge points C1″ in cluster set S1′, edge points C2″ in cluster set S2′, and edge points C3″ in cluster set S3′. The preset representative points of the third node are edge points C1″, C2″, and C3″ of the second node. The selection method will be described below and will not be repeated here. Clustering is performed on all feature vectors of the third node based on the preset representative points to obtain the following: Figure 3c The third node is shown with its corresponding three cluster sets S1", S2", and S3", as well as their corresponding representative points C1", C2", and C3". In the third node's sub-index structure, the third node's representative points C1", C2", and C3" are associated with the feature vectors in the cluster sets S1", S2", and S3" to which they belong.
[0122] Figure 3d A schematic diagram of the index structure of the above database S is shown, which includes a sub-index structure of a first node, a sub-index structure of a second node, and a sub-index structure of a third node.
[0123] like Figure 3d As shown, the sub-index structure corresponding to the first node includes a representative point item and an inverted file item. The representative point item includes cluster set S1 having a corresponding representative point C1, cluster set S2 having a corresponding representative point C2, cluster set S3 having a corresponding representative point C3, and cluster set S4 having a corresponding representative point C4.
[0124] The corresponding representative point C1 of the cluster set S1 has a corresponding inverted file D1, and the inverted file D1 includes each feature vector in the cluster set S1 corresponding to the corresponding representative point C1.
[0125] The corresponding representative point C2 of the cluster set S2 has a corresponding inverted file D2, and the inverted file D2 includes each feature vector in the cluster set S2 corresponding to the corresponding representative point C2.
[0126] The corresponding representative point C3 of the cluster set S3 has a corresponding inverted file D3, and the inverted file D3 includes each feature vector in the cluster set S3 corresponding to the corresponding representative point C3.
[0127] The corresponding representative point C4 of the cluster set S4 has a corresponding inverted file D4, and the inverted file D4 includes each feature vector in the cluster set S4 corresponding to the corresponding representative point C4.
[0128] The sub-index structure of the second node and the sub-index structure of the third node are similar to the sub-index structure of the first node, and are not described in detail below.
[0129] It is understood that after the preset number of cluster sets of the second node, that is, the first preset number, is determined, the second preset number of edge points to be determined in each cluster set of the first node can be determined according to the following method:
[0130] In a first practicable solution, a method for determining a second preset number of edge points for each cluster set in a first node is as follows: based on the first preset number and the radius of each cluster set in the first node, the second preset number of edge points for each cluster set is determined according to a ratio between the first preset number and the radius of each cluster set; it is understood that in some embodiments, when the calculated preset number of edge points for any cluster set is not an integer, a final preset number can be obtained according to a rounding rule. For example, the rounding rule can be to add 1 to the integer digit of the value corresponding to the current number and discard the decimal part to obtain the value obtained as the final value corresponding to the preset number.
[0131] For example, the first preset number is 4, that is, the total preset number of edge points is 4. Figure 3a In the cluster set corresponding to the first node shown, assuming that the radius of cluster set S1 is 16, the radius of cluster set S2 is 14, the radius of cluster set S3 is 10, and the radius of cluster set S4 is 17, the ratio of the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 16:14:10:17; based on the preset total number of edge points and the above-mentioned ratio of the number of edge points of 16:14:10:17, it can be determined that the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 1.1, 0.9, 0.7, and 1.7. According to the above rounding rule, it can be concluded that the second preset number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 2, 1, 1, and 2, respectively.
[0132] It can be understood that in the embodiment of the present application, by using a preset number of edge points in each node as the preset representative points of the next node, the clustering of each node can be made as different as possible, thereby effectively improving the search accuracy.
[0133] Secondly, the above method of determining the preset number of edge points of each cluster set based on the first preset number and the ratio of the radius of each cluster set can make the distribution of edge points more uniform, avoiding the situation where some cluster sets have a very small radius but a large number of edge points are determined.
[0134] In the second feasible scheme, the method for determining the second preset number of edge points of each cluster set in the first node is: according to the first preset number, sort the cluster sets in the first node from large to small according to the radius, and select a set number of edge points from each cluster set until the preset first number is selected.
[0135] For example, the first preset number is 4, that is, the total preset number of edge points is 4. Figure 3a In the cluster sets corresponding to the first node shown, assuming that the radius of cluster set S1 is 16, the radius of cluster set S2 is 14, the radius of cluster set S3 is 10, and the radius of cluster set S4 is 17, the order of the radius of each cluster set from large to small is cluster set S4-cluster set S1-cluster set S2-cluster set S3; when the set number of edge points selected in each cluster set is 2, according to the order of cluster set S4-cluster set S1-cluster set S2-cluster set S3, the second preset number of edge points that need to be determined in cluster set S4 and cluster set S1 is two. Because the preset total number of edge points has been reached at this time. Subsequent cluster sets S2 and cluster set S3 will no longer select edge points, that is, the number of cluster sets S2 and cluster set S3 behind cluster set S1 is 0.
[0136] It can be understood that the above method of sorting the cluster sets from large to small according to the radius of each cluster set based on the first preset number and selecting a set number of edge points from each cluster set can determine a smaller number of edge points in cluster sets with smaller radius, and determine more edge points in other cluster sets with larger radius, so that the determined edge points can fully represent the corresponding cluster sets, effectively improving the search accuracy.
[0137] In a third feasible method, the method for determining the second preset number of edge points of each cluster set in the first node is: determining the sum of the distances between the representative point of each cluster set in the first node and its closest set number of feature vectors, and determining the second preset number of edge points of each cluster set based on the ratio of the sum of the distances corresponding to each cluster set and the first preset number.
[0138] It can be understood that the set number of the above-selected feature vectors close to the representative points of each cluster set can be set according to actual needs.
[0139] It can be understood that when the sum of the distances between the representative point of a cluster set and its closest set number of feature vectors is large, it can be proved to a certain extent that most of the feature vectors in the cluster set are far away from the center point, so there may be more edge points. At this time, setting the second preset number to be obtained in the cluster set to be larger can enable the edge points determined in the larger cluster set to fully represent the cluster set, effectively improving the search accuracy.
[0140] For example, the first preset number is 4, that is, the total preset number of edge points is 4. Figure 3a In the cluster set corresponding to the first node shown, assuming that the sum of the distances between the representative point C1 in cluster set S1 and its closest set number of feature vectors is 16, the sum of the distances between the representative point C2 in cluster set S2 and its closest set number of feature vectors is 14, the sum of the distances between the representative point C3 in cluster set S3 and its closest set number of feature vectors is 10, and the sum of the distances between the representative point C4 in cluster set S4 and its closest set number of feature vectors is 17. Then the ratio of the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 16:14:10:17; based on the preset total number of edge points 4 and the above-mentioned ratio of the number of edge points of 16:14:10:17, it can be determined that the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 1.1, 0.9, 0.7, and 1.7. According to the above rounding rule, it can be concluded that the second preset numbers of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 are 2, 1, 1, and 2, respectively.
[0141] It can be understood that the above-mentioned method can be used to determine the second preset number of edge points required for each cluster set in other nodes.
[0142] After determining the second preset number of edge points to be acquired in each cluster set based on the above method, a corresponding second preset number of edge points can be further determined within the corresponding cluster set. The following describes the method for determining the second preset number of edge points in any cluster set provided in the embodiments of the present application, taking the method for determining the second preset number of edge points in the first cluster set within the first node as an example:
[0143] In the first feasible scheme, the method for determining the second preset number of edge points from the first cluster set can be: obtaining the first distance between the representative point of the first cluster set and all the feature vectors in the first cluster set; sorting the feature vectors from far to near according to the first distance to obtain the first sequence corresponding to the first cluster set; and determining the first second preset number of feature vectors in the first sequence as edge points in the cluster set.
[0144] It can be understood that in the embodiment of the present application, edge points can be determined based on the distance between each feature vector in the first cluster set and the representative point, so that feature vectors farther away from the representative point can be used as edge points, making the selection of edge points more accurate.
[0145] In the embodiment of the present application, the eigenvectors in the first cluster set are sorted from farthest to closest based on the distance between each eigenvector and the representative point, that is, based on how close each eigenvector is to the representative point. This makes it easier to select corresponding edge points based on a set number of edge points. For example, if the set number of edge points is five, the first five eigenvectors in the sorted first sequence can be directly used as edge points.
[0146] In a second feasible scheme, the method for determining a second preset number of edge points from the first cluster set can be: obtaining a first distance between a representative point of the first cluster set and all feature vectors in the first cluster set; taking feature vectors whose first distance is greater than the set distance as feature vectors in a first sequence, and then taking a second preset number of feature vectors in the first sequence as edge points, or sorting each feature vector in the first sequence from far to near according to the first distance, and taking the first second preset number of feature vectors in the sorting as edge points.
[0147] It is understood that in the embodiments of the present application, the first sequence can be obtained based on feature vectors in the first cluster set whose distance from the representative point is greater than a set distance. That is, the feature vectors in the first sequence are vectors that are farther from the representative point and greater than the set distance. This can make the method for selecting adjacent cluster sets more standardized and simple. For example, edge points can be obtained by simply setting a corresponding distance threshold parameter in the algorithm for selecting edge points.
[0148] In a third feasible scheme, the method for determining a second preset number of edge points from the first cluster set can be: determining at least one adjacent cluster set adjacent to the first cluster set in cluster sets other than the first cluster set; obtaining the distance between each feature vector in the first cluster set and the representative point of each adjacent cluster set; sorting the feature vectors from near to far according to the distance, and obtaining a first sequence corresponding to each adjacent cluster set; and taking the first set number of feature vectors in the first sequence as edge points.
[0149] Among them, the method for obtaining at least one adjacent cluster set adjacent to the first cluster set can be: sorting each cluster set in the above-mentioned multiple cluster sets except the first cluster set from near to far according to the distance between the representative point of each cluster set and the representative point of the first cluster set, and obtaining the second sequence corresponding to the first cluster set; and taking the first second preset number of cluster sets in the second sequence as the adjacent cluster sets adjacent to the first cluster set.
[0150] The following is the aforementioned Figure 3a Taking the first cluster set S1 in as an example, the method of obtaining the edge points in the first cluster set S1 is introduced:
[0151] First, at least one adjacent cluster set of the first cluster set S1 can be obtained. The method of obtaining at least one adjacent cluster set of the first cluster set S1 can be: obtaining the distance between the representative points of the other three cluster sets except the cluster set S1 and the representative point C1 of the first cluster set S1. For example, Figure 4 As shown, the distance between the representative point C2 of cluster set S2 and the representative point C1 of the first cluster set S1 is d5, the distance between the representative point C3 of cluster set S3 and the representative point C1 of the first cluster set S1 is d6, and the distance between the representative point C4 of cluster set S4 and the representative point C1 of the first cluster set S1 is d7. Then, according to the distance between the representative points of each of the three cluster sets and the representative point C1 of the first cluster set S1, the three cluster sets are sorted from near to far to obtain the second sequence corresponding to the representative point C1. Assuming that d7 < d5 < d6, the second sequence corresponding to the representative point C1 is cluster set S4 - cluster set S2 - cluster set S3. At this time, the representative point C1 is indexed and associated with the first second preset number of cluster sets in the second sequence. Assuming that the second preset number is 2, cluster set S2 and cluster set S4 can be regarded as adjacent cluster sets adjacent to the first cluster set S1.
[0152] Then, the distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2, and the distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S4 are obtained. Figure 5aAs shown in , for the feature vector X1, the distance d2_1 between the feature vector X1 in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained, and the distances between other feature vectors and the representative point C2 are not repeated here; according to the distance between each feature vector and the representative point C2, each feature vector is sorted from near to far. Assuming that the first sequence obtained by sorting the 15 feature vectors in the first cluster set S1 from far to near according to the distance is X1-X3-X5-......-X15. Assuming that the preset second preset number of edge points of the corresponding cluster set obtained according to each neighboring set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X1, can be used as an edge point. At the same time, the distance between each feature vector in the first cluster set S1 and the representative point C4 of the adjacent cluster set S4 is obtained, as shown Figure 5a As shown in , for feature vector X1, the distance d4_1 between feature vector X1 in the first cluster set S1 and the representative point C4 of the adjacent cluster set S4 is obtained. The distances between other feature vectors and the representative point C4 are not repeated here. According to the distance between each feature vector and the representative point C4, each feature vector is sorted from near to far. Assuming that the first sequence obtained by sorting the 15 feature vectors in the first cluster set S1 from near to far according to the distance is X7-X8-X1-...-X14. Assuming that the second preset number of edge points of the corresponding cluster set obtained according to each adjacent set is one, the first feature vector in the first sequence corresponding to the fourth cluster set S4, that is, feature vector X7, can be used as an edge point.
[0153] It can be understood that the smaller the second distance is, the closer the feature vector is to the adjacent cluster set, that is, the closer it is to the edge of the first cluster set. Therefore, the above method of obtaining edge points by combining the distances between each feature vector and each adjacent cluster set in the first cluster is convenient for obtaining edge points of the first cluster set in the direction pointing to each adjacent cluster set. In this way, when searching in the next node, the representative point closest to the query vector can be determined based on the distance between the edge point and the query vector, and the cluster set corresponding to the representative point can be searched. For query vectors that are far away from the representative points of each cluster set but close to the edge point, the probability of the target vector being found can be increased during the query process, effectively improving the search accuracy.
[0154] It is understood that the above method of obtaining neighboring cluster sets of the first cluster set, i.e., adjacent cluster sets, by sorting the representative points of each cluster set according to the distance between the representative points of the first cluster set is merely illustrative. Alternatively, the embodiment of the present application may also use other methods to obtain neighboring cluster sets of the first cluster set, i.e., adjacent cluster sets.
[0155] Among them, the method for obtaining adjacent cluster sets can also be: cluster sets in the second sequence are formed by cluster sets whose representative points of each cluster set except the first cluster set in the above-mentioned multiple cluster sets are less than the set distance from the representative points of the first cluster set; and then any second preset number of cluster sets in the second sequence are used as adjacent cluster sets, or the distances between the representative points of each cluster set in the second sequence and the representative points of the first cluster set are sorted from near to far, and the first second preset number of cluster sets in the sorting are used as adjacent cluster sets.
[0156] For example, Figure 4 As shown, the method for determining adjacent cluster sets adjacent to cluster set S1 can be: first, obtain the distances between the representative points of cluster sets other than cluster set S1 and the representative point of cluster set S1. For example, the distance between the representative point C2 of cluster set S2 and the representative point C1 of the first cluster set S1 is d5, the distance between the representative point C3 of cluster set S3 and the representative point C1 of the first cluster set S1 is d6, and the distance between the representative point C4 of cluster set S4 and the representative point C1 of the first cluster set S1 is d7. Then, d5, d6, and d7 are compared with the set distance D. If d5 and d7 are less than the set distance D, cluster sets S2 and cluster set S4 form the cluster sets in the second sequence. Then, the distances d5 and d7 between the representative points in cluster sets S2 and cluster set S4 in the second sequence and the representative points of cluster set S1 are sorted from near to far. If d7 is less than d5, the sorting is cluster set S4 - cluster set S2. If the second preset number of adjacent cluster sets is one, cluster set S4 is used as the adjacent cluster set.
[0157] For another example, the method for obtaining adjacent cluster sets can also be: estimating the approximate radius distance of each cluster set except the first cluster set where the representative point of the first cluster set itself is located, obtaining the difference between the distance between the representative point of each cluster set and the representative point of the first cluster set and the approximate radius distance, and according to the difference, sorting each cluster set from near to far to obtain a second sequence, and taking the first second preset number of cluster sets in the second sequence as adjacent cluster sets.
[0158] It can be understood that in some embodiments, the above-mentioned method of estimating the approximate radius distance of each cluster set except the first cluster set where the target feature vector itself is located can be: obtaining the distance between all feature vectors in each cluster set and the representative points in each cluster set, and taking the maximum distance between all feature vectors and the representative points as the approximate radius distance of each cluster set.
[0159] For example, Figure 5bAs shown in the figure, the method for determining adjacent cluster sets adjacent to the cluster set S1 can be as follows: First, determine each cluster set S2, S3, and S4 other than the cluster set S1. Take the maximum distance between each feature vector in the cluster set S2 and the representative point C2 of the cluster set S2 as the approximate radius distance of the cluster set S2. Suppose the maximum distance is the distance r1 between the feature vector Y3 and the representative point C2 of the cluster set S2, then take r1 as the approximate radius distance of the cluster set S2; take the maximum distance between each feature vector in the cluster set S3 and the first center point C3 as the approximate radius distance of the cluster set S2. Suppose the maximum distance is the distance r2 between the feature vector Z1 and the representative point C3 of the cluster set S3, then take r2 as the approximate radius distance of the cluster set S3; take the maximum distance between each feature vector in the cluster set S4 and the first center point C4 as the approximate radius distance of the cluster set S4. Suppose the maximum distance is the distance r3 between the feature vector W5 and the representative point C4 of the cluster set S4, then take r3 as the approximate radius distance r3 of the cluster set S4.
[0160] Then, determine the difference between the distance d5 between the representative point C2 of the cluster set S2 and the representative point C1 of the cluster set S1 and the radius distance r1 of the cluster set S2 as d5 - r1, the difference between the distance d6 between the representative point C3 of the cluster set S3 and the representative point C1 of the cluster set S1 and the radius distance r2 of the cluster set S3 as d6 - r2, and the difference between the distance d7 between the representative point C4 of the cluster set S4 and the representative point C1 of the cluster set S1 and the radius distance r3 of the cluster set S4 as d7 - r3. According to the differences, sort the cluster sets S2, S3, and S4 from near to far to obtain the second sequence. Suppose d7 - r3 < d5 - r1 < d6 - r2, then the second sequence is the cluster set S4 - the cluster set S2 - the cluster set S3. Take the first second preset number of cluster sets in the second sequence as the adjacent cluster sets. Suppose take the first 1 number of cluster sets in the second sequence as the adjacent cluster sets, then the adjacent cluster set is the cluster set S4.
[0161] In some embodiments, the method for estimating the approximate radius of each cluster set can also be any other implementable method, such as estimating through a neural network model or related algorithms.
[0162] It can be understood that the difference between the distance between the representative point of any cluster set and the representative point of the first cluster set and the approximate radius can approximately represent the distance between the marginal feature vector in this cluster set and the representative point of the first cluster set. When the distance between the marginal feature vector and the representative point of the first cluster set is relatively close, it is possible that the cluster set where this marginal feature vector is located is the adjacent set of the first cluster set.
[0163] In a fourth feasible solution, the method for determining at least one edge point that meets the preset conditions can be: determining at least one adjacent cluster set adjacent to the first cluster set in cluster sets other than the first cluster set; obtaining a first distance between each feature vector in the first cluster set and a representative point of the first cluster set, as well as a second distance between each feature vector in the first cluster set and a representative point of each adjacent cluster set, and taking the sum of the first and second distances; sorting each feature vector from far to near according to the sum of the distances, to obtain the first sequence corresponding to each adjacent cluster set; and using the first set number of feature vectors in the first sequence as edge points. It can be understood that the method for obtaining at least one adjacent cluster set adjacent to the first cluster set in the fourth solution is the same as the method for obtaining adjacent cluster sets described in the third solution, and will not be repeated here.
[0164] It can be understood that the first sequence is obtained by sorting the sum of the first distance and the second distance from large to small. The feature vector with the largest distance sum in the obtained first sequence is the feature vector that is farther from the representative point of the first cluster set and also farther from the representative point of the adjacent cluster set. In other words, this feature vector may be located at an edge point in the opposite direction from the representative point of the representative point to the edge point. Once the first sequence corresponding to the adjacent cluster sets in each direction of the first cluster set is obtained, the edge points in each direction of the first cluster set can be obtained. In this way, using the edge points in each direction of the first cluster set as edge points can effectively improve search accuracy.
[0165] Get the following Figure 3a Taking at least one edge point of the first cluster set S1 as an example, the method of obtaining edge points in the fourth implementation scheme in the embodiment of the present application is described:
[0166] like Figure 5c As shown in , it is assumed that the adjacent cluster sets adjacent to the first cluster set S1 are the aforementioned Figure 4 According to the adjacent adjacent cluster set S2 of the first cluster set S1 determined above, the sum of the first distance between each feature vector in the first cluster set S1 and the representative point C1 of the first cluster set S1 and the second distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained.
[0167] For example, Figure 5cAs shown in the figure, the sum of the first distance d1_1 between the feature vector X1 in the first cluster set S1 and the representative point C1 and the second distance d2_1 to the representative point C2 is d_s2. The way to obtain the sum of distances for the other 14 feature vectors is the same and will not be repeated here. Assuming that the first sequence corresponding to the cluster set S2 obtained by sorting the 15 feature vectors in the first cluster set S1 from far to near according to the sum of distances is X2-X3-X1-......-X14, and assuming that the second preset number of edge points of the corresponding cluster set obtained according to each neighboring set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X2, can be used as an edge point.
[0168] At the same time, according to the adjacent adjacent cluster set S4 of the first cluster set S1 determined above, the sum of the first distance between each feature vector in the first cluster set S1 and the representative point C1 of the first cluster set S1 and the second distance between each feature vector and the representative point C4 of the adjacent cluster set S4 is obtained, for example, Figure 4 In the figure, the sum of the distances d_s4 between the eigenvector X1 in the first cluster set S1 and the first distance d1_1 representing the point C1 and the second distance d4_1 representing the point C4 is obtained. The other 14 eigenvectors obtain the sum of the distances in the same way and will not be repeated here. Assuming that the first sequence obtained by sorting the 15 eigenvectors in the first cluster set S1 from far to near according to the sum of the distances is X4-X1-X3-......-X15, and assuming that the number of preset edge points of the corresponding cluster set obtained according to each neighboring set is one, the first eigenvector in the first sequence corresponding to the fourth cluster set S4, that is, the eigenvector X4, can be used as an edge point.
[0169] In a fifth feasible solution, determining a second preset number of edge points from the first cluster set can be accomplished by: determining at least one adjacent cluster set adjacent to the first cluster set from cluster sets other than the first cluster set; obtaining a first distance between each feature vector in the first cluster set and a representative point of the first cluster set, and a second distance between each feature vector in the first cluster set and a representative point of each adjacent cluster set. Based on the ratio of the difference between the second distance and the first distance and the first distance, the feature vectors in the first cluster set are sorted in ascending order according to the ratio, obtaining a first sequence corresponding to each adjacent cluster set; and the first second preset number of feature vectors in the first sequence are used as edge points. It is understood that the method for obtaining at least one adjacent cluster set adjacent to the cluster set in the fifth solution is the same as the method for obtaining adjacent cluster sets described in the third solution and will not be further elaborated here.
[0170] It can be understood that when the second distance between the feature vector and the representative point of the adjacent cluster set is smaller, and the first distance between the feature vector and the representative point of the first cluster set is larger, it proves that the feature vector is farther away from the representative point of the first cluster set, that is, the ratio of the difference between the second distance and the first distance to the first distance is smaller. Therefore, by sorting the feature vectors from small to large according to the ratio of the difference between the second distance and the first distance to the first distance, more accurate edge points of the first cluster set can be obtained.
[0171] For example, to get Figure 3a Taking the second preset number of edge points of the cluster set S1 as an example, the method of obtaining edge points in the fifth implementation scheme in the embodiment of the present application is described:
[0172] Assume that the adjacent cluster sets of cluster set S1 are the aforementioned Figure 4 According to the adjacent cluster set S2 of the cluster set S1 determined above, the sum of the first distance between each feature vector in the cluster set S1 and the representative point C1 of the cluster set S1 and the second distance between each feature vector in the cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained.
[0173] For example, Figure 5d As shown in , the ratio of the second distance d2_1 between the feature vector X1 in the cluster set S1 and the representative point C2 and the first distance d1_1 to the representative point C1 is d_b2. The other 14 feature vectors obtain the distance ratio in the same way and will not be repeated here. Assuming that the first sequence corresponding to the cluster set S2 obtained by sorting the 15 feature vectors in the cluster set S1 from small to large according to the ratio is X8-X3-X1-......-X14, and assuming that the preset number of adjacent representative points of the corresponding cluster set obtained according to each adjacent set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X8, can be used as an edge point.
[0174] At the same time, according to the adjacent adjacent cluster set S4 of the cluster set S1 determined above, the second distance d4_1 between the feature vector X1 in the cluster set S1 and the representative point C4 and the ratio of the distance difference between the first distance d1_1 and the representative point C1 to the first distance d1_1 are obtained as d_b4. The ratios of the other 15 feature vectors are obtained in the same way, for example, Figure 5dIn the figure, the ratio of the distance difference between the eigenvector X1 in the cluster set S1 and the second distance d4_1 of the representative point C4 and the first distance d1_1 of the representative point C1 to the first distance d1_1 is d_b4. The ratios of the other 14 eigenvectors are obtained in the same way and will not be repeated here. Assuming that the first sequence obtained by sorting the 15 eigenvectors in the cluster set S1 from small to large according to the ratio is X9-X1-X3-......-X15, and assuming that the number of preset second representative points of the corresponding cluster set obtained according to each neighboring set is one, the first eigenvector in the first sequence corresponding to the cluster set S4, that is, the eigenvector X9, can be used as an edge point.
[0175] Based on the index construction method of the present application, during a query, the distance between the query vector and the representative point (center point) of the cluster set within each node can be obtained, as well as the distance between the query vector and the representative point of each node, and the target vector corresponding to the query vector within each node can be obtained. The target vectors corresponding to the query vector within each node can then be aggregated and compared to search for a target vector that is closer to the query vector or more accurate, effectively improving search accuracy.
[0176] Furthermore, when building the index, the second and subsequent nodes are clustered using the edge points of the previous node as the representative points of the current node. This allows the distance between edge points farther from the center and the query vector to be considered, avoiding the problem in existing techniques where the target vector is an edge point, while the existing techniques only consider the distance to the center point, resulting in a failure to find a more accurate target vector.
[0177] Based on the index construction method of the present application, the same feature vector corresponds to different cluster sets and representative points of the cluster sets in different nodes, and the edge points of each cluster set in the first node are used as the representative points of the second node. In this way, the probability of the target vector being searched can be increased during the search process, thereby improving the accuracy of the search.
[0178] Corresponding to the above vector index construction method, when searching for such a vector, the retrieval system can first obtain the query vector; obtain the third distance between the representative point of each cluster set in each node and the query vector; determine the target representative point in each node based on the third distance, and determine the fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector; determine the first target vector corresponding to the query vector in each node based on the fourth distance; and determine the second target vector corresponding to the query vector, that is, the finally determined target vector, from the first target vector corresponding to the query vector in each node according to the fourth distance.
[0179] For example, based on the above construction Figure 3d In the index structure shown, the retrieval system can first obtain the query vector A and distribute the query vector A to the first node, the second node, and the third node. Then, the third distance between the representative point of each first cluster set in the first node and the query vector A, the third distance between the representative point of each second cluster set in the second node and the query vector A, and the third distance between the representative point of each third cluster set in the third node and the query vector A are determined respectively. For example Figure 6a It shows that the third distances between the query vector A and the representative point C1 of cluster set S1, the representative point C2 of cluster set S2, the representative point C3 of cluster set S3 and the representative point C4 of cluster set S4 in the first node are da1, da2, da3 and da4 respectively. Figure 6b It shows that the third distances between the query vector A and the representative point C1' of cluster set S1', the representative point C2' of cluster set S2', the representative point C3' of cluster set S3' and the representative point C4' of cluster set S4' in the second node are dm1, dm2, dm3 and dm4 respectively. Figure 6c It shows that the third distances between the query vector A and the representative point C" of the cluster set S1", the representative point C2" of the cluster set S2", and the representative point C3" of the cluster set S3" in the third node are dk1, dk2 and dk3 respectively.
[0180] According to the third distance between the query vector A in the three nodes and each representative point in each cluster set, the target representative point in each node is determined. In some implementations, each representative point in each node is deduplicated and sorted according to the third distance to the target vector, and the first preset number of representative points closest to each node are selected as the target representative points. For example, the closest representative point is selected in each node as the target representative point of each node. Assuming that the representative point closest to the query vector A in the first node is C1, the representative point closest to the query vector A in the second node is C1', and the representative point closest to the query vector A in the third node is C2', then the representative point C1 closest to the query vector A in the first node, the representative point C1' closest to the query vector A in the second node, and the representative point C2' closest to the query vector A in the third node are used as the target representative points corresponding to each node.
[0181] According to Figure 3d The index association shown obtains the fourth distance between each feature vector and the query vector in the cluster set S1 where the representative point C1 in the first node is located, the cluster set S1' where the representative point C1' in the second node is located, and the cluster set S2" where the representative point C2" in the third node is located.
[0182] In some embodiments, the eigenvectors whose fourth distance from the query vector A satisfies being less than a set value can be used as the first target vectors. For example, the eigenvectors within a set range of the distance from the query vector A in the clustering set S1 of the first node, the clustering set S1' of the second node, and the clustering set S2'' of the third node are used as the target vectors corresponding to the query vector A in each node. As Figure 7a shown, assume that the eigenvectors within the set range of the distance from the query vector A in the clustering set S1 of the first node are eigenvector X1 and eigenvector X2, and the corresponding fourth distances are dn1 and dn2 respectively. As Figure 7b shown, the eigenvectors within the set range of the distance from the query vector A in the clustering set S1' of the second node are eigenvector X1', eigenvector X2', eigenvector X3', and the corresponding fourth distances are dt1, dt2, dt3 respectively. As Figure 7c shown, the eigenvectors within the set range of the distance from the query vector A in the clustering set S2'' of the third node are eigenvector Y1' and eigenvector Y2', and the corresponding fourth distances are dw1 and dw2 respectively. Then the eigenvectors X1 and X2 corresponding to the first node, the eigenvectors X1', X2', X3' corresponding to the second node, and the eigenvectors Y1' and Y2' corresponding to the third node are the first target vectors corresponding to the query vector. According to the fourth distances between the obtained first target vectors and the query vector A, the top pre-set number of second target vectors closest to the query vector A can be determined among the obtained first target vectors. For example, the pre-set number of second target vectors is two. Assume dw1 < dn1 < dn2 < dt1 < dt2 < dt3 < dw2, then according to the fourth distances, Y1'' in the third node and X1 in the first node are determined as the second target vectors.
[0183] It can be understood that the second target vectors are the target vectors corresponding to the final query vector.
[0184] It can be understood that when there are identical eigenvectors among the first target vectors, one of them is discarded.
[0185] The vector search method provided in this application distributes the query vector to each node, can obtain the distances between the query vector and the representative points (i.e., the center points) of the clustering sets within each node, and can also obtain the distances between the query vector and the representative points of each node, and obtain the target vectors corresponding to the query vector within each node. Then the target vectors corresponding to the query vector within each node can be aggregated and compared to achieve searching for a target vector closer to or more accurate to the query vector, which can effectively improve the search accuracy.
[0186] It can be understood that the application of the index construction method to the index construction in the above-mentioned image database in the embodiment of the present application is only an example. The index construction method provided in the embodiment of the present application can be applied to various video, voice, protein molecular structure and other databases, that is, the index construction method provided in the embodiment of the present application can be widely used in image, video, voice, protein molecular structure retrieval and other fields.
[0187] It is understood that the retrieval system mentioned in the embodiments of the present application may include at least one database, for example, the aforementioned image database, as well as a video database, a document database, etc. The image database includes feature vectors corresponding to multiple original image data, the video database includes feature vectors corresponding to multiple original video data, and the document database includes feature vectors corresponding to multiple original document data. It is practicable that each database may construct an index using the aforementioned index construction method.
[0188] The index construction method provided in the embodiment of the present application is described in detail below. It is understood that the index construction method provided in the embodiment of the present application can be executed by the retrieval system or by other electronic devices, that is, the other electronic devices will construct indexes for each database and then deploy the constructed indexes of each database to the retrieval system.
[0189] The index construction method provided by the embodiment of the present application is described in detail below by taking the index construction method executed by the retrieval system as an example. In particular, there are three nodes in the system, and the order of the nodes is the first node, the second node, and the third node. Figure 8 A flow chart of an index construction method according to an embodiment of the present application is shown.
[0190] like Figure 8 As shown, the index construction method in the embodiment of the present application may include:
[0191] 801: Acquire each feature vector corresponding to each data in the database to be indexed in each node.
[0192] It is understood that the database may include one or more data structures such as images, videos, audio, and protein molecular structures. Since all types of data can be converted into high-dimensional feature vectors, the retrieval system may first convert each raw data in the database into a corresponding feature vector. It is understood that each raw data in the database may also be retained and stored in the database.
[0193] For example, the retrieval system may first obtain Figure 1a The database S shown is converted into feature vectors by image data in the same image database.
[0194] 802: The obtained feature vectors are redundantly (repeatedly) placed in a preset number of nodes.
[0195] It can be understood that the preset number of nodes may be greater than or equal to two nodes.
[0196] For example, the obtained Figure 1a The feature vectors converted from the image data in the database S shown are redundantly (repeatedly) placed in three nodes, for example, Figure 2 In the first node, the second node and the third node shown in FIG, it can be understood that the eigenvectors in these three nodes are the same.
[0197] 803: Preset representative points in the first node, and perform clustering processing on the feature vectors in the first node based on the preset representative points to obtain a corresponding number of cluster sets, wherein each cluster set has a corresponding representative point.
[0198] A corresponding number of representative points are pre-set for the first node, and the pre-set representative points are used to perform clustering processing on the feature vectors in the node to obtain multiple cluster sets and representative points corresponding to each cluster set.
[0199] It is understood that in some embodiments, after clustering the feature vectors within the nodes according to the preset representative points of any node to obtain the corresponding cluster sets, the representative points of each cluster set can be recalculated. For example, the arithmetic mean of each feature vector in each cluster set is used as the representative point of the cluster set. It is understood that the recalculated representative points of each cluster set are generally inconsistent with the initially preset representative points. However, for the convenience of description in the embodiments of the present application, the technical solutions in the embodiments of the present application are introduced by taking the preset representative points as an example to approximately replace the representative points after clustering.
[0200] In some implementations, the feature vectors in the first node are clustered based on pre-set representative points, and each feature vector is assigned to a corresponding cluster set, each cluster set having a corresponding representative point. It is understood that the clustering method for each feature vector can be a k-means clustering method, an agglomerative algorithm, or the like.
[0201] For example, the clustering of the first node is described by taking the k-means clustering method and the first preset number being 4 as an example. Figure 2As shown, in the first node, four preset representative points are pre-set for the image database S. It can be understood that the preset representative points of the first node can be randomly generated and can be implemented as multiple points with the greatest possible distance. Then, according to the distance between each feature vector in the first node and the preset representative point of each cluster set, each feature vector is assigned to the cluster set corresponding to the nearest preset representative point, and the representative point corresponding to each cluster set is re-determined to obtain the following: Figure 3a The multiple cluster sets S1, S2, S3, S4 and the representative points C1, C2, C3, C4 corresponding to each cluster set are shown. It is understandable that the preset representative points corresponding to each cluster set in the first node can be used as the representative points corresponding to the cluster set, or the arithmetic mean vector of all feature vectors in the cluster set can be determined as the representative point of the cluster set, or the representative point of the cluster set can be determined in other ways. It is understandable that the distance mentioned in the embodiments of the present application can be Euclidean distance, or other distances such as inner product distance.
[0202] It is understood that the clustering method for performing clustering processing on the eigenvectors in the first node may also be other clustering methods. It is understood that the clustering method may also be agglomerative clustering method or other clustering methods.
[0203] 804: Obtain a first preset number of edge points from each cluster set of the first node as preset representative points of each cluster set of the second node, cluster the feature vectors within the second node based on the preset representative points of each cluster set of the second node, and obtain a corresponding first preset number of cluster sets, each cluster set having a corresponding representative point.
[0204] It is understood that the representative points corresponding to each cluster set obtained after clustering processing in the second node may be the same as or different from the preset representative points, that is, the edge vectors of the first node. The representative points corresponding to each cluster set obtained after clustering processing may be different from the preset representative points and may be the average vector corresponding to all feature vectors in each cluster set, or the representative points in the cluster set may be determined in other ways.
[0205] It can be understood that the clustering method for the feature vectors at the second node and other nodes can adopt the k-means clustering method, Agglomerative algorithm, etc. mentioned above.
[0206] It is understood that after the total number of cluster sets of the second node is determined, that is, after the first preset number is determined, the second preset number of edge points to be determined in each cluster set of the first node can be determined according to the following method:
[0207] In a first practicable solution, a method for determining a second preset number of edge points for each cluster set in a first node is as follows: based on the first preset number and the radius of each cluster set in the first node, the second preset number of edge points for each cluster set is determined according to a ratio between the first preset number and the radius of each cluster set; it is understood that in some embodiments, when the calculated preset number of edge points for any cluster set is not an integer, a final preset number can be obtained according to a rounding rule. For example, the rounding rule can be to add 1 to the integer digit of the value corresponding to the current number and discard the decimal part to obtain the value obtained as the final value corresponding to the preset number.
[0208] For example, the first preset number is 4, that is, the total preset number of edge points is 4. Figure 3a In the cluster set corresponding to the first node shown, assuming that the radius of cluster set S1 is 16, the radius of cluster set S2 is 14, the radius of cluster set S3 is 10, and the radius of cluster set S4 is 17, the ratio of the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 16:14:10:17; based on the preset total number of edge points and the above-mentioned ratio of the number of edge points of 16:14:10:17, it can be determined that the number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 1.1, 0.9, 0.7, and 1.7. According to the above rounding rule, it can be concluded that the second preset number of edge points to be determined in cluster set S1, cluster set S2, cluster set S3, and cluster set S4 is 2, 1, 1, and 2, respectively.
[0209] It can be understood that in the embodiment of the present application, by using a preset number of edge points in each node as the preset representative points of the next node, the clustering of each node can be made as different as possible, thereby effectively improving the search accuracy.
[0210] Secondly, the above method of determining the preset number of edge points of each cluster set based on the first preset number and the ratio of the radius of each cluster set can make the distribution of edge points more uniform, avoiding the situation where some cluster sets have a very small radius but a large number of edge points are determined.
[0211] In the second feasible scheme, the method for determining the second preset number of edge points of each cluster set in the first node is: according to the first preset number, sort the cluster sets in the first node from large to small according to the radius, and select a set number of edge points from each cluster set until the preset first number is selected.
[0212] For example, the first preset number is 4, that is, the total preset number of edge points is 4. Figure 3aIn the cluster set corresponding to the first node shown, assuming that the radius of cluster set S1 is 16, the radius of cluster set S2 is 14, the radius of cluster set S3 is 10, and the radius of cluster set S4 is 17, the order of the radius of each cluster set is cluster set S4-cluster set S1-cluster set S2-cluster set S3; when the set number of edge points selected in each cluster set is 2, according to the order of cluster set S4-cluster set S1-cluster set S2-cluster set S3, the second preset number of edge points that need to be determined in cluster set S4 and cluster set S1 is two. Because the preset total number of edge points has been reached at this time. Subsequent cluster sets S2 and cluster set S3 will no longer select edge points, that is, the number of cluster sets S2 and cluster set S3 arranged after cluster set S1 is 0.
[0213] It can be understood that the above method of sorting according to the number of feature vectors or radius in each cluster set from large to small according to the first preset number, and selecting a set number of edge points from each cluster set can determine a smaller number of edge points in smaller cluster sets, and determine more edge points in other larger cluster sets, so that the determined edge points can fully represent the corresponding cluster sets, effectively improving the search accuracy.
[0214] It can be understood that the above-mentioned method can be used to determine the second preset number of edge points required for each cluster set in other nodes.
[0215] After determining the second preset number of edge points required for each node, for example, each cluster set within the first node, based on the above method, it is necessary to determine the corresponding second preset number of edge points within the corresponding cluster set. The following describes the method for determining the second preset number of edge points in any cluster set provided in the embodiment of the present application, taking the method for determining the second preset number of edge points in the first cluster set within the first node as an example:
[0216] In the first feasible scheme, the method for determining the second preset number of edge points from the first cluster set can be: obtaining the first distance between the representative point of the first cluster set and all the feature vectors in the first cluster set; sorting the feature vectors from far to near according to the first distance to obtain the first sequence corresponding to the first cluster set; and determining the first second preset number of feature vectors in the first sequence as edge points in the cluster set.
[0217] It can be understood that in the embodiment of the present application, edge points can be determined based on the distance between each feature vector in the first cluster set and the representative point, so that feature vectors farther away from the representative point can be used as edge points, making the selection of edge points more accurate.
[0218] In the embodiment of the present application, the eigenvectors in the first cluster set are sorted from farthest to closest based on the distance between each eigenvector and the representative point, that is, based on how close each eigenvector is to the representative point. This makes it easier to select corresponding edge points based on a set number of edge points. For example, if the set number of edge points is five, the first five eigenvectors in the sorted first sequence can be directly used as edge points.
[0219] In a second feasible scheme, the method for determining a second preset number of edge points from the first cluster set can be: obtaining a first distance between a representative point of the first cluster set and all feature vectors in the first cluster set; taking feature vectors whose first distance is greater than the set distance as feature vectors in a first sequence, and then taking a second preset number of feature vectors in the first sequence as edge points, or sorting each feature vector in the first sequence from far to near according to the first distance, and taking the first second preset number of feature vectors in the sorting as edge points.
[0220] It is understood that in the embodiments of the present application, the first sequence can be obtained based on feature vectors in the first cluster set whose distance from the representative point is greater than a set distance. That is, the feature vectors in the first sequence are vectors that are farther from the representative point and greater than the set distance. This can make the method for selecting adjacent cluster sets more standardized and simple. For example, edge points can be obtained by simply setting a corresponding distance threshold parameter in the algorithm for selecting edge points.
[0221] In a third feasible scheme, the method for determining a second preset number of edge points from the first cluster set can be: determining at least one adjacent cluster set adjacent to the first cluster set in cluster sets other than the first cluster set; obtaining the distance between each feature vector in the first cluster set and the representative point of each adjacent cluster set; sorting the feature vectors from near to far according to the distance, and obtaining a first sequence corresponding to each adjacent cluster set; and taking the first set number of feature vectors in the first sequence as edge points.
[0222] Among them, the method for obtaining at least one adjacent cluster set adjacent to the first cluster set can be: sorting each cluster set in the above-mentioned multiple cluster sets except the first cluster set from near to far according to the distance between the representative point of each cluster set and the representative point of the first cluster set, and obtaining the second sequence corresponding to the first cluster set; and taking the first second preset number of cluster sets in the second sequence as the adjacent cluster sets adjacent to the first cluster set.
[0223] The following is the aforementioned Figure 3a Taking the first cluster set S1 in as an example, the method of obtaining the edge points in the first cluster set S1 is introduced:
[0224] First, at least one adjacent cluster set of the first cluster set S1 can be obtained. The method of obtaining at least one adjacent cluster set of the first cluster set S1 can be: obtaining the distance between the representative points of the other three cluster sets except the cluster set S1 and the representative point C1 of the first cluster set S1. For example, Figure 4 As shown, the distance between the representative point C2 of cluster set S2 and the representative point C1 of the first cluster set S1 is d5, the distance between the representative point C3 of cluster set S3 and the representative point C1 of the first cluster set S1 is d6, and the distance between the representative point C4 of cluster set S4 and the representative point C1 of the first cluster set S1 is d7. Then, according to the distance between the representative points of each of the three cluster sets and the representative point C1 of the first cluster set S1, the three cluster sets are sorted from near to far to obtain the second sequence corresponding to the representative point C1. Assuming that d7 < d5 < d6, the second sequence corresponding to the representative point C1 is cluster set S4 - cluster set S2 - cluster set S3. At this time, the representative point C1 is indexed and associated with the first second preset number of cluster sets in the second sequence. Assuming that the second preset number is 2, cluster set S2 and cluster set S4 can be regarded as adjacent cluster sets adjacent to the first cluster set S1.
[0225] Then, the distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2, and the distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S4 are obtained. Figure 5a As shown in , for the feature vector X1, the distance d2_1 between the feature vector X1 in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained, and the distances between other feature vectors and the representative point C2 are not repeated here; according to the distance between each feature vector and the representative point C2, each feature vector is sorted from near to far. Assuming that the first sequence obtained by sorting the 15 feature vectors in the first cluster set S1 from far to near according to the distance is X1-X3-X5-......-X15. Assuming that the preset second preset number of edge points of the corresponding cluster set obtained according to each neighboring set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X1, can be used as an edge point. At the same time, the distance between each feature vector in the first cluster set S1 and the representative point C4 of the adjacent cluster set S4 is obtained, as shown Figure 3aAs shown in , for feature vector X1, the distance d4_1 between feature vector X1 in the first cluster set S1 and the representative point C4 of the adjacent cluster set S4 is obtained. The distances between other feature vectors and the representative point C4 are not repeated here. According to the distance between each feature vector and the representative point C4, each feature vector is sorted from near to far. Assuming that the first sequence obtained by sorting the 15 feature vectors in the first cluster set S1 from near to far according to the distance is X7-X8-X1-...-X14. Assuming that the second preset number of edge points of the corresponding cluster set obtained according to each adjacent set is one, the first feature vector in the first sequence corresponding to the fourth cluster set S4, that is, feature vector X7, can be used as an edge point.
[0226] It can be understood that the smaller the second distance is, the closer the feature vector is to the adjacent cluster set, that is, the closer it is to the edge of the first cluster set. Therefore, the above method of obtaining edge points by combining the distances between each feature vector and each adjacent cluster set in the first cluster is convenient for obtaining the edge points of the first cluster set in the direction close to each adjacent cluster set, and taking the edge points of the first cluster set in the direction close to each adjacent cluster set as edge points, so that when searching, the representative point closest to the query vector can be determined based on the distance between the edge point and the representative point and the query vector, and the cluster set corresponding to the representative point is searched. For query vectors that are far away from the representative points of each cluster set but close to the edge point, the probability of the target vector being found can be increased during the query process, effectively improving the search accuracy.
[0227] It is understood that the above method of obtaining neighboring cluster sets of the first cluster set, i.e., adjacent cluster sets, by sorting the representative points of each cluster set according to the distance between the representative points of the first cluster set is merely illustrative. Alternatively, the embodiment of the present application may also use other methods to obtain neighboring cluster sets of the first cluster set, i.e., adjacent cluster sets.
[0228] Among them, the method for obtaining adjacent cluster sets can also be: cluster sets in the second sequence are formed by cluster sets whose representative points of each cluster set except the first cluster set in the above-mentioned multiple cluster sets are less than the set distance from the representative points of the first cluster set; and then any second preset number of cluster sets in the second sequence are used as adjacent cluster sets, or the distances between the representative points of each cluster set in the second sequence and the representative points of the first cluster set are sorted from near to far, and the first second preset number of cluster sets in the sorting are used as adjacent cluster sets.
[0229] For example, Figure 4As shown, the method for determining adjacent cluster sets adjacent to cluster set S1 can be: first, obtain the distances between the representative points of cluster sets other than cluster set S1 and the representative point of cluster set S1. For example, the distance between the representative point C2 of cluster set S2 and the representative point C1 of the first cluster set S1 is d5, the distance between the representative point C3 of cluster set S3 and the representative point C1 of the first cluster set S1 is d6, and the distance between the representative point C4 of cluster set S4 and the representative point C1 of the first cluster set S1 is d7. Then, d5, d6, and d7 are compared with the set distance D. If d5 and d7 are less than the set distance D, cluster sets S2 and cluster set S4 form the cluster sets in the second sequence. Then, the distances d5 and d7 between the representative points in cluster sets S2 and cluster set S4 in the second sequence and the representative points of cluster set S1 are sorted from near to far. If d7 is less than d5, the sorting is cluster set S4 - cluster set S2. If the second preset number of adjacent cluster sets is one, cluster set S4 is used as the adjacent cluster set.
[0230] For another example, the method for obtaining adjacent cluster sets can also be: estimating the approximate radius distance of each cluster set except the first cluster set where the representative point of the first cluster set itself is located, obtaining the difference between the distance between the representative point of each cluster set and the representative point of the first cluster set and the approximate radius distance, and according to the difference, sorting each cluster set from near to far to obtain a second sequence, and taking the first second preset number of cluster sets in the second sequence as adjacent cluster sets.
[0231] It can be understood that in some embodiments, the above-mentioned method of estimating the approximate radius distance of each cluster set except the first cluster set where the target feature vector itself is located can be: obtaining the distance between all feature vectors in each cluster set and the representative points in each cluster set, and taking the maximum distance between all feature vectors and the representative points as the approximate radius distance of each cluster set.
[0232] For example, Figure 5bAs shown in [figure], the method for determining adjacent cluster sets adjacent to the cluster set S1 can be as follows: First, determine each cluster set S2, S3, and S4 other than the cluster set S1. Take the maximum distance between each feature vector in the cluster set S2 and the representative point C2 of the cluster set S2 as the approximate radius distance of the cluster set S2. Assume that the maximum distance is the distance r1 between the feature vector Y3 and the representative point C2 of the cluster set S2, then take r1 as the approximate radius distance of the cluster set S2; take the maximum distance between each feature vector in the cluster set S3 and the first center point C3 as the approximate radius distance of the cluster set S2. Assume that the maximum distance is the distance r2 between the feature vector Z1 and the representative point C3 of the cluster set S3, then take r2 as the approximate radius distance of the cluster set S3; take the maximum distance between each feature vector in the cluster set S4 and the first center point C4 as the approximate radius distance of the cluster set S4. Assume that the maximum distance is the distance r3 between the feature vector W5 and the representative point C4 of the cluster set S4, then take r3 as the approximate radius distance r3 of the cluster set S4.
[0233] Then, determine the difference between the distance d5 between the representative point C2 of the cluster set S2 and the representative point C1 of the cluster set S1 and the radius distance r1 of the cluster set S2 as d5-r1, the difference between the distance d6 between the representative point C3 of the cluster set S3 and the representative point C1 of the cluster set S1 and the radius distance r2 of the cluster set S3 as d6-r2, and the difference between the distance d7 between the representative point C4 of the cluster set S4 and the representative point C1 of the cluster set S1 and the radius distance r3 of the cluster set S4 as d7-r3. According to the differences, sort the cluster sets S2, S3, and S4 from near to far to obtain the second sequence. Assume that d7-r3 < d5-r1 < d6-r2, then the second sequence is the cluster set S4 - the cluster set S2 - the cluster set S3. Take the first second preset number of cluster sets in the second sequence as the adjacent cluster sets. Assume that take the first 1 number of cluster sets in the second sequence as the adjacent cluster sets, then the adjacent cluster set is the cluster set S4.
[0234] In some embodiments, the method for estimating the approximate radius of each cluster set can also be any other implementable method, such as estimating through a neural network model or a related algorithm, etc.
[0235] It can be understood that the difference between the distance between the representative point of any cluster set and the representative point of the first cluster set and the approximate radius can approximately represent the distance between the marginal feature vector in this cluster set and the representative point of the first cluster set. When the distance between the marginal feature vector and the representative point of the first cluster set is relatively close, it is possible that the cluster set where this marginal feature vector is located is the adjacent set of the first cluster set.
[0236] In a fourth feasible solution, the method for determining at least one edge point that meets the preset conditions can be: determining at least one adjacent cluster set adjacent to the first cluster set in cluster sets other than the first cluster set; obtaining a first distance between each feature vector in the first cluster set and a representative point of the first cluster set, as well as a second distance between each feature vector in the first cluster set and a representative point of each adjacent cluster set, and taking the sum of the first and second distances; sorting each feature vector from far to near according to the sum of the distances, to obtain the first sequence corresponding to each adjacent cluster set; and using the first set number of feature vectors in the first sequence as edge points. It can be understood that the method for obtaining at least one adjacent cluster set adjacent to the first cluster set in the fourth solution is the same as the method for obtaining adjacent cluster sets described in the third solution, and will not be repeated here.
[0237] It can be understood that the first sequence is obtained by sorting the sum of the first distance and the second distance from large to small. The feature vector with the largest distance sum in the obtained first sequence is the feature vector that is farther from the representative point of the first cluster set and also farther from the representative point of the adjacent cluster set. In other words, this feature vector may be located at an edge point in the opposite direction from the representative point of the representative point to the edge point. Once the first sequence corresponding to the adjacent cluster sets in each direction of the first cluster set is obtained, the edge points in each direction of the first cluster set can be obtained. In this way, using the edge points in each direction of the first cluster set as edge points can effectively improve search accuracy.
[0238] Get the following Figure 3a Taking at least one edge point of the first cluster set S1 as an example, the method of obtaining edge points in the fourth implementation scheme in the embodiment of the present application is described:
[0239] like Figure 5c As shown in , it is assumed that the adjacent cluster sets adjacent to the first cluster set S1 are the aforementioned Figure 4 According to the adjacent adjacent cluster set S2 of the first cluster set S1 determined above, the sum of the first distance between each feature vector in the first cluster set S1 and the representative point C1 of the first cluster set S1 and the second distance between each feature vector in the first cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained.
[0240] For example, Figure 5cAs shown in the figure, the sum of the first distance d1_1 between the feature vector X1 in the first cluster set S1 and the representative point C1 and the second distance d2_1 to the representative point C2 is d_s2. The way to obtain the sum of distances for the other 14 feature vectors is the same and will not be repeated here. Assuming that the first sequence corresponding to the cluster set S2 obtained by sorting the 15 feature vectors in the first cluster set S1 from far to near according to the sum of distances is X2-X3-X1-......-X14, and assuming that the second preset number of edge points of the corresponding cluster set obtained according to each neighboring set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X2, can be used as an edge point.
[0241] At the same time, according to the adjacent adjacent cluster set S4 of the first cluster set S1 determined above, the sum of the first distance between each feature vector in the first cluster set S1 and the representative point C1 of the first cluster set S1 and the second distance between each feature vector and the representative point C4 of the adjacent cluster set S4 is obtained, for example, Figure 4 In the figure, the sum of the distances d_s4 between the eigenvector X1 in the first cluster set S1 and the first distance d1_1 representing the point C1 and the second distance d4_1 representing the point C4 is obtained. The other 14 eigenvectors obtain the sum of the distances in the same way and will not be repeated here. Assuming that the first sequence obtained by sorting the 15 eigenvectors in the first cluster set S1 from far to near according to the sum of the distances is X4-X1-X3-......-X15, and assuming that the number of preset edge points of the corresponding cluster set obtained according to each neighboring set is one, the first eigenvector in the first sequence corresponding to the fourth cluster set S4, that is, the eigenvector X4, can be used as an edge point.
[0242] In a fifth feasible solution, determining a second preset number of edge points from the first cluster set can be accomplished by: determining at least one adjacent cluster set adjacent to the first cluster set from cluster sets other than the first cluster set; obtaining a first distance between each feature vector in the first cluster set and a representative point of the first cluster set, and a second distance between each feature vector in the first cluster set and a representative point of each adjacent cluster set. Based on the ratio of the difference between the second distance and the first distance and the first distance, the feature vectors in the first cluster set are sorted in ascending order according to the ratio, obtaining a first sequence corresponding to each adjacent cluster set; and the first second preset number of feature vectors in the first sequence are used as edge points. It is understood that the method for obtaining at least one adjacent cluster set adjacent to the cluster set in the fifth solution is the same as the method for obtaining adjacent cluster sets described in the third solution and will not be further elaborated here.
[0243] It can be understood that when the second distance between the feature vector and the representative point of the adjacent cluster set is smaller, and the first distance between the feature vector and the representative point of the first cluster set is larger, it proves that the feature vector is farther away from the representative point of the first cluster set, that is, the ratio of the difference between the second distance and the first distance to the first distance is smaller. Therefore, by sorting the feature vectors from small to large according to the ratio of the difference between the second distance and the first distance to the first distance, more accurate edge points of the first cluster set can be obtained.
[0244] For example, to get Figure 3a Taking the second preset number of edge points of the cluster set S1 as an example, the method of obtaining edge points in the fifth implementation scheme in the embodiment of the present application is described:
[0245] Assume that the adjacent cluster sets of cluster set S1 are the aforementioned Figure 4 According to the adjacent cluster set S2 of the cluster set S1 determined above, the sum of the first distance between each feature vector in the cluster set S1 and the representative point C1 of the cluster set S1 and the second distance between each feature vector in the cluster set S1 and the representative point C2 of the adjacent cluster set S2 is obtained.
[0246] For example, Figure 5d As shown in , the ratio of the second distance d2_1 between the feature vector X1 in the cluster set S1 and the representative point C2 and the first distance d1_1 to the representative point C1 is d_b2. The other 14 feature vectors obtain the distance ratio in the same way and will not be repeated here. Assuming that the first sequence corresponding to the cluster set S2 obtained by sorting the 15 feature vectors in the cluster set S1 from small to large according to the ratio is X8-X3-X1-......-X14, and assuming that the preset number of adjacent representative points of the corresponding cluster set obtained according to each adjacent set is one, the first feature vector in the first sequence corresponding to the adjacent cluster set S2, that is, the feature vector X8, can be used as an edge point.
[0247] At the same time, according to the adjacent adjacent cluster set S4 of the cluster set S1 determined above, the second distance d4_1 between the feature vector X1 in the cluster set S1 and the representative point C4 and the ratio of the distance difference between the first distance d1_1 and the representative point C1 to the first distance d1_1 are obtained as d_b4. The ratios of the other 14 feature vectors are obtained in the same way, for example, Figure 5dIn the figure, the ratio of the distance difference between the eigenvector X1 in the cluster set S1 and the second distance d4_1 of the representative point C4 and the first distance d1_1 of the representative point C1 to the first distance d1_1 is d_b4. The ratios of the other 15 eigenvectors are obtained in the same way and will not be repeated here. Assuming that the first sequence obtained by sorting the 15 eigenvectors in the cluster set S1 from small to large according to the ratio is X9-X1-X3-......-X15, and assuming that the number of preset second representative points of the corresponding cluster set obtained according to each neighboring set is one, the first eigenvector in the first sequence corresponding to the cluster set S4, that is, the eigenvector X9, can be used as an edge point.
[0248] 805: Determine whether all nodes have been clustered.
[0249] In some implementations, if the number of preset nodes is two, that is, all nodes have been clustered, then go to step 806 to determine the cluster set in which each target vector is located in each node; and establish an index association between each target vector and the representative point corresponding to the cluster set in which each target vector is located in each node.
[0250] If the number of preset nodes is not two, that is, there are nodes that have not been clustered, go to step 807, obtain a third preset number of edge points from each cluster set of the second node, as the preset representative points of each cluster set of the third node, cluster the feature vectors in the third node based on the preset representative points of each cluster set of the third node, obtain the third preset number of cluster sets, and establish an index association corresponding to the third node, wherein each cluster set in the third node has a corresponding representative point.
[0251] 806: Establish an index association between each feature vector and a representative point corresponding to each node.
[0252] In some implementations, the target vector can be determined in all nodes, such as the cluster set where the first node and the second node are located; and an index association is established between the target vector and the representative points corresponding to the target vector in all nodes, such as the cluster set where the first node and the second node are located.
[0253] For example, for Figure 3a The first node shown can establish an index association between the target vector and the representative point corresponding to the cluster set where the target vector is located in the first node in the sub-index structure. Figure 9 As shown, the sub-index structure corresponding to the first node includes a representative point item and an inverted file item. The representative point item includes cluster set S1 having a corresponding representative point C1, cluster set S2 having a corresponding representative point C2, cluster set S3 having a corresponding representative point C3, and cluster set S4 having a corresponding representative point C4.
[0254] The corresponding representative point C1 of the cluster set S1 has a corresponding inverted file D1, and the inverted file D1 includes each feature vector in the cluster set S1 corresponding to the corresponding representative point C1.
[0255] The corresponding representative point C2 of the cluster set S2 has a corresponding inverted file D2, and the inverted file D2 includes each feature vector in the cluster set S2 corresponding to the corresponding representative point C2.
[0256] The corresponding representative point C3 of the cluster set S3 has a corresponding inverted file D3, and the inverted file D3 includes each feature vector in the cluster set S3 corresponding to the corresponding representative point C3.
[0257] The corresponding representative point C4 of the cluster set S4 has a corresponding inverted file D4, and the inverted file D4 includes each feature vector in the cluster set S4 corresponding to the corresponding representative point C4.
[0258] Figure 9 It also shows that Figure 3b The sub-index structure corresponding to the second node shown is similar to the sub-index structure of the first node and is not described in detail here.
[0259] 807: Obtain a third preset number of edge points from each cluster set of the second node as preset representative points of each cluster set of the third node, cluster the feature vectors in the third node based on the preset representative points of each cluster set of the third node, and obtain a third preset number of cluster sets, wherein each cluster set in the third node has a corresponding representative point.
[0260] It can be understood that a third preset number of edge points are obtained from each cluster set of the second node as the preset representative points of each cluster set of the third node. The method of obtaining each cluster set of the third node after clustering the feature vectors in the second node based on the preset representative points of each cluster set of the third node is the same as the method of determining each cluster set of the second node in the above step 804. The specific method will not be repeated here.
[0261] For example, according to the method of determining each cluster set of the second node in step 804 above, the following is obtained: Figure 3c The clusters in the third node are combined to form cluster set S1 ″, cluster set S2 ″ and cluster set S3 ″.
[0262] Figure 10 The flowchart of a search method in an embodiment of the present application is shown. The search method can be used in various databases including the above-mentioned index structure, and the search method can be executed by a retrieval system including the above-mentioned database. Figure 10As shown, the search method in the embodiment of the present application may include:
[0263] 1001: Get the query vector.
[0264] It is understood that when a user searches for information, they can enter corresponding query data in the search window or search box of the search system. After obtaining the query data, the search system can convert the query data into a corresponding query vector. It is understood that the query data entered by the user can be in any format.
[0265] For example, the query data input by the user may be in the format of an image. After the retrieval system obtains the image, it may convert the image into a corresponding query vector.
[0266] For example, the query data input by the user may be in text format. After the retrieval system obtains the text, it may convert the text into a corresponding query vector.
[0267] For example, the query data input by the user may be in a video format. After the retrieval system obtains the video, it may convert the video into a corresponding query vector.
[0268] 1002: Obtain the third distance between the first representative point of each cluster set in each node and the query vector.
[0269] For example, based on the above construction Figure 3d For the index association shown, the retrieval system can first obtain a query vector A and distribute the query vector A to the first, second, and third nodes. The retrieval system can then determine the third distances between the query vector A and the representative points of each first cluster in the first node, the third distances between the query vector A and the representative points of each second cluster in the second node, and the third distances between the query vector A and the representative points of each third cluster in the third node.
[0270] For example Figure 6a It shows that the third distances between the query vector A and the representative point C1 of cluster set S1, the representative point C2 of cluster set S2, the representative point C3 of cluster set S3 and the representative point C4 of cluster set S4 in the first node are da1, da2, da3 and da4 respectively. Figure 6b It shows that the third distances between the query vector A and the representative point C1' of cluster set S1', the representative point C2' of cluster set S2', the representative point C3' of cluster set S3' and the representative point C4' of cluster set S4' in the second node are dm1, dm2, dm3 and dm4 respectively. Figure 6cIt shows that the third distances between the query vector A and the representative point C" of the cluster set S1", the representative point C2" of the cluster set S2", and the representative point C3" of the cluster set S3" in the third node are dk1, dk2 and dk3 respectively.
[0271] 1003: Determine a target representative point in each node according to the third distance, and determine a fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector.
[0272] In some implementations, a representative point in each node whose third distance to the query vector is within a set distance may be used as a target representative point.
[0273] In some implementations, each representative point in each node can also be sorted according to the third distance between the node and the query vector, and a preset number of representative points can be used as target representative points before sorting, and the fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector can be determined.
[0274] For example, according to Figures 3a-3c The third distance between the query vector A and each representative point in each cluster set in the three nodes shown is used to determine the target representative point in each node from the query vector, and a representative point with the closest distance is selected in each node as the target representative point of each node. Assuming that the representative point with the closest distance to the query vector A in the first node is C1, the representative point with the closest distance to the query vector A in the second node is C1', and the representative point with the closest distance to the query vector A in the third node is C2', then the representative point C1 with the closest distance to the query vector A in the first node, the representative point C1' with the closest distance to the query vector A in the second node, and the representative point C2' with the closest distance to the query vector A in the third node are the target representative points corresponding to each node. According to Figure 3d The index association shown obtains the fourth distance between each feature vector and the query vector in the cluster set S1 where the representative point C1 in the first node is located, the cluster set S1' where the representative point C1' in the second node is located, and the cluster set S2" where the representative point C2" in the third node is located.
[0275] 1004: Determine a first target vector corresponding to the query vector in each node according to the fourth distance.
[0276] In some embodiments, the feature vectors may be sorted from near to far according to the fourth distance, and the first preset number of feature vectors in the sorting may be used as the first target vector.
[0277] In some embodiments, a feature vector whose fourth distance to the query vector A is less than a set value may be used as the first target vector.
[0278] For example, the feature vectors in the cluster set S1 in the first node, the cluster set S1' in the second node, and the cluster set S2" in the third node obtained in the above step, whose distances from the query vector A are within a set range, are used as the target vectors corresponding to the query vector A in each node.
[0279] like Figure 7a As shown, it is assumed that the feature vectors in the cluster set S1 in the first node that are within the set range with the query vector A are feature vector X1 and feature vector X2, and the corresponding fourth distances are dn1 and dn2 respectively, as shown in FIG. Figure 7b As shown, the feature vectors in the cluster set S1' in the second node that are within the set range with the query vector A are feature vector X1', feature vector X2', feature vector X3' and the corresponding fourth distances are dt1, dt2, dt3 respectively, as shown in FIG. Figure 7c As shown, the feature vectors in the cluster set S2" in the third node that are within the set range with the query vector A are feature vector Y1' and feature vector Y2', and the corresponding fourth distances are dw1 and dw2, respectively. Then the feature vector X1 and feature vector X2 corresponding to the first node, the feature vector X1', feature vector X2', feature vector X3' corresponding to the second node, and the feature vector Y1' and feature vector Y2' corresponding to the third node are the first target vector corresponding to the query vector.
[0280] 1005: Determine, according to the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each node.
[0281] It can be understood that the second target vector is the target vector corresponding to the final query vector.
[0282] In some implementations, the first target vectors corresponding to each node may be sorted from near to far according to the fourth distance, and the first preset number of feature vectors in the sorting may be obtained as the second target vector.
[0283] For example, according to the fourth distance between the first target vector and the query vector A, the first target vectors can be sorted to obtain the first preset number of feature vectors in the sorting as the second target vector
[0284] Assume that Figure 7aThe first target vectors determined therein are the eigenvectors X1 and X2 corresponding to the first node, the eigenvectors X1', X2', and X3' corresponding to the second node, and the eigenvectors Y1' and Y2' corresponding to the third node. And the distances between the above eigenvectors and the query vector are dn1, dn2, dt1, dt2, dt3, dw1, and dw2 respectively. Assuming dw1 < dn1 < dn2 < dt1 < dt2 < dt3 < dw2, the sorting corresponding to the first target vectors is eigenvector Y1' - eigenvector X1 - eigenvector X2, eigenvector X1' - eigenvector X2' - eigenvector X3' - eigenvector Y2'. Assuming the preset number of the second target vectors is two, determine Y1" in the third node and X1 in the first node as the second target vectors.
[0285] It can be understood that in the embodiments of the present application, when the retrieval system obtains the target vectors, it can output the original data corresponding to the target vectors to the client.
[0286] For example, when the database is an image database, the retrieval system can output the original image data corresponding to the target vectors to the client.
[0287] It can be understood that the above search method can be used to search 3 nodes in the retrieval system, or can be used to search multiple nodes in the retrieval system.
[0288] When the retrieval system includes nodes, the retrieval system can perform the above Figure 10 shown search method on the multiple nodes based on the query vector, obtain the corresponding search results, and then output all the search results.
[0289] It can be understood that the format of the input data obtained by the retrieval system and the format of the output data determined by the retrieval system can be the same or different. The output data format is related to the data format included in the searched database. For example, when the data format in the searched database includes text format, image format or video format. Then the output data format has the possibility of text format, image format or video format.
[0290] Figure 11 The schematic diagram of an index construction device according to an embodiment of the present application is shown. As shown in the figure, the index construction device includes:
[0291] The first determination unit is used to determine the target vectors and the first clustering set where the target vectors are located in the current node, where the first clustering set has a first representative point;
[0292] a second determining unit, configured to determine a second cluster set in which the target vector is located within the next node, the second cluster set having a corresponding representative point, the preset representative point corresponding to the second cluster set being an edge point of one of the cluster sets within the first node; wherein the feature vector within the first node is the same as the feature vector within the second node;
[0293] The association unit establishes, in each of the nodes, an index association between the target vector and the first cluster set where the target vector is located.
[0294] Figure 12 A schematic diagram of a search device according to an embodiment of the present application is shown. Figure 12 As shown, the search device includes:
[0295] A first acquisition unit, configured to acquire a query vector;
[0296] A second obtaining unit is used to obtain a third distance between the representative point of each cluster set in each node and the query vector;
[0297] a first determining unit, configured to determine a target representative point in each node according to the third distance, and determine a second distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector;
[0298] a second determining unit, configured to determine, based on the fourth distance, a first target vector corresponding to the query vector in each of the nodes;
[0299] The third determining unit is configured to determine, according to the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each of the nodes.
[0300] like Figure 13 As shown, the embodiment of the present application also includes a retrieval system, including the above-mentioned index construction device, and at least one database and search device.
[0301] Figure 14 A block diagram of an electronic device according to an embodiment of the present application is shown. In one embodiment, the electronic device 1400 may include one or more processors 1404, system control logic 1408 connected to at least one of the processors 1404, system memory 1412 connected to the system control logic 1408, non-volatile memory (NVM) 1416 connected to the system control logic 1408, and a network interface 1420 connected to the system control logic 1408.
[0302] In some embodiments, the processor 1404 may include one or more single-core or multi-core processors. In some embodiments, the processor 1404 may include any combination of general-purpose processors and specialized processors (e.g., graphics processors, application processors, baseband processors, etc.). In embodiments where the electronic device 1400 employs an eNB (Evolved Node B) 101 or a RAN (Radio Access Network) controller 102, the processor 1404 may be configured to execute various embodiments, for example, one or more of the multiple embodiments shown in FIG. 3 or 5 .
[0303] In some embodiments, system control logic 1408 may include any suitable interface controller to provide any suitable interface to at least one of processors 1404 and / or any suitable device or component in communication with system control logic 1408 .
[0304] In some embodiments, the system control logic 1408 may include one or more memory controllers to provide an interface to the system memory 1412. The system memory 1412 may be used to load and store data and / or instructions. In some embodiments, the memory 1412 of the electronic device 1400 may include any suitable volatile memory, such as a suitable dynamic random access memory (DRAM).
[0305] NVM / memory 1416 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, NVM / memory 1416 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of an HDD (Hard Disk Drive), a CD (Compact Disc) drive, and a DVD (Digital Versatile Disc) drive.
[0306] NVM / storage 1416 may include a portion of storage resources on the device on which electronic device 1400 is installed, or it may be accessible to the device but not necessarily part of the device. For example, NVM / storage 1416 may be accessed over a network via network interface 1420.
[0307] In particular, system memory 1412 and NVM / storage 1416 may include, respectively, a temporary copy and a permanent copy of instructions 1424. Instructions 1424 may include instructions that, when executed by at least one of processors 1404, cause electronic device 1400 to implement the method illustrated in FIG. 3 or 5 . In some embodiments, instructions 1424, hardware, firmware, and / or software components thereof may additionally or alternatively reside in system control logic 1408, network interface 1420, and / or processor 1404.
[0308] The network interface 1420 may include a transceiver for providing a radio interface for the electronic device 1400, thereby communicating with any other suitable devices (such as a front-end module, an antenna, etc.) via one or more networks. In some embodiments, the network interface 1420 may be integrated with other components of the electronic device 1400. For example, the network interface 1420 may be integrated with at least one of the processor 1404, the system memory 1412, the NVM / storage 1416, and a firmware device (not shown) having instructions. When at least one of the processors 1404 executes the instructions, the electronic device 1400 implements the method shown in Figures 3 or 5.
[0309] The network interface 1420 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 1420 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.
[0310] In one embodiment, at least one of the processors 1404 may be packaged together with logic for one or more controllers of the system control logic 1408 to form a system-in-package (SiP). In one embodiment, at least one of the processors 1404 may be integrated on the same die with logic for one or more controllers of the system control logic 1408 to form a system-on-chip (SoC).
[0311] Electronic device 1400 may further include an input / output (I / O) device 1432. I / O device 1432 may include a user interface that enables a user to interact with electronic device 1400; peripheral component interfaces may also be designed to enable peripheral components to interact with electronic device 1400. In some embodiments, electronic device 1400 may further include a sensor for determining at least one of environmental conditions and location information related to electronic device 1400.
[0312] In some embodiments, the user interface may include, but is not limited to, a display (e.g., an LCD display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., an LED flash), and a keyboard.
[0313] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0314] In some embodiments, the sensors may include, but are not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit may also be part of or interact with the network interface 1420 to communicate with components of a positioning network (e.g., Global Positioning System (GPS) satellites).
[0315] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0316] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0317] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented in assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0318] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed over a network or through other computer-readable media. Therefore, a machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to floppy disks, optical disks, optical discs, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Therefore, a machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).
[0319] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.
[0320] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems raised by this application. In addition, in order to highlight the innovative part of this application, the above-mentioned device embodiments of this application do not introduce units / modules that are not closely related to solving the technical problems raised by this application. This does not mean that other units / modules do not exist in the above-mentioned device embodiments.
[0321] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.
[0322] While the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the present application.
Claims
1. An index construction method, applied to an electronic system, characterized in that: The electronic system includes a plurality of nodes for vector storage, wherein the feature vectors in the plurality of nodes are the same; The method comprises: Determine the cluster sets of the current node; Determining a first preset number of edge points in each cluster set of the current node as preset representative points of the next node; Based on the preset representative point of the next node, obtaining each cluster set of the next node; Determine a target vector and a first cluster set in each node where the target vector is located, wherein the target vector is a feature vector corresponding to the data in the database; In each of the nodes, an index association is established between the target vector and a representative point of the first cluster set where the target vector is located.
2. The index construction method according to claim 1, characterized in that: in, Determining a first cluster set in each node where the target vector is located includes: Obtain the preset representative points corresponding to each cluster set; Obtaining the distance between the target vector and the preset representative points corresponding to each cluster set in each node; In each cluster set within each node, the cluster set with the shortest distance between the corresponding preset representative point and the target vector is used as the first cluster set where the target vector is located.
3. The index construction method according to claim 2, characterized in that: in, Determining a first preset number of edge points in each cluster set of the current node includes: Determining a second preset number of edge points of each cluster set in the current node according to the first preset number and the number of feature vectors of each cluster set in the current node; The second preset number of corresponding edge points is determined from each cluster set within the current node.
4. The index construction method according to claim 3, characterized in that: in, Determining the second preset number of corresponding edge points from each cluster set within the current node includes: Determine adjacent cluster sets of each cluster set within the current node; For each eigenvector of a corresponding cluster set, obtaining a first distance between the eigenvector and a representative point of the corresponding cluster set, and obtaining a second distance between the eigenvector and a representative point of an adjacent cluster set; A corresponding first sequence is determined according to the first distance and the second distance, and a second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
5. The index construction method according to claim 4, characterized in that: in, Determining a first sequence according to the first distance and the second distance, and using a second preset number of feature vectors in the first sequence as edge points of the corresponding cluster set, includes: Obtaining the sum of the first distance and the second distance; Sort the eigenvectors by the sum of the distances from largest to smallest to obtain the first sequence; The first second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
6. The index construction method according to claim 4, characterized in that: in, Determining a first sequence according to the first distance and the second distance, and using a second preset number of feature vectors in the first sequence as edge points of the corresponding cluster set, includes: Obtaining a ratio of a difference between the second distance and the first distance to the first distance; Sort the eigenvectors in ascending order according to the ratios to obtain the first sequence; The first second preset number of feature vectors in the first sequence are used as edge points of the corresponding cluster set.
7. The index construction method according to claim 3, characterized in that: in, Determining the second preset number of corresponding edge points from each cluster set within the current node includes: Determining a first distance between each feature vector in a corresponding cluster set and a representative point of the corresponding cluster set; A first sequence is determined from the eigenvectors according to the first distance, and a second preset number of eigenvectors in the first sequence are used as edge points of the first cluster set.
8. The index construction method according to claim 3, characterized in that: in, Determining the second preset number of corresponding edge points from each cluster set within the current node includes: Determine adjacent cluster sets of each cluster set within the current node; Determining a second distance between each feature vector in a corresponding cluster set and a representative point of an adjacent cluster set of the corresponding set; A first sequence is determined from the eigenvectors according to the second distance, and a second preset number of eigenvectors in the first sequence are used as edge points of the first cluster set.
9. The method according to any one of claims 2 to 8, characterized in that: The distance includes Euclidean distance, inner product distance and Hamming distance.
10. An index building device, characterized in that: include: A first determining unit is configured to determine a target vector and a first cluster set in which the target vector is located in a current node, wherein the first cluster set has a first representative point, and the target vector is a feature vector corresponding to data in a database; a second determining unit, configured to determine a second cluster set in which the target vector is located in a next node, the second cluster set having a corresponding representative point, the preset representative point corresponding to the second cluster set being an edge point of one of the cluster sets in the current node; wherein the feature vector in the current node is the same as the feature vector in the next node; The association unit establishes, in each of the nodes, an index association between the target vector and a representative point of the first cluster set where the target vector is located, and the feature vectors in each of the nodes are the same.
11. A vector search method, characterized in that: include: Get the query vector; Obtaining a third distance between a representative point of each cluster set in each node and the query vector, wherein a method for determining the representative point of each cluster set includes: determining each cluster set of the current node, determining a first preset number of edge points in each cluster set of the current node as representative points of the next node, obtaining each cluster set of the next node based on the preset representative point of the next node, using the preset representative point of the next node as the representative point of each cluster set of the next node, or using the arithmetic mean of each feature vector in each cluster set of the next node as the representative point of each cluster set of the next node; Determine a target representative point in each node according to the third distance, and determine a fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector; Determining, based on the fourth distance, a first target vector corresponding to the query vector in each node, where the first target vector is a feature vector corresponding to data in a database; determining, according to the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each of the nodes; The characteristic vectors in each node are the same.
12. The vector search method according to claim 11, characterized in that: Determining, based on the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each node includes: According to the fourth distance, the first target vectors corresponding to the query vector in each node are sorted from small to large according to the fourth distance, and the target vector in the previously set order is determined as the second target vector corresponding to the query vector.
13. A vector search device, characterized in that: Applied to data systems: including: A first acquisition unit, configured to acquire a query vector; a second acquisition unit, configured to acquire a third distance between a representative point of each cluster set in each node and the query vector, wherein a method for determining the representative point of each cluster set includes: determining each cluster set of the current node, determining a first preset number of edge points in each cluster set of the current node as representative points of the next node, acquiring each cluster set of the next node based on the preset representative point of the next node, using the preset representative point of the next node as the representative point of each cluster set of the next node, or using the arithmetic mean of each feature vector in each cluster set of the next node as the representative point of each cluster set of the next node; a first determining unit, configured to determine a target representative point in each node according to the third distance, and determine a fourth distance between each feature vector in the target cluster set corresponding to the target representative point and the query vector; a second determining unit, configured to determine, based on the fourth distance, a first target vector corresponding to the query vector in each node, where the first target vector is a feature vector corresponding to the data in the database; A third determining unit is configured to determine, based on the fourth distance, a second target vector corresponding to the query vector from the first target vectors corresponding to the query vector in each of the nodes; wherein the feature vectors in each of the nodes are the same.
14. A retrieval system, characterized in that: It includes the index building device according to claim 10 and / or the vector searching device according to claim 13.
15. A database, characterized in that An index structure is included, wherein the index structure includes a plurality of sub-index structures, each sub-index structure includes a plurality of representative point items and a plurality of inverted file items; the representative point items include representative points corresponding to each cluster set in the data system, and the inverted file items include inverted files corresponding to each representative point; Each inverted file includes each feature vector in the cluster set corresponding to the representative point corresponding to each inverted file, and each feature vector is a feature vector corresponding to the data in the database; The method for determining each representative point includes: determining each cluster set of the current node, determining a first preset number of edge points in each cluster set of the current node as the representative points of the next node, obtaining each cluster set of the next node based on the preset representative points of the next node, using the preset representative points of the next node as the representative points of each cluster set of the next node, or using the arithmetic mean of each feature vector in each cluster set of the next node as the representative point of each cluster set of the next node, and the feature vectors in the current node and the next node are the same.
16. An electronic device, characterized in that: include: A memory for storing instructions executed by one or more processors of an electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the index construction method according to any one of claims 1 to 9 or the vector search method according to any one of claims 11 to 12.
17. A readable medium, characterized in that The readable medium stores instructions, which, when executed on an electronic device, enable the machine to execute the index construction method according to any one of claims 1 to 9 or the vector search method according to any one of claims 11 to 12.
18. A computer program product, characterized in that The method comprises instructions for implementing the index construction method according to any one of claims 1 to 9 or the vector search method according to any one of claims 11 to 12.