A method and system for maximum inner product search of high-dimensional sparse data with adaptive clustering

By optimizing adaptive clustering and MinHash index, the problems of high computational cost and high latency in maximum inner product search for high-dimensional sparse data are solved, achieving efficient candidate generation and accurate inner product verification. It is suitable for business scenarios such as large-scale e-commerce product retrieval, short video recommendation and ad matching.

CN123178684APending Publication Date: 2026-11-27NORTHEASTERN UNIV CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611391267.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-09
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing maximum inner product search methods for high-dimensional sparse data face challenges in terms of computational cost and efficiency. In particular, the full linear scan of traditional methods leads to a sharp increase in computational cost as the data size increases, making it difficult to meet the millisecond-level response requirements of online business. Furthermore, existing solutions suffer from problems such as loss of numerical precision due to binary encoding, uneven load due to fixed window partitioning, and difficulty in adapting global pruning thresholds to skewed data distribution.

Method used

We employ a high-dimensional sparse data maximum inner product search method using adaptive clustering. This method optimizes candidate verification overhead and balances retrieval accuracy and query efficiency by using low-frequency dimension weighting, spherical clustering routing, and adaptive candidate size control for clusters. This includes IDF-weighted adaptive SOS encoding, cosine similarity clustering, MinHash index structure, and adaptive candidate generation for clusters.

Benefits of technology

It effectively reduces the size of candidate verification, lowers online query latency, adapts to large-scale real-world retrieval scenarios, improves retrieval efficiency and resource utilization, and meets the low latency requirements of online business.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178684A_ABST
    Figure CN123178684A_ABST
Patent Text Reader

Abstract

The application discloses a high-dimensional sparse data maximum inner product search method and system based on adaptive clustering, and belongs to the technical field of information retrieval and data processing. In view of the problems of low frequency dimension differentiation and insufficient expression of low frequency dimension, dimension frequency information is introduced in the coding stage to strengthen the expression of high differentiation features in the candidate generation stage. In view of the problem that the global sketch is weak in adapting to the local data distribution, vectors with similar directions are organized through spherical clustering, and a boundary overflow mechanism is used to avoid candidate omission caused by hard partition. In view of the problem that the density of local candidates is uneven and the unified control mode has high redundancy, a cluster adaptive candidate strategy is designed, and the number of MinHash signatures and the candidate budget are adjusted according to the cluster size. The candidate verification overhead is compressed, the retrieval accuracy and query efficiency are balanced, the large-scale actual retrieval scene is adapted, and the problems of losing numerical precision in binary coding, causing uneven load due to fixed window division, and being difficult to adapt to data skewed distribution due to global pruning threshold are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information retrieval and data processing technology, and in particular relates to a method and system for searching the maximum inner product of high-dimensional sparse data using adaptive clustering. Background Technology

[0002] With the widespread adoption of large language models and retrieval enhancement generation technologies, intelligent retrieval systems have been widely applied in practical business scenarios such as e-commerce product retrieval, short video recommendation, ad matching, and enterprise knowledge base question answering. Existing solutions typically employ neural sparse retrieval models, mapping text, user behavior, or material descriptions into high-dimensional sparse vectors with tens of thousands of dimensions, and matching the most semantically relevant results through Maximum Inner Product Search (MIPS). However, traditional methods often employ a full linear scan, and their computational cost increases dramatically with the data scale. A single query may involve millions of inner product operations, making it difficult to meet the millisecond-level response requirements of online businesses. Therefore, the industry focuses on Approximate Maximum Inner Product Search (AMIPS), seeking a trade-off between accuracy and efficiency.

[0003] The existing technical solutions mainly include the following two types: Solution 1: Zhao et al. proposed the SOSIA scheme. This method first maps the original vectors to a binary space through a sparse-to-set (SOS) transformation, allowing the overlap of the binary sets to estimate the size of the inner product between the original vectors. Then, it constructs an index structure based on minimum hashing (MinHash), quickly filtering candidate sets during queries through hash collisions. Finally, it calculates the exact inner product of the candidate vectors and returns the Top-order vectors. result.

[0004] Option 2: Li et al. proposed the SINDI scheme, an inverted index method for sparse vectors. This scheme has three core optimizations: using single-instruction multiple-data stream technology to batch calculate non-zero elements, improving the speed of inner product operations; building an inverted index according to fixed dimension intervals, reading only the query-related dimensions, reducing memory overhead; and estimating the upper limit of the inner product based on the vector magnitude, filtering low-matching vectors in advance, reducing redundant and precise calculations.

[0005] However, the SOSIA scheme described by Zhao et al. uses the SOS transformation to compress real-valued weights into binary activation states. The specific values ​​of each vector are lost after the transformation, and only the positional information of the non-zero dimensions is retained. Since high-frequency dimensions appear frequently in different vectors, they are prone to causing concentrated hash collisions. A large number of vectors that collide only because they share high-frequency dimensions are mixed into the candidate set. It is necessary to calculate the exact inner product of each vector to exclude them, which increases the index size and query latency.

[0006] The SINDI scheme described by Li et al. divides dimensional intervals using fixed windows. When the data distribution is skewed, some windows become access hotspots, while the remaining windows have low utilization, resulting in uneven load distribution. Its modulus pruning is based on calculating the upper bound of the inner product using the product of vector moduli, which is unrelated to the actual dimensional overlap, resulting in limited compression effect. Furthermore, the global threshold needs to be optimized for each dataset, leading to high adaptation costs. Summary of the Invention

[0007] To address the shortcomings of existing technologies, this invention proposes a method and system for searching the maximum inner product of high-dimensional sparse data using adaptive clustering. By using low-frequency dimension weighting, spherical clustering routing, and adaptive candidate size control of clusters, it effectively compresses candidate verification overhead, balances retrieval accuracy and query efficiency, and adapts to various large-scale real-world retrieval scenarios. This solves problems in existing solutions such as loss of numerical precision due to binary encoding, uneven load caused by fixed window partitioning, and difficulty in adapting global pruning thresholds to skewed data distribution.

[0008] The technical solution of this invention is as follows: On the one hand, this invention provides a method for searching the maximum inner product of high-dimensional sparse data in adaptive clustering, comprising the following steps: Obtain the original sparse dataset Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata .

[0009] Using cosine similarity as a metric, the original sparse dataset The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata .

[0010] According to the size of each extended cluster Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. .

[0011] Use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. ; Based on MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. .

[0012] For the global candidate set Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

[0013] Furthermore, the acquisition of the original sparse dataset Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata Specifically, it includes: A1: Obtain the original sparse dataset .

[0014] The original sparse dataset , including several data vectors and query vector The data vector is a vector obtained by encoding the document content, and the query vector is a vector obtained by encoding the query content. This is the number of the data vector.

[0015] A2: Traverse the original sparse dataset Calculate the document frequency in each non-zero dimension of the data vector. Then, the original IDF weights for each non-zero dimension are calculated. .

[0016] The document frequency Defined as the number of data vectors that take non-zero values ​​in this non-zero dimension: (1); in, The numbering for non-zero dimensions. A set of non-zero dimensions representing a data vector.

[0017] By document frequency Calculate the original IDF weights for each non-zero dimension : (2); in, For the original sparse dataset Total number of data vectors in the middle.

[0018] A3: Adjust the original IDF weights Linear mapping to a preset IDF weight range The normalized dimension weights are obtained. Then, according to the normalized dimension weights Determine the unfold length of each non-zero dimension. Assign to each non-zero dimension Each binary encoding slot.

[0019] The process of the linear mapping is as follows: (3); in, and These are the lower and upper bounds of the preset IDF weight interval, respectively; The numbering for non-zero dimensions. The number of non-zero dimensions. It is a very small positive number.

[0020] The method for calculating the unfolded length is as follows: (4); in, Based on the foundation, and These are the lower and upper bounds of the unfolded length, respectively.

[0021] A4: For each data vector With probability For each non-zero dimension Each binary encoding slot undergoes independent Bernoulli sampling to determine whether it is active. If active, the binary encoding slot has a value of 1; if inactive, it has a value of 0, thus obtaining the binary code. For data vectors The Middle The values ​​can be taken in a non-zero dimension.

[0022] A5: Concatenate all binary codes of each non-zero dimension to obtain the normalized dimension weights. It is unfolded into a binary sequence, generating slot prefix positions for each non-zero dimension. And add it before the corresponding non-zero dimension binary sequence, then add the position with the slot prefix. Concatenate all non-zero dimension binary sequences to generate a binary code set. .

[0023] A6: Based on the normalized dimension weights Slot prefix position and the unfolded length of each non-zero dimension Generate encoded metadata and the original sparse dataset Save separately.

[0024] Furthermore, the original sparse dataset is measured using cosine similarity. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata Specifically, it includes: B1: From the original sparse dataset Selected from The data vectors, after L2 normalization, are used as the initial cluster centers. , This is the cluster center number.

[0025] B2: For each data vector Calculate its relationship with the current cluster centers. cosine similarity , each data vector Assign to the primary cluster of the cluster center with the highest cosine similarity. .

[0026] B3: For each primary cluster Calculate the mean vector of all data vectors in the main cluster and update the cluster center. Repeat B2 and B3 until the cluster center no longer changes or the preset number of iterations is reached, then execute B4.

[0027] B4: Record the current data vector Its main cluster center cosine similarity Set boundary overflow factor For each data vector Calculate its relationship with each non-cluster center. cosine similarity If satisfied This indicates that it is not the main cluster center. The corresponding primary cluster is the data vector. Clusters that are directionally close are called neighbor clusters, which are data vectors Add it to the neighboring cluster as a boundary sample, and then iterate through all the data vectors. Then, each primary cluster, together with all the boundary samples added to it, constitutes an extended cluster. Output clustering metadata .

[0028] The primary cluster center is the cluster center of the primary cluster to which the data vector belongs, and the non-primary cluster center is a cluster center other than the cluster center of the primary cluster to which the data vector belongs.

[0029] Furthermore, the description of the size of each extended cluster... Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. Specifically, it includes the following steps: C1: For each extended cluster The size of the extended cluster is obtained by counting the number of data vectors it contains. Based on the preset baseline number of MinHash functions and expanding cluster size Determine the number of MinHash functions for each extended cluster. .

[0030] (5); in, The number of MinHash functions is the baseline.

[0031] C2: For extended clusters Each data vector within According to its binary encoding set use A separate MinHash function Calculate the MinHash signature For each MinHash function Build a bucket And will expand the cluster Each data vector within Store the number in the corresponding bucket. In the middle, output the MinHash index structure. , This is the number of the MinHash function.

[0032] Furthermore, the use of encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. Specifically, it includes the following steps: D1: Using encoded metadata For the current query vector input Perform IDF weighted SOS encoding to generate query binary encoding. .

[0033] D2: Read clustering metadata Calculate the current query vector Cluster centers of each extended cluster cosine similarity .

[0034] D3: Cosine similarity Sort from highest to lowest, and select the top results with the highest cosine similarity. The extended cluster numbers corresponding to each cluster center constitute the active cluster set. .

[0035] Furthermore, the MinHash-based index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. This includes the following steps: E1: For the set of active clusters Each active extended cluster Initialize the collision counter and read the MinHash index structure. Use the extended cluster in sequence MinHash function Calculate the query binary code MinHash signature, access the corresponding bucket The numbers of all data vectors in the dataset are used to accumulate the MinHash collision count for each data vector.

[0036] E2: Based on the number of MinHash collisions Arrange the data vectors within the expanded cluster from highest to lowest order, and extract the candidate budgets before ranking. The data vectors are used as local candidate subsets of the extended cluster. The candidate budget is based on a preset candidate retention ratio. It has been confirmed.

[0037] E3: Merge local candidate subsets of all activated clusters, and remove duplicates to form a global candidate set. .

[0038] On the other hand, the present invention also provides a high-dimensional sparse data maximum inner product search system for adaptive clustering, used to implement a high-dimensional sparse data maximum inner product search method for adaptive clustering, including: The encoding module is used to obtain the original sparse dataset. Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata .

[0039] The clustering module is used to cluster the original sparse dataset using cosine similarity as a metric. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata .

[0040] The index structure building module is used to build the index according to the size of each extended cluster. Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. .

[0041] Activation module, used to use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. .

[0042] Candidate generation module, used for MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. .

[0043] The results output module is used to process the global candidate set. Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

[0044] Thirdly, this application proposes an electronic device comprising: one or more processors, and a memory for storing instructions that, when executed by the one or more processors, cause the one or more processors to perform the adaptive clustering high-dimensional sparse data maximum inner product search method.

[0045] Fourthly, this application proposes a computer-readable storage medium storing executable instructions that, when executed, cause a processor to perform the adaptive clustering high-dimensional sparse data maximum inner product search method.

[0046] Fifthly, this application proposes a computer program product, including a computer program or instructions that, when executed by a processor, implement the aforementioned adaptive clustering method for searching the maximum inner product of high-dimensional sparse data.

[0047] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention uses sketch candidate generation and original inner product verification as its core framework. To address the issues of low discriminative power in high-frequency dimensions and insufficient representation in low-frequency dimensions, dimensional frequency information is introduced during the encoding stage to enhance the representation of high-discriminative features in the candidate generation stage. To address the weak ability of global sketches to adapt to local data distributions, spherical clustering is used to organize vectors with similar orientations, and a boundary overflow mechanism is employed to avoid candidate omissions caused by hard partitioning. To address the issues of uneven local candidate density and high redundancy in the unified control method, a cluster-adaptive candidate strategy is designed, adjusting the number of MinHash signatures and the candidate budget according to the cluster size. In the query stage, active expanded clusters are first located, then a local candidate set is generated, and finally, the true inner product is calculated and the Top-order result is returned. result.

[0048] The aforementioned improvement strategies work synergistically in the candidate generation process, effectively compressing the candidate size in the precise inner product verification stage and controlling online query latency to the millisecond level. After the offline index is built, the online stage only involves lightweight MinHash bucket access and a small amount of inner product calculation, which is suitable for large-scale real-world retrieval scenarios where the index is relatively stable, response latency requirements are high, and resource consumption is sensitive. Attached Figure Description

[0049] Figure 1 This is a schematic diagram of the overall architecture of an adaptive clustering method for searching the maximum inner product of high-dimensional sparse data according to an embodiment of the present invention.

[0050] Figure 2 This is a flowchart of the IDF-weighted adaptive SOS coding process according to an embodiment of the present invention.

[0051] Figure 3 This is a flowchart of spherical K-means clustering and boundary overflow in an embodiment of the present invention.

[0052] Figure 4 This is a flowchart illustrating the cluster adaptive MinHash index construction process in an embodiment of the present invention.

[0053] Figure 5 This is a flowchart of the online query processing according to an embodiment of the present invention. Detailed Implementation

[0054] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0055] Example 1: A maximum inner product search method for high-dimensional sparse data in adaptive clustering, such as... Figure 1 As shown, the core process comprises three stages: offline index building, composite index storage, and online query processing. Specifically, it includes the following steps: Step 1: Obtain the original sparse dataset Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata .

[0056] like Figure 2 As shown, the specific steps include the following: Step 1.1: Obtain the original sparse dataset .

[0057] The original sparse dataset , including several data vectors and query vector The data vector is a vector obtained by encoding the document content, and the query vector is a vector obtained by encoding the query content. This is the number of the data vector.

[0058] In this embodiment, the SPLADE-1M public sparse vector dataset is selected. This dataset originates from the MS MARCO v1 text corpus and is generated by the SPLADE neural sparse retrieval model, containing 1 million (document) data vectors. and 6,980 query vectors The vector dimension is 30,109, (document) data vector The average number of non-zero elements is approximately 126.3, and the query vector... The average number of non-zero elements is approximately 49.1, and the original sparse dataset is stored in Compressed Sparse Row (CSR) format. .

[0059] Step 1.2: Traverse the original sparse dataset Calculate the document frequency in each non-zero dimension of the data vector. Then, the original IDF weights for each non-zero dimension are calculated. .

[0060] The document frequency Defined as the number of data vectors that take non-zero values ​​in this non-zero dimension: (1); in, The numbering for non-zero dimensions. A set of non-zero dimensions representing a data vector.

[0061] By document frequency Calculate the original IDF weights for each non-zero dimension : (2); in, For the original sparse dataset Total number of data vectors in the middle.

[0062] Step 1.3: Adjust the original IDF weights Linear mapping to a preset IDF weight range The normalized dimension weights are obtained. Then, according to the normalized dimension weights Determine the unfold length of each non-zero dimension. Assign to each non-zero dimension Each binary encoding slot.

[0063] The process of the linear mapping is as follows: (3); in, and These are the lower and upper bounds of the preset IDF weight interval, used to control the range of change in dimension weights and ensure that high-frequency dimensions retain basic expressive strength. The numbering for non-zero dimensions. The number of non-zero dimensions. It should be a very small positive number to prevent the denominator from being zero.

[0064] The method for calculating the unfolded length is as follows: (4); in, Based on the foundation, and These are the lower and upper bounds of the unfolded length, respectively.

[0065] Step 1.4: For each data vector With probability For each non-zero dimension Each binary encoding slot undergoes independent Bernoulli sampling to determine whether it is active. If active, the binary encoding slot has a value of 1; if inactive, it has a value of 0, thus obtaining the binary code. For data vectors The Middle The values ​​can be taken in a non-zero dimension.

[0066] Step 1.5: Concatenate all binary codes of each non-zero dimension to obtain the normalized dimension weights. It is unfolded into a binary sequence, generating slot prefix positions for each non-zero dimension. And add it before the corresponding non-zero dimension binary sequence, then add the position with the slot prefix. Concatenate all non-zero dimension binary sequences to generate a binary code set. .

[0067] Step 1.6: Based on the normalized dimension weights Slot prefix position and the unfolded length of each non-zero dimension Generate encoded metadata and the original sparse dataset Save separately.

[0068] Step 2: Use cosine similarity as a metric to analyze the original sparse dataset. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata .

[0069] like Figure 3 As shown, the specific steps include the following: Step 2.1: From the original sparse dataset Selected from The data vectors, after L2 normalization, are used as the initial cluster centers. , This is the cluster center number.

[0070] Step 2.2: For each data vector Calculate its relationship with the current cluster centers. cosine similarity , each data vector Assign to the primary cluster of the cluster center with the highest cosine similarity. .

[0071] Step 2.3: For each primary cluster Calculate the mean vector of all data vectors in the main cluster and update the cluster center. Repeat steps 2.2 and 2.3 until the cluster center no longer changes or the preset number of iterations is reached, and then execute step 2.4.

[0072] Step 2.4: Record the current data vector Its main cluster center cosine similarity Set boundary overflow factor For each data vector Calculate its relationship with each non-cluster center. cosine similarity If satisfied This indicates that it is not the main cluster center. The corresponding primary cluster is the data vector. Clusters that are directionally close are called neighbor clusters, which are data vectors Add it to the neighboring cluster as a boundary sample, and then iterate through all the data vectors. Then, each primary cluster, together with all the boundary samples added to it, constitutes an extended cluster. Output clustering metadata .

[0073] The primary cluster center is the cluster center of the primary cluster to which the data vector belongs, and the non-primary cluster center is a cluster center other than the cluster center of the primary cluster to which the data vector belongs.

[0074] Step 3: According to the size of each extended cluster Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. .

[0075] like Figure 4 As shown, the specific steps include the following: Step 3.1: For each extended cluster The size of the extended cluster is obtained by counting the number of data vectors it contains. Based on the preset baseline number of MinHash functions and expanding cluster size Determine the number of MinHash functions for each extended cluster. .

[0076] (5); in, The base MinHash function count refers to a global hyperparameter that users manually pre-set and configure before index building, based on the dataset size, accuracy requirements, and query throughput needs. This parameter does not automatically adjust with changes in the expanded clusters, but rather serves as the base number for subsequent adaptive cluster calculations. The average cluster size under ideal uniform partitioning.

[0077] In this embodiment, =170 is the default value selected after conducting parameter sensitivity experiments on the SPLADE-1M dataset. In practical applications, users can flexibly configure it within the range of 100~250.

[0078] Step 3.2: For the extended cluster Each data vector within According to its binary encoding set use A separate MinHash function Calculate the MinHash signature For each MinHash function Build a bucket And will expand the cluster Each data vector within Store the number in the corresponding bucket. In the middle, output the MinHash index structure. , This is the number of the MinHash function.

[0079] Step 4: Use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. .

[0080] like Figure 5 As shown, the specific steps include the following: Step 4.1: Use encoded metadata For the current query vector input Perform IDF weighted SOS encoding to generate query binary encoding. .

[0081] Step 4.2: Read clustering metadata Calculate the current query vector Cluster centers of each extended cluster cosine similarity .

[0082] Step 4.3: Calculate the cosine similarity. Sort from highest to lowest, and select the top results with the highest cosine similarity. The extended cluster numbers corresponding to each cluster center constitute the active cluster set. .

[0083] Step 5: Based on the MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. .

[0084] like Figure 5 As shown, the specific steps include the following: Step 5.1: Activate the cluster set Each active extended cluster Initialize the collision counter and read the MinHash index structure. Use the extended cluster in sequence MinHash function Calculate the query binary code MinHash signature, access the corresponding bucket The numbers of all data vectors in the dataset are used to accumulate the MinHash collision count for each data vector.

[0085] Step 5.2: Calculate by MinHash collision count Arrange the data vectors within the expanded cluster from highest to lowest order, and extract the candidate budgets before ranking. The data vectors are used as local candidate subsets of the extended cluster. .

[0086] The candidate budget is based on a preset candidate retention ratio. It has been confirmed.

[0087] Step 5.3: Merge the local candidate subsets of all activated clusters and remove duplicates to form the global candidate set. .

[0088] Step 6: Process the global candidate set Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

[0089] Step 6.1: Process the global candidate set Each data vector in Scan the non-zero dimensions of the intersection of the current query vector and the data vector, and calculate the exact inner product for each non-zero dimension set of the intersection of the current query vector and the data vector. .

[0090] Step 6.2: Sort the data vectors from largest to smallest according to their exact inner product values, and output the first... A data vector is returned as the result. .

[0091] This invention was experimentally verified on the publicly available SPLADE-1M sparse vector dataset. The experimental environment was as follows: the operating system was Ubuntu 22.04 LTS, the server was equipped with two Intel Xeon Gold 6348 processors, 128GB of RAM, and two NVIDIA RTX 3090 GPUs, and the implementation was based on C++17. The test dataset was obtained by encoding the MS MARCO v1 corpus using the SPLADE model, containing 1 million data vectors with an original dimension of 30109. The average number of non-zero terms in the data vectors was approximately 126.3, and the average number of non-zero terms in the query vectors was approximately 49.1.

[0092] The experiment used Recall@50 as the accuracy metric, with the Top-50 accurate results obtained from a full linear scan as the true benchmark; Query throughput (Queries Per Second, QPS) was used as the efficiency metric to evaluate the system's processing capacity per unit time; and average number of validations, index building time, and index memory usage were used as overhead metrics. Specific parameter settings are shown in Table 1.

[0093] Table 1. Main parameter settings for embodiments of the present invention;

[0094] Example 2: The offline index construction and query process of one embodiment of the present invention is as follows, taking the SPLADE-1M dataset as an example for illustration, and the parameters are selected as the default configuration in Table 1.

[0095] This embodiment completes the entire offline index building process in approximately 171.4 seconds, including approximately 0.1 seconds for IDF statistics, approximately 61.9 seconds for spherical K-means clustering, approximately 82.7 seconds for MinHash signature calculation, and approximately 26.7 seconds for boundary overflow and bucket construction; the total storage usage is approximately 1.48GB, of which the original CSR vector... Approximately 0.94GB, MinHash index structure Approximately 0.38GB, encoding and clustering metadata Approximately 0.16GB in size.

[0096] In terms of query performance, the average processing time for a single query is approximately 1.4ms, corresponding to a query throughput of approximately 737 (Recall@50=0.95). The time consumption distribution for each stage is as follows: query encoding and cluster routing approximately 0.05ms (3.6%), local collision statistics approximately 1.05ms (75.0%), candidate merging and deduplication approximately 0.05ms (3.6%), and original inner product verification approximately 0.25ms (17.9%). The main computational bottleneck is concentrated in the MinHash bucket access and collision statistics stages. Original inner product verification, due to the effective control of the candidate size within the tens of thousands, has an average verification count of approximately 15.4k under the baseline configuration, and its computational cost is significantly lower than linear scanning. When the recall target is increased to 0.97, the average verification count increases to approximately 18.6k, and the query throughput is approximately 545; when the recall target is increased to 0.99, the average verification count is approximately 27.3k, and the query throughput is approximately 432.

[0097] To support a wide range of values ​​for the parameters of this invention, this section provides four additional embodiments based on Embodiment 1. All of these embodiments are based on the SPLADE-1M dataset, and only the corresponding parameters are adjusted while keeping other parameters consistent with Embodiment 1.

[0098] Example 3 ( and Configuration): In this embodiment, The value was changed from 15 to 10. The number of probe clusters was increased from 5 to 8. Increasing the number of probe clusters increased the number of accessed local regions from 5 to 8, raising the data coverage from approximately 33% to approximately 53%. With this configuration, Recall@50 is approximately 0.98, query throughput is approximately 490, and the average number of validations is approximately 23.1k. If using... =25、 =3, Recall@50 is approximately 0.94, query throughput is approximately 1050, and average validation count is approximately 10.5k; if =32、 =5, Recall@50 is about 0.91, query throughput is about 1280, and average number of validations is about 7.9k. In 5~32, It functions normally within a range of 1 to 15; a smaller value can be selected when pursuing recall. With larger When pursuing throughput, a larger capacity can be selected. With smaller .

[0099] Example 4 ( and Configuration): In this embodiment, The value was adjusted from 0.03 to 0.05. The budget was adjusted from 0.8 to 0.6. Increasing the candidate budget increased the number of validation candidates in each active cluster by approximately 67%. (Increasing from approximately 2400 to approximately 4000), after lowering the boundary overflow factor, the overflow judgment criteria are relaxed, and the average cluster size increases by approximately 25%. Under this configuration, Recall@50 is approximately 0.98, query throughput is approximately 380, and the average number of validations is approximately 35.2k. If using... =0.01、 =1.2, Recall@50 is about 0.92, query throughput is about 1100, and average number of validations is about 7.8k. In the range of 0.01 to 0.10, Within the range of 0.5 to 1.5, the verification scale and boundary coverage can be effectively controlled collaboratively.

[0100] Example 5 (IDF weight interval) Configuration): In this embodiment, the IDF weight range is adjusted from [0.5, 3.0] to [1.0, 2.5]. Narrowing the range reduces the difference in dimensionality representation but improves encoding stability. With this configuration, Recall@50 is approximately 0.955, query throughput is approximately 720, and the average number of validations is approximately 15.8k. If [0.3, 1.5] is used, Recall@50 is approximately 0.89; if a uniform weight of [1.0, 1.0] is used (degenerating to standard SOS), Recall@50 is approximately 0.945. The IDF weight range of [0.3, 4.0] works normally.

[0101] Example 6 (Baseline MinHash Function Count) Configuration): In this embodiment, The value was adjusted from 170 to 120. Reducing the hash function slightly decreases collision statistics stability, but reduces the overhead of MinHash signature calculation and bucket access. With this configuration, Recall@50 is approximately 0.95, query throughput is approximately 780, and the average number of verifications is approximately 16.8k. =220, Recall@50 is approximately 0.968, query throughput is approximately 600, and average validation count is approximately 18.5k; if =100, Recall@50 is approximately 0.934, query throughput is approximately 820, and average number of validations is approximately 17.2k. It can work effectively in the range of 100 to 250.

[0102] The above embodiments demonstrate that the main parameters of the present invention ( , , , IDF weight range , When the values ​​are selected from the range listed in Table 1, the system functions normally and achieves good retrieval results (recall rate 0.89~0.98, query throughput approximately 380~1300). This invention has the following outstanding beneficial effects: (1) The retrieval efficiency is improved by an order of magnitude, meeting the online millisecond response requirements. Under the baseline configuration, the average latency of a single query is only 1.4ms, and the query throughput reaches 737, which is more than 15 times higher than the full linear scan; under the high throughput configuration, the throughput can reach 1280, which can stably carry the peak traffic of high-concurrency businesses such as e-commerce recommendation and advertising matching, improving user experience and system carrying capacity.

[0103] (2) The candidate verification scale is compressed to the extreme, and the computing power and energy consumption are significantly reduced. When Recall@50=0.95, the average number of verifications is only 15.4k. Compared with the millions of calculations of full scan, the amount of computing power is reduced by more than 98% under the baseline configuration. The compression of the candidate scale directly reduces the CPU floating-point operation and memory access volume, the processor energy consumption decreases simultaneously, the long-tail latency of the system is more controllable, a single server can carry higher concurrency, and the deployment cost is significantly reduced.

[0104] (3) Accuracy and efficiency are smoothly adjustable and highly adaptable to different scenarios. By using multiple parameters such as the number of clusters, the number of probe clusters, and the candidate budget, a continuous trade-off between recall and throughput can be achieved without complex tuning for each dataset. The cluster adaptive mechanism can automatically match the data distribution of different clusters and adapt to diverse business scenarios, from high-precision knowledge base question answering to high-throughput product retrieval.

[0105] (4) High hardware utilization and easy engineering implementation. Clustering routing reduces global random memory access and improves CPU cache hit rate; the offline index occupies only 1.48GB, which can be deployed on ordinary commercial servers; the index construction supports parallel processing throughout the entire process, and the full construction of millions of vectors takes only about 3 minutes; the online stage only involves lightweight MinHash bucket access and sparse inner product calculation, with no complex dependencies, and can be seamlessly embedded into existing retrieval systems with low operation and maintenance costs.

[0106] In summary, this invention effectively addresses the core pain points of high computational cost, high latency, and poor adaptability in the maximum inner product search of high-dimensional sparse vectors. While ensuring retrieval accuracy, it significantly improves efficiency and reduces resource consumption. It is particularly suitable for large-scale, low-latency business scenarios such as e-commerce product retrieval, short video recommendation, ad matching, and enterprise knowledge base question answering. Relying on offline indexes, it ensures stable online retrieval performance, demonstrating outstanding value in engineering implementation and commercial applications.

[0107] Example 7: A maximum inner product search system for high-dimensional sparse data in adaptive clustering is provided to implement a maximum inner product search method for high-dimensional sparse data in adaptive clustering, comprising: The encoding module is used to obtain the original sparse dataset. Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata .

[0108] The clustering module is used to cluster the original sparse dataset using cosine similarity as a metric. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata .

[0109] The index structure building module is used to build the index according to the size of each extended cluster. Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. .

[0110] Activation module, used to use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. .

[0111] Candidate generation module, used for MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. .

[0112] The results output module is used to process the global candidate set. Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

[0113] Example 8: This embodiment proposes an electronic device, including: one or more processors, and a memory, wherein the memory is used to store instructions, and when the instructions are executed by the one or more processors, the one or more processors perform the adaptive clustering high-dimensional sparse data maximum inner product search method.

[0114] The electronic device may be a mobile phone, computer, or tablet computer, etc., and includes a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements a high-dimensional sparse data maximum inner product search method for adaptive clustering as described in the embodiments. It is understood that the electronic device may also include input / output (I / O) interfaces and communication components.

[0115] The processor is used to execute all or part of the steps in the adaptive clustering high-dimensional sparse data maximum inner product search method as described in the above embodiments. The memory is used to store various types of data, which may include, for example, instructions for any application or method in an electronic device, as well as application-related data.

[0116] The processor can be implemented as an Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), controller, microcontroller, microprocessor, or other electronic components, and is used to execute the high-dimensional sparse data maximum inner product search method for adaptive clustering described in the above embodiments.

[0117] Example 9: This embodiment proposes a computer-readable storage medium that stores executable instructions. When these instructions are executed, if they are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.

[0118] The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the adaptive clustering high-dimensional sparse data maximum inner product search method described in various embodiments of this application.

[0119] The aforementioned storage media include: flash memory, hard disks, multimedia cards, card-type memory (e.g., SD (Secure Digital Memory Card) or DX (Memory Data Register, MDR) memory), random access memory (RAM), static random-access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, disks, optical discs, servers, APP (Application) application stores, and other media capable of storing program verification codes. These media store computer programs, which, when executed by a processor, can implement the various steps of the aforementioned adaptive clustering high-dimensional sparse data maximum inner product search method.

[0120] Example 10: This embodiment proposes a computer program product, including a computer program or instructions, which, when executed by a processor, implements the aforementioned adaptive clustering method for searching the maximum inner product of high-dimensional sparse data.

[0121] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a computer program product.

[0122] The various embodiments in this application are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0123] The scope of protection of this application is not limited to the embodiments described above. Obviously, those skilled in the art can make various modifications and variations to this disclosure without departing from the scope and spirit of this disclosure. If such modifications and variations fall within the scope of this disclosure and its equivalents, then the intent of this disclosure also includes these modifications and variations.

Claims

1. A method for maximum inner product search in high-dimensional sparse data using adaptive clustering, characterized in that, Includes the following steps: Obtain the original sparse dataset Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata ; Using cosine similarity as a metric, the original sparse dataset The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata ; According to the size of each extended cluster Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. ; Use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. ; Based on MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. ; For the global candidate set Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

2. The adaptive clustering method for searching the maximum inner product of high-dimensional sparse data according to claim 1, characterized in that, The acquisition of the original sparse dataset Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata Specifically, it includes: A1: Obtain the original sparse dataset ; The original sparse dataset , including several data vectors and query vector The data vector is a vector obtained by encoding the document content, and the query vector is a vector obtained by encoding the query content. This is the number of the data vector; A2: Traverse the original sparse dataset Calculate the document frequency in each non-zero dimension of the data vector. Then, the original IDF weights for each non-zero dimension are calculated. ; The document frequency Defined as the number of data vectors that take non-zero values ​​in this non-zero dimension: (1); in, The numbering for non-zero dimensions. Represents the set of non-zero dimensions of a data vector; By document frequency Calculate the original IDF weights for each non-zero dimension : (2); in, For the original sparse dataset Total number of data vectors in the middle; A3: Adjust the original IDF weights Linear mapping to a preset IDF weight range The normalized dimension weights are obtained. Then, according to the normalized dimension weights Determine the unfold length of each non-zero dimension. Assign to each non-zero dimension One binary encoding slot; The process of the linear mapping is as follows: (3); in, and These are the lower and upper bounds of the preset IDF weight interval, respectively; The numbering for non-zero dimensions. The number of non-zero dimensions. It is a very small positive number; The method for calculating the unfolded length is as follows: (4); in, Based on the foundation, and These are the lower and upper bounds of the unfolded length, respectively; A4: For each data vector With probability For each non-zero dimension Each binary encoding slot undergoes independent Bernoulli sampling to determine whether each slot is active. If active, the slot has a value of 1; if inactive, it has a value of 0, thus obtaining the binary code. For data vectors The Middle Values ​​can be taken in one non-zero dimension; A5: Concatenate all binary codes of each non-zero dimension to obtain the normalized dimension weights. It is unfolded into a binary sequence, generating slot prefix positions for each non-zero dimension. And add it before the corresponding non-zero dimension binary sequence, then add the position with the slot prefix. Concatenate all non-zero dimension binary sequences to generate a binary code set. ; A6: Based on the normalized dimension weights Slot prefix position and the unfolded length of each non-zero dimension Generate encoded metadata and the original sparse dataset Save separately.

3. The adaptive clustering method for searching the maximum inner product of high-dimensional sparse data according to claim 1, characterized in that, The original sparse dataset is measured using cosine similarity. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata Specifically, it includes: B1: From the original sparse dataset Selected from The data vectors, after L2 normalization, are used as the initial cluster centers. , The cluster center number; B2: For each data vector Calculate its relationship with the current cluster centers. cosine similarity , each data vector Assign to the primary cluster of the cluster center with the highest cosine similarity. ; B3: For each primary cluster Calculate the mean vector of all data vectors in the main cluster and update the cluster center. Repeat B2 and B3 until the cluster center no longer changes or the preset number of iterations is reached, then execute B4. B4: Record the current data vector Its main cluster center cosine similarity Set boundary overflow factor For each data vector Calculate its relationship with each non-cluster center. cosine similarity If satisfied This indicates that it is not the main cluster center. The corresponding primary cluster is the data vector Clusters that are directionally close are called neighbor clusters, which are data vectors Add it to the neighboring cluster as a boundary sample, and then iterate through all data vectors. Then, each primary cluster, together with all the boundary samples added to it, constitutes an extended cluster. Output clustering metadata ; The primary cluster center is the cluster center of the primary cluster to which the data vector belongs, and the non-primary cluster center is a cluster center other than the cluster center of the primary cluster to which the data vector belongs.

4. The adaptive clustering method for searching the maximum inner product of high-dimensional sparse data according to claim 1, characterized in that, The scale of each extended cluster Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. Specifically, it includes the following steps: C1: For each extended cluster The size of the extended cluster is obtained by counting the number of data vectors it contains. Based on the preset baseline number of MinHash functions and expanding cluster size Determine the number of MinHash functions for each extended cluster. ; (5); in, The number of MinHash functions is the baseline; C2: For extended clusters Each data vector within According to its binary encoding set use A separate MinHash function Calculate the MinHash signature For each MinHash function Build a bucket And will expand the cluster Each data vector within Store the number in the corresponding bucket. In the middle, output the MinHash index structure. , This is the number of the MinHash function.

5. The adaptive clustering method for searching the maximum inner product of high-dimensional sparse data according to claim 1, characterized in that, The use of encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. Specifically, it includes the following steps: D1: Using encoded metadata For the current query vector input Perform IDF weighted SOS encoding to generate query binary encoding. ; D2: Read clustering metadata Calculate the current query vector Cluster centers of each extended cluster cosine similarity ; D3: Cosine similarity Sort from highest to lowest, and select the top results with the highest cosine similarity. The extended cluster numbers corresponding to each cluster center constitute the active cluster set. .

6. The method for searching the maximum inner product of high-dimensional sparse data in adaptive clustering according to claim 1, characterized in that, The MinHash-based index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. This includes the following steps: E1: For the set of active clusters Each active extended cluster Initialize the collision counter and read the MinHash index structure. Use the extended cluster in sequence MinHash function Calculate the query binary code MinHash signature, access the corresponding bucket The index of all data vectors in the dataset is used to accumulate the MinHash collision count for each data vector. E2: Based on the number of MinHash collisions Arrange the data vectors within the expanded cluster from highest to lowest order, and extract the candidate budgets before ranking. The data vectors are used as local candidate subsets of the extended cluster. The candidate budget is based on a preset candidate retention ratio. It is confirmed; E3: Merge local candidate subsets of all activated clusters, and remove duplicates to form a global candidate set. .

7. A maximum inner product search system for high-dimensional sparse data in adaptive clustering, used to implement the maximum inner product search method for high-dimensional sparse data in adaptive clustering as described in any one of claims 1-6, characterized in that, include: The encoding module is used to obtain the original sparse dataset. Then, dimensional IDF-weighted adaptive SOS encoding is performed to generate a binary encoding set. and encoded metadata ; The clustering module is used to cluster the original sparse dataset using cosine similarity as a metric. The data vectors in the middle are divided into each main cluster Record each data vector and the main cluster cluster center Similarity based on boundary overflow factor Expand the primary cluster into an extended cluster. And obtain clustering metadata ; The index structure building module is used to build the index according to the size of each extended cluster. Determine the number of MinHash functions And construct the MinHash index structure based on the binary encoding set. ; Activation module, used to use encoded metadata For the current query vector Perform IDF weighted SOS encoding to obtain the query binary encoding set, and then perform clustering metadata. Calculate the current query vector The cosine similarity with the cluster centers of each extended cluster is used to select the clusters with the highest cosine similarity. The extended clusters constitute the set of active clusters. ; Candidate generation module, used for MinHash index structure In the activated cluster set The system counts and sorts the MinHash collisions of each data vector, then extracts a set number of data vectors based on their MinHash collision counts, merges them, removes duplicates, and generates a global candidate set. ; The results output module is used to process the global candidate set. Calculate the exact inner product of the data vectors, sort them, and output the top vectors with the largest inner product. A data vector is returned as the result. .

8. An electronic device, characterized in that, include: One or more processors, and a memory for storing instructions that, when executed by the one or more processors, cause the one or more processors to perform a high-dimensional sparse data maximum inner product search method for adaptive clustering as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, It stores executable instructions that, when executed, cause the processor to perform a high-dimensional sparse data maximum inner product search method for adaptive clustering as described in any one of claims 1-6.

10. A computer program product, characterized in that, Includes a computer program or instructions that, when executed by a processor, implement the high-dimensional sparse data maximum inner product search method for adaptive clustering as described in any one of claims 1-6.