Consistent Weighted Sampling Made More Practical

Wei Wu, Bin Li, Ling Chen, Chengqi Zhang

Abstract

Estimating similarity between weighted sets is a fundamental task in large-scale data mining. While Improved Consistent Weighted Sampling (ICWS) has been the standard for calculating Generalized Jaccard Similarity, its computational complexity and memory requirements pose significant challenges. This paper introduces Practical Consistent Weighted Sampling (PCWS), a streamlined implementation that simplifies the underlying hashing equations. By reducing the number of required random variables from five to four per feature, PCWS achieves a 20% reduction in memory usage and up to a 33% reduction in runtime, while maintaining the exact theoretical guarantees and accuracy of ICWS.

Introduction

In big data analytics, calculating similarity between objects—such as documents represented by word frequency vectors—is computationally intensive. Locality Sensitive Hashing (LSH) techniques like Min-Hash are commonly used for binary sets to estimate Jaccard Similarity. However, real-world data often involves weighted features (e.g., tf-idf values), necessitating the use of Generalized Jaccard Similarity.

The previous state-of-the-art method, Improved Consistent Weighted Sampling (ICWS), provides accurate estimates but is computationally heavy. It requires generating and storing five independent random variables for every feature in every hash function. For datasets with millions of features and thousands of hashes, this leads to a massive memory footprint and slow processing times.

Methodology: From ICWS to PCWS

The authors conducted a mathematical audit of the ICWS algorithm to uncover its underlying mechanisms. They discovered that the complex equations in ICWS were essentially a "black box" for a simpler process.

Mathematical Transformation

By rearranging the ICWS equations, the researchers demonstrated that the algorithm implicitly samples from an exponential distribution using an unbiased estimator of feature weights. This insight allowed them to replace a complex three-variable calculation with a single log-transformed uniform variable.

Simplification and Equivalence

The resulting algorithm, Practical Consistent Weighted Sampling (PCWS), requires only four random variables instead of five. The authors theoretically proved that PCWS is mathematically equivalent to ICWS, preserving two essential properties:

  1. Uniformity: Elements are sampled with probability proportional to their weights.
  2. Consistency: If a sub-element is selected from a set, it is also selected from any subset containing it, ensuring the validity of the hashing scheme.

Experimental Evaluation

PCWS was evaluated against six algorithms, including Min-Hash and ICWS, across five large-scale text datasets including classification tasks (Real-sim, Rcv1, and Kdd) and retrieval tasks (Webspam and Url).

Key Results

The experimental results confirm that PCWS offers significant engineering optimizations without sacrificing performance.

Efficiency and Memory

PCWS consistently reduced empirical runtime by 20% to 33% compared to ICWS. On the Kdd dataset, the speedup reached nearly 3x as the number of hash functions increased. Furthermore, the reduction from five to four variables per feature/hash resulted in a consistent 20% reduction in memory footprint, a critical advantage in memory-constrained big data environments.

Runtime comparison on the Webspam dataset, showing PCWS significantly outperforming ICWS as fingerprint length increases.

Accuracy

In both classification and Top-K retrieval tasks, PCWS matched or slightly exceeded the accuracy of ICWS. This validates the theoretical proof of equivalence, demonstrating that the speed and memory gains do not come at the cost of precision.

Accuracy comparison on the Realsim dataset, confirming that PCWS maintains the same performance as ICWS.

Conclusion

PCWS demonstrates that deep mathematical understanding of existing algorithms can lead to significant practical optimizations. By stripping away unnecessary complexity, the authors transformed a gold-standard algorithm into a more efficient tool for large-scale similarity estimation. Future work may extend this consistent sampling logic to more complex data structures, such as hierarchical or nested weighted sets.

Summary updated

BibTeX
@inproceedings{wu2017consistent,
  author = {Wei Wu and Bin Li and Ling Chen and Chengqi Zhang},
  title = {{Consistent Weighted Sampling Made More Practical}},
  booktitle = {The Web Conference},
  year = {2017},
  doi = {10.1145/3038912.3052598},
}
Figure