33
submitted 1 year ago by [email protected] to c/[email protected]

What are your real-world applications of this versatile data structure?

They are useful for optimization in databases like sqlite and query engines like apache spark. Application developers can use them as concise representations of user data for filtering previously seen items.

The linked site gives a short introduction to bloom filters along with some links to further reading:

A Bloom filter is a data structure designed to tell you, rapidly and memory-efficiently, whether an element is present in a set. The price paid for this efficiency is that a Bloom filter is a probabilistic data structure: it tells us that the element either definitely is not in the set or may be in the set.

you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 7 points 1 year ago

A classic use for them is spam filtering.

Suppose you have a set of spam detection systems/rules which are somewhat expensive to execute, eg a ML model or keyword blocklist. Spam tends to come in waves, and frequently it can be as simple as reposting the same message dozens of times.

Once your systems determine a piece of content is spam (or you manually flag content), it's a good idea to insert the content into a bloom filter. This means that future posts of the identical content will be flagged without needing to execute the expensive checks, especially if there's a surge of content stressing your systems.

Since it's probabilistic, you can't use this unless you have some sort of manual reviewing queue or system, as it's possible for false positives to be flagged. However, you can also run more intensive checks once you've flagged content, to detect false positives.

The false positives can also be a feature, not a bug: with careful choice of hash functions, your bloom filter can actually detect slightly modified content, since most of the hashes may still be the same.

I've worked at companies which use this strategy so it's very real world.

[-] [email protected] 1 points 1 year ago

Cool, so in this case your filter is basically a classifier ML model. How would you set the hash functions then though?

[-] [email protected] 1 points 1 year ago

Usually it's a bunch of different string hashes of the text content. They could be different hashing algorithms, but it's more common to take a single hash algorithm and simply create a bunch of hash functions that operate on different parts of the data.

If it's not text data, there's a whole bunch of other hashing strategies but I only ever saw bloom filters used with text.

this post was submitted on 06 Sep 2023
33 points (97.1% liked)

Programming

17024 readers
310 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS