Adaptive Learned Bloom Filter (Ada-BF): Efficient Utilization of the Classifier

Zhenwei Dai, Anshumali ShrivastavaarXiv 2019

Abstract

Recent work suggests improving the performance of Bloom filter by incorporating a machine learning model as a binary classifier. However, such learned Bloom filter does not take full advantage of the predicted probability scores. We proposed new algorithms that generalize the learned Bloom filter by using the complete spectrum of the scores regions. We proved our algorithms have lower False Positive Rate (FPR) and memory usage compared with the existing approaches to learned Bloom filter. We also demonstrated the improved performance of our algorithms on real-world datasets.

Introduction

Bloom filters (BF) are essential tools in computer science for fast, memory-efficient membership testing. While they never yield false negatives, they do produce false positives due to hashing collisions. Recent "Learned Bloom Filters" (LBF) improved performance by using a machine learning model as a pre-filter: if the model is very confident an item is a "key" (member of the set), it bypasses the filter. If not, the item is checked against a backup Bloom filter.

The authors identify two major flaws in this approach: first, the wastage of information by using a single binary threshold, and second, a heavy dependency on the model's ability to generalize. If the data distribution shifts, a fixed threshold becomes unreliable, potentially leading to a spike in false positives.

Adaptive Filtering Across the Score Spectrum

The core innovation of Ada-BF is observing that the density of keys increases as the classifier score $s(x)$ increases, while the density of non-keys decreases. By adaptively changing the filter's "strength" (hash functions or memory) across these density gradients, a superior trade-off is achieved compared to a single global setting.

Comparison of (A) Standard LBF, (B) Ada-BF, and (C) Disjoint Ada-BF architectures.

The authors propose two new algorithms that utilize the complete spectrum of the classifier's probability scores:

  • Ada-BF (Adaptive Learned Bloom Filter): This approach uses a single bit array but varies the number of hash functions ($K$) based on the classifier's score. Items in score regions where the model is less certain (more likely to be non-keys) are hashed more times to reduce the local false positive rate.
  • Disjoint Ada-BF: Instead of one array, this version divides the score spectrum into multiple regions and assigns a dedicated, variable-sized Bloom filter to each region. This allows for precise memory allocation where it is needed most.

Empirical Evaluation

The researchers evaluated their algorithms on two real-world security tasks: Malicious URLs Detection (485,730 unique URLs) and Virus Scan (138,047 files). The classifiers used lexical features and file metadata, respectively.

Score distribution of benign URLs showing the density gradient used for adaptive tuning.

The empirical results show a massive leap over standard and "sandwiched" learned Bloom filters:

  • FPR Reduction: On the Malicious URL task, Ada-BF reduced the False Positive Rate (FPR) by 81% compared to LBF when using a 500Kb memory budget.
  • Memory Efficiency: To achieve a target FPR of 0.2% in the Virus Scan task, standard LBF required 300Kb, while Ada-BF required only 150Kb—a 50% memory saving.
  • Robustness: Even when the machine learning model was relatively weak, the adaptive approach still significantly outperformed the baselines.

Conclusion

Ada-BF is a strict generalization of the standard LBF that offers significant improvements in memory efficiency and robustness to distribution shifts. While it introduces some computational overhead due to variable hashing, it paves the way for more efficient integration of machine learning into probabilistic data structures, potentially extending to Cuckoo filters and beyond.

Summary updated

BibTeX
@misc{dai2019adaptive,
  author = {Zhenwei Dai and Anshumali Shrivastava},
  title = {{Adaptive Learned Bloom Filter (Ada-BF): Efficient Utilization of the Classifier}},
  year = {2019},
  eprint = {1910.09131},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.09131},
}
Figure