Vector retrieval method, device, electronic device and storage medium
By extracting sample vectors and clustering clusters, the scope of vector retrieval is narrowed, the problem of low vector retrieval efficiency under massive data is solved, and efficient vector retrieval is achieved.
Patent Information
- Application Number
- CN202311489341.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2043-11-09
AI Technical Summary
In the case of massive data, traditional vector retrieval methods have high computational complexity, resulting in excessive delays and difficulty in meeting business timeliness requirements.
By extracting sample vectors from the vector database, determine their feature groups and cluster sets, determine the retrieval scope based on clusters and adjacent clusters, and narrow the retrieval scope to improve efficiency.
It significantly reduces the computational complexity of vector retrieval, improves retrieval efficiency, and can meet business timeliness requirements under large-scale data.
Smart Images

Figure CN117609285B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of vector retrieval, and in particular to a vector retrieval method, device, electronic device and storage medium. Background Art
[0002] In the AI era, information retrieval has become an important part of daily work and life, such as cloud disk file search, equity product recommendation, intelligent customer service Q&A and other fields. The development of technologies such as natural language processing has rapidly improved the processing capabilities of unstructured data such as text and images, and has also greatly promoted changes in the field of information retrieval. The traditional deterministic search algorithm based on keywords has been transformed into vector-based similarity retrieval, that is, in a given vector database, the target vector with the highest similarity (such as Euclidean distance, cosine similarity, Hamming distance and other metrics) with the vector to be searched is retrieved.
[0003] Traditional vector search methods include brute force search and some tree-based search methods, but in the case of massive data, the search efficiency drops sharply. In actual use scenarios, the Approximate Nearest Neighbor (ANN) algorithm is usually used.
[0004] According to the ANN vector retrieval implementation method, the common vector retrieval methods are mainly the following: vector retrieval method based on neighbor graph, method based on clustering and method based on space segmentation. However, when the data scale is large, the retrieval and matching operation for the full amount of vector data will sharply increase the computational complexity, resulting in excessive delay and difficulty in meeting the timeliness requirements of the business. Summary of the invention
[0005] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0006] To this end, the first purpose of this application is to propose a vector retrieval method to reduce the computational complexity of vector retrieval and improve retrieval efficiency when the vector data scale is large.
[0007] The second objective of this application is to provide a vector retrieval device.
[0008] The third objective of the present application is to provide an electronic device.
[0009] A fourth objective of the present application is to provide a computer-readable storage medium.
[0010] A fifth object of the present application is to provide a computer program product.
[0011] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a vector search method, including:
[0012] Extracting part of the first vector from the vector database as a sample vector, and determining the cluster sets of J feature groups corresponding to the sample vector, wherein J is a natural number greater than or equal to 1;
[0013] Determine J first feature groups of the first vector, and for each of the first feature groups, determine a first cluster and a first adjacent cluster to which the first vector belongs from a set of clusters corresponding to the first feature group, and determine a first search range corresponding to the first vector in each of the first feature groups according to the first cluster and the first adjacent cluster;
[0014] Determine J second feature groups of the second vector to be retrieved, and for each of the second feature groups, determine the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group;
[0015] Determine a second search range corresponding to a second vector in the second feature group according to a correspondence between the first vector in the first feature group and the first search range, and merge the second search ranges of J second feature groups to obtain a target search range;
[0016] According to the target search range, the second vector is searched in the vector database to obtain a similar vector set of the second vector.
[0017] Further, determining a first search range corresponding to the first vector in each of the first feature groups according to the first cluster and the first adjacent cluster includes:
[0018] The first cluster and the first adjacent cluster corresponding to the first cluster are merged as a first search range corresponding to the first vector in one of the first feature groups.
[0019] Further, the determining a second search range corresponding to the second vector in the second feature group includes:
[0020] The second cluster and a second adjacent cluster corresponding to the second cluster are merged as a second search range corresponding to the second vector in one of the second feature groups.
[0021] Further, determining a first search range corresponding to the first vector in each of the first feature groups according to the first cluster and the first adjacent cluster includes:
[0022] Obtaining a first dimension reduction vector of the first vector in the first feature group;
[0023] Acquire a first central area and a first edge area of the first cluster;
[0024] Determining region information where the first dimensionality reduction vector is located in the first cluster;
[0025] When the first dimension reduction vector is located in the first central area, the first central area is used as a first search range corresponding to the first vector in one of the first feature groups;
[0026] When the first dimension reduction vector is located in the first edge area, the first cluster and a first adjacent cluster corresponding to the first cluster are merged to obtain a first search range corresponding to the first vector in one of the first feature groups.
[0027] Further, the determining a second search range corresponding to the second vector in the second feature group includes:
[0028] Obtaining a second reduced dimension vector of the second vector in the second feature group;
[0029] Acquire a second central area and a second edge area of the second cluster;
[0030] Determining information about a region where the second dimensionality reduction vector is located in the second cluster;
[0031] When the second dimension reduction vector is located in the second central area, the second central area is used as a second search range corresponding to the second vector in one of the second feature groups;
[0032] When the second dimension reduction vector is located in the second edge area, the second clustering cluster and the second adjacent clustering cluster of the second clustering cluster are merged to obtain a second search range corresponding to the second vector in one of the second feature groups.
[0033] Further, determining a first search range corresponding to the first vector in each of the first feature groups according to the first cluster and the first adjacent cluster includes:
[0034] Obtaining a line connecting the center points of the first cluster and the first adjacent cluster;
[0035] Based on the center point connection line, determining a first center area, a first edge area, and a first bounded edge area of the first cluster, wherein the first bounded edge area is determined by a positional relationship between the first cluster and the first adjacent cluster;
[0036] Obtaining a second reduced dimension vector of the second vector in the second feature group;
[0037] Determine region information where the second dimension reduction vector is located in the second cluster, and determine a first search range corresponding to the first vector in each of the first feature groups based on the region information.
[0038] Further, the determining, based on the region information, a first search range corresponding to the first vector in each of the first feature groups includes:
[0039] When the first dimension reduction vector is located in the first central area, the first central area is used as a first search range corresponding to one of the first feature groups;
[0040] When the first dimension reduction vector is located in the first edge area, taking the first cluster as a first search range corresponding to one of the first feature groups;
[0041] When the first dimensionality reduction vector is located in the first bounded edge area, a first neighboring cluster retrieval area is determined in the first neighboring cluster based on the center point line and the perpendicular bisector of the center point line, and the first neighboring cluster retrieval area and the first cluster are merged to obtain a first retrieval range corresponding to one of the first feature groups.
[0042] Further, the determining a second search range corresponding to the second vector in the second feature group includes:
[0043] Obtaining a center point connection line between the second cluster and the second adjacent cluster;
[0044] Based on the center point connection line, determine a second center area, a second edge area, and a second bounded edge area of the second cluster, where the second bounded edge area is determined by a positional relationship between the second cluster and the second adjacent cluster;
[0045] Obtaining a second reduced dimension vector of the second vector in the second feature group;
[0046] Determine the region information where the second dimension reduction vector is located in the second cluster, and determine a second search range corresponding to the second vector in the second feature group based on the region information.
[0047] Further, the determining, based on the region information, a second search range corresponding to the second vector in the second feature group includes:
[0048] When the second dimension reduction vector is located in the second central area, the second central area is used as a second search range corresponding to one of the second feature groups;
[0049] When the second dimension reduction vector is located in the second edge area, taking the second cluster as a second search range corresponding to one of the second feature groups;
[0050] When the second dimensionality reduction vector is located in the second bounded edge area, a second neighboring cluster retrieval area is determined in the second neighboring cluster based on the center point line and the perpendicular bisector of the center point line, and the second neighboring cluster retrieval area and the second cluster are merged to obtain a second retrieval range corresponding to one of the second feature groups.
[0051] Furthermore, searching the second vector in the vector database according to the target search range to obtain a similar vector set of the second vector includes:
[0052] Calculating the similarity between the second vector and a third vector within the target search range;
[0053] Sorting the similarities in descending order to obtain a sorted third vector set;
[0054] A similar vector set of the second vector is obtained from the third vector set based on a preset requirement.
[0055] Further, determining J feature groups corresponding to the sample vectors includes:
[0056] Performing feature dimension reduction on the sample vector to obtain a sample dimension reduction vector;
[0057] Vector features of the sample dimensionality reduction vector are obtained, and feature grouping is performed based on the vector features to obtain J feature groups of the sample vector.
[0058] Furthermore, the determining of the cluster sets of the J feature groups corresponding to the sample vectors includes:
[0059] Adaptively cluster the sample dimension reduction vectors in each of the feature groups to obtain a plurality of clusters, and construct cluster sets for each of the J feature groups.
[0060] Further, for any one of the first vector and the second vector, determining the cluster to which the any one of the vector belongs includes:
[0061] Obtaining the center vectors of all clusters in the cluster set;
[0062] Calculate the center distance between any one of the vectors and the center vector;
[0063] Obtaining the cluster corresponding to the center vector with the smallest center distance as the cluster to which any one of the vectors belongs;
[0064] When any one of the vectors is a first vector, the cluster to which the any one of the vectors belongs is a first cluster; when any one of the vectors is a second vector, the cluster to which the any one of the vectors belongs is a second cluster.
[0065] Further, for any one of the first vector and the second vector, determining a neighboring cluster of the cluster to which the any one of the vector belongs includes:
[0066] Determine the cluster to which any vector belongs from the cluster set as the target cluster;
[0067] Constructing a center point connection line between the target cluster and other clusters in the cluster set;
[0068] Determine whether the midpoint of the center point connection line is located within the target cluster;
[0069] If so, determining that the cluster is a neighboring cluster of the target cluster;
[0070] Among them, when any one of the vectors is a first vector and the target cluster is a first cluster, the neighboring cluster of the target cluster is a first neighboring cluster; when any one of the vectors is a second vector and the target cluster is a second cluster, the neighboring cluster of the target cluster is a second neighboring cluster.
[0071] To achieve the above-mentioned purpose, the second aspect of the present application proposes a vector retrieval device, including a sample vector processing module, a first vector processing module, a second vector processing module, a retrieval range determination module and a vector retrieval module;
[0072] The sample vector processing module is used to extract part of the first vector from the vector database as the sample vector, and determine the cluster sets of J feature groups corresponding to the sample vector, where J is a natural number greater than or equal to 1;
[0073] The first vector processing module is used to determine J first feature groups of the first vector, and for each of the first feature groups, determine a first cluster and a first adjacent cluster to which the first vector belongs from a set of clusters corresponding to the first feature group, and determine a first search range corresponding to the first vector in each of the first feature groups according to the first cluster and the first adjacent cluster;
[0074] The second vector processing module is used to determine J second feature groups of the second vector to be retrieved, and for each of the second feature groups, determine the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group;
[0075] The search range determination module is used to determine the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merge the second search ranges of J second feature groups to obtain a target search range;
[0076] The vector search module is used to search the second vector in the vector database according to the target search range, and obtain a similar vector set of the second vector.
[0077] To achieve the above-mentioned purpose, the third aspect of the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0078] The memory stores computer-executable instructions;
[0079] The processor executes the computer-executable instructions stored in the memory to implement the above method.
[0080] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present application proposes a computer-readable storage medium, in which computer-readable storage medium is stored computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described above.
[0081] To achieve the above-mentioned purpose, the fifth aspect of the present application proposes a computer program product, including a computer program, which implements the above-mentioned method when executed by a processor.
[0082] The present application provides a vector search method, device, electronic device and storage medium, which extracts sample vectors from the full first vector to obtain feature groups of the sample vectors and cluster cluster sets corresponding to the feature groups, thereby determining the first feature group, the first cluster cluster and the first adjacent cluster cluster of the full first vector according to the feature group and the cluster cluster set, further obtaining the first search range, determining the second search range of the second vector to be searched according to the correspondence between the first vector and the first search range, and further determining the target search range of the second vector, thereby searching the second vector within the target search range to obtain a similar vector set. When the vector data scale is large, the setting of the present application can greatly reduce the computational complexity of vector search and improve the search efficiency.
[0083] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0085] Figure 1 A schematic diagram of a flow chart of a vector search method provided in an embodiment of the present application;
[0086] Figure 2 This is a flowchart of steps S201-S202 in a vector search method provided in an embodiment of the present application.
[0087] Figure 3 A schematic diagram of the positional relationship between a cluster and its adjacent clusters in a vector retrieval method provided in an embodiment of the present application.
[0088] Figure 4 This is a flowchart of steps S301-S303 in a vector search method provided in an embodiment of the present application.
[0089] Figure 5 This is a flowchart of steps S401-S404 in a vector search method provided in an embodiment of the present application.
[0090] Figure 6 This is a flowchart of steps S501-S503 in a vector search method provided in an embodiment of the present application.
[0091] Figure 7 A schematic diagram of dividing the central area and edge area of a cluster in a vector retrieval method provided in an embodiment of the present application.
[0092] Figure 8 This is a flowchart of steps S601-S604 in a vector search method provided in an embodiment of the present application.
[0093] Fig. 9 A schematic diagram of dividing a central area, an edge area, and a bounded edge area of a cluster in a vector retrieval method provided in an embodiment of the present application.
[0094] Fig.10 A schematic diagram of the structure of a vector retrieval device provided in an embodiment of the present application.
[0095] Description of reference numerals:
[0096] 1. Sample vector processing module; 2. First vector processing module; 3. Second vector processing module; 4. Search range determination module; 5. Vector search module. DETAILED DESCRIPTION
[0097] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0098] A vector retrieval method and device according to an embodiment of the present application will be described below with reference to the accompanying drawings.
[0099] Figure 1 A schematic diagram of a flow chart of a vector search method provided in an embodiment of the present application.
[0100] The present application embodiment discloses a vector search method, such as Figure 1 As shown, the method comprises the following steps:
[0101] Step S101: extract part of the first vectors from the vector database as sample vectors, and determine the cluster sets of J feature groups corresponding to the sample vectors, where J is a natural number greater than or equal to 1.
[0102] Since there are a large number of vectors in the vector database, if a search is performed in all vectors every time a vector search is needed, it will lead to high computational complexity and low efficiency.
[0103] Therefore, this embodiment extracts part of the first vectors from the vector database as sample vectors, and obtains feature grouping and clustering relationships of the sample vectors by analyzing the sample vectors, thereby obtaining feature grouping and clustering relationships of the full amount of first vectors.
[0104] Specifically, the first vector is obtained as follows:
[0105] Get the first vector from the vector database. Assuming the number of sample vectors is M and the dimension is N, the first vector can be expressed as:
[0106] v m =(v m,1 ,v m,2 ,…,v m,N )(1≤m≤M);
[0107] The sample vector is extracted as follows:
[0108] According to the preset rules (such as random sampling), D (D≤M) vectors are extracted from the full M first vectors as sample vectors, and the sample vectors are recorded as:
[0109]
[0110] Specifically, after obtaining the sample vector, the sample vector is processed to obtain the feature grouping of the sample vector and the corresponding cluster set, such as Figure 2 As shown, specifically including:
[0111] S201, perform feature dimensionality reduction on the sample vector to obtain a sample dimensionality reduction vector.
[0112] Among them, the sample vector is subjected to feature dimensionality reduction, that is, the high-dimensional feature vector in the sample vector is transformed into a low-dimensional vector through matrix transformation, which specifically includes:
[0113] 1. Get the mean vector: for the sample vector The mean vector is:
[0114]
[0115] 2. Obtain the projection matrix: remove the mean of the sample vector data, calculate the covariance matrix, and perform eigenvalue decomposition on it, extract the eigenvectors corresponding to the largest first L (N ≥ L) eigenvalues to construct the projection matrix P;
[0116] 3. Sample vector feature dimensionality reduction: Perform feature dimensionality reduction on the probe sample set data to obtain an L-dimensional vector, i.e., the sample dimensionality reduction vector:
[0117]
[0118] S202: Obtain vector features of the sample dimensionality reduction vector, perform feature grouping based on the vector features, and obtain J feature groups of the sample vector.
[0119] For the sample dimensionality reduction vector, the sample dimensionality reduction vector is feature grouped to divide the L-dimensional features in the sample vector into multiple groups, that is, to convert the high-dimensional vector into multiple parallel low-dimensional sub-vectors, as follows:
[0120] 1. Feature aggregation sorting: for sample dimensionality reduction vector The L vector features of , calculate the aggregation index (such as variance, etc.) in turn, recorded as θ l (1≤l≤L), and sort the vector features from large to small;
[0121] 2. Feature grouping: The vector features sorted by the degree of aggregation are grouped according to the preset rules. Each group does not overlap with each other. Let the number of groups be J and the number of features in each group be G. j , the corresponding vector feature number is The following conditions must be met:
[0122]
[0123] The first condition indicates that the sum of the number of features in each feature group is L, the second condition indicates that each feature group does not overlap, and the third condition indicates that all vector features participate in the grouping.
[0124] After segmentation, the sample low-dimensional vector in each feature group is:
[0125]
[0126] The function f1(x,y) means to filter out the subvectors whose element number set is y for the vector x.
[0127] So far, J feature groups for the sample vectors have been obtained by performing feature dimension reduction and feature grouping on the sample vectors.
[0128] After obtaining J feature groups corresponding to the sample vectors, since there are still many sample dimensionality reduction vectors in each feature group, in order to facilitate retrieval, this embodiment also performs adaptive clustering processing on the sample dimensionality reduction vectors in each feature group to obtain a cluster cluster set corresponding to each feature group.
[0129] The adaptive clustering processing method of this embodiment is to reduce the dimension vector of the samples after feature grouping. Adaptive clustering is performed to make the number of clusters in the more discrete feature groups larger, improving the granularity, while the number of clusters in the feature groups with better aggregation is smaller to save storage space. The cluster relationship within each feature group is further determined based on the adaptive clustering results, which specifically includes the following steps:
[0130] 1. Adaptive clustering: For each feature grouping, the number of K-means clustering clusters can be determined by using algorithms such as the silhouette coefficient method. Let the number of clusters for the Jth feature grouping be K j , the center vector of each cluster is Then given a sample dimensionality reduction vector The cluster number to which it belongs is:
[0131]
[0132] That is, the cluster to which the cluster center vector with the smallest distance belongs is selected as the cluster to which the sample dimensionality reduction vector belongs;
[0133] 2. Calculate the distance between cluster centers: For the Jth feature group, the distance d between the i-th cluster and the k-th cluster center vector in the group j,i,k for
[0134]
[0135] For sample dimensionality reduction vectors that are far apart in space, their distance can be represented by the distance between cluster centers.
[0136] 3. Determine the adjacent cluster set: Let the sample vector belonging to the i-th cluster of the J-th group be numbered H j,i , then the radius of the cluster to which the sample vector belongs is r j,i for
[0137]
[0138] Therefore, cluster C j,i It can be regarded as the center vector The radius is r j,i According to the relative positions of the clusters, the neighboring cluster sets of each cluster in the group are further determined, among which the neighboring cluster set E of the i-th cluster of the J-th group is j,i for:
[0139]
[0140] That is, the cluster set that satisfies the condition that half of the distance between the center vectors of adjacent clusters is less than the radius of the cluster is the neighboring cluster set of the cluster.
[0141] Figure 3 A schematic diagram showing the positional relationship between a cluster and its neighboring clusters is shown. Figure 3 As shown, there are four clusters C1, C2, C3 and C4, with points C1, C2, C3 and C4 as the center points of each cluster respectively. Line segments C1-C2, C1-C3 and C1-C4 are respectively connecting the center points of cluster C1 with the other three clusters. The dotted lines are the perpendicular bisectors of the corresponding line segments C1-C2, C1-C3 and C1-C4. The triangles represent the vector samples of the corresponding clusters. It can be seen that the perpendicular bisectors of line segment C1-C2 are both in clusters C1 and C2, which means that C1 and C2 are neighboring clusters; C1 and C4 do not have a neighboring cluster relationship; C3 is a neighboring cluster of C1, but C1 is not a neighboring cluster of C3, which further shows that the neighboring clusters are not symmetrical.
[0142] So far, through the settings of this embodiment, the feature dimensionality reduction, feature grouping and adaptive clustering of the sample vector have been completed, and J feature groups corresponding to the sample vector, the cluster cluster set corresponding to each feature group and the adjacent cluster set corresponding to each cluster cluster have been obtained, which can be used as the clustering standard for the subsequent full first vector to determine the J feature groups corresponding to the full first vector and the cluster clusters corresponding to each feature group. Therefore, when performing vector retrieval, the cluster cluster set and the adjacent cluster set to which the vector to be retrieved in each feature group belongs can be determined according to the characteristics of the vector to be retrieved, thereby narrowing the retrieval scope and improving the retrieval efficiency.
[0143] Step S102, determining J first feature groups of the first vector, and for each first feature group, determining the first cluster and the first adjacent cluster to which the first vector belongs from the cluster set corresponding to the first feature group, and determining the first search range corresponding to the first vector in each first feature group according to the first cluster and the first adjacent cluster;
[0144] According to the feature dimension reduction and feature grouping results of the sample vector, the first vector and the second vector to be retrieved are processed in the same way to obtain J first feature groups of the first vector and J second feature groups of the second vector.
[0145] Specifically, the specific steps of determining the J first feature groups of the first vector are as follows:
[0146] 1. Feature dimensionality reduction: extract the first vector v of the whole quantity m (1≤m≤M), remove the mean and project the first vector to obtain the first L-dimensional reduced vector of the first vector
[0147]
[0148] 2. Feature grouping: According to the feature grouping results of the sample vector, the first dimension reduction vector Divided into J groups of first dimensionality reduction vectors, that is, J first feature groups, the first dimensionality reduction vector contained in the jth first feature group for:
[0149]
[0150] That is, J first feature groups of the first vector are determined.
[0151] After the first feature grouping of the first vector is determined, for each first feature grouping, the first cluster corresponding to each first feature grouping of the first vector can be determined according to the cluster set corresponding to the sample vector.
[0152] It can be seen that after the above sample vectors are adaptively clustered, a cluster set of sample vectors is obtained, and the cluster set can be applied to all first vectors to determine the first cluster to which each first vector belongs. Figure 4 As shown, the specific steps include:
[0153] S301, obtaining the center vectors of all clusters in the cluster set;
[0154] S302, calculating the center distance between any vector and the center vector;
[0155] S303 , obtaining the cluster corresponding to the center vector with the smallest center distance as the cluster to which any vector belongs.
[0156] When any vector is a first vector, the cluster to which any vector belongs is a first cluster.
[0157] Specifically, first obtain the center vector of each cluster in the same first feature group, calculate the center distance between the first vector and all center vectors, and obtain the center vector corresponding to the shortest center distance, and according to the cluster to which the center vector belongs, take the cluster as the first cluster to which the first vector belongs.
[0158] The details are as follows:
[0159] Determine the first cluster to which the first vector belongs: for the first reduced dimension vector of the jth group The serial number w of the first cluster to which it belongs m,j for:
[0160]
[0161] That is, the cluster to which the central vector with the smallest cluster center distance belongs is selected as the first cluster of the first dimensionality reduction vector.
[0162] Furthermore, according to the method of determining the neighboring cluster set of the cluster cluster based on the sample vector, the first neighboring cluster cluster of the first cluster cluster is obtained. Figure 5 As shown, the specific steps include:
[0163] S401, determining one of the first clusters from the cluster set as a target cluster;
[0164] S402, constructing a center point connection line between the target cluster and other clusters in the cluster set;
[0165] S403, determining whether the midpoint of the center point connection line is located within the target cluster;
[0166] S404, if located, determining the cluster to be a neighboring cluster of the target cluster;
[0167] When any vector is a first vector and the target cluster is a first cluster, the neighboring cluster of the target cluster is a first neighboring cluster.
[0168] Specifically, a target cluster in the first cluster is first determined, and according to the center distance between the center points of the target cluster and other clusters, a neighboring cluster of the target cluster is determined as the first neighboring cluster.
[0169] So far, the J first feature groups, the first cluster within the first feature group, and the first adjacent cluster corresponding to the full first vector have been determined respectively through the J feature groups, the clusters within the feature groups, and the adjacent clusters corresponding to the sample vectors.
[0170] At this time, the first search range may be determined according to the first cluster and the first adjacent cluster, that is, if the vector to be searched is in the first cluster, the first cluster and the first adjacent cluster may be combined as the first search range.
[0171] Specifically, the method for obtaining the vector index numbers in the first cluster and the first adjacent cluster is as follows:
[0172] According to the adaptive clustering results of the sample vectors, we can know the first cluster to which the first dimension reduction vector in each first feature group of each first vector belongs. Let the set of all vector index numbers in the i-th first cluster in the j-th first feature group be S j,i (1≤j≤J,1≤i≤K j ), and define the vector index number set in the first neighbor cluster but:
[0173]
[0174] Where f2(x,y) represents the cosine similarity calculation.
[0175] Step S103 : determining J second feature groups of the second vector to be retrieved, and for each second feature group, determining the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group.
[0176] In this embodiment, according to the feature dimension reduction and feature grouping results of the sample vector, the second vector is also subjected to feature dimension reduction and feature grouping, as follows:
[0177] 1. Feature dimensionality reduction: According to the feature dimensionality reduction method of the sample vector, extract the N-dimensional second vector X to be searched, remove the mean and project the vector to obtain the L-dimensional second dimensionality reduction vector
[0178]
[0179] 2. Feature grouping: According to the feature grouping method of the sample vector, the second dimensionality reduction vector is divided into J second feature groups, each of which includes multiple second dimensionality reduction vectors. Then the j-th group of sub-vectors is:
[0180]
[0181] It can be seen from steps S301-S303 that when any vector is a second vector, the cluster to which any vector belongs is a second cluster. According to steps S301-S303, the second cluster corresponding to the second dimension reduction vector can be determined, as follows:
[0182] Determine the second cluster: the second dimension reduction vector for the jth second feature grouping The serial number of the second cluster to which it belongs for
[0183]
[0184] That is, the cluster to which the central vector with the smallest cluster center distance belongs is selected as the second cluster of the second dimensionality reduction vector.
[0185] It can be known from steps S401 to S404 that when any vector is the second vector and the target cluster is the second cluster, the neighboring cluster of the target cluster is the second neighboring cluster.
[0186] Specifically, firstly, a target cluster in the second cluster is determined, and according to the center distance between the center points of the target cluster and other clusters, a neighboring cluster of the target cluster is determined as the second neighboring cluster.
[0187] So far, J second feature groups, second clusters within the second feature groups, and second adjacent clusters corresponding to the second vector to be retrieved have been determined respectively through the J feature groups, clusters within the feature groups, and adjacent clusters corresponding to the sample vectors.
[0188] Step S104, determining the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merging the second search ranges of the J second feature groups to obtain a target search range.
[0189] It can be seen that if the vector to be searched is in the second cluster, the second cluster and the second adjacent cluster corresponding to the second cluster can be merged according to the correspondence between the first vector and the first search range as the second search range of the second vector in one of the second feature groups.
[0190] It is worth mentioning that in this embodiment, the sample feature grouping, the first feature grouping and the second feature grouping have the same definition, and the sample clustering in the sample feature grouping and the first clustering in the first feature grouping have the same definition, but they are named separately for the convenience of distinction in this embodiment.
[0191] The purpose of this embodiment is to perform feature dimensionality reduction and feature grouping on the second vector to be retrieved, and according to the second clustering cluster in which the second dimensionality reduction vector in each feature group is located, the second clustering cluster is regarded as the first clustering cluster, and the first search range of the second vector in the first clustering cluster is obtained, and the first search range can be used as the second search range of the second vector.
[0192] The method for obtaining the vector index sequence number set in the second neighbor cluster is as follows:
[0193] According to the adaptive clustering result of the sample vector, the second cluster to which the second reduced dimensionality vector in the second feature group corresponding to the second vector to be retrieved belongs is obtained. If the second reduced dimensionality vector of the jth second feature group is located in the ith second cluster, then the vector index number set F in the second adjacent cluster to be searched is determined. j :
[0194]
[0195] Where f2(x,y) represents the cosine similarity calculation.
[0196] So far, this embodiment has determined the second search range of the second vector to be searched in each second feature group. Therefore, the second search ranges in all second feature groups are combined to determine the target search range of the second vector in all second feature groups.
[0197] It can be understood that the target search range here is obtained by analyzing the second clustering cluster where each second dimensionality reduction vector corresponding to the second vector is located.
[0198] The specific formula for obtaining the target search range is as follows:
[0199] 1. Determine the second search range of each second feature group: Determine the second search range of each feature group according to the second clustering cluster and the second adjacent clustering cluster where the second dimension reduction vector of the second vector to be searched is located. Suppose the vector sequence number set of the jth (1≤j≤J) group is μ j , then μ j For S j,i and The union of
[0200] 2. Determine the target search range: The second search range of all second feature groups is taken as the union, which is the target search range of the overall vector.
[0201] Step S105 : searching the second vector in the vector database according to the target search range to obtain a set of similar vectors to the second vector.
[0202] After determining the target search range of the second vector to be searched, the second vector can be searched in the target search range, such as Figure 6 As shown, the specific steps include:
[0203] S501, calculating the similarity between the second vector and the third vector within the target search range;
[0204] S502, sorting the similarities in descending order to obtain a sorted third vector set;
[0205] S503: Acquire a similar vector set of the second vector from the third vector set based on priority sorting and preset requirements.
[0206] Specifically, the similarity ρ between the second vector and all third vectors within the target search range is calculated based on the relative space approximation, then
[0207]
[0208] in,
[0209]
[0210] The calculated similarities are sorted from small to large to obtain a sorted third vector set, from which a similar vector set can be selected according to preset requirements, such as quantity requirements or similarity threshold requirements.
[0211] In addition, in similarity retrieval, Euclidean distance, cosine similarity and other methods are usually used for measurement. Suppose vector A = {a1, a2, ..., a N} and B={b1,b2,…,b N}, N is the vector length, then the Euclidean distance and cosine similarity calculation formulas are:
[0212]
[0213] When vectors A and B are both normalized vectors, the Euclidean distance and cosine similarity have the following relationship:
[0214]
[0215] That is, there is a monotonic mapping relationship between cosine similarity and Euclidean distance. In information retrieval scenarios in natural language processing fields such as large language models, the vector expression obtained by embedding coding is usually a normalized probability vector or a normalized vector. Therefore, this embodiment is also applicable to information retrieval scenarios using cosine similarity as a metric.
[0216] It is worth mentioning that if the clusters of low-dimensional vectors of all vectors are used as category mappings when calculating vector similarity, that is, using d j,i,k Approximate distance calculation can further speed up the retrieval efficiency and occupy less space. For example, for the 1536-dimensional vector obtained by the GPT-XX model of XX company, when stored using 32-bit floating point numbers, a single vector occupies 6144 bytes. If the dimension is first reduced to 128 features and each group of 8 features is grouped, there are 16 groups. Each group is assumed to be clustered into 256 clusters (8 bits) on average, then the space occupied is 16 bytes, which can reduce the storage space of a single vector sample by 99.7%.
[0217] This embodiment provides another vector retrieval method. Figure 7 This is a schematic diagram of dividing the central area and edge area of a cluster in a vector retrieval method of this embodiment. Figure 7 This embodiment is described.
[0218] The difference between the embodiment of the present application and the above-mentioned embodiment is that, in the present embodiment, according to the specific situation of the first cluster, such as the number of vectors, the size of the cluster and other information, the first cluster is divided into a central area and an edge area to obtain a first central area and a first edge area.
[0219] like Figure 7 As shown, in the first cluster C1, the solid circular line is the edge line of the first cluster C1, and the radius of the first central area is determined, that is, C1 can be taken as the center of the circle, and a dotted circular line can be drawn according to the radius to divide the first central area and the first edge area. Among them, the area inside the dotted circular line is the first central area of the first cluster C1, and the annular area between the dotted circular line and the solid circular line is the first edge area of the first cluster C1.
[0220] Based on this, in this embodiment, taking any first vector as an example, when in one of the first feature groups, the first dimensionality reduction vector of the first vector is located in the first central area of one of the first clusters, the first central area of the first cluster can be used as the first search range of the first vector; when the first dimensionality reduction vector of the first vector is located in the first edge area of one of the first clusters, the first cluster and the first adjacent cluster corresponding to the first cluster can be merged as the first search range of the first vector.
[0221] Step S104, determining the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merging the second search ranges of the J second feature groups to obtain a target search range.
[0222] Firstly, a second reduced dimension vector after the dimension reduction of the second vector is determined, and a second search range is determined according to the regional division of the second cluster where the second reduced dimension vector is located in each feature group.
[0223] Similarly, after the first cluster corresponding to the first vector is divided into regions, the region division information of the second cluster can be determined, thereby determining the second central region and the second edge region of the second cluster.
[0224] Specifically, the second reduced dimensionality vector of the second vector in each second feature grouping is obtained, and the regional information of the second reduced dimensionality vector in the second cluster cluster is determined. When the second reduced dimensionality vector of the second vector in one of the second feature groups is located in the second central area of one of the second cluster clusters, the second central area of the second cluster cluster can be used as the second search range of the second vector; when the second reduced dimensionality vector of the second vector is located in the second edge area of two of the second cluster clusters, the second cluster cluster and the second adjacent cluster clusters corresponding to the second cluster cluster can be merged as the second search range of the second vector.
[0225] So far, this embodiment has determined the second search range corresponding to the second vector to be searched in each second feature group, and all the second search ranges in J second feature groups are combined to obtain the target search range.
[0226] The description of other parts of this embodiment is the same as that of the above embodiment, so it will not be repeated here.
[0227] This embodiment provides another vector retrieval method.
[0228] When the vector to be searched is restricted to the same cluster and adjacent clusters, searching within the cluster to which the vector at the edge of the cluster belongs will reduce the search accuracy; while if all adjacent clusters are included in the search range, there is still a large amount of calculation.
[0229] In order to solve the above problem, the embodiment of the present application is different from the above embodiment in that, in the present embodiment, a bounded edge area of the cluster is further set.
[0230] like Figure 8 As shown, according to the first cluster and the first adjacent cluster, determining the first search range corresponding to the first vector in each first feature group includes:
[0231] S601, obtaining a center point connection line between a first cluster and a first adjacent cluster;
[0232] S602: Determine a first central region, a first edge region, and a first bounded edge region of a first cluster based on a central point connection line, wherein the first bounded edge region is determined by a positional relationship between the first cluster and a first adjacent cluster;
[0233] S603, obtaining a second dimension reduction vector of the second vector in the second feature group;
[0234] S604: Determine region information where the second dimension reduction vector is located in the second cluster, and determine a first search range corresponding to the first vector in each first feature group based on the region information.
[0235] First, determine the center point line between the first cluster and the first adjacent cluster, and determine the perpendicular bisector of the center point line. Divide the first cluster into regions according to the center point line and the perpendicular bisector to obtain the first center region, the first edge region and the first bounded edge region of the first cluster. The first center region refers to the region close to the center of the first cluster, and the first vector in this region has a high similarity to the center vector; the first edge region refers to the annular region in the first cluster excluding the first center region; the first bounded edge region refers to the region in the first edge region that is close to the first adjacent cluster.
[0236] Similar to the above embodiment, a first reduced dimension vector of the first vector in the first feature group is obtained, and a first search range of the first vector in the first feature group is determined according to the region information of the first reduced dimension vector in the first cluster.
[0237] For the convenience of explanation, Fig. 9 A schematic diagram showing the division of the central area, edge area and bounded edge area of the clusters.
[0238] like Fig. 9 As shown, taking the two-dimensional plane space as an example, clusters C1 and C2 are adjacent clusters to each other, and line segment AB is the perpendicular bisector of the line connecting the center points of the clusters. At the same time, a circle (circular dotted line) is drawn with C1 as the center and is tangent to line segment AB (for the convenience of explanation, the circular dotted line area is tangent to line segment AB. In other embodiments, the central area of the clusters can be specified according to actual conditions, and this application does not impose any restrictions on this). The area within the circular dotted line is regarded as the central area of cluster C1; the circular ring area formed by the circular dotted line and the edge line of cluster C1 is the edge area; the area where the edge area overlaps with triangle ABC1 is the bounded edge area.
[0239] It is worth mentioning that when a cluster has a bounded edge region, the edge region of the cluster is modified from the annular region to the remaining part of the annular region without the bounded edge region, so as to distinguish the edge region from the bounded edge region, that is, Figure 8 The incomplete annular area above triangle ABC1.
[0240] It can be understood that the round particles and the triangular particles are samples within the C1 cluster, wherein the round particles are located in the central area and the edge area of the cluster C1, the triangular particles are located in the bounded edge area of the cluster C1, and the square particles and the diamond particles are samples within the C2 cluster.
[0241] Specifically, when the vector to be retrieved is located in the bounded edge area of C1, that is, the area where the triangular particles are located, in this embodiment, the search range of the vector to be retrieved is further extended from cluster C1 to the opposite area of the adjacent cluster C2 (the overlapping area between cluster C2 and triangle ABC2), that is, the adjacent cluster search range, that is, the area where the square particles are located.
[0242] In this embodiment, according to the region where the first dimension reduction vector is located in the first cluster, the first search range of the first vector in the first feature group is determined in a targeted manner. The specific determination rule of the first search range is as follows:
[0243] 1. When the first dimension reduction vector is located in the first central area, the first central area is used as the first search range of the first feature group;
[0244] 2. When the first dimension reduction vector is located in the first edge region, the first cluster is used as the first search range for grouping the first feature;
[0245] 3. When the first dimension reduction vector is located in the first bounded edge region, the first neighboring cluster search region is determined in the first neighboring cluster based on the center point connection line and the median perpendicular line ( Fig. 9 The overlapping area between the edge line of cluster C2 and triangle ABC2), the first adjacent cluster search area and the first cluster are merged to obtain the first search range of the first feature grouping.
[0246] This embodiment adopts dynamic bounded range calibration according to the relative positions of adjacent clusters, which can effectively narrow the search range, thereby balancing the search efficiency and accuracy.
[0247] So far, this embodiment has obtained the J first feature groups to which all the first vectors belong, the first cluster in each first feature group, the first adjacent cluster of each first cluster, and the region where each first reduced dimensionality vector is located in the first cluster. Therefore, it is only necessary to perform feature grouping and adaptive clustering on the second vector to be retrieved in the same way to determine the feature group, cluster and region where the second reduced dimensionality vector is located in the cluster, thereby determining the second search range.
[0248] Step S104, determining the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merging the second search ranges of the J second feature groups to obtain a target search range.
[0249] In each second feature grouping, firstly, the second cluster corresponding to the second vector is determined, and then the region where the second reduced-dimensionality vector is located in the second clustering is determined, and then the second search range in each feature grouping can be determined.
[0250] By the above Fig. 9 From the description of determining the central region, edge region, and bounded edge region of a cluster, it can be seen that by establishing a line connecting the centers of a cluster and an adjacent cluster and a perpendicular bisector of the line connecting the centers, the central region, edge region, and bounded edge region of the cluster can be divided. Similarly, by establishing a line connecting the centers of a second cluster and a second adjacent cluster and a perpendicular bisector of the line connecting the centers, the second central region, second edge region, and second bounded edge region in the second cluster can be determined.
[0251] Furthermore, after determining the region in the second cluster where the second reduced dimension vector corresponding to the second vector to be searched is located, the second search range can be determined according to the correspondence between the first reduced dimension vector and the first search range. The specific correspondence is as follows:
[0252] 1. When the second dimension reduction vector is located in the second central area, the second central area is used as the second search range of the second feature group;
[0253] 2. When the second dimension reduction vector is located in the second edge region, the second cluster is used as the second search range of the second feature grouping;
[0254] 3. When the second dimension reduction vector is located in the second bounded edge area, a second neighboring search area is determined in the second neighboring cluster based on the center point line and the perpendicular bisector, and the second neighboring search area and the second cluster are merged to obtain a second search range of the second feature grouping.
[0255] So far, this embodiment has determined the second search range corresponding to the second vector to be searched in each second feature group, and all the second search ranges in J second feature groups are combined to obtain the target search range.
[0256] The description of other parts of this embodiment is the same as that of the above embodiment, so it will not be repeated here.
[0257] In order to implement the above embodiment, the present application also proposes a vector retrieval device.
[0258] Fig.10 A schematic diagram of the structure of a vector search device provided in an embodiment of the present application.
[0259] like Fig.10 As shown, the device includes a sample vector processing module 1, a first vector processing module 2, a second vector processing module 3, a search range determination module 4 and a vector search module 5;
[0260] The sample vector processing module 1 is used to extract part of the first vector from the vector database as the sample vector, and determine the cluster sets of the J feature groups corresponding to the sample vector, where J is a natural number greater than or equal to 1;
[0261] The first vector processing module 2 is used to determine J first feature groups of the first vector, and for each first feature group, determine the first cluster and the first adjacent cluster to which the first vector belongs from the cluster set corresponding to the first feature group, and determine the first search range corresponding to the first vector in each first feature group according to the first cluster and the first adjacent cluster;
[0262] The second vector processing module 3 is used to determine J second feature groups of the second vector to be retrieved, and for each second feature group, determine the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group;
[0263] The search range determination module 4 is used to determine the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merge the second search ranges of J second feature groups to obtain a target search range;
[0264] The vector search module 5 is used to search the second vector in the vector database according to the target search range, and obtain a set of similar vectors of the second vector.
[0265] It should be noted that the above explanation of the vector retrieval method embodiment is also applicable to the vector retrieval device of this embodiment, and will not be repeated here.
[0266] In order to implement the above embodiments, the present application also proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.
[0267] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.
[0268] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which implements the methods provided by the above embodiments when executed by a processor.
[0269] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0270] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.
[0271] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.
[0272] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0273] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0274] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0275] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0276] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0277] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0278] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0279] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A vector retrieval method, characterized in that: include: Extracting part of the first vector from the vector database as a sample vector, and determining the cluster sets of J feature groups corresponding to the sample vector, wherein J is a natural number greater than or equal to 1; Determine J first feature groups of the first vector, and for each of the first feature groups, determine a first cluster and a first adjacent cluster to which the first vector belongs from a set of clusters corresponding to the first feature group; Obtaining a first dimension reduction vector of the first vector in the first feature group; Acquire a first central area and a first edge area of the first cluster; When the first dimension reduction vector is located in the first central area, the first central area is used as a first search range corresponding to the first vector in the first feature group; When the first dimension reduction vector is located in the first edge area, merging the first cluster and a first adjacent cluster corresponding to the first cluster to obtain a first search range corresponding to the first vector in the first feature group; Determine J second feature groups of the second vector to be retrieved, and for each of the second feature groups, determine the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group; Determine a second search range corresponding to a second vector in the second feature group according to a correspondence between the first vector in the first feature group and the first search range, and merge the second search ranges of J second feature groups to obtain a target search range; According to the target search range, the second vector is searched in the vector database to obtain a similar vector set of the second vector.
2. A vector search method according to claim 1, characterized in that: The determining, according to the first cluster and the first adjacent cluster, a first search range corresponding to the first vector in each of the first feature groups includes: The first cluster and the first adjacent cluster corresponding to the first cluster are merged as a first search range corresponding to the first vector in one of the first feature groups.
3. A vector retrieval method according to claim 2, characterized in that: The determining a second search range corresponding to the second vector in the second feature group includes: The second cluster and a second adjacent cluster corresponding to the second cluster are merged as a second search range corresponding to the second vector in one of the second feature groups.
4. The vector retrieval method according to claim 1, characterized in that: The determining a second search range corresponding to the second vector in the second feature group includes: Obtaining a second reduced dimension vector of the second vector in the second feature group; Acquire a second central area and a second edge area of the second cluster; Determine the region information where the second dimension reduction vector is located in the second cluster, and determine a second search range corresponding to the second vector in the second feature group based on the region information.
5. The vector retrieval method according to claim 4, characterized in that: The determining, based on the region information, a second search range corresponding to the second vector in the second feature group includes: When the second dimension reduction vector is located in the second central area, the second central area is used as a second search range corresponding to the second vector in one of the second feature groups; When the second dimension reduction vector is located in the second edge area, the second clustering cluster and the second adjacent clustering cluster of the second clustering cluster are merged to obtain a second search range corresponding to the second vector in one of the second feature groups.
6. A vector search method according to claim 1, characterized in that: The determining, according to the first cluster and the first adjacent cluster, a first search range corresponding to the first vector in each of the first feature groups includes: Obtaining a line connecting the center points of the first cluster and the first adjacent cluster; Based on the center point connection line, determining a first center area, a first edge area, and a first bounded edge area of the first cluster, wherein the first bounded edge area is determined by a positional relationship between the first cluster and the first adjacent cluster; Obtaining a second reduced dimension vector of the second vector in the second feature group; Determine region information where the second dimension reduction vector is located in the second cluster, and determine a first search range corresponding to the first vector in each of the first feature groups based on the region information.
7. A vector search method according to claim 6, characterized in that: The determining, based on the region information, a first search range corresponding to the first vector in each of the first feature groups comprises: When the first dimension reduction vector is located in the first central area, the first central area is used as a first search range corresponding to one of the first feature groups; When the first dimension reduction vector is located in the first edge area, taking the first cluster as a first search range corresponding to one of the first feature groups; When the first dimensionality reduction vector is located in the first bounded edge area, a first neighboring cluster retrieval area is determined in the first neighboring cluster based on the center point line and the perpendicular bisector of the center point line, and the first neighboring cluster retrieval area and the first cluster are merged to obtain a first retrieval range corresponding to one of the first feature groups.
8. The vector retrieval method according to claim 6, characterized in that: The determining a second search range corresponding to the second vector in the second feature group includes: Obtaining a line connecting the center points of the second cluster and the second adjacent cluster; Based on the center point connection line, determine a second center area, a second edge area, and a second bounded edge area of the second cluster, where the second bounded edge area is determined by a positional relationship between the second cluster and the second adjacent cluster; Obtaining a second reduced dimension vector of the second vector in the second feature group; Determine the region information where the second dimension reduction vector is located in the second cluster, and determine a second search range corresponding to the second vector in the second feature group based on the region information.
9. The vector retrieval method according to claim 8, characterized in that: The determining, based on the region information, a second search range corresponding to the second vector in the second feature group includes: When the second dimension reduction vector is located in the second central area, the second central area is used as a second search range corresponding to one of the second feature groups; When the second dimension reduction vector is located in the second edge area, taking the second cluster as a second search range corresponding to one of the second feature groups; When the second dimensionality reduction vector is located in the second bounded edge area, a second neighboring cluster retrieval area is determined in the second neighboring cluster based on the center point line and the perpendicular bisector of the center point line, and the second neighboring cluster retrieval area and the second cluster are merged to obtain a second retrieval range corresponding to one of the second feature groups.
10. The vector search method according to claim 1, characterized in that: The step of searching the second vector in the vector database according to the target search range to obtain a set of similar vectors of the second vector includes: Calculating the similarity between the second vector and a third vector within the target search range; Sorting the similarities in descending order to obtain a sorted third vector set; A similar vector set of the second vector is obtained from the third vector set based on the sorting and preset requirements.
11. The vector search method according to claim 1, characterized in that: Determining J feature groups corresponding to the sample vectors includes: Performing feature dimension reduction on the sample vector to obtain a sample dimension reduction vector; Vector features of the sample dimensionality reduction vector are obtained, and feature grouping is performed based on the vector features to obtain J feature groups of the sample vector.
12. The vector search method according to claim 11, characterized in that: The determining of the cluster sets of the J feature groups corresponding to the sample vectors includes: Adaptively cluster the sample dimension reduction vectors in each of the feature groups to obtain a plurality of clusters, and construct cluster sets for each of the J feature groups.
13. The vector search method according to claim 1, characterized in that: For any one of the first vector and the second vector, determining a cluster to which the any one of the vector belongs includes: Obtaining the center vectors of all clusters in the cluster set; Calculate the center distance between any one of the vectors and the center vector; Obtaining the cluster corresponding to the center vector with the smallest center distance as the cluster to which any one of the vectors belongs; When any one of the vectors is a first vector, the cluster to which the any one of the vectors belongs is a first cluster; when any one of the vectors is a second vector, the cluster to which the any one of the vectors belongs is a second cluster.
14. The vector search method according to claim 13, characterized in that: For any one of the first vector and the second vector, determining a neighboring cluster of the cluster to which the any one of the vector belongs includes: Determine the cluster to which any vector belongs from the cluster set as the target cluster; Constructing a center point connection line between the target cluster and other clusters in the cluster set; Determine whether the midpoint of the center point connection line is located within the target cluster; If so, determining that the cluster is a neighboring cluster of the target cluster; Among them, when any one of the vectors is a first vector and the target cluster is a first cluster, the neighboring cluster of the target cluster is a first neighboring cluster; when any one of the vectors is a second vector and the target cluster is a second cluster, the neighboring cluster of the target cluster is a second neighboring cluster.
15. A vector search device, characterized in that: It includes a sample vector processing module, a first vector processing module, a second vector processing module, a search range determination module and a vector search module; The sample vector processing module is used to extract part of the first vector from the vector database as the sample vector, and determine the cluster sets of J feature groups corresponding to the sample vector, wherein J is a natural number greater than or equal to 1; The first vector processing module is used to determine J first feature groups of the first vector, and for each of the first feature groups, determine a first cluster and a first adjacent cluster to which the first vector belongs from a set of clusters corresponding to the first feature group; Obtaining a first dimension reduction vector of the first vector in the first feature group; Acquire a first central area and a first edge area of the first cluster; When the first dimension reduction vector is located in the first central area, the first central area is used as a first search range corresponding to the first vector in the first feature group; When the first dimension reduction vector is located in the first edge area, merging the first cluster and a first adjacent cluster corresponding to the first cluster to obtain a first search range corresponding to the first vector in the first feature group; The second vector processing module is used to determine J second feature groups of the second vector to be retrieved, and for each of the second feature groups, determine the second cluster and the second adjacent cluster to which the second vector belongs from the cluster set corresponding to the second feature group; The search range determination module is used to determine the second search range corresponding to the second vector in the second feature group according to the correspondence between the first vector in the first feature group and the first search range, and merge the second search ranges of J second feature groups to obtain a target search range; The vector search module is used to search the second vector in the vector database according to the target search range to obtain a similar vector set of the second vector.
16. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 14 when executed by a processor.
18. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 14 when being executed by a processor.
