Title: ADAPTIVE LEARNED BLOOM FILTER (ADA-BF): EFFICIENT UTILIZATION OF THE CLASSIFIER Anonymous

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.

1. INTRODUCTION:

Bloom filter (BF) is a widely used data structure for low-memory and high-speed approximate membership testing (Bloom, 1970) . Bloom filters compress a given set S into bit arrays, where we can approximately test whether a given element (or query) x belongs to a set S, i.e., x ∈ S or otherwise. Several applications, in particular caching in memory constrained systems, have benefited tremendously from BF (Broder et al., 2002) .

Bloom filter ensures a zero false negative rate (FNR), which is a critical requirement for many applications. However, BF does not have a non-zero false positive rate (FPR) (Dillinger and Manolios, 2004 ) due to hashing collisions, which measures the performance of BF. There is a known theoretical limit to this reduction. To achieve a FPR of , BF costs at least n log 2 (1/ ) log 2 e bits (n = |S|), which is log 2 e ≈ 44% off from the theoretical lower bound (Carter et al., 1978) . Mitzenmacher (2002) proposed Compressed Bloom filter to address the suboptimal space usage of BF, where the space usage can reach the theoretical lower bound in the optimal case.

To achieve a more significant reduction of FPR, researchers have generalized BF and incorporated information beyond the query itself to break through the theoretical lower bound of space usage. Bruck et al. (2006) has made use of the query frequency and varied the number of hash functions based on the query frequency to reduce the overall FPR. Recent work (Kraska et al., 2018; Mitzenmacher, 2018) has proposed to improve the performance of standard Bloom filter by incorporating a machine learning model. This approach paves a new hope of reducing false positive rates beyond the theoretical limit, by using context-specific information in the form of a machine learning model (Hsu et al., 2019) . Rae et al. (2019) further proposed Neural Bloom Filter that learns to write to memory using a distributed write scheme and achieves compression gains over the classical Bloom filter.

The key idea behind Kraska et al. (2018) is to use the machine learning model as a pre-filter to give each query x a score s(x). s(x) is usually positively associated with the odds that x ∈ S.

The assumption is that in many practical settings, the membership of a query in the set S can be figured out from observable features of x and such information is captured by the classifier assigned score s(x). The proposal of Kraska et al. uses this score and treats query x with score s(x) higher than a pre-determined threshold τ (high confidence predictions) as a direct indicator of the correct membership. Queries with scores less than τ are passed to the back-up Bloom filter.

Compared to the standard Bloom filter, learned Bloom filter (LBF) uses a machine learning model to answer keys with high score s(x). Thus, the classifier reduces the number of the keys hashed into the Bloom filter. When the machine learning model has a reliable prediction performance, learned Bloom filter significantly reduce the FPR and save memory usage (Kraska et al., 2018) . Mitzenmacher (2018) further provided a formal mathematical model for estimating the performance of LBF. In the same paper, the author proposed a generalization named sandwiched learned Bloom filter (sandwiched LBF), where an initial filter is added before the learned oracle to improve the FPR if the parameters are chosen optimally. Wastage of Information: For existing learned Bloom filters to have a lower FPR, the classifier score greater than the threshold τ should have a small probability of wrong answer. Also, a significant fraction of the keys should fall in this high threshold regime to ensure that the backup filter is small. However, when the score s(x) is less than τ , the information in the score s(x) is never used. Thus, there is a clear waste of information. For instance, consider two elements x 1 and x 2 with τ > s(x 1 ) s(x 2 ). In the existing solutions, x 1 and x 2 will be treated in the exact same way, even though there is enough prior to believing that x 1 is more likely positive compared to x 2 . Strong dependency on Generalization: It is natural to assume that prediction with high confidence implies a low FPR when the data distribution does not change. However, this assumption is too strong for many practical settings. First and foremost, the data distribution is likely to change in an online streaming environment where Bloom filters are deployed. Data streams are known to have bursty nature with drift in distribution (Kleinberg, 2003) . As a result, the confidence of the classifier, and hence the threshold, is not completely reliable. Secondly, the susceptibility of machine learning oracles to adversarial examples brings new vulnerability in the system. Examples can be easily created where the classifier with any given confidence level τ , is incorrectly classified. Bloom filters are commonly used in networks where such increased adversarial false positive rate can hurt the performance. An increased latency due to collisions can open new possibilities of Denial-of-Service attacks (DoS) (Feinstein et al., 2003) . Motivation: For a binary classifier, the density of score distribution, f (s(x)) shows a different trend for elements in the set and outside the set S. We observe that for keys, f (s(x)|x ∈ S) shows ascending trend as s(x) increases while f (s(x)|x / ∈ S) has an opposite trend. To reduce the overall FPR, we need lower FPRs for groups with a high f (s(x)|x / ∈ S). Hence, if we are tuning the number of hash functions differently, more hash functions are required for the corresponding groups. While for groups with a few non-keys, we allow higher FPRs. This variability is the core idea to obtaining a sweeter trade-off. Our Contributions: Instead of only relying on the classifier whether score s(x) is above a single specific threshold, we propose two algorithms, Ada-BF and disjoint Ada-BF, that rely on the complete spectrum of scores regions by adaptively tuning Bloom filter parameters in different score regions. 1) Ada-BF tunes the number of hash functions differently in different regions to adjust the FPR adaptively; disjoint Ada-BF allocates variable memory Bloom filters to each region. 2) Our theoretical analysis reveals a new set of trade-offs that brings lower FPR with our proposed scheme compared to existing alternatives. 3) We evaluate the performance of our algorithms on two datasets: malicious URLs and malware MD5 signatures, where our methods reduce the FPR by over 80% and save 50% of the memory usage over existing learned Bloom filters. Notations: Our paper includes some notations that need to be defined here. Let [g] denote the index set {1, 2, • • • , g}. We define query x as a key if x ∈ S, or a non-key if x / ∈ S. Let n denote the size of keys (n = |S|), and m denote the size of non-keys. We denote K as the number of hash functions used in the Bloom filter.

2. REVIEW: BLOOM FILTER AND LEARNED BLOOM FILTER:

Bloom Filter: Standard Bloom filter for compressing a set S consists of an R-bits array and K independent random hash function h 1 , h 2 , • • • , h K , taking integer values between 0 and R -1, i.e., h i : S ⇒ {0, 1, • • • , R -1}. The bit array is initialized with all 0. For every item x ∈ S, the bit value of

h i (x) = 1, for all i ∈ {0, 1, • • • , K}, is set to 1.

To check a membership of an item x in the set S, we return true if all the bits h i (x ), for all i ∈ {0, 1, • • • , K}, have been set to 1. It is clear that Bloom filter has zero FNR (false negative rate). However, due to lossy hash functions, x may be wrongly identified to be positive when x / ∈ S while all the h i (x )s are set to 1 due to random collisions. It can be shown that if the hash functions are independent, the expected FPR can be written as follows

E (FPR) = 1 -1 - 1 R Kn K .

Learned Bloom filter: Learned Bloom filter adds a binary classification model to reduce the effective number of keys going to the Bloom filter. The classifier is pre-trained on some available training data to classify whether any given query x belongs to S or not based on its observable features. LBF sets a threshold, τ , where x is identified as a key if s(x) ≥ τ . Otherwise, x will be inserted into a Bloom filter to identify its membership in a further step (Figure 1 ). Like standard Bloom filter, LBF also has zero FNR. And the false positives can be either caused by that false positives of the classification model (s(x|x / ∈ S) ≥ τ ) or that of the Bloom filter.

It is clear than when the region s(x) ≥ τ contains large number of keys, the number of keys inserted into the Bloom filter decreases which leads to favorable FPR. However, since we identify the region s(x) ≥ τ as positives, higher values of τ is better. At the same time, large τ decreases the number of keys in the region s(x) ≥ τ , increasing the load of the Bloom filter. Thus, there is a clear trade-off.

3 A STRICT GENERALIZATION: ADAPTIVE LEARNED BLOOM FILTER (ADA-BF)

With the formulation of LBF in the previous section, LBF actually divides the x into two groups.

When s(x) ≥ τ , x will be identified as a key directly without testing with the Bloom filter. In other words, it uses zero hash function to identify its membership. Otherwise, we will test its membership using K hash functions. In other view, LBF switches from K hash functions to no hash function at all, based on s(x) ≥ τ or not. Continuing with this mindset, we propose adaptive learned Bloom filter, where x is divided into g groups based on s(x), and for group j, we use K j hash functions to test its membership. The structure of Ada-BF is represented in Figure 1(b) . More specifically, we divide the spectrum into g regions, where

