Index building methods, devices, vector search methods, and retrieval systems

By establishing index associations between feature vectors and other cluster sets, the problem of low accuracy in existing retrieval systems is solved, achieving higher retrieval accuracy and a higher probability of feature vectors being retrieved.

CN114691940BActive Publication Date: 2026-03-06SHANGHAI XUYU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-18
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing retrieval systems suffer from low accuracy in building inverted indexes because the representative points of cluster sets cannot fully represent all feature vectors in the cluster sets.

Method used

During the index construction process, an index association is established between each feature vector and at least one second cluster set that meets the preset conditions, in addition to the cluster set in which it is located. By determining the distance and approximate radius of the target vector to other cluster sets, the cluster set with the closer distance is selected as the second cluster set.

Benefits of technology

It improves the accuracy of vector retrieval, increases the probability of feature vectors being retrieved from the database, and avoids the problem of low search accuracy caused by the fact that representative points cannot fully represent the feature vectors in the cluster set.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691940B_ABST
    Figure CN114691940B_ABST
Patent Text Reader

Abstract

This application relates to the field of data retrieval technology, and discloses an index construction method, apparatus, vector search method, and retrieval system. The index construction method includes: determining a target vector and a first cluster set containing the target vector; determining at least one second cluster set that meets preset conditions from other cluster sets besides the first cluster set; and establishing an index association between the target vector and the second cluster set. Based on this scheme, each feature vector in the database can be associated with at least one other cluster set besides its own. This allows for the determination of the next one or more cluster sets to be retrieved during subsequent vector retrieval, based on the number of vectors associated with the first cluster set from other cluster sets. This effectively increases the probability of each feature vector in the database being retrieved and allows for more accurate acquisition of the target vector corresponding to the query vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data retrieval technology, and in particular to an index construction method, apparatus, vector search method and retrieval system. Background Technology

[0002] With the rapid growth of data, data retrieval is widely used in fields such as image, video, voice, and protein molecular structure retrieval. Since various types of data, such as image data, can be abstracted into high-dimensional feature vectors, the similarity between data can be quantified as the distance between feature vectors in a vector space. For example, the closer the distance between two feature vectors, the higher the similarity of the original data corresponding to those two feature vectors. Therefore, data retrieval can be transformed into vector search in a vector space; that is, the process of searching for several data points similar to the query data in a 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] Currently, some retrieval systems build inverted indexes for databases to facilitate user searches. The construction method for an inverted index involves first clustering the feature vectors corresponding to each data point in the database, for example, using k-means clustering. This divides the entire vector space into several cluster sets, each with a representative point. Each feature vector is then assigned to the cluster containing its nearest representative point. When retrieving a query vector, the system determines the closest representative point based on the distance between the query vector and multiple representative points. It then searches all feature vectors within the cluster containing that representative point. Essentially, searching all feature vectors yields the distance between each feature vector and the query vector. Finally, the clusters with the closest distances to the query vector are selected as the search results.

[0004] However, some feature vectors in certain clusters are closer to the query vector than the feature vectors found in the search above. But since the representative point of the cluster is not the closest to the query vector, the system does not search for the feature vectors in the cluster, resulting in the failure to obtain a more accurate target vector for the query vector, and thus the accuracy of the search results is low. Summary of the Invention

[0005] To address the issue of low accuracy in retrieval results from vector search methods, embodiments of this application provide an index construction method, apparatus, vector search method, and retrieval system.

[0006] In a first aspect, embodiments of this application provide an index construction method, including:

[0007] Determine the target vector and the first cluster set in which the target vector belongs;

[0008] From other cluster sets besides the first cluster set, at least one second cluster set that meets the preset conditions is determined for the target vector;

[0009] Establish an index association between the target vector and the second cluster set.

[0010] Based on the above scheme, each feature vector in the database is associated with at least one other cluster set besides its own. During subsequent vector retrieval, after retrieving the first cluster set, the next one or more cluster sets to be retrieved can be determined based on the number of vectors associated with each other cluster set in the first cluster set. This effectively increases the probability of each feature vector in the database being retrieved and allows for more precise acquisition of the target vector corresponding to the query vector. It effectively avoids the problem of low search accuracy caused by the fact that representative points in a cluster set cannot completely represent all feature vectors in the cluster set.

[0011] It is understood that the target vector in the first cluster set mentioned in the embodiments of this application can be any vector in the first cluster set.

[0012] In one possible implementation of the first aspect above, determining at least one second cluster set that meets preset conditions for the target vector from other cluster sets besides the first cluster set includes:

[0013] Obtain the distance between the target vector and the representative points of each of the other cluster sets outside the first cluster set;

[0014] Based on the distance, a first sequence corresponding to the target vector is determined from other cluster sets outside the first cluster set, and a set number of cluster sets in the first sequence are determined as a second cluster set that meets preset conditions.

[0015] It is understood that in this embodiment of the application, the cluster sets that are closer to each vector can be determined based on the distance between the representative point corresponding to each cluster set and each vector in the first cluster set. By establishing an association between the cluster sets that are closer to each vector and each vector, in the subsequent vector retrieval process, after retrieving the first cluster set, the next one or more cluster sets to be retrieved can be determined based on the number of vectors in the first cluster set associated with other cluster sets respectively. This effectively increases the probability that each feature vector in the database will be retrieved, thereby enabling more accurate acquisition of the target vector corresponding to the query vector.

[0016] In one possible implementation of the first aspect above, determining a first sequence corresponding to the target vector from other cluster sets outside the first cluster set based on the distance, and determining a predetermined number of cluster sets in the first sequence as a second cluster set that meets preset conditions, includes:

[0017] Based on the distance from smallest to largest, sort the other cluster sets outside the first cluster set to determine the first sequence corresponding to the target vector;

[0018] A predetermined number of cluster sets in the first sequence are selected as the second cluster set that meets the preset conditions.

[0019] It is understood that in this embodiment, sorting the cluster sets according to the distance between the representative points of each cluster set and the target vector in the first cluster set makes it more convenient to select the corresponding second cluster set based on a predetermined number of second cluster sets. For example, if the predetermined number of second cluster sets is five, the first five cluster sets in the first sequence can be directly used as the second cluster sets that meet the preset conditions. Furthermore, using the first predetermined number of cluster sets in the first sequence as the second cluster sets ensures that the selected second cluster sets are all cluster sets that are close to the target vector, thus improving the retrieval accuracy in subsequent retrieval processes.

[0020] In one possible implementation of the first aspect above, determining a first sequence corresponding to the target vector from other cluster sets outside the first cluster set based on the distance, and determining a predetermined number of cluster sets in the first sequence as a second cluster set that meets preset conditions, includes:

[0021] Among the cluster sets other than the first cluster set, the cluster sets whose distance is less than a set distance are taken as the cluster sets in the first sequence;

[0022] Each cluster set in the first sequence is used as the second cluster set;

[0023] Alternatively, the cluster sets in the first sequence can be sorted in ascending order according to the distance between the corresponding points and the target vector, and the cluster sets with the predetermined order can be determined as the second cluster set that meets the preset conditions.

[0024] It is understood that in this embodiment of the application, the cluster sets whose distance is less than a set distance among the other cluster sets besides the first cluster set are taken as the cluster sets in the first sequence. That is, the method of determining the second cluster set by setting a distance threshold ensures that the distance between the selected cluster set and the target vector is within the range specified by the user, making the method of selecting the second cluster set more standardized and simple. For example, the second cluster set can be obtained simply by setting the corresponding distance threshold parameter in the algorithm for selecting the cluster set.

[0025] In one possible implementation of the first aspect above, determining at least one second cluster set that meets preset conditions for the target vector from other cluster sets besides the first cluster set includes:

[0026] Obtain the distance between the target vector and the representative points of each of the other cluster sets outside the first cluster set;

[0027] Obtain the approximate radius of each cluster set other than the first cluster set;

[0028] Obtain the difference between the distance and the approximate radius;

[0029] Based on the difference, a first sequence corresponding to the target vector is determined from other cluster sets outside the first cluster set, and a set number of cluster sets in the first sequence are determined as a second cluster set that meets the preset conditions.

[0030] It can be understood that the difference between the distance between a representative point of any cluster and the target feature vector and its approximate radius can approximately represent the distance between the nearest edge feature vector in that cluster and the target feature vector. When the distance between an edge feature vector and the target feature vector is relatively short, it is possible that the original data corresponding to the edge feature vector and the target feature vector are quite similar. Therefore, an index association can be established between the cluster containing the edge feature vector and the target feature vector.

[0031] It is understood that, in some embodiments, the method for obtaining the approximate radius of each cluster set other than the first cluster set containing the target feature vector itself can be: obtaining the distance between all feature vectors in each cluster set and the representative point in each cluster set, and using the maximum distance between all feature vectors and the representative point as the approximate radius of each cluster set. In some embodiments, the method for estimating the approximate radius of each cluster set can also be any other feasible method, such as estimation using a neural network model or related algorithms.

[0032] In one possible implementation of the first aspect above, determining the first cluster set in which the target vector belongs includes:

[0033] Obtain the distance between the target vector and the representative points corresponding to all cluster sets;

[0034] The cluster set that has the closest distance between the corresponding representative point and the target vector among all cluster sets is taken as the first cluster set in which the target vector belongs.

[0035] In one possible implementation of the first aspect above, the distance includes Euclidean distance and inner product distance.

[0036] It is understood that the distances in the embodiments of this application, including Euclidean distance and inner product distance, are merely distance descriptions and can also be represented by any other feasible distance.

[0037] Secondly, this application provides an index building apparatus, comprising:

[0038] The first determining unit is used to determine the target vector and the first cluster set in which the target vector belongs;

[0039] The second determining unit is used to determine at least one second cluster set that meets preset conditions from other cluster sets besides the first cluster set for the target vector;

[0040] The association unit is used to establish an index association between the target vector and the second cluster set.

[0041] Thirdly, this application provides a vector search method, including:

[0042] Retrieve the query vector;

[0043] Obtain the distance between the query vector and the representative point corresponding to each cluster set in the database;

[0044] The first representative point closest to the query vector is determined, and the cluster set corresponding to the first representative point is taken as the first cluster set of the first-level search. The distance between each feature vector in the first cluster set and the query vector is determined.

[0045] From other cluster sets besides the first cluster set, determine at least one cluster set whose number of associated feature vectors in the first cluster set meets a preset condition as at least one second cluster set for the second-level search, and determine the distance between each feature vector in the second cluster set and the query vector;

[0046] When the number of searched cluster sets reaches a preset number, the feature vectors whose distance from the query vector is within a set range among all feature vectors of the first and second cluster sets that have been searched are taken as the target vector corresponding to the query vector.

[0047] It's understandable that if a cluster set contains the most feature vectors associated with the first cluster set (meaning multiple feature vectors from the first cluster set are related to this cluster set), then the representative point of this cluster set is relatively close to multiple feature vectors from the first cluster set. Therefore, the feature vectors contained in the cluster set corresponding to this representative point are also likely to be close to the query vector. Thus, a search can be performed within this cluster set, increasing the probability of retrieving each feature vector from the database and allowing for a more precise acquisition of the target vector corresponding to the query vector.

[0048] In one possible implementation of the third aspect above, it further includes: when the number of searched cluster sets has not reached a preset number, then

[0049] The cluster set with the most feature vectors in the second cluster set is identified as the third cluster set to be searched.

[0050] It is understandable that the above preset number can be determined based on the size of the number of database vectors. When the number of database vectors is large, the above preset number can be large, and when the number of database vectors is small, the above preset number can be small.

[0051] Fourthly, embodiments of this application provide a search device applied to a database, comprising:

[0052] The first acquisition unit is used to acquire the query vector;

[0053] The second acquisition unit is used to acquire the distance between the query vector and the representative point corresponding to each cluster set in the database;

[0054] The first determining unit is used to determine the first representative point that is closest to the query vector, and to set the...

[0055] The cluster set corresponding to the first corresponding point is used as the first cluster set of the first-level search, and the distance between each feature vector in the first cluster set and the query vector is determined.

[0056] The second determining unit is used to determine, from other cluster sets besides the first cluster set, at least one cluster set that satisfies a preset condition in the first cluster set as the second cluster set for the second-level search, and to determine the distance between each feature vector in the second cluster set and the query vector;

[0057] The execution unit is used to execute the searched clusters when the number of searched clusters reaches a preset number.

[0058] Among all feature vectors of the first cluster set and the second cluster set, the feature vector whose distance from the query vector is within a set range is taken as the target vector corresponding to the query vector.

[0059] Fifthly, embodiments of this application provide a retrieval system, including the above-described index building apparatus and / or the above-described search apparatus.

[0060] Sixthly, embodiments of this application provide an index structure, including representative point items and inverted file items; the representative point items include each representative point corresponding to each cluster set in the database, and the inverted file items include each inverted file corresponding to each cluster set;

[0061] The inverted index includes each feature vector in the cluster set corresponding to the inverted index, as well as the second cluster set information of each feature vector.

[0062] In a seventh aspect, embodiments of this application provide an electronic device, including: 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 above-described index building method or the above-described search method.

[0063] Eighthly, embodiments of this application provide a readable medium storing instructions that, when executed on an electronic device, cause the machine to perform the aforementioned index building method or the aforementioned search method.

[0064] Ninthly, embodiments of this application provide a computer program product, including instructions for implementing the above-described index construction method or the above-described search method. Attached Figure Description

[0065] Figure 1a A schematic diagram of an image database S is shown according to some embodiments of this application;

[0066] Figure 1b According to some embodiments of this application, a schematic diagram of constructing an inverted index for an image database S is shown;

[0067] Figure 2a A schematic diagram of an image database S is shown according to some embodiments of this application;

[0068] Figure 2b According to some embodiments of this application, a schematic diagram of indexing an image database S is shown;

[0069] Figure 2c According to some embodiments of this application, a schematic diagram of the storage of data information of a feature vector and data information of each cluster set that is indexed and associated with the feature vector is shown;

[0070] Figure 2d According to some embodiments of this application, a schematic diagram showing the association between partial feature vectors in database S and the indexes of each cluster set is shown;

[0071] Figure 2e A schematic diagram of vector retrieval is shown according to some embodiments of this application;

[0072] Figure 3 According to some embodiments of this application, a flowchart of an index construction method is shown;

[0073] Figure 4 According to some embodiments of this application, a schematic diagram of an index structure corresponding to a database S is shown;

[0074] Figure 5 According to some embodiments of this application, a flowchart of a search method is shown;

[0075] Figure 6 According to some embodiments of this application, a flowchart of an index building apparatus is shown;

[0076] Figure 7 A schematic diagram of a search device is shown according to some embodiments of this application;

[0077] Figure 8 A schematic diagram of a retrieval system is shown according to some embodiments of this application;

[0078] Figure 9 A block diagram of an electronic device is shown according to some embodiments of this application. Detailed Implementation

[0079] The illustrative embodiments of this application include, but are not limited to, an index building method, apparatus, database, and search method.

[0080] As mentioned earlier, the accuracy of retrieval results obtained by building inverted indexes in current databases is relatively low.

[0081] For example, Figure 1a The image shown is a schematic diagram of an image database S in a retrieval system. Database S includes feature vectors corresponding to each image. Figure 1b The image below is a diagram illustrating the construction of an inverted index for the image database S. Figure 1bAs shown, the feature vectors in database S are first assigned to four cluster sets through clustering: cluster set S1, cluster set S2, cluster set S3, and cluster set S4. 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.

[0082] It is understood that the representative point mentioned in the embodiments of this application can be the center point of the cluster set, that is, a point whose distance from each point is within a preset range; or it can be a point based on other rules.

[0083] When performing vector retrieval on the query vector A corresponding to the query image based on the aforementioned database S, the retrieval system determines the distance between each representative point and the query vector A. For example, ... Figure 1b As shown, the retrieval system determines the distance between representative point C1 and query vector A as d1, representative point C2 as d2, representative point C3 as d3, and representative point C4 as d4. Assuming d4 > d3 > d1 > d2, the system identifies C2 as the representative point closest to query vector A. Then, it searches for each feature vector in the cluster set S2 containing C2. This search essentially obtains the distance between each feature vector and query vector A. The feature vectors Y1 and Y2 in cluster set S2 that are close to query vector A or within a set distance range are then used as the target vector for query vector A. Finally, the original image data corresponding to the target vector is output to the client.

[0084] However, as Figure 1b As shown, the feature vector X1 in the cluster set S1 is actually the feature vector in the database S that is closest to the query vector A. However, since the representative point C1 of the cluster set S1 is not closest to the query vector, the system does not search for the feature vector in the cluster set S1, which results in the failure to obtain the accurate target vector of the query vector A, causing the most accurate retrieval result to be missed and affecting the accuracy of the retrieval.

[0085] To address the aforementioned issues, this application provides a method for constructing an index, specifically including: obtaining feature vectors corresponding to each data in the database to be indexed; performing clustering processing on each feature vector to obtain multiple cluster sets, each cluster set having a corresponding representative point; assigning each feature vector to its corresponding first cluster set; further, determining at least one second cluster set that satisfies preset conditions, excluding the first cluster set to which each feature vector belongs; and finally, establishing an index association for each feature vector based on the first cluster set and at least one second cluster set.

[0086] It is understandable that the above clustering processing method can be K-means or other clustering methods. Among them, the K-means clustering method can first pre-define any number of cluster sets and the representative points corresponding to each cluster set, then obtain the distance between each feature vector in the database and the representative point corresponding to each cluster set; and then assign each feature vector to the cluster set corresponding to the nearest representative point.

[0087] The method for obtaining the second cluster set that satisfies the preset conditions for each feature vector can be as follows: Take the multiple cluster sets (excluding the first cluster set containing the target feature vector itself) and sort them from closest to farthest according to the distance between the representative points of each cluster set and the target feature vector, thus obtaining the first sequence corresponding to the target feature vector; take the first preset number of cluster sets in the first sequence as the second cluster set, and establish an index association between the target feature vector and the second cluster set. It can be understood that each feature vector can be associated with at least one second cluster set besides its own cluster set.

[0088] It is understood that in this embodiment, sorting the cluster sets according to the distance between the representative points of each cluster set and the target vector in the first cluster set makes it more convenient to select the corresponding second cluster set based on a predetermined number of second cluster sets. For example, if the predetermined number of second cluster sets is five, the first five cluster sets in the first sequence can be directly used as the second cluster sets that meet the preset conditions. Furthermore, using the first predetermined number of cluster sets in the first sequence as the second cluster sets ensures that the selected second cluster sets are all cluster sets that are close to the target vector, thus improving the retrieval accuracy in subsequent retrieval processes.

[0089] It is understood that the method described above for obtaining the second cluster set by sorting according to the distance between the representative points of each cluster set and the target feature vector is merely an illustrative example. In practice, other methods may also be used to obtain the second cluster set in this embodiment of the application.

[0090] For example, the second cluster set can also be obtained by: taking the cluster sets in the above multiple cluster sets other than the first cluster set where the target feature vector itself is located, and forming the cluster sets in the first sequence where the distance between the representative point and the target feature vector is less than a set distance; then taking all the cluster sets in the first sequence as the second cluster set, or sorting the distance between the representative point and the target feature vector in the first sequence from near to far, and taking the cluster set that is in the first set order as the second cluster set.

[0091] It is understood that in this embodiment of the application, the cluster sets whose distance is less than a set distance among the other cluster sets besides the first cluster set are taken as the cluster sets in the first sequence. That is, the method of determining the second cluster set by setting a distance threshold ensures that the distance between the selected cluster set and the target vector is within the range specified by the user, making the method of selecting the second cluster set more standardized and simple. For example, the second cluster set can be obtained simply by setting the corresponding distance threshold parameter in the algorithm for selecting the cluster set.

[0092] For example, the second cluster set can also be obtained by: estimating the approximate radius of each cluster set other than the first cluster set containing the target feature vector itself; using the difference between the distance between the representative point of each cluster set and the representative point of the target feature vector and the approximate radius as the closest distance between the feature vector and the target vector in each cluster set; sorting the cluster sets from closest to furthest based on the closest distance between the feature vector and the target vector to obtain a first sequence; and using the first predetermined number of cluster sets in the first sequence as the second cluster set.

[0093] Alternatively, the clusters in each cluster set whose nearest distance between the feature vector and the target vector is less than a set value can be grouped into a first sequence, and all cluster sets in the first sequence can be used as the second cluster set. Or, the clusters in the first sequence can be sorted from nearest to farthest based on the nearest distance between the feature vector and the target feature vector, and the clusters in the first sequence that are in the first set order can be used as the second cluster set.

[0094] It can be understood that the difference between the distance between a representative point of any cluster and the target feature vector and its approximate radius can approximately represent the distance between the nearest edge feature vector in that cluster and the target feature vector. When the distance between an edge feature vector and the target feature vector is relatively short, it is possible that the original data corresponding to the edge feature vector and the target feature vector are quite similar. Therefore, an index association can be established between the cluster containing the edge feature vector and the target feature vector.

[0095] It is understood that, in some embodiments, the method for estimating the approximate radius of each cluster set other than the first cluster set containing the target feature vector itself can be: obtaining the distance between all feature vectors in each cluster set and the representative point in each cluster set, and using the maximum distance between all feature vectors and the representative point as the approximate radius of each cluster set. In some embodiments, the method for estimating the approximate radius of each cluster set can also be any other feasible method, such as estimation using a neural network model or related algorithms.

[0096] The number of cluster sets associated with each feature vector, i.e. the preset number mentioned above, can be related to the size of the database. For example, when the database has a large amount of data, the preset number can be set to a larger amount; when the database has a small amount of data, the preset number can be set to a smaller amount.

[0097] Corresponding to the vector index construction method described above, when retrieving such vectors, the retrieval system can first obtain the query vector during the vector retrieval process; then, determine the representative point in the database that is closest to the query vector, and use the cluster set corresponding to this representative point as the first cluster set for the first-level search, and determine the distance between each feature vector in the first cluster set and the query vector; then, obtain the cluster sets associated with each feature vector in the first cluster set; and use at least one cluster set among the multiple cluster sets whose number of associated feature vectors in the first cluster set meets a preset condition as at least one second cluster set for the second-level search; and obtain the distance between each feature vector in the second cluster set and the query vector. When the number of searched cluster sets reaches a preset number, the feature vectors whose distance to the query vector is within a set range among all searched feature vectors are used as the target vector corresponding to the query vector. When the number of searched cluster sets does not reach the preset number, the system continues to obtain the cluster sets for the next level of search and searches the cluster sets for the next level of search.

[0098] It is understandable that the number of cluster sets to be searched in each level of search can be one or more. The following example, using the method of determining the second cluster set for the second-level search, illustrates how the cluster sets for each level of search are determined. Specifically, the method for determining the second cluster set for the second-level search can be:

[0099] The cluster set with the most feature vectors in the first cluster set is used as the second cluster set for the second-level search.

[0100] Alternatively, the cluster sets other than the first cluster set can be sorted from most to least related to the first cluster set, and the cluster set that ranks first in the sorted order can be used as the second cluster set for the second-level search.

[0101] It's understandable that if a cluster set contains the most feature vectors associated with the first cluster set (meaning multiple feature vectors from the first cluster set are related to this cluster set), then the representative point of this cluster set is relatively close to multiple feature vectors from the first cluster set. Therefore, the feature vectors contained in the cluster set corresponding to this representative point are also likely to be close to the query vector. Thus, a search can be performed within this cluster set, increasing the probability of retrieving each feature vector from the database and allowing for a more precise acquisition of the target vector corresponding to the query vector.

[0102] Based on the above scheme, each feature vector in the database is associated with at least one other cluster set besides its own. During subsequent vector retrieval, after retrieving the first cluster set, the next one or more cluster sets to be retrieved can be determined based on the number of vectors associated with each other cluster set in the first cluster set. This effectively increases the probability of each feature vector in the database being retrieved and allows for more precise acquisition of the target vector corresponding to the query vector. It effectively avoids the problem of low search accuracy caused by the fact that representative points in a cluster set cannot completely represent all feature vectors in the cluster set.

[0103] For example, Figure 2a The image shown is a schematic diagram of an image database S in a retrieval system. Database S includes feature vectors corresponding to each image. Figure 2b The diagram below illustrates the indexing and construction of the image database S according to an embodiment of this application. Figure 2a As shown in Figure b, the index construction method provided in this application embodiment can be as follows: First, the system distributes each feature vector in the database S into four cluster sets through the above-mentioned k-means clustering process. The four cluster sets are cluster set S1, cluster set S2, cluster set S3, and cluster set S4. Among them, 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. Then, each feature vector in each cluster set is associated with an index by establishing an index association with cluster sets that meet preset conditions, excluding the cluster set in which it belongs.

[0104] like Figure 2b As shown, taking feature vector Y1 in cluster set S2 as an example, during the index construction process, the method by which this application obtains the second cluster set that satisfies the preset conditions with feature vector Y1 in cluster set S2 can be as follows:

[0105] Obtain the distances between feature vector Y1 and the representative points of all cluster sets except cluster set S2. For example, the distance between feature vector Y1 and the representative point C1 of cluster set S1 is d5, the distance between feature vector Y1 and the representative point C3 of cluster set S3 is d6, and the distance between feature vector Y1 and the representative point C4 of cluster set S4 is d7. Then, sort the above three cluster sets according to the distance between their respective representative points and feature vector Y1 from closest to furthest to obtain the first sequence corresponding to feature vector Y1. Assuming that d5 < d6 < d7, the first sequence corresponding to feature vector Y1 is cluster set S1 - cluster set S3 - cluster set S4. At this time, establish an index association between feature vector Y1 and the first preset number of cluster sets in the first sequence. Assuming that the preset number is 2, cluster sets S1 and S3 can be used as the second cluster sets that satisfy the preset conditions for feature vector Y1, and an index association can be established between feature vector Y1 and cluster sets S1 and S3.

[0106] In some embodiments, the data information of each feature vector and the data information of each cluster set associated with each feature vector by an index can be stored in the inverted index file corresponding to the cluster set to which each feature vector belongs. The data information of the feature vector may include the feature vector's Identity Document (ID) and the feature vector itself. The data information of each cluster set associated with the feature vector by an index may include the ID of each cluster set.

[0107] For example, Figure 2c The diagram illustrates the storage format of the data information of feature vector Y1, the data information of cluster set S1 and cluster set S3 that are indexed and associated with feature vector Y1, and the inverted index file corresponding to the cluster set S2 where feature vector Y1 resides. Figure 2c As shown, the data information of feature vector Y1 includes the ID of feature vector Y1 and feature vector Y1, the data information of cluster set S1 includes the ID of cluster set S1, and the data information of cluster set S3 includes the ID of cluster set S3.

[0108] Based on the above method, the second cluster set that satisfies the preset conditions for each feature vector in the cluster set S2 can be obtained, and an index association can be established between each feature vector and the corresponding second cluster set that satisfies the preset conditions.

[0109] Figure 2dThis diagram illustrates the association between some feature vectors in database S and the indices of each cluster set. Each cluster set can be represented by a representative point. Database S includes cluster sets S1, S2, S3, and S4. 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. Figure 3 As shown, the feature vector Y1 in cluster set S2 has an index association not only with the representative point C2 corresponding to its own cluster set S2, but also with the representative point C1 corresponding to cluster set S1 and the representative point C3 corresponding to cluster set S3.

[0110] When performing vector retrieval on query vector A based on the aforementioned database S, the retrieval system determines the distance between the representative point of each cluster set in database S and query vector A. For example, ... Figure 2e As shown, the retrieval system determines the distance between representative point C1 and query vector A as d1, representative point C2 as d2, representative point C3 as d3, and representative point C4 as d4. It then identifies the representative point C2 as the one closest to query vector A among the four. Finally, it searches for each feature vector in the cluster set S2 containing representative point C2. This can be understood as obtaining the distance between each feature vector and the query vector.

[0111] Based on the index established for each feature vector in cluster set S2, the second cluster set for each feature vector in cluster set S2 is obtained. The cluster set with the most associated feature vectors of cluster set S2 among multiple cluster sets is determined as the second cluster set for the second-level search. For example, if the cluster set with the most associated feature vectors of cluster set S2 among cluster sets S1, S3 and S4 is cluster set S1, then cluster set S1 is used as the second cluster set for the second-level search.

[0112] The system then searches the feature vectors in cluster set S1, that is, it obtains the distance between each feature vector in cluster set S1 and the query vector A.

[0113] Assuming the system is set to have two preset search sets, the search ends, and the feature vectors in clusters S2 and S1 whose distance from the query vector A is less than or equal to a set value are taken as the target vectors. For example, if the feature vectors in clusters S2 and S1 whose distance from the query vector A satisfies the set value are feature vectors X1, Y1, and Y2, then feature vectors X1, Y1, and Y2 are the target vectors corresponding to the query vector.

[0114] Assuming the system has more than two preset search sets, the system further obtains the third cluster set for the third-level search. The method for obtaining the third cluster set for the third-level search is the same as the method for obtaining the second cluster set for the second-level search, and will not be repeated here. The search continues until the number of searched cluster sets reaches the preset number of search sets, at which point the search ends.

[0115] It is understood that the application of the index building method to the index building of the above-mentioned image database in this embodiment is only an example. The index building method provided in this embodiment can be applied to various databases such as video, audio, and protein molecular structure. That is, the index building method provided in this embodiment can be widely used in the fields of image, video, audio, and protein molecular structure retrieval.

[0116] It is understood that the retrieval system mentioned in the embodiments of this application may include at least one database, for example, it may include the image database mentioned above, and may also include 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. Implementably, each database can be indexed using the above-described index construction method.

[0117] The index building method provided in the embodiments of this application will be described in detail below. It can be understood that the index building method provided in the embodiments of this application can be executed by a retrieval system or by other electronic devices. That is, other electronic devices will build an index on the database and then deploy the indexed database to the retrieval system.

[0118] The following describes in detail the index construction method provided in this application embodiment, taking the index construction method executed by the retrieval system as an example. Figure 3 This paper illustrates a flowchart of an index construction method according to an embodiment of this application.

[0119] like Figure 3 As shown, the index construction method in this application embodiment may include:

[0120] 301: Retrieves the feature vectors corresponding to each data item in the database for which an index is to be created.

[0121] It is understood that the database can be one or more data structures including various images, videos, audio, protein molecular structures, etc. Since various types of data can be converted into high-dimensional feature vectors, the retrieval system can first convert the original data in the database into corresponding feature vectors. It is also understood that the original data in the database can be retained and stored therein.

[0122] For example, for the image database mentioned above, the retrieval system can first convert each image data in the image database into a corresponding feature vector.

[0123] 302: Perform clustering on each feature vector and assign each feature vector to a corresponding cluster set; where each cluster set has a corresponding representative point.

[0124] It is understood that the clustering process for each feature vector in this embodiment can be k-means clustering, wherein the k-means clustering method specifically includes:

[0125] We obtain K initial representative points for clusters and k pre-defined cluster sets, each cluster set corresponding to one representative point. It can be understood that at this stage, the cluster sets have not yet been assigned feature vectors; they are merely virtual sets with corresponding representative points. The value of K, i.e., the number of cluster sets, can be manually set according to actual needs.

[0126] The distance between each feature vector in the database and the initial representative point corresponding to each cluster set is obtained; each feature vector is then assigned to the cluster set corresponding to the nearest initial representative point. It is understood that the distance mentioned in this embodiment can be Euclidean distance, inner product distance, or other distances.

[0127] In some embodiments, the initial representative points corresponding to each of the above cluster sets can be used as the representative points corresponding to the cluster sets. In other embodiments, the representative points in each cluster set can be redefined. For example, the average vector of all feature vectors in the cluster set can be used as the representative point.

[0128] It is understood that the above-described clustering process for each feature vector can also be other clustering methods.

[0129] 303: Determine at least one second cluster set that satisfies the preset conditions, excluding the first cluster set to which each feature vector belongs.

[0130] The following example uses any one of the target feature vectors to illustrate how to obtain the second cluster set that meets the preset conditions corresponding to the target vector.

[0131] The method for obtaining the second cluster set that satisfies the preset conditions for the target feature vector can be as follows: Take the multiple cluster sets other than the first cluster set containing the target feature vector itself, and sort them from closest to farthest according to the distance between the representative points of each cluster set and the target feature vector, thus obtaining the first sequence corresponding to the target feature vector; take the first preset number of cluster sets in the first sequence as the second cluster set, and establish an index association between the target feature vector and the second cluster set. It can be understood that each feature vector can be associated with at least one second cluster set other than its own cluster set.

[0132] It is understood that the method described above for obtaining the second cluster set by sorting according to the distance between the representative points of each cluster set and the target feature vector is merely illustrative. In practice, other methods may also be used to obtain the second cluster set in this embodiment of the application.

[0133] For example, the second cluster set can also be obtained by: taking the cluster sets in the above multiple cluster sets other than the first cluster set where the target feature vector itself is located, and forming the cluster sets in the first sequence where the distance between the representative point and the target feature vector is less than a set distance; then taking all the cluster sets in the first sequence as the second cluster set, or sorting the distance between the representative point and the target feature vector in the first sequence from near to far, and taking the cluster set that is in the first set order as the second cluster set.

[0134] For example, the second cluster set can also be obtained by: estimating the approximate radius of each cluster set other than the first cluster set containing the target feature vector itself; using the difference between the distance between the representative point of each cluster set and the representative point of the target feature vector and the approximate radius as the closest distance between the feature vector and the target vector in each cluster set. Cluster sets in which the closest distance between the feature vector and the target vector is less than a predetermined value are grouped into a first sequence; all cluster sets in the first sequence are used as the second cluster set; or, the cluster sets in the first sequence are sorted from closest to furthest based on the closest distance between the feature vector and the target feature vector, and the cluster sets in the first sequence that are at the top of the predetermined order are used as the second cluster set.

[0135] It can be understood that the difference between the distance between a representative point of any cluster and the target feature vector and its approximate radius can approximately represent the distance between the nearest edge feature vector in that cluster and the target feature vector. When the distance between an edge feature vector and the target feature vector is relatively short, it is possible that the original data corresponding to the edge feature vector and the target feature vector are quite similar. Therefore, an index association can be established between the cluster containing the edge feature vector and the target feature vector.

[0136] It is understood that, in some embodiments, the method for estimating the approximate radius of each cluster set other than the first cluster set containing the target feature vector itself can be: obtaining the distance between all feature vectors in each cluster set and the representative point in each cluster set, and using the maximum distance between all feature vectors and the representative point as the approximate radius of each cluster set. In some embodiments, the method for estimating the approximate radius of each cluster set can also be any other feasible method, such as estimation using a neural network model or related algorithms.

[0137] It is understood that the above preset quantity can be related to the size of the database. For example, when the database has a large amount of data, the above preset quantity can be larger; when the database has a small amount of data, the above preset quantity can be smaller.

[0138] For example, regarding the aforementioned Figure 2b The method for obtaining the second cluster set corresponding to feature vector Y1 that satisfies the preset conditions in cluster set S2 can be as follows:

[0139] Obtain the distances between feature vector Y1 and the representative points of all cluster sets except cluster set S2. For example, the distance between feature vector Y1 and the representative point C1 of cluster set S1 is d5, the distance between feature vector Y1 and the representative point C3 of cluster set S3 is d6, and the distance between feature vector Y1 and the representative point C4 of cluster set S4 is d7. Then, sort the distances between the representative points of the above three cluster sets and feature vector Y1 from closest to furthest to obtain the first sequence corresponding to feature vector Y1. Assuming that d5 < d6 < d7, the first sequence corresponding to feature vector Y1 is cluster set S1 - cluster set S3 - cluster set S4. At this time, establish an index association between feature vector Y1 and the first preset number of cluster sets in the first sequence. Assuming that the preset number is 2, cluster set S1 and cluster set S3 can be used as the second cluster set that meets the preset conditions for feature vector Y1.

[0140] It is understood that, in other embodiments, the method for obtaining the cluster set that satisfies the preset conditions corresponding to the corresponding feature vector can also be:

[0141] Obtain the distance between the representative point and the corresponding feature vector in each of the above multiple cluster sets, excluding the cluster set containing the corresponding feature vector itself. Select the cluster set whose distance between the corresponding representative point and the corresponding feature vector is less than a predetermined value as the cluster set corresponding to the corresponding feature vector that satisfies the preset conditions.

[0142] For example, for feature vector Y1 in cluster set S2 in Figure 2 above, the way to determine the second cluster set corresponding to feature vector Y1 that satisfies the preset conditions can also be:

[0143] Obtain the distances between feature vector Y1 and representative points of other cluster sets besides cluster set S2. For example, the distance between feature vector Y1 and representative point C1 of cluster set S1 is d5, the distance between feature vector Y1 and representative point C3 of cluster set S3 is d6, and the distance between feature vector Y1 and representative point C4 of cluster set S4 is d7. After judgment, the distances d5 and d6 between feature vector Y1 and representative point C1 of cluster set S1 and representative point C3 of cluster set S3 are less than the set distances. Therefore, cluster set S1 and cluster set S3 are selected as the second cluster set that meets the preset conditions.

[0144] 304: Establish index associations between each feature vector and the first cluster set and at least one second cluster set.

[0145] In this embodiment, after determining at least one second cluster set corresponding to each feature vector, an index association can be established between each feature vector and the second cluster set. An index association can also be established between the feature vector and its own first cluster set. In some embodiments, when a feature vector is assigned to a corresponding cluster set, an index association between the feature vector and that cluster set has already been established; in this case, only the index association between the feature vector and the second cluster set needs to be established.

[0146] For example, regarding the aforementioned Figure 2b If the feature vector Y1 in cluster set S2 has corresponding second cluster sets S1 and S3 that satisfy preset conditions, then an index association can be established between feature vector Y1 and cluster sets S1 and S3. Additionally, since the feature vector itself belongs to cluster set S2, an index association can be established between feature vector Y1 and cluster set S2. In some embodiments, when feature vector Y1 is assigned to cluster set S2, an index association between feature vector Y1 and cluster set S2 has already been established; in this case, only the index association between feature vector Y1 and cluster sets S1 and S3 needs to be established.

[0147] The index structure constructed using the above-described index construction method in the embodiments of this application is described below. The index structure may include two parts: representative point entries and inverted file entries. Representative point entries may include representative points corresponding to each cluster set, and inverted file entries may include inverted files corresponding to each representative point. Each inverted file includes each feature vector in the cluster set corresponding to the representative point, as well as the second cluster set information for each feature vector.

[0148] The second cluster set information for each feature vector can be the ID of the second cluster set associated with each feature vector and / or the representative point corresponding to the second cluster set associated with each feature vector.

[0149] For example, Figure 4 A schematic diagram of the index structure corresponding to the database S shown in Figure 2 is illustrated. For example... Figure 4 As shown, the index structure of database S includes representative point entries and inverted file entries. The representative point entries include four representative points: C1, C2, C3, and C4. Representative point C1 has a corresponding inverted file D1, which includes the feature vectors of each feature vector in the cluster set S1 corresponding to C1, as well as the second cluster set information for each feature vector.

[0150] The representative point C2 has a corresponding inverted file D2, which includes each feature vector in the cluster set S2 corresponding to the representative point C2 and the second cluster set information of each feature vector.

[0151] The representative point C3 has a corresponding inverted file D3, which includes each feature vector in the cluster set S3 corresponding to the representative point C3 and the second cluster set information of each feature vector.

[0152] The representative point C4 has a corresponding inverted file D4, which includes the feature vectors in the cluster set S4 corresponding to the representative point C4 and the second cluster set information of each feature vector.

[0153] This application embodiment also includes a database, which is constructed using the above-described index construction method. The database includes: multiple cluster sets, each cluster set having at least one feature vector; wherein, each cluster set has a corresponding representative point;

[0154] Each feature vector in a cluster set has an index association with at least one cluster set that meets a preset condition, excluding the cluster set containing each feature vector.

[0155] Figure 5A flowchart illustrating a search method according to an embodiment of this application is shown. This search method can be used with various databases including the above-described index structure, and can be executed by a retrieval system including the aforementioned databases. Figure 5 As shown, the search method in the embodiments of this application may include:

[0156] 501: Get query vector;

[0157] It is understandable that when users conduct information retrieval, they can enter corresponding query data in the search window or search box of the retrieval system. After obtaining the query data, the retrieval system can convert the query data into a corresponding query vector. It is also understandable that the query data entered by the user can be in any format.

[0158] For example, the query data entered by the user can be in image format. After the retrieval system obtains the image, it can convert the image into a corresponding query vector.

[0159] For example, the query data entered by the user can be in text format. After the retrieval system obtains the text, it can convert the text into the corresponding query vector.

[0160] For example, the query data entered by the user can be in video format. After the retrieval system obtains the video, it can convert the video into a corresponding query vector.

[0161] 502: Get the distance between the query vector and the representative point corresponding to each cluster set in the database;

[0162] It is understood that in the embodiments of this application, the above distance can be Euclidean distance or inner product distance, etc.

[0163] Once the query vector is obtained, the retrieval system determines the distance between the representative point of each cluster in the database and the query vector. For example, as mentioned above... Figure 2c As shown, after obtaining the query vector A, the retrieval system will determine the distance between query vector A and representative point C1 as d1, the distance between query vector A and representative point C2 as d2, the distance between query vector A and representative point C3 as d3, and the distance between query vector A and representative point C4 as d4.

[0164] 503: Determine the first representative point in the database that is closest to the query vector, take the cluster set corresponding to the first representative point as the first cluster set of the first-level search, and determine the distance between each feature vector in the first cluster set and the query vector.

[0165] It is understood that in the embodiments of this application, the first cluster set refers to the cluster set containing the representative points that are closest to each feature vector.

[0166] For example, as mentioned above Figure 2c As shown, when the representative point C2 is determined to be the closest to the query vector A among the four representative points, then the cluster set S2 in which the representative point C2 is located is the first cluster set.

[0167] It is understood that in this embodiment of the application, the cluster set corresponding to the first representative point in the database that is closest to the query vector can be used as the first cluster set for the search, and then a full search is performed on the cluster set to obtain the distance between each feature vector in the cluster set and the query vector.

[0168] 504: Get the cluster set associated with each feature vector in the first cluster set.

[0169] It is understood that in this embodiment of the application, the inverted file in the database's index structure contains each feature vector in the cluster set corresponding to the representative point, as well as the associated feature set information of each feature vector. The associated feature set information of each feature vector includes the feature set associated with each feature vector and / or the representative point corresponding to the feature set associated with each feature vector.

[0170] Therefore, the cluster set or representative point associated with each feature vector in the first cluster set can be obtained through the inverted file corresponding to the representative point of the first cluster set.

[0171] 505: Take at least one cluster set in the database whose number of feature vectors associated with the first cluster set meets a preset condition as at least one second cluster set for the second-level search, and determine the distance between each feature vector in the second cluster set and the query vector.

[0172] It is understandable that the second cluster set for the second-level search can be determined as follows:

[0173] The cluster set with the most feature vectors in the first cluster set is used as the second cluster set for the second-level search.

[0174] Alternatively, the cluster sets other than the first cluster set can be sorted from most to least related to the first cluster set, and the cluster set that ranks first in the sorted order can be used as the second cluster set for the second-level search.

[0175] It can be understood that by using the cluster sets associated with each feature vector—that is, the association information between each feature vector and multiple cluster sets—the cluster set with the most associated feature vectors in the first cluster set can be obtained. This cluster set is then used as the next cluster set for the search.

[0176] It's understandable that if a cluster set contains the most feature vectors associated with the first cluster set (meaning multiple feature vectors from the first cluster set are related to this cluster set), then the representative point of this cluster set is relatively close to multiple feature vectors from the first cluster set. Therefore, it's more likely that the feature vectors in the cluster set corresponding to this representative point are also close to the query vector. Using this method, the target vector of the query vector can be obtained more accurately.

[0177] In some embodiments, the method for obtaining the cluster set with the largest number of feature vectors associated with the first cluster set among the plurality of cluster sets can employ a recommendation algorithm, etc. For example, a specific implementation of the recommendation algorithm can be to use a method of counting representative points. Specifically, when searching for each feature vector in the cluster set, after each feature vector is searched, the representative points of the cluster set associated with that feature vector are counted once. When the search in the cluster set is completed, the count value of the representative points corresponding to each cluster set is obtained. This count value is the number of feature vectors in the associated first cluster set. Thus, the representative point with the largest count value is the representative point with the largest number of feature vectors in the associated first cluster set, and the cluster set containing the representative point with the large count value is then used as the next cluster set to be searched.

[0178] It is understood that, in the embodiments of this application, after determining the next cluster set to be searched, all feature vectors in the next cluster set to be searched can be searched, that is, the distance between each feature vector in the next cluster set to be searched and the query vector can be obtained.

[0179] 506: Determine if the number of cluster sets searched has reached the preset number.

[0180] If so, proceed to step 507 and select the feature vectors in the searched cluster set whose distance from the query vector is less than a set value as the target vector corresponding to the query vector.

[0181] If not, proceed to step 508, and select the cluster set with the most associated feature vectors from all cluster sets in the database as the third cluster set for the third-level search, and determine the distance between each feature vector in the third cluster set and the query vector.

[0182] In this embodiment of the application, the search ends when the number of cluster sets searched reaches a preset number, that is, when the second cluster set searched is the preset number of cluster sets.

[0183] In this embodiment of the application, if the number of cluster sets searched has not reached a preset number, the next level of cluster sets to be searched is obtained according to the above steps. The search ends when the number of cluster sets searched reaches the preset number.

[0184] It is understandable that after the search ends, it is necessary to identify the feature vectors in the searched cluster set whose distance from the query vector is less than a set value, and use them as the target vector of the query vector.

[0185] It is understandable that the number of target vectors can be one or multiple.

[0186] 507: Select the feature vectors in the searched cluster set whose distance from the query vector is within a set range as the target vector corresponding to the query vector.

[0187] 508: Select the cluster set with the most associated feature vectors from the second cluster set among all cluster sets in the database as the third cluster set for the third-level search, and determine the distance between each feature vector in the third cluster set and the query vector.

[0188] It is understood that in this embodiment of the application, after the retrieval system obtains the target vector, it can output the original data corresponding to the target vector to the client.

[0189] For example, if the database is an image database, the retrieval system can output the original image data corresponding to the target vector to the client.

[0190] It is understandable that the above search method can be used to search one database in the retrieval system, or it can be used to search multiple databases in the retrieval system.

[0191] For example, when a retrieval system includes only one database, and a search method is used to search that database within the retrieval system, the retrieval system can perform operations on that database based on the query vector. Figure 5 The search method shown is used to obtain the search results output corresponding to the database. It can be understood that the search results can be the original data corresponding to the target vector of the query vector retrieved in the database.

[0192] When a retrieval system includes multiple databases, the retrieval system can perform the above operation on each of the multiple databases based on the query vector. Figure 5 The search method shown in the figure is used to obtain a search result corresponding to each database, and then all search results are output.

[0193] It is understandable that the input data acquired by the retrieval system and the output data determined by the retrieval system can have the same or different formats. The output data format is related to the data formats contained in the searched database. For example, if the data formats in the searched database include text, image, or video formats, then the output data format may also be text, image, or video.

[0194] For example, if the input data is in the format of an image, and the retrieval system includes a database in which all data is in the format of images, then the output data will also be in the format of an image.

[0195] For example, if a retrieval system includes a database, and the data in the database includes text, image, or video formats, then the data output by the retrieval system may be in text, image, or video format.

[0196] For example, if the retrieval system includes a first database, a second database, and a third database, and the data format in the first database includes text format, the data format in the second database includes image format, and the data format in the third database includes video format, then the data format output by the retrieval system may be text format, image format, or video format.

[0197] Figure 6 A schematic diagram of an index building apparatus according to an embodiment of this application is shown, such as... Figure 6 As shown, the index building apparatus includes:

[0198] The first determining unit is used to determine the target vector and the first cluster set in which the target vector belongs;

[0199] The second determining unit is used to determine at least one second cluster set that meets preset conditions from at least one other cluster set besides the first cluster set;

[0200] The association unit is used to establish an index association between the target vector and at least one of the second cluster sets.

[0201] Figure 7 A schematic diagram of a search device according to an embodiment of this application is shown, such as... Figure 7 As shown, the search device includes:

[0202] The first acquisition unit is used to acquire the query vector;

[0203] The second acquisition unit is used to acquire the distance between the query vector and the representative point corresponding to each cluster set in the database;

[0204] The first determining unit is used to determine the first representative point that is closest to the query vector, take the cluster set corresponding to the first corresponding point as the first cluster set of the first-level search, and determine the distance between each feature vector in the first cluster set and the query vector.

[0205] The second determining unit is used to determine, from other cluster sets besides the first cluster set, at least one cluster set that satisfies a preset condition in the first cluster set as the second cluster set for the second-level search, and to determine the distance between each feature vector in the second cluster set and the query vector;

[0206] The execution unit is configured to, when the number of searched cluster sets reaches a preset number, select the feature vectors of the first and second cluster sets that are searched and whose distance from the query vector is within a set range as the target vector corresponding to the query vector.

[0207] This application also includes a retrieval system, which may include the above-described index building device, and / or at least one database and / or search device. Figure 8 A schematic diagram of a retrieval system according to an embodiment of this application is shown. Figure 8 The retrieval system shown includes an index building device, a database, and a search device.

[0208] Figure 9 A block diagram of an electronic device according to an embodiment of this 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 network interface 1420 connected to the system control logic 1408.

[0209] In some embodiments, processor 1404 may include one or more single-core or multi-core processors. In some embodiments, processor 1404 may include any combination of general-purpose processors and special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In embodiments where electronic device 1400 employs eNB (Evolved Node B) 101 or RAN (Radio Access Network) controller 102, processor 1404 may be configured to perform various corresponding embodiments, such as... Figure 3 Or one or more of the multiple embodiments shown in 5.

[0210] In some embodiments, system control logic 1408 may include any suitable interface controller to provide any suitable interface to at least one of the processors 1404 and / or any suitable device or component communicating with system control logic 1408.

[0211] In some embodiments, system control logic 1408 may include one or more memory controllers to provide an interface to system memory 1412. System memory 1412 may be used to load and store data and / or instructions. In some embodiments, memory 1412 of electronic device 1400 may include any suitable volatile memory, such as suitable dynamic random access memory (DRAM).

[0212] 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 HDD (Hard Disk Drive), CD (Compact Disc) drive, and DVD (Digital Versatile Disc) drive.

[0213] NVM / Storage 1416 may include a portion of the storage resources on the device on which Electronics 1400 is installed, or it may be accessible by the device, but is not necessarily part of the device. For example, NVM / Storage 1416 may be accessed over a network via Network Interface 1420.

[0214] Specifically, system memory 1412 and NVM / memory 1416 may each include a temporary copy and a permanent copy of instruction 1424. Instruction 1424 may include, when executed by at least one of processors 1404, causing electronic device 1400 to perform, as Figure 3 Or the instructions of the method shown in Figure 5. In some embodiments, instructions 1424, hardware, firmware and / or their software components may additionally / alternatively be placed in system control logic 1408, network interface 1420 and / or processor 1404.

[0215] Network interface 1420 may include a transceiver for providing a radio interface to electronic device 1400, thereby enabling communication with any other suitable device (such as a front-end module, antenna, etc.) via one or more networks. In some embodiments, network interface 1420 may be integrated into other components of electronic device 1400. For example, network interface 1420 may be integrated into at least one of processor 1404, system memory 1412, NVM / memory 1416, and firmware device (not shown) with instructions that, when at least one of processor 1404 executes the instructions, electronic device 1400 implements as follows: Figure 3 Or the method shown in 5.

[0216] 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.

[0217] In one embodiment, at least one of the processors 1404 may be packaged together with the logic of one or more controllers for system control logic 1408 to form a system-in-package (SiP). In another embodiment, at least one of the processors 1404 may be integrated on the same die with the logic of one or more controllers for system control logic 1408 to form a system-on-a-chip (SoC).

[0218] The electronic device 1400 may further include an input / output (I / O) device 1432. The I / O device 1432 may include a user interface enabling a user to interact with the electronic device 1400; the peripheral component interface is designed to allow peripheral components to also interact with the electronic device 1400. In some embodiments, the electronic device 1400 may also include sensors for determining at least one type of environmental condition and location information related to the electronic device 1400.

[0219] In some embodiments, the user interface may include, but is not limited to, a display (e.g., a liquid crystal 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., a light-emitting diode flash), and a keyboard.

[0220] 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.

[0221] In some embodiments, the sensor may include, but is 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 the positioning network, such as Global Positioning System (GPS) satellites.

[0222] The embodiments disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including 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.

[0223] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the 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.

[0224] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0225] 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 thereon 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 via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, CD-ROMs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other propagation signals. Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.

[0226] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.

[0227] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.

[0228] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0229] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art will understand that various changes in form and detail may be made thereto without departing from the scope of this application.

Claims

1. An index construction method, characterized by, The method comprises the following steps: determining a target vector in a database and a first cluster set in which the target vector is located; determining at least one second cluster set meeting a first preset condition for the target vector from other cluster sets except the first cluster set; establishing an index association between the target vector and the second cluster set; The method comprises the following steps: obtaining distances between the target vector and representative points corresponding to each cluster set except the first cluster set; determining at least one second cluster set meeting the first preset condition for the target vector from the other cluster sets except the first cluster set according to the distances; The method comprises the following steps: obtaining an approximate radius of each cluster set except the first cluster set; obtaining a difference value between the distance and the approximate radius; determining a first sequence corresponding to the target vector from the other cluster sets except the first cluster set according to the difference value, and determining a set number of cluster sets in the first sequence as the second cluster set meeting the first preset condition, the set number being related to the size of the data amount of the database; The index association corresponding to each target vector in the database is used to determine a first-level search cluster set and a second-level search cluster set corresponding to a query vector, the first-level search cluster set being a cluster set corresponding to a representative point closest to the query vector in the database, and the second-level search cluster set being each cluster set except the first-level search cluster set in the database, and the cluster sets in a front set order in the sorting are sorted from more to less according to the number of feature vectors associated with the first-level search cluster set. The method comprises the following steps:

2. The method of claim 1, wherein, obtaining distances between the target vector and representative points corresponding to each cluster set; determining a cluster set in which the target vector is located as a cluster set corresponding to a representative point closest to the target vector in all cluster sets. The distance comprises a Euclidean distance and an inner product distance.

3. The method according to claim 1 or 2, characterized in that, The method comprises the following steps:

4. An index construction apparatus characterized by comprising: a first determining unit is configured to determine a target vector in a database and a first cluster set in which the target vector is located; a second determining unit is configured to determine at least one second cluster set meeting a first preset condition for the target vector from other cluster sets except the first cluster set; an association unit is configured to establish an index association between the target vector and the second cluster set; The method comprises the following steps: obtaining distances between the target vector and representative points corresponding to each cluster set except the first cluster set; ​ ​ According to the distance, at least one second cluster set meeting the first preset condition is determined for the target vector from other cluster sets except the first cluster set; The step of determining at least one second cluster set meeting the first preset condition for the target vector from other cluster sets except the first cluster set according to the distance comprises the steps of: Obtaining an approximate radius of each cluster set except the first cluster set; Obtaining a difference value between the distance and the approximate radius; According to the difference value, a first sequence corresponding to the target vector is determined from other cluster sets except the first cluster set, and a set number of cluster sets in the first sequence are determined as the second cluster sets meeting the first preset condition, the set number being related to the size of the data amount of the database; The indexes corresponding to each target vector in the database are used to determine the cluster set of the first-level search and the cluster set of the second-level search corresponding to the query vector, the cluster set of the first-level search being the cluster set corresponding to the representative point closest to the query vector in the database, and the cluster set of the second-level search being each cluster set except the cluster set of the first-level search in the database, and the cluster sets located in the front set order in the sorting according to the number of feature vectors associated with the cluster set of the first-level search from more to less.

5. A vector search method characterized by, The method comprises the steps of: Obtaining a query vector; Obtaining the distance between the query vector and the representative point corresponding to each cluster set in the database; Determining the first representative point closest to the query vector, and determining the cluster set corresponding to the first representative point as the first cluster set of the first-level search, and determining the distance between each feature vector in the first cluster set and the query vector; Determining at least one cluster set meeting the second preset condition from other cluster sets except the first cluster set as at least one second cluster set of the second-level search, the second cluster set being the cluster set located in the front set order in the sorting according to the number of feature vectors associated with the first cluster set from more to less in the other cluster sets, and determining the distance between each feature vector in the second cluster set and the query vector; When the number of searched cluster sets reaches a preset number, the feature vectors having a distance within a set range with the query vector among all feature vectors of the searched first cluster set and second cluster set are determined as the target vector corresponding to the query vector; The establishment mode of the association between the feature vectors in the first cluster set and other cluster sets except the first cluster set comprises the steps of: Based on the distance between the feature vectors in the first cluster set and the representative points corresponding to other cluster sets except the first cluster set; According to the distance, at least one cluster set meeting the first preset condition is determined for the feature vectors in the first cluster set from other cluster sets except the first cluster set. ​ ​ establishing the association between the feature vectors in the first cluster set and at least one cluster set meeting the first preset condition; the determining of the at least one cluster set meeting the first preset condition for the feature vectors in the first cluster set from other cluster sets except the first cluster set according to the distance comprises: obtaining an approximate radius of each cluster set except the first cluster set; obtaining a difference value between the distance and the approximate radius; determining a first sequence corresponding to the feature vectors in the first cluster set from other cluster sets except the first cluster set according to the difference value, and determining a set number of cluster sets in the first sequence as the cluster sets meeting the first preset condition, the set number being related to the size of the data amount of the database.

6. The method of claim 5, wherein, further comprising: when the number of searched cluster sets does not reach a preset number, determining a cluster set with the largest number of feature vectors associated with the second cluster set as a third cluster set to be searched. application to a database, comprising:

7. A search apparatus characterized by comprising: a first obtaining unit configured to obtain a query vector; a second obtaining unit configured to obtain a distance between the query vector and a representative point corresponding to each cluster set in the database; a first determining unit configured to determine a first representative point closest to the query vector, determine a cluster set corresponding to the first representative point as a first cluster set for first-level search, and determine a distance between each feature vector in the first cluster set and the query vector; a second determining unit configured to determine at least one cluster set meeting a second preset condition in association with the number of feature vectors in the first cluster set from other cluster sets except the first cluster set as a second cluster set for second-level search, and determine a distance between each feature vector in the second cluster set and the query vector, the second cluster set being a cluster set located in a front set number of cluster sets in the other cluster sets in descending order of the number of feature vectors associated with the first cluster set; a performing unit configured to, when the number of searched cluster sets reaches a preset number, determine, as target vectors corresponding to the query vector, feature vectors having a distance within a set range from the query vector among all feature vectors in the searched first cluster set and second cluster set. the establishment of the association between the feature vectors in the first cluster set and the other cluster sets except the first cluster set comprises: based on distances between the feature vectors in the first cluster set and representative points corresponding to each cluster set except the first cluster set; determining at least one cluster set meeting the first preset condition for the feature vectors in the first cluster set from other cluster sets except the first cluster set according to the distance; establishing the association between the feature vectors in the first cluster set and at least one cluster set meeting the first preset condition; ​ ​ ​ ​ The method comprises the following steps: obtaining the approximate radius of each cluster set other than the first cluster set; obtaining the difference between the distance and the approximate radius; determining, according to the difference, a first sequence corresponding to the feature vectors in the first cluster set from each cluster set other than the first cluster set, and determining a set number of cluster sets in the first sequence as the cluster sets satisfying the first preset condition, the set number being related to the size of the data amount of the database.

8. A retrieval system characterized by, The index construction device of claim 4 and / or the search device of claim 7.

9. An index structure, characterized by The index structure comprises representative point items and inverted file items; the representative point items comprise representative points corresponding to each cluster set in the database, and the inverted file items comprise inverted files corresponding to each cluster set; The inverted file comprises each feature vector in the cluster set corresponding to the inverted file, and second cluster set information of the each feature vector; The method for determining the second cluster set information of each feature vector comprises: obtaining the distance between each feature vector and the representative point corresponding to each cluster set other than the first cluster set; determining, according to the distance, at least one second cluster set satisfying the first preset condition for each feature vector from each cluster set other than the first cluster set; The method comprises the following steps: obtaining the approximate radius of each cluster set other than the first cluster set; obtaining the difference between the distance and the approximate radius; determining, according to the difference, a first sequence corresponding to the feature vectors in the first cluster set from each cluster set other than the first cluster set, and determining a set number of cluster sets in the first sequence as the cluster sets satisfying the first preset condition, the set number being related to the size of the data amount of the database. The index structure is used to determine the cluster set of the first-level search and the cluster set of the second-level search corresponding to a query vector, the cluster set of the first-level search is the cluster set corresponding to the representative point closest to the query vector in the database, and the cluster set of the second-level search is each cluster set other than the cluster set of the first-level search in the database, which is sorted from more to less according to the number of feature vectors associated with the cluster set of the first-level search, and the cluster set located in the front set order. The memory is configured to store instructions executed by one or more processors of an electronic device, and the processor is one of the one or more processors of the electronic device and is configured to execute the index construction method of any one of claims 1 to 3 or the vector search method of any one of claims 5 to 6.

10. An electronic device, comprising: ​ ​ 11. A readable medium characterized by The readable medium stores instructions which, when executed on the electronic device, cause the machine to perform the index construction method of any one of claims 1 to 3 or the vector search method of any one of claims 5 to 6.

12. A computer program product, characterised in that, instructions for implementing the index construction method of any one of claims 1 to 3 or the vector search method of any one of claims 5 to 6.

Citation Information

Patent Citations

  • Data storage method and device and data query method and device

    CN113297331A