BloomFilterer
- class BloomFilterer(mapped_triples: Tensor, error_rate: float = 0.001)[source]
Bases:
Filterer
A filterer for negative triples based on the Bloom filter.
Pure PyTorch, a proper module which can be moved to GPU, and support batch-wise computation.
See also
https://github.com/hiway/python-bloom-filter/ - for calculation of sizes, and rough structure of code
https://github.com/skeeto/hash-prospector#two-round-functions - for parts of the hash function
Initialize the Bloom filter based filterer.
- Parameters:
Methods Summary
add
(triples)Add triples to the Bloom filter.
contains
(batch)Check whether a triple is contained.
num_bits
(num[, error_rate])Determine the required number of bits.
num_probes
(num_elements, num_bits)Determine the number of probes / hashing rounds.
probe
(batch)Iterate over indices from the probes.
Methods Documentation
- add(triples: Tensor) None [source]
Add triples to the Bloom filter.
- Parameters:
triples (Tensor)
- Return type:
None
- static num_bits(num: int, error_rate: float = 0.01) int [source]
Determine the required number of bits.