x ∈ Group j if s(x) ∈ [τ j-1 , τ j ), j = 1, 2, • • • , g. Without loss of generality, here, we assume 0 = τ 0 < τ 1 < • • • < τ g-1 < τ g = 1.

Keys from group j are inserted into Bloom filter using K j independent hash functions. Thus, we use different number of universal hash functions for keys from different groups.

For a group j, the expected FPR can be expressed as,

E (FPR j ) = 1 -1 - 1 R g t=1 ntKt Kj = α Kj (1)

where

n t = n t=1 I(τ t-1 ≤ s(x i |x i ∈ S) < τ t )

is the number of keys falling in group t, and K j is the number of hash functions used in group j. By varying K j , E (FPR j ) can be controlled differently for each group.

Variable number of hash functions gives us enough flexibility to tune the FPR of each region. To avoid the bit array being overloaded, we only increase the K j for groups with large number of keys n j , while decrease K j for groups with small n j . It should be noted that f (s(x)|x ∈ S) shows an opposite trend compared to f (s(x)|x / ∈ S) as s(x) increases (Figure 2 ). Thus, there is a need for variable tuning, and a spectrum of regions gives us the room to exploit these variability efficiently. Clearly, Ada-BF generalizes the LBF. When Ada-BF only divides the queries into two groups, by setting K 1 = K, K 2 = 0 and τ 1 = τ , Ada-BF reduces to the LBF.

3.1. SIMPLIFYING THE HYPER-PARAMETERS:

To implement Ada-BF, there are some hyper-parameters to be determined, including the number of hash functions for each group K j and the score thresholds to divide groups, τ j (τ 0 = 0, τ g = 1). Altogether, we need to tune 2g -1 hyper-parameters. Use these hyper-parameters, for Ada-BF, the expected overall FPR can be expressed as,

E (FPR) = g j=1 p j E (FPR j ) = g j=1 p j α Kj (2)

where

p j = P r(τ j-1 ≤ s(x i |x i / ∈ S) < τ j ).

Empirically, p j can be estimated by pj =

1 m m i=1 I(τ j-1 ≤ s(x i |x i / ∈ S) < τ j ) = mj m

(m is size of non-keys in the training data and m j is size of non-keys belonging to group j). It is almost impossible to find the optimal hyperparameters that minimize the E (FPR) in reasonable time. However, since the estimated false positive items g j=1 m j α Kj = O(max j (m j α Kj )), we prefer m j α Kj to be similar across groups when E (FPR) is minimized. While α Kj decreases exponentially fast with larger K j , to keep m j α Kj stable across different groups, we require m j to grow exponentially fast with K j . Moreover, since f (s(x)|x / ∈ S) increases as s(x) becomes smaller for most cases, K j should also be larger for smaller s(x). Hence, to balance the number of false positive items, as j diminishes, we should increase K j linearly and let m j grow exponentially fast.

With this idea, we provide a strategy to simplify the tuning procedure. We fix = c. This strategy ensures pj to grow exponentially fast with K j . Now, we only have three hyper-parameters, c, K min and K max (K max = K 1 ). By default, we may also set K min = K g = 0, equivalent to identifying all the items in group g as keys.

pj pj+1 = c and K j -K j+1 = 1 for j = 1, 2, • • • , g -1.

Lemma 1: Assume 1) the scores of non-keys, s(x)|x / ∈ S, are independently following a distribution f ; 2) The scores of non-keys in the training set are independently sampled from a distribution f . Then, the overall estimation error of pj , j |p j -p j |, converges to 0 in probability as m becomes larger. Moreover, if m ≥ 2(k-1)

2 1 π + 1-2/π δ 2

, with probability at least 1 -δ, we have

j |p j -p j | ≤ .

Even though in the real application, we cannot access the exact value of p j , which may leads to the estimation error of the real E (FPR). However, Lemma 1 shows that as soon as we can collect enough non-keys to estimate the p j , the estimation error is almost negligible. Especially for the large scale membership testing task, collecting enough non-keys is easy to perform.

3.2. ANALYSIS OF ADAPTIVE LEARNED BLOOM FILTER:

Compared with the LBF, Ada-BF makes full use the of the density distribution s(x) and optimizes the FPR in different regions. Next, we will show Ada-BF can reduce the optimal FPR of the LBF without increasing the memory usage. When p j /p j+1 = c j ≥ c > 1 and K j -K j+1 = 1, the expected FPR follows,

E (FPR) = g j=1 p j α Kj = g j=1 c g-j α Kj g j=1 c g-j ≤      (1 -c)(1 -(cα) g ) ( 1 α -c)(α g -(cα) g ) α Kmax , cα = 1 1 -c 1 -c g • g, cα = 1 (3)

where K max = K 1 . To simplify the analysis, we assume cα > 1 in the following theorem. Given the number of groups g is fixed, this assumption is without loss of generality satisfied by raising c since α will increase as c becomes larger. For comparisons, we also need τ of the LBF to be equal to τ g-1 of the Ada-BF. In this case, queries with scores higher than τ are identified as keys directly by the machine learning model. So, to compare the overall FPR, we only need to compare the FPR of queries with scores lower than τ .

Theorem 1: For Ada-BF, given pj pj+1 ≥ c > 1 for all j ∈ [g -1], if there exists λ > 0 such that cα ≥ 1 + λ holds, and n j+1 -n j > 0 for all j ∈ [g -1] (n j is the number of keys in group j). When g is large enough and g ≤ 2K , then Ada-BF has smaller FPR than the LBF. Here K is the number of hash functions of the LBF.

Theorem 1 requires the number of keys n j keeps increasing while p j decreases exponentially fast with j. As shown in figure 2 , on real dataset, we observe from the histogram that as score increases, f (s(x)|x / ∈ S) decreases very fast while f (s(x)|x ∈ S) increases. So, the assumptions of Theorem 1 are more or less satisfied.

Moreover, when the number of buckets is large enough, the optimal K of the LBF is large as well. Given the assumptions hold, theorem 1 implies that we can choose a larger g to divide the spectrum into more groups and get better FPR. The LBF is sub-optimal as it only has two regions. Our experiments clearly show this trend. For figure 3 (a), Ada-BF achieves 25% of the FPR of the LBF when the bitmap size = 200Kb, while when the budget of buckets = 500Kb, Ada-BF achieves 15% of the FPR of the LBF. For figure 3(b), Ada-BF only reduces the FPR of the LBF by 50% when the budget of buckets = 100Kb, while when the budget of buckets = 300Kb, Ada-BF reduces 70% of the FPR of the LBF. Therefore, both the analytical and experimental results indicate superior performance of Ada-BF by dividing the spectrum into more small groups. On the contrary, when g is small, Ada-BF is more similar to the LBF, and their performances are less differentiable.

4. DISJOINT ADAPTIVE LEARNED BLOOM FILTER (DISJOINT ADA-BF):

Ada-BF divides keys into g groups based on their scores and hashes the keys into the same Bloom filter using different numbers of hash functions. With the similar idea, we proposed an alternative approach, disjoint Ada-BF, which also divides the keys into g groups, but hashes keys from different groups into independent Bloom filters. The structure of disjoint Ada-BF is represented in Figure 1(c ). Assume we have total budget of R bits for the Bloom filters and the keys are divided into g groups using the same idea of that in Ada-BF. Consequently, the keys from group j are inserted into j-th Bloom filter whose length is R j (R = g j=1 R j ). Then, during the look up stage, we just need to identify a query's group and check its membership in the corresponding Bloom filter.

Analogous to Ada-BF, disjoint Ada-BF also has a lot of hyper-parameters, including the thresholds of scores for groups division and the lengths of each Bloom filters. To determine thresholds τ j , we use similar tuning strategy discussed in the previous section of tuning the number of groups g and mj mj+1 = c. To find R j that optimizes the overall FPR, again, we refer to the idea in the previous section that the expected number of false positives should be similar across groups. For a Bloom filter with R j buckets, the optimal number of hash functions K j can be approximated as K j = Rj nj log(2), where n j is the number of keys in group j. And the corresponding optimal expected FPR is E (FPR j ) = µ Rj /nj (µ ≈ 0.618). Therefore, to enforce the expected number of false items being similar across groups, R j needs to satisfy

m j • µ R j n j = m 1 • µ R 1 n 1 ⇐⇒ R j n j - R 1 n 1 = (j -1)log(c) log(µ)

Since n j is known given the thresholds τ j and the total budget of buckets R are known, thus, R j can be solved accordingly. Moreover, when the machine learning model is accurate, to save the memory usage, we may also set R g = 0, which means the items in group j will be identified as keys directly.

4.2. ANALYSIS OF DISJOINT ADAPTIVE LEARNED BLOOM FILTER:

The disjoint Ada-BF uses a group of shorter Bloom filters to store the hash outputs of the keys. Though the approach to control the FPR of each group is different from the Ada-BF, where the Ada-BF varies K and disjoint Ada-BF changes the buckets allocation, both methods share the same core idea to lower the overall FPR by reducing the FPR of the groups dominated by non-keys. Disjoint Ada-BF allocates more buckets for these groups to a achieve smaller FPR. In the following theorem, we show that to achieve the same optimal expected FPR of the LBF, disjoint Ada-BF consumes less buckets. Again, for comparison we need τ of the LBF is equal to τ g-1 of the disjoint Ada-BF.

Theorem 2: If pj pj+1 = c > 1 and n j+1 -n j > 0 for all j ∈ [g -1] (n j is the number of keys in group j), to achieve the optimal FPR of the LBF, the disjoint Ada-BF consumes less buckets compared with the LBF when g is large.

5. EXPERIMENT:

Baselines: We test the performance of four different learned Bloom filters: 1) standard Bloom filter, 2) learned Bloom filter, 3) sandwiched learned Bloom filter, 4) adaptive learned Bloom filter, and 5) disjoint adaptive learned Bloom filter. We use two datasets which have different associated tasks, namely: 1) Malicious URLs Detection and 2) Virus Scan. Since all the variants of Bloom filter structures ensure zero FNR, the performance is measured by their FPRs and corresponding memory usage.

5.1. TASK1: MALICIOUS URLS DETECTION:

We explore using Bloom filters to identify malicious URLs. We used the URLs dataset downloaded from Kaggle, including 485,730 unique URLs. 16.47% of the URLs are malicious, and others are benign. We randomly sampled 30% URLs (145,719 URLs) to train the malicious URL classification model. 17 lexical features are extracted from URLs as the classification features, such as "host name length", "path length", "length of top level domain", etc. We used "sklearn.ensemble.RandomForestClassifier1 " to train a random forest model. After saving the model with "pickle", the model file costs 146Kb in total. "sklearn.predict_prob" was used to give scores for queries.

We tested the optimal FPR for the four learned Bloom filter methods under the total memory budget = 200Kb to 500Kb (kilobits). Since the standard BF does not need a machine learning model, to make a fair comparison, the bitmap size of BF should also include the machine learning model size (146 Kb in this experiment). Thus, the total bitmap size of BF is 346Kb to 646Kb. To implement the LBF, we tuned τ between 0 and 1, and picked the one giving the minimal FPR. The number of hash functions was determined by K = Round( R n0 log 2), where n 0 is the number of keys hashed into the Bloom filter conditional τ . To implement the sandwiched LBF, we searched the optimal τ and calculated the corresponding initial and backup filter size by the formula in Mitzenmacher (2018) . When the optimal backup filter size is larger than the total bits budget, sandwiched LBF does not need a initial filter and reduces to a standard LBF. For the Ada-BF, we used the tuning strategy described in the previous section. K min was set to 0 by default. Thus, we only need to tune the combination of (K max , c) that gives the optimal FPR. Similarly, for disjoint Ada-BF, we fixed R g = 0 and searched for the optimal (g, c).

Result: Our trained machine learning model has a classification accuracy of 0.93. Considering the non-informative frequent class classifier (just classify as benign URL) gives accuracy of 0.84, our trained learner is not a strong classifier. However, the distribution of scores is desirable (Figure 2 ), where as s(x) increases, the empirical density of s(x) decreases for non-keys and also increases for keys. In our experiment, when the sandwiched LBF is optimized, the backup filter size always exceeds the total bitmap size. Thus, it reduces to the LBF and has the same FPR (as suggested by Figure 4(a) ).

Our experiment shows that compared to the LBF and sandwiched LBF, both Ada-BF and disjoint Ada-BF achieve much lower FPRs. When filter size = 500Kb, Ada-BF reduces the FPR by 81% compared to LBF or sandwiched LBF (disjoint FPR reduces the FPR by 84%). Moreover, to achieve a FPR ≈ 0.9%, Ada-BF and disjoint Ada-BF only require 200Kb, while both LBF and the sandwiched LBF needs more than 350Kb. And to get a FPR ≈ 0.35%, Ada-BF and disjoint Ada-BF reduce the memory usage from over 500Kb of LBF to 300Kb, which shows that our proposed algorithms save over 40% of the memory usage compared with LBF and sandwiched LBF. 

5.2. TASK 2: VIRUS SCAN:

Bloom filter is widely used to match the file's signature with the virus signature database. Our dataset includes the information of 41323 benign files and 96724 viral files. The virus files are collected from VirusShare database (Vir). The dataset provides the MD5 signature of the files, legitimate status and other 53 variables characterizing the file, like "Size of Code", "Major Link Version" and "Major Image Version". We trained a machine learning model with these variables to differentiate the benign files from the viral documents. We randomly selected 20% samples as the training set to build a binary classification model using Random Forest model2 . We used "sklearn.ensemble.RandomForestClassifier" to tune the model, and the Random Forest classifier costs about 136Kb. The classification model achieves 0.98 prediction accuracy on the testing set. The predicted the class probability (with the function "predict_prob" in "sklearn" library) is used as the score s(x). Other implementation details are similar to that in Task 1. Result: As the machine learning model achieves high prediction accuracy, figure 4 suggests that all the learned Bloom filters show huge advantage over the standard BF where the FPR is reduced by over 98%. Similar to the previous experiment results, we observe consistently lower FPRs of our algorithms although the the score distributions are not smooth or continuous (Figure 3 ). Again, our methods show very similar performance. Compared with LBF, our methods reduce the FPRs by over 80%. To achieve a 0.2% FPR, the LBF and sandwiched LBF cost about 300Kb bits, while Ada-BF only needs 150Kb bits, which is equivalent to 50% memory usage reduction compared to the previous methods.

5.3. SENSITIVITY TO HYPER-PARAMETER TUNING:

Compared with the LBF and sandwiched LBF where we only need to search the space of τ to optimize the FPR, our algorithms require to tune a series of score thresholds. In the previous sections, we have proposed a simple but useful tuning strategies where the score thresholds can be determined by only two hyper-parameters, (K, c). Though our hyper-parameter tuning technique may lead to a sub-optimal choice, our experiment results have shown we can still gain significantly lower FPR compared with previous LBF. Moreover, if the number of groups K is misspecified from the optimal choice (of K), we can still achieve very similar FPR compared with searching both K and c. Figure 5 shows that for both Ada-BF and disjoint Ada-BF, tuning c while fixing K has already achieved similar FPRs compared with optimal case by tuning both (K, c), which suggests our algorithm does not require very accurate hyper-parameter tuning to achieve significant reduction of the FPR.

5.4 DISCUSSION: SANDWICHED LEARNED BLOOM FILTER VERSUS LEARNED BLOOM FILTER Sandwiched LBF is a generalization of LBF and performs no worse than LBF. Although Mitzenmacher (2018) has shown how to allocate bits for the initial filter and backup filter to optimize the expected FPR, their result is based on the a fixed FNR and FPR. While for many classifiers, FNR and FPR are expressed as functions of the prediction score τ . Figure 4 (a) shows that the sandwiched LBF always has the same FPR as LBF though we increase the bitmap size from 200Kb to 500Kb. This is because the sandwiched LBF is optimized when τ corresponds to a small FPR and a large FNR, where the optimal backup filter size even exceeds the total bitmap size. Hence, we should not allocate any bits to the initial filter, and the sandwiched LBF reduces to LBF. On the other hand, our second experiment suggests as the bitmap size becomes larger, sparing more bits to the initial filter is clever, and the sandwiched LBF shows the its advantage over the LBF (Figure 6(b) ).

6. CONCLUSION:

We have presented new approaches to implement learned Bloom filters. We demonstrate analytically and empirically that our approaches significantly reduce the FPR and save the memory usage compared with the previously proposed LBF and sandwiched LBF even when the learner's discrimination power . We envision that our work will help and motivate integrating machine learning model into probabilistic algorithms in a more efficient way. The machine learning model used in the learned Bloom filters is critical because it has discrimination power between the keys and non-keys and is more efficient in identifying keys in some cases. To show its unique role, we replaced the machine learning model with another Bloom filter such that it becomes a hierarchical Bloom filter (learner is replaced by an initial filter). To implement the hierarchical Bloom filter, we spare 50% of the bit budget to the initial filter and use the other bits to build the backup filter.

Figure 7 shows that the hierarchical BF does not outperform the original BF under all the budget of buckets, and in some cases, it even achieves a worse FPR. Hence, using a random hash function to replace the learner is not a memory efficient approach. 

Z j (x) = m i=1 1(s(x) ∈ [τ j-1 , τ j )|x / ∈ S), then Z j (x) ∼ Bernoulli(p j )

, and m j = m i=1 Z j (x i ) counts the number of non-keys falling in group j and pj = mj m . To upper bound the probability of the overall estimation error of p j , first, we need to evaluate its expectation,

E K j=1 |p j -p j | .

Since m j is a binomial random variable, its exact cdf is hard to compute. But with central limit theorem, when m is large,

mj -mpj √ mpj (1-pj )

-→ N (0, 1). Thus, we can approximate E (|p j -p

j |) = E | mj -mpj √ mpj (1-pj ) | • pj (1-pj ) m ≈ 2 π • pj (1-pj ) m (if Z ∼ N (0, 1), E (|Z|) = 2 π ).

Then, the expectation of overall error is approximated by

E K j=1 |p j -p j | ≈ 2 mπ • K j=1

p j (1 -p j ) , which goes to 0 as m becomes larger.

We need to further upper bound the tail probability of K j=1 |p j -p j |. First, we upper bound the variance of

K j=1 |p j -p j |, Var   K j=1 |p j -p j |   ≤ K K j=1 Var (|p j -p j |) = K K j=1 Var (p j -p j ) -E (|p j -p j |) 2 ≈ K m K j=1   p j (1 -p j ) - 2 π K i=1 p j (1 -p j ) 2   K m V (p)

Now, by envoking the Chebyshev's inequality,

EQUATION

Then, by Eq 4 and Eq 5, we can upper bound

P K j=1 |p j -p j | ≥ by, P   K j=1 |p j -p j | ≥   ≤ KV (p) m -E K j=1 |p j -p j | 2 ≤ (1 -2 π )(K -1) m - 2 mπ (K -1) 2 (6) When m ≥ 2(k-1) 2 1 π + 1-2/π δ 2

, we have m - Proof of Theorem 1: For comparison, we choose τ = τ g-1 , for both LBF and Ada-BF, queries with scores larger than τ are identified as keys directly by the same machine learning model. Thus, to compare the overall FPR, we only need to evaluate the FPR of queries with score lower than τ .

Let p 0 = P [s(x) < τ |x / ∈ S] be the probability of a key with score lower than τ . Let n 0 denote the number of keys with score less than τ , n 0 = i:xi∈S I(s(x i ) < τ ). For learned Bloom filter using K hash functions, the expected FPR follows,

EQUATION

)

where R is the length of the Bloom filter. For Ada-BF, assume we fix the number of groups g. Then, we only need to determine K max and K min = K max -g+1. Let p j = P r(τ j-1 ≤ s(x) < τ j |x / ∈ S) The expected FPR of the Ada-BF is,

EQUATION

where g-1 j=1 n j = n 0 . Next, we give a strategy to select K max which ensures a lower FPR of Ada-BF than LBF.

Select K max = K + g 2 -1 . Then, we have

n 0 K = g-1 j=1 n j K = K   n 1 + g-1 i=2 (n 1 + j-1 i=1 T i ) = n 1 (g -1) + g-2 j=1

T j (g -j -1)

  = 2K g -2   (g -1)(g -2) 2 n 1 + g-2 j=1 (g -2)(g -1 -j) 2 T j   ≤ 2 g -2   (g -1)(g -2) 2 n 1 + g-2 j=1 (g + j -2)(g -1 -j) 2 T j   = 2 g -2 g-1 j=1 (j -1)n j (9)

