Partitioned Learned Bloom Filters

Kapil Vaidya, Eric Knorr, Michael Mitzenmacher, Tim Kraska

TL;DR

Partitioned Learned Bloom Filters (PLBF) significantly improve the space efficiency of membership testing by dividing a machine learning model's score space into multiple regions, each with its own optimized backup filter. By framing model utilization as a formal optimization problem, the authors achieve up to 26x lower false positive rates compared to previous "learned" heuristics for the same memory footprint.

The Problem: Inefficient Learned Bloom Filters

Bloom filters are a staple in computer science, used everywhere from web browsers (to check for malicious URLs) to databases (to avoid unnecessary disk lookups). They are "probabilistic," meaning they are incredibly space-efficient but occasionally return a "false positive"—claiming an item is in a set when it isn't.

While standard Bloom filters have a hard theoretical limit on how much space they can save, "Learned Bloom Filters" (LBF) try to beat this limit by using a machine learning model as a pre-filter. If the model is confident an item is a "key" (in the set), we trust it; if not, we check a backup Bloom filter.

The problem? Previous LBF designs were inefficient. They either used a single arbitrary threshold to decide when to trust the model or relied on simple heuristics to manage multiple regions. This paper addresses the gap between having a good model and actually using its output scores optimally to minimize memory usage.

Methods: Introducing the PLBF

The authors introduce the Partitioned Learned Bloom Filter (PLBF). Their approach moves away from "one-size-fits-all" thresholds by routing queries based on the model's confidence score.

Architecture of a Partitioned Learned Bloom Filter

The PLBF framework operates on several core principles:

  1. Score Partitioning: They divide the model's output score range (typically 0 to 1) into $k$ distinct regions.
  2. Tailored Backup Filters: Each region is assigned its own backup Bloom filter with a specific, optimized false positive rate (FPR).
  3. Formal Optimization: They formulate the problem of choosing thresholds and FPRs as a constrained optimization problem: minimize total memory usage while keeping the overall FPR below a target $F$.
Score distributions partitioned into k regions
  1. The KL Divergence Connection: Using Karush-Kuhn-Tucker (KKT) conditions, they prove a beautiful theoretical result: the maximum space saving is linearly proportional to the Kullback-Leibler (KL) divergence between the score distributions of keys and non-keys.
  2. Dynamic Programming (DP): To find the best boundaries for these regions, they provide a fast DP algorithm that maximizes this divergence across the discretized score space.

Datasets

The authors evaluated PLBF against three primary datasets:

  • Synthetic: Data generated using Zipfian distributions to simulate various levels of model "quality" and score distributions.
  • URLs: A real-world dataset of ~450,000 URLs (23% malicious, 77% benign). The goal is to identify malicious URLs using features like hostname length and special character counts.
  • EMBER: A large-scale malware benchmark containing 1.1 million SHA-256 file hashes (400k malicious, 400k benign used for testing).

Key Insights

  • The "Aha" Moment: The realization that space efficiency is mathematically tied to KL divergence is a major contribution. It shifts the focus from just "model accuracy" to "how well the model separates distributions into buckets."
  • Density Matters: The optimal FPR for a specific region should be proportional to the ratio of keys to non-keys in that region. If a score range is "mostly keys," you can afford a higher FPR in its backup filter to save space.
  • The Power of a Few Partitions: While more partitions always help theoretically, the authors found that just 4 to 6 regions are usually enough to capture the vast majority of the performance gains.
  • Beating Heuristics: Previous state-of-the-art methods like "Sandwiching" or "AdaBF" are actually just special, sub-optimal cases of the PLBF framework.

Key Results

PLBF consistently outperformed all baselines (standard Bloom filters, original LBF, and AdaBF) across all datasets:

  • Massive Space Savings: On the URL dataset, for the same amount of memory, PLBF achieved a 26x smaller false positive rate than the "Sandwiching" approach and a 9x smaller rate than AdaBF.
  • Robustness: Even on the EMBER dataset, where the ML model was less accurate (F1 score of 0.85), PLBF still provided a 3x improvement in FPR over previous methods.
  • Efficiency: The DP algorithm for finding thresholds is fast. For a typical dataset, it takes only a few seconds to calculate optimal parameters, making it practical for real-world systems.

Limitations and Future Work

  • Discretization Sensitivity: The DP algorithm relies on a discretization parameter $N$. While higher $N$ leads to better filters, it increases construction time. Finding the "sweet spot" is necessary for time-sensitive applications.
  • Distribution Shift: The optimization assumes that the distribution of non-keys seen during training is representative of the queries seen during deployment. If the "query workload" changes significantly, the chosen thresholds may no longer be optimal.
  • Model Training: The authors suggest that current ML models are trained to minimize loss (like MSE), but training them specifically to maximize the KL divergence of their output scores could lead to even more efficient filters. This remains an open area for future research.

Summary updated

BibTeX
@inproceedings{vaidya2021partitioned,
  author = {Kapil Vaidya and Eric Knorr and Michael Mitzenmacher and Tim Kraska},
  title = {{Partitioned Learned Bloom Filters}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
}
Figure