besskge.negative_sampler.TypeBasedShardedNegativeSampler

class besskge.negative_sampler.TypeBasedShardedNegativeSampler(triple_types, n_negative, sharding, corruption_scheme, local_sampling, seed)[source]

Corrupt entities with entities of the same type.

Initialize type-based negative sampler.

Parameters:
  • triple_types (ndarray[Any, dtype[int32]]) – shape: (n_triple, 2) Type IDs of head and tail entities for all triples.

  • n_negative (int) – see RandomShardedNegativeSampler.__init__()

  • sharding (Sharding) – see RandomShardedNegativeSampler.__init__()

  • corruption_scheme (str) – see RandomShardedNegativeSampler.__init__()

  • local_sampling (bool) – see RandomShardedNegativeSampler.__init__()

  • seed (int) – see RandomShardedNegativeSampler.__init__()

corruption_scheme: str

Which entity to corrupt; “h”, “t”, “ht”

flat_negative_format: bool

Sample negatives per triple partition, instead of per triple

local_sampling: bool

Sample negatives only from processing device

rng: Generator

RNG