By Eq 9. we further get the relationship between α and β.

g-1 j=1

K j n j = g-1 j=1 (K max -j + 1)n j ≤ n 0 K max - g 2 + 1 ≤ n 0 K =⇒ α ≤ β.

Moreover, by Eq. 3, we have,

E (FPR a ) = (1 -c)(1 -(cα) g ) ( 1 α -c)(α g -(cα) g ) α Kmax ≤ (1 -c)(1 -(cα) g ) ( 1 α -c)(α g -(cα) g ) β Kmax ≤ β Kmax α(c -1) cα -1 < E (FPR) 1 + λ λ β Kmax-K ≤ E (FPR) 1 + λ λ β g/2-1 .

Therefore, as g increases, the upper bound of E (FPR a ) decreases exponentially fast. Moreover, since 1+λ λ is a constant, when g is large enough, we have 1+λ λ β g/2-1 ≤ 1. Thus, the E (FPR e ) is reduced to strictly lower than E (FPR).

Proof of Theorem 2: Let η = log(c) log(µ) ≈ log(c) log(0.618) < 0. By the tuning strategy described in the previous section, we require the expected false positive items should be similar across the groups. Thus, we have

p 1 • µ R1/n1 = p j • µ Rj /nj =⇒ R j = n j R 1 n 1 + (j -1)η , for j ∈ [g -1]

where R j is the budget of buckets for group j. For group j, since all the queries are identified as keys by the machine learning model directly, thus, R g = 0. Given length of Bloom filter for group 1, R 1 , the total budget of buckets can be expressed as,

g-1 j=1 R j = g-1 j=1 n j n 1 R 1 + (j -1)n j η

Let p 0 = P r(s(x) < τ |x / ∈ S) and p j = P r(τ j-1 ≤ s(x) < τ j |x / ∈ S). Let n 0 denote the number of keys with score less than τ , n 0 = i:xi∈S I(s(x i ) < τ ), and n j be the number of keys in group

:

The Random Forest classifier consists 10 decision trees, and each tree has at most

leaf nodes.

The Random Forest classifier consists 15 decision trees, and each tree has at most 5 leaf nodes.

Figures and Tables:

Figure 1: Panel A-C show the structure of LBF, Ada-BF and disjoint Ada-BF respectively.

Since the true density of s(x|x / ∈ S) is unknown. To implement the strategy, we estimate

Figure 2: Histogram of the classifier's score distributions of keys (Malicious) and non-keys (Benign) for Task 1. We can see that n j (number of keys in region j) is monotonic when score > 0.3. The partition was only done to ensure pj pj +1 ≥ c

Figure 3: Histogram of the classifier score distributions for the Virus Scan Dataset. The partition was only done to ensure pj pj +1 ≥ c.

Figure 4: FPR with memory budget for all the five baselines (the bit budget of BF = bitmap size + learner size). (a) FPRs comparison of Malicious URL detection experiment; (b) FPRs comparison of Virus scan experiment.

Figure 6: FPR comparison between LBF and sandwiched LBF under different bitmap sizes. (a) malicious URL experiment; (b) malware detection experiment

j -p j | ≥ ≤ δ.

Peer review (iclr2020):
The paper proposed an adaptive learned bloom filter. Rather than setting a threshold of prediction score, the paper partitions the score into several intervals; for query insider each interval, the paper either uses a group of independent hash functions to hash the query in one unified bloom filter or introduce an independent bloom filter. The paper proposes efficient ways to tune the hyper-parameters, and provides the analysis of the error. Experiments on two applications show the effectiveness of the proposed methods. The idea seems useful. However, I have a few concerns/questions. My decision depends on the responses of the author(s). (1) Although the paper claims the score information can be fully exploited, the paper seems to do hashing for all possible queries. Why not set up a tau such that only when the score is below tau, we conduct the adaptive hashing? When the score is bigger than tau, we still claim an identification of the key? In this way, a bunch of keys can still be saved and without extra hashing. (2) The proposed method seems to be a hierarchical hashing strategy. The first level is to hash the queries into different intervals through a score function learned from data. Why not compose another group of random hash to do the first level hashing? What is the major benefit of collecting training examples to run a machine learning model? Accordingly, why not compare with such a baseline using a group of random hashing to do the first level?