A learned Bloom filter combines a model with a backup filter. Its space benefit depends on the query distribution and model size.
What a Bloom filter guarantees
A Bloom filter approximates membership in a set of n elements with an m-bit array and k hash functions. It has no false negatives when every insertion is represented and bits required by stored members are not cleared. Non-members can still produce false positives.
The standard approximation below assumes independent, uniform hashing. It describes the classical Bloom filter's space-error relationship, not the information-theoretic lower bound for every approximate-membership structure.
FPR ≈ (1 - exp(-kn/m))^k
k ≈ (m/n) ln(2)A learned filter tries to encode regularities in the stored set and its queries. Comparisons must include the model's memory and inference cost.
Correcting the model's false negatives
Kraska et al.'s SIGMOD 2018 paper introduced learned Bloom filters alongside learned indexes. A score at or above the threshold returns possibly present. A lower score invokes a backup filter containing every actual member that the model scores below the threshold.
Immediately rejecting keys predicted absent can produce false negatives. The backup filter prevents that error. Replacing the model without rebuilding the corresponding backup can break the guarantee, so both must represent the same set version.
flowchart LR
Q[Query key] --> M{Model score}
M -->|At or above threshold| Y[Possibly present]
M -->|Below threshold| B{Backup filter}
B -->|Possibly present| Y
B -->|Definitely absent| N[Absent]
What sandwiching adds
Mitzenmacher's NeurIPS 2018 paper analyzes this design and adds a classical Bloom filter before the model. This initial filter stores the entire set. Rejecting non-members there can reduce model invocations.
flowchart LR
Q[Query] --> I{Initial filter for the full set}
I -->|Definitely absent| N[Absent]
I -->|Possibly present| M{Model}
M -->|High score| Y[Possibly present]
M -->|Low score| B{Backup filter}
B -->|Definitely absent| N
B -->|Possibly present| Y
The initial filter does not correct the model's false negatives. The backup preserves real members with low scores. The paper analyzes bit allocation between the two filters under specified model sizes and false-positive and false-negative rates.
| Component | What it stores or evaluates | Cost to check |
|---|---|---|
| Initial filter | Entire stored set | Extra bits and initial lookup |
| Model | Membership score of an input key | Model size and inference time |
| Backup filter | Actual members with low model scores | Number of correction keys and additional lookup |
Changes in distribution and membership
A learned filter's false-positive rate depends on the non-member query distribution. If production queries differ from the training negatives, the same space benefit need not persist. Classical filter analysis also assumes particular hashing and query behavior; it does not guarantee safety against arbitrary adversarial queries.
With a fixed model, insert each new key into the sandwich design's initial filter. Also insert new keys scoring below the threshold into the backup. Changing the model or threshold changes the backup membership across the stored set, so rebuild the backup filter.
For frequent deletion, you can also compare a structure that explicitly supports deletion, such as the CoNEXT 2014 Cuckoo Filter. Only inserted elements may be deleted, and capacity limits and insertion failures still require handling.
Measure total memory, lookup latency, false positives, construction, and update costs on the same set and queries. This post establishes neither production performance in a particular LSM engine nor universal superiority of learned filters.
Summary
The no-false-negative property comes from combining the learned model with its backup filter. The sandwich design's initial filter reduces non-member queries that reach the model. Space savings depend on model size and query distribution, and comparisons must include updates. Neither an analytical result nor a particular prototype benchmark is a general production guarantee.