A Memory-Efficient Sketch Method for Estimating High Similarities in Streaming Sets

Pinghui Wang, Yiyan Qi, Yuanming Zhang, Qiaozhu Zhai, Chenxu Wang, John C. S. Lui, Xiaohong GuanKDD 2019 · DOI

Abstract

Estimating set similarity and detecting highly similar sets are fundamental problems in areas such as databases, machine learning, and information retrieval. MinHash is a well-known technique for approximating Jaccard similarity, but its compressed variants like $b$-bit MinHash and Odd Sketch fail to handle streaming data. We introduce MaxLogHash, a memory-efficient sketch method designed to accurately estimate Jaccard similarities in streaming sets. By using registers as small as 6 bits, MaxLogHash achieves a 5x memory reduction over standard MinHash while maintaining accuracy and processing speed. Experimental results demonstrate that MaxLogHash outperforms state-of-the-art alternatives like HyperMinHash, particularly in eliminating estimation bias for high similarities.

Introduction

Computing Jaccard similarity—the intersection of two sets divided by their union—is a foundational task in data mining. For massive datasets, exact computation is computationally prohibitive, leading to the widespread adoption of MinHash. MinHash creates a compact "sketch" or signature of a set to estimate similarity. However, standard MinHash typically utilizes 32-bit or 64-bit registers, which becomes memory-intensive when managing billions of sets.

While compressed versions like $b$-bit MinHash exist, they are not "streaming-friendly"; they require the entire set to be present upfront. In real-world scenarios such as IoT logs or network traffic, data arrives continuously, and set cardinality is unknown. Existing streaming-friendly compressed sketches, such as HyperMinHash, suffer from severe estimation bias when sets are highly similar. MaxLogHash addresses these challenges by providing a highly compressed, incrementally updatable sketch.

Methodology

MaxLogHash stores the logarithm of the hash value, referred to as the log-rank, rather than the raw minimum hash value. For an incoming item $v$ in a stream, the algorithm calculates its log-rank as $\lfloor -\log_2 h(v) \rfloor$, where $h(v)$ is a uniform hash between 0 and 1. The sketch maintains the maximum log-rank observed across $k$ registers.

Convergence of the estimator parameter $\alpha_n$ as a function of set cardinality $n$.

Because of the logarithmic scale, a 64-bit hash space can be represented using only a 6-bit register ($2^6 = 64$). To ensure accuracy, the sketch also maintains a 1-bit indicator per register to flag if exactly one unique element achieved the maximum log-rank. The authors derived a mathematical estimator based on these values, utilizing a parameter $\alpha_n$ that quickly converges as the set size $n$ increases, as shown in the figure above. To further optimize performance, the MaxLogOPH (One Permutation Hashing) variant reduces update complexity from $O(k)$ to $O(1)$ by hashing items to a single random register.

Experimental Evaluation

The performance of MaxLogHash was evaluated using both synthetic (balanced and unbalanced set-pairs) and real-world datasets (MUSHROOM and CONNECT). The primary metrics were Root Mean Square Error (RMSE) and Bias.

Comprehensive comparison of RMSE and Bias for MaxLogHash, MinHash, and HyperMinHash across balanced and unbalanced set-pairs.

Key Results

  • Memory Efficiency: MaxLogHash requires approximately 5.4x less memory than standard MinHash to achieve the same RMSE. This is due to the reduction from 32-bit registers to 6-bit registers.
  • Accuracy and Bias: As illustrated in the comparative plots, MaxLogHash successfully eliminates the high-similarity bias observed in HyperMinHash. While HyperMinHash's bias degrades significantly as similarity approaches 1.0, MaxLogHash remains stable and nearly unbiased.
  • Computational Performance: MaxLogHash is 4 to 5 orders of magnitude faster at estimating similarity between two sketches than HyperMinHash. Furthermore, the MaxLogOPH variant increases ingestion throughput by approximately 420x compared to standard MinHash.

Conclusion and Future Work

MaxLogHash provides a robust solution for similarity estimation in high-throughput data streams. It combines the memory benefits of log-scale compression with the functional requirements of streaming updates. While the current implementation is insert-only and the $O(1)$ variant shows slightly higher errors for very small sets (cardinality < 200), future work will focus on extending the method to handle weighted streaming vectors and fully dynamic streams that support both insertions and deletions.

Summary updated

BibTeX
@inproceedings{wang2019memory,
  author = {Pinghui Wang and Yiyan Qi and Yuanming Zhang and Qiaozhu Zhai and Chenxu Wang and John C. S. Lui and Xiaohong Guan},
  title = {{A Memory-Efficient Sketch Method for Estimating High Similarities in Streaming Sets}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2019},
  doi = {10.1145/3292500.3330825},
}
Figure