besskge.negative_sampler.RandomShardedNegativeSampler
- class besskge.negative_sampler.RandomShardedNegativeSampler(n_negative, sharding, seed, corruption_scheme, local_sampling, flat_negative_format=False)[source]
Sample random negative entities for each triple in batch.
Initialize random negative sampler.
- Parameters:
n_negative (
int
) – Number of negative samples per shard-pair (ifflat_negative_format
) or per triple.sharding (
Sharding
) – Sharding of entities.seed (
int
) – Seed of RNG.corruption_scheme (
str
) – “h”: corrupt head entities; “t”: corrupt tail entities; “ht”: corrupt head entities for the first half of each triple partition, tail entities for the second half.local_sampling (
bool
) – If True, sample negative entities only from the shard where the triple is processed.flat_negative_format (
bool
) – If True, samplen_negative
negative entities for each shard-pair, instead of each triple. If True, requires use of negative sample sharing. Default: False.