diff --git a/_modules/besskge/utils.html b/_modules/besskge/utils.html index a250d2d..28b723d 100644 --- a/_modules/besskge/utils.html +++ b/_modules/besskge/utils.html @@ -140,7 +140,7 @@
Row-wise rotated tensors.
"""
# Always compute sin and cos in fp16, as faster on IPU
- if r.dtype == torch.float32:
+ if r.dtype == torch.float32 and r.device.type == "ipu":
r_cos = torch.cos(r.to(dtype=torch.float16)).to(dtype=torch.float32)
r_sin = torch.sin(r.to(dtype=torch.float16)).to(dtype=torch.float32)
else:
diff --git a/generated/besskge.batch_sampler.RandomShardedBatchSampler.html b/generated/besskge.batch_sampler.RandomShardedBatchSampler.html
index 8473af3..fd4c3c3 100644
--- a/generated/besskge.batch_sampler.RandomShardedBatchSampler.html
+++ b/generated/besskge.batch_sampler.RandomShardedBatchSampler.html
@@ -109,18 +109,18 @@ besskge.batch_sampler.RandomShardedBatchSampler
partitioned_triple_set (PartitionedTripleSet
) – The pre-processed collection of triples.
negative_sampler (ShardedNegativeSampler
) – The sampler for negative entities.
-shard_bs (int
) – The micro-batch size. This is the number of positive triples
+
shard_bs (int
) – The micro-batch size. This is the number of positive triples
processed on each shard.
-batches_per_step (int
) – The number of batches to sample at each call.
-seed (int
) – The RNG seed.
-hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
-weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
+
batches_per_step (int
) – The number of batches to sample at each call.
+seed (int
) – The RNG seed.
+hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
+weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
triple weighting. Default: 0.0.
-duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
+
duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
identical halves.
This is to be used with “ht” corruption scheme at inference time.
Default: False.
-return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
+
return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
of the triples in the batch. Default: False.
@@ -136,10 +136,10 @@ besskge.batch_sampler.RandomShardedBatchSamplerParameters:
options (Options
) – poptorch.Options used to compile and run the model.
-shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
-num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
-persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
-buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
+shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
+num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
+persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
+buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
Return type:
@@ -156,14 +156,14 @@ besskge.batch_sampler.RandomShardedBatchSamplerget_dataloader_sampler(shuffle=True)[source]
Returns the dataloader sampler.
Instantiate the appropriate torch.data.Sampler
class for the
-torch.utils.data.DataLoader
class to be used with the
+torch.utils.data.DataLoader
class to be used with the
sharded batch sampler.
- Parameters:
-shuffle (bool
) – Shuffle triples at each new epoch.
+shuffle (bool
) – Shuffle triples at each new epoch.
- Return type:
--
+
-
- Returns:
The dataloader sampler.
@@ -177,10 +177,10 @@ besskge.batch_sampler.RandomShardedBatchSampler
- Parameters:
-idx (List
[int
]) – The batch index.
+-
- Return type:
-Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
+Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
- Returns:
Per-partition indices of positive triples, and other relevant data.
@@ -192,13 +192,13 @@ besskge.batch_sampler.RandomShardedBatchSampler
static worker_init_fn(worker_id)
Worker initialization function to be passed to
-torch.utils.data.DataLoader
.
+torch.utils.data.DataLoader
.
diff --git a/generated/besskge.batch_sampler.RigidShardedBatchSampler.html b/generated/besskge.batch_sampler.RigidShardedBatchSampler.html
index 2d1cf52..bb04c28 100644
--- a/generated/besskge.batch_sampler.RigidShardedBatchSampler.html
+++ b/generated/besskge.batch_sampler.RigidShardedBatchSampler.html
@@ -111,18 +111,18 @@ besskge.batch_sampler.RigidShardedBatchSampler
partitioned_triple_set (PartitionedTripleSet
) – The pre-processed collection of triples.
negative_sampler (ShardedNegativeSampler
) – The sampler for negative entities.
-shard_bs (int
) – The micro-batch size. This is the number of positive triples
+
shard_bs (int
) – The micro-batch size. This is the number of positive triples
processed on each shard.
-batches_per_step (int
) – The number of batches to sample at each call.
-seed (int
) – The RNG seed.
-hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
-weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
+
batches_per_step (int
) – The number of batches to sample at each call.
+seed (int
) – The RNG seed.
+hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
+weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
triple weighting. Default: 0.0.
-duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
+
duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
identical halves.
This is to be used with “ht” corruption scheme at inference time.
Default: False.
-return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
+
return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
of the triples in the batch. Default: False.
@@ -138,10 +138,10 @@ besskge.batch_sampler.RigidShardedBatchSamplerParameters:
options (Options
) – poptorch.Options used to compile and run the model.
-shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
-num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
-persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
-buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
+shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
+num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
+persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
+buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
Return type:
@@ -158,14 +158,14 @@ besskge.batch_sampler.RigidShardedBatchSamplerget_dataloader_sampler(shuffle)
Returns the dataloader sampler.
Instantiate the appropriate torch.data.Sampler
class for the
-torch.utils.data.DataLoader
class to be used with the
+torch.utils.data.DataLoader
class to be used with the
sharded batch sampler.
- Parameters:
-shuffle (bool
) – Shuffle triples at each new epoch.
+shuffle (bool
) – Shuffle triples at each new epoch.
- Return type:
--
+
-
- Returns:
The dataloader sampler.
@@ -179,10 +179,10 @@ besskge.batch_sampler.RigidShardedBatchSampler
- Parameters:
-idx (List
[int
]) – The batch index.
+-
- Return type:
-Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
+Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
- Returns:
Per-partition indices of positive triples, and other relevant data.
@@ -194,13 +194,13 @@ besskge.batch_sampler.RigidShardedBatchSampler
static worker_init_fn(worker_id)
Worker initialization function to be passed to
-torch.utils.data.DataLoader
.
+torch.utils.data.DataLoader
.
diff --git a/generated/besskge.batch_sampler.ShardedBatchSampler.html b/generated/besskge.batch_sampler.ShardedBatchSampler.html
index 2289457..130c293 100644
--- a/generated/besskge.batch_sampler.ShardedBatchSampler.html
+++ b/generated/besskge.batch_sampler.ShardedBatchSampler.html
@@ -108,18 +108,18 @@ besskge.batch_sampler.ShardedBatchSampler
partitioned_triple_set (PartitionedTripleSet
) – The pre-processed collection of triples.
negative_sampler (ShardedNegativeSampler
) – The sampler for negative entities.
-shard_bs (int
) – The micro-batch size. This is the number of positive triples
+
shard_bs (int
) – The micro-batch size. This is the number of positive triples
processed on each shard.
-batches_per_step (int
) – The number of batches to sample at each call.
-seed (int
) – The RNG seed.
-hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
-weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
+
batches_per_step (int
) – The number of batches to sample at each call.
+seed (int
) – The RNG seed.
+hrt_freq_weighting (bool
) – If True, uses frequency-based triple weighting. Default: False.
+weight_smoothing (float
) – Weight-smoothing parameter for frequency-based
triple weighting. Default: 0.0.
-duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
+
duplicate_batch (bool
) – If True, the batch sampled from each triple partition has two
identical halves.
This is to be used with “ht” corruption scheme at inference time.
Default: False.
-return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
+
return_triple_idx (bool
) – If True, return the indices (wrt partitioned_triple_set.triples)
of the triples in the batch. Default: False.
@@ -135,10 +135,10 @@ besskge.batch_sampler.ShardedBatchSamplerParameters:
options (Options
) – poptorch.Options used to compile and run the model.
-shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
-num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
-persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
-buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
+shuffle (bool
) – If True, shuffles triples at each new epoch. Default: True.
+num_workers (int
) – see torch.utils.data.DataLoader.__init__()
. Default: 0.
+persistent_workers (bool
) – see torch.utils.data.DataLoader.__init__()
. Default: False.
+buffer_size (int
) – Size of the ring buffer in shared memory used to preload batches.
Return type:
@@ -155,14 +155,14 @@ besskge.batch_sampler.ShardedBatchSamplerget_dataloader_sampler(shuffle)[source]
Returns the dataloader sampler.
Instantiate the appropriate torch.data.Sampler
class for the
-torch.utils.data.DataLoader
class to be used with the
+torch.utils.data.DataLoader
class to be used with the
sharded batch sampler.
- Parameters:
-shuffle (bool
) – Shuffle triples at each new epoch.
+shuffle (bool
) – Shuffle triples at each new epoch.
- Return type:
--
+
-
- Returns:
The dataloader sampler.
@@ -176,10 +176,10 @@ besskge.batch_sampler.ShardedBatchSampler
- Parameters:
-idx (List
[int
]) – The batch index.
+-
- Return type:
-Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
+Dict
[str
, Union
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[bool_
]]]]
- Returns:
Per-partition indices of positive triples, and other relevant data.
@@ -191,13 +191,13 @@ besskge.batch_sampler.ShardedBatchSampler
static worker_init_fn(worker_id)[source]
Worker initialization function to be passed to
-torch.utils.data.DataLoader
.
+torch.utils.data.DataLoader
.
diff --git a/generated/besskge.bess.BessKGE.html b/generated/besskge.bess.BessKGE.html
index 8eea5aa..b745a7e 100644
--- a/generated/besskge.bess.BessKGE.html
+++ b/generated/besskge.bess.BessKGE.html
@@ -112,12 +112,12 @@ besskge.bess.BessKGE
negative_sampler (ShardedNegativeSampler
) – Sampler of negative entities.
score_fn (BaseScoreFunction
) – Scoring function.
-loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
-evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
+
loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
+evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
Default: None.
-return_scores (bool
) – If True, return positive and negative scores of batches to the host.
+
return_scores (bool
) – If True, return positive and negative scores of batches to the host.
Default: False.
-augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
+
augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
(according to the corruption scheme) of other positive triples
in the micro-batch. Default: False.
@@ -138,26 +138,26 @@ besskge.bess.BessKGE
Parameters:
-head (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
head (Tensor
) – shape: (1, n_shard, positive_per_partition)
Head indices.
-relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
Relation indices.
-tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
Tail indices.
-triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
+
triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
Mask to filter the triples in the micro-batch
before computing metrics.
-negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
+
negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
Indices of negative entities,
with B = 1, 2 or n_shard * positive_per_partition.
-triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
+
triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
Weights of positive triples.
-negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
+
negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
Mask to identify padding negatives, to discard when computing metrics.
Return type:
-
+
Returns:
Micro-batch loss, scores and metrics.
@@ -167,7 +167,7 @@ besskge.bess.BessKGE
-property n_embedding_parameters: int
+property n_embedding_parameters: int
Returns the number of trainable parameters in the embedding tables
@@ -178,14 +178,14 @@ besskge.bess.BessKGE
Parameters:
-head (Tensor
) – see BessKGE.forward()
-relation (Tensor
) – see BessKGE.forward()
-tail (Tensor
) – see BessKGE.forward()
-negative (Tensor
) – see BessKGE.forward()
+head (Tensor
) – see BessKGE.forward()
+relation (Tensor
) – see BessKGE.forward()
+tail (Tensor
) – see BessKGE.forward()
+negative (Tensor
) – see BessKGE.forward()
Return type:
-
+
Returns:
Positive (shape: (n_shard * positive_per_partition,))
diff --git a/generated/besskge.bess.EmbeddingMovingBessKGE.html b/generated/besskge.bess.EmbeddingMovingBessKGE.html
index 1e4e385..4d6d256 100644
--- a/generated/besskge.bess.EmbeddingMovingBessKGE.html
+++ b/generated/besskge.bess.EmbeddingMovingBessKGE.html
@@ -116,12 +116,12 @@
besskge.bess.EmbeddingMovingBessKGE
negative_sampler (ShardedNegativeSampler
) – Sampler of negative entities.
score_fn (BaseScoreFunction
) – Scoring function.
-loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
-evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
+
loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
+evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
Default: None.
-return_scores (bool
) – If True, return positive and negative scores of batches to the host.
+
return_scores (bool
) – If True, return positive and negative scores of batches to the host.
Default: False.
-augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
+
augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
(according to the corruption scheme) of other positive triples
in the micro-batch. Default: False.
@@ -142,26 +142,26 @@ besskge.bess.EmbeddingMovingBessKGE
Parameters:
-head (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
head (Tensor
) – shape: (1, n_shard, positive_per_partition)
Head indices.
-relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
Relation indices.
-tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
Tail indices.
-triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
+
triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
Mask to filter the triples in the micro-batch
before computing metrics.
-negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
+
negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
Indices of negative entities,
with B = 1, 2 or n_shard * positive_per_partition.
-triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
+
triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
Weights of positive triples.
-negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
+
negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
Mask to identify padding negatives, to discard when computing metrics.
Return type:
-
+
Returns:
Micro-batch loss, scores and metrics.
@@ -171,7 +171,7 @@ besskge.bess.EmbeddingMovingBessKGE
-property n_embedding_parameters: int
+property n_embedding_parameters: int
Returns the number of trainable parameters in the embedding tables
@@ -182,14 +182,14 @@ besskge.bess.EmbeddingMovingBessKGE
Parameters:
-head (Tensor
) – see BessKGE.forward()
-relation (Tensor
) – see BessKGE.forward()
-tail (Tensor
) – see BessKGE.forward()
-negative (Tensor
) – see BessKGE.forward()
+head (Tensor
) – see BessKGE.forward()
+relation (Tensor
) – see BessKGE.forward()
+tail (Tensor
) – see BessKGE.forward()
+negative (Tensor
) – see BessKGE.forward()
Return type:
-
+
Returns:
Positive (shape: (n_shard * positive_per_partition,))
diff --git a/generated/besskge.bess.ScoreMovingBessKGE.html b/generated/besskge.bess.ScoreMovingBessKGE.html
index 90e861b..00cc533 100644
--- a/generated/besskge.bess.ScoreMovingBessKGE.html
+++ b/generated/besskge.bess.ScoreMovingBessKGE.html
@@ -119,12 +119,12 @@
besskge.bess.ScoreMovingBessKGE
negative_sampler (ShardedNegativeSampler
) – Sampler of negative entities.
score_fn (BaseScoreFunction
) – Scoring function.
-loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
-evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
+
loss_fn (Optional
[BaseLossFunction
]) – Loss function, required when training. Default: None.
+evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
Default: None.
-return_scores (bool
) – If True, return positive and negative scores of batches to the host.
+
return_scores (bool
) – If True, return positive and negative scores of batches to the host.
Default: False.
-augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
+
augment_negative (bool
) – If True, augment sampled negative entities with the head/tails
(according to the corruption scheme) of other positive triples
in the micro-batch. Default: False.
@@ -145,26 +145,26 @@ besskge.bess.ScoreMovingBessKGE
Parameters:
-head (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
head (Tensor
) – shape: (1, n_shard, positive_per_partition)
Head indices.
-relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
relation (Tensor
) – shape: (1, n_shard, positive_per_partition)
Relation indices.
-tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
+
tail (Tensor
) – shape: (1, n_shard, positive_per_partition)
Tail indices.
-triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
+
triple_mask (Optional
[Tensor
]) – shape: (1, n_shard, positive_per_partition)
Mask to filter the triples in the micro-batch
before computing metrics.
-negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
+
negative (Tensor
) – shape: (1, n_shard, B, padded_negative)
Indices of negative entities,
with B = 1, 2 or n_shard * positive_per_partition.
-triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
+
triple_weight (Optional
[Tensor
]) – shape: (1, n_shard * positive_per_partition,) or (1,)
Weights of positive triples.
-negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
+
negative_mask (Optional
[Tensor
]) – shape: (1, B, n_shard, padded_negative)
Mask to identify padding negatives, to discard when computing metrics.
Return type:
-
+
Returns:
Micro-batch loss, scores and metrics.
@@ -174,7 +174,7 @@ besskge.bess.ScoreMovingBessKGE
-property n_embedding_parameters: int
+property n_embedding_parameters: int
Returns the number of trainable parameters in the embedding tables
@@ -185,14 +185,14 @@ besskge.bess.ScoreMovingBessKGE
Parameters:
-head (Tensor
) – see BessKGE.forward()
-relation (Tensor
) – see BessKGE.forward()
-tail (Tensor
) – see BessKGE.forward()
-negative (Tensor
) – see BessKGE.forward()
+head (Tensor
) – see BessKGE.forward()
+relation (Tensor
) – see BessKGE.forward()
+tail (Tensor
) – see BessKGE.forward()
+negative (Tensor
) – see BessKGE.forward()
Return type:
-
+
Returns:
Positive (shape: (n_shard * positive_per_partition,))
diff --git a/generated/besskge.bess.TopKQueryBessKGE.html b/generated/besskge.bess.TopKQueryBessKGE.html
index 5cd771c..9e78de2 100644
--- a/generated/besskge.bess.TopKQueryBessKGE.html
+++ b/generated/besskge.bess.TopKQueryBessKGE.html
@@ -119,17 +119,17 @@
besskge.bess.TopKQueryBessKGE
Parameters:
-k (int
) – For each query return the top-k most likely predictions.
-candidate_sampler (Union
[TripleBasedShardedNegativeSampler
, PlaceholderNegativeSampler
]) – Sampler of candidate entities to score against queries.
+
k (int
) – For each query return the top-k most likely predictions.
+candidate_sampler (Union
[TripleBasedShardedNegativeSampler
, PlaceholderNegativeSampler
]) – Sampler of candidate entities to score against queries.
Use besskge.negative_sampler.PlaceholderNegativeSampler
to score queries against all entities in the knowledge graph, avoiding
unnecessary loading of negative entities on device.
score_fn (BaseScoreFunction
) – Scoring function.
-evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
+
evaluation (Optional
[Evaluation
]) – Evaluation module, for computing metrics on device.
Default: None.
-return_scores (bool
) – If True, return scores of the top-k best completions.
+
return_scores (bool
) – If True, return scores of the top-k best completions.
Default: False.
-window_size (int
) – Size of the sliding window, namely the number of negative entities
+
window_size (int
) – Size of the sliding window, namely the number of negative entities
scored against each query at each step of the on-device for-loop.
Should be decreased with large batch sizes, to avoid an OOM error.
Default: 100.
@@ -149,22 +149,22 @@ besskge.bess.TopKQueryBessKGE
- Parameters:
-relation (Tensor
) – shape: (shard_bs,)
+
relation (Tensor
) – shape: (shard_bs,)
Relation indices.
-head (Optional
[Tensor
]) – shape: (shard_bs,)
Head indices, if known. Default: None.
-tail (Optional
[Tensor
]) – shape: (shard_bs,)
Tail indices, if known. Default: None.
-negative (Optional
[Tensor
]) – shape: (n_shard, B, padded_negative)
+
negative (Optional
[Tensor
]) – shape: (n_shard, B, padded_negative)
Candidates to score against the queries.
It can be the same set for all queries (B=1),
or specific for each query in the batch (B=shard_bs).
If None, score each query against all entities in the knowledge
graph. Default: None.
-triple_mask (Optional
[Tensor
]) – shape: (shard_bs,)
Mask to filter the triples in the micro-batch
before computing metrics. Default: None.
-negative_mask (Optional
[Tensor
]) – shape: (n_shard, B, padded_negative)
+
negative_mask (Optional
[Tensor
]) – shape: (n_shard, B, padded_negative)
If candidates are provided, mask to discard padding
negatives when computing best completions.
Requires the use of mask_on_gather=True
in the candidate
@@ -174,7 +174,7 @@
besskge.bess.TopKQueryBessKGEReturn type:
--
+
-
diff --git a/generated/besskge.dataset.KGDataset.html b/generated/besskge.dataset.KGDataset.html
index 5704d97..9d7f198 100644
--- a/generated/besskge.dataset.KGDataset.html
+++ b/generated/besskge.dataset.KGDataset.html
@@ -103,14 +103,14 @@ besskge.dataset.KGDataset
- Parameters:
-
@@ -124,7 +124,7 @@ besskge.dataset.KGDataset
- Parameters:
-root (Path
) – Local path to the dataset. If the dataset is not present in this
+
root (Path
) – Local path to the dataset. If the dataset is not present in this
location, then it is downloaded and stored here.
- Return type:
@@ -146,7 +146,7 @@ besskge.dataset.KGDataset
- Parameters:
-root (Path
) – Local path to the dataset. If the dataset is not present in this
+
root (Path
) – Local path to the dataset. If the dataset is not present in this
location, then it is downloaded and stored here.
- Return type:
@@ -169,7 +169,7 @@ besskge.dataset.KGDataset
- Parameters:
-root (Path
) – Local path to the dataset. If the dataset is not present in this
+
root (Path
) – Local path to the dataset. If the dataset is not present in this
location, then it is downloaded and stored here.
- Return type:
@@ -194,7 +194,7 @@ besskge.dataset.KGDataset
- Parameters:
-root (Path
) – Local path to the dataset. If the dataset is not present in this
+
root (Path
) – Local path to the dataset. If the dataset is not present in this
location, then it is downloaded and stored here.
- Return type:
@@ -208,7 +208,7 @@ besskge.dataset.KGDataset
-
-entity_dict:
Optional
[List
[str
]] = None
+entity_dict: Optional
[List
[str
]] = None
Entity labels by ID; str[n_entity]
@@ -221,17 +221,17 @@ besskge.dataset.KGDataset
- Parameters:
-df (Union
[DataFrame
, Dict
[str
, DataFrame
]]) – Pandas DataFrame of all triples in the knowledge graph dataset,
+
df (Union
[DataFrame
, Dict
[str
, DataFrame
]]) – Pandas DataFrame of all triples in the knowledge graph dataset,
or dictionary of DataFrames of triples for each part of the dataset split
-head_column (Union
[int
, str
]) – Name of the DataFrame column storing head entities
-relation_column (Union
[int
, str
]) – Name of the DataFrame column storing relations
-tail_column (Union
[int
, str
]) – Name of the DataFrame column storing tail entities
-entity_types (Union
[Series
, Dict
[str
, str
], None
]) – If entities have types, dictionary or pandas Series of mappings
+
head_column (Union
[int
, str
]) – Name of the DataFrame column storing head entities
+relation_column (Union
[int
, str
]) – Name of the DataFrame column storing relations
+tail_column (Union
[int
, str
]) – Name of the DataFrame column storing tail entities
+entity_types (Union
[Series
, Dict
[str
, str
], None
]) – If entities have types, dictionary or pandas Series of mappings
entity label -> entity type (as strings).
-split (Tuple
[float
, float
, float
]) – Tuple to set the train/validation/test split.
+
split (Tuple
[float
, float
, float
]) – Tuple to set the train/validation/test split.
Only used if no pre-defined dataset split is specified,
i.e. if df is not a dictionary.
-seed (int
) – Random seed for the train/validation/test split.
+
seed (int
) – Random seed for the train/validation/test split.
Only used if no pre-defined dataset split is specified,
i.e. if df is not a dictionary.
@@ -257,13 +257,13 @@ besskge.dataset.KGDataset
- Parameters:
-data (ndarray
[Any
, dtype
[int32
]]) – Numpy array of triples [head_id, relation_id, tail_id]. Shape
+
data (ndarray
[Any
, dtype
[int32
]]) – Numpy array of triples [head_id, relation_id, tail_id]. Shape
(num_triples, 3).
-split (Tuple
[float
, float
, float
]) – Tuple to set the train/validation/test split.
-seed (int
) – Random seed for the train/validation/test split.
-entity_dict (Optional
[List
[str
]]) – Optional entity labels by ID.
-relation_dict (Optional
[List
[str
]]) – Optional relation labels by ID.
-type_offsets (Optional
[Dict
[str
, int
]]) – Offset of entity types
+split (Tuple
[float
, float
, float
]) – Tuple to set the train/validation/test split.
+seed (int
) – Random seed for the train/validation/test split.
+entity_dict (Optional
[List
[str
]]) – Optional entity labels by ID.
+relation_dict (Optional
[List
[str
]]) – Optional relation labels by ID.
+type_offsets (Optional
[Dict
[str
, int
]]) – Offset of entity types
- Return type:
@@ -277,7 +277,7 @@ besskge.dataset.KGDataset
-
-property ht_types: Dict[str, ndarray[Any, dtype[int32]]] | None
+property ht_types: Dict[str, ndarray[Any, dtype[int32]]] | None
If entities have types, type IDs of triples’ heads/tails;
{part: int32[n_triple, {h_type, t_type}]}
@@ -288,7 +288,7 @@ besskge.dataset.KGDatasetKGDataset
object saved with KGDataset.save()
.
- Parameters:
-path (Path
) – Path to saved KGDataset
object.
+-
- Return type:
-
@@ -301,33 +301,33 @@
besskge.dataset.KGDataset
-
-n_entity:
int
+n_entity: int
Number of entities (nodes) in the knowledge graph
-
-n_relation_type:
int
+n_relation_type: int
Number of relation types (edge labels) in the knowledge graph
-
-neg_heads:
Optional
[Dict
[str
, ndarray
[Any
, dtype
[int32
]]]] = None
+neg_heads: Optional
[Dict
[str
, ndarray
[Any
, dtype
[int32
]]]] = None
IDs of (possibly triple-specific) negative heads;
{part: int32[n_triple or 1, n_neg_heads]}
-
-neg_tails:
Optional
[Dict
[str
, ndarray
[Any
, dtype
[int32
]]]] = None
+neg_tails: Optional
[Dict
[str
, ndarray
[Any
, dtype
[int32
]]]] = None
IDs of (possibly triple-specific) negative tails;
{part: int32[n_triple or 1, n_neg_tails]}
-
-relation_dict:
Optional
[List
[str
]] = None
+relation_dict: Optional
[List
[str
]] = None
Relation type labels by ID; str[n_relation_type]
@@ -337,24 +337,24 @@ besskge.dataset.KGDataset
- Parameters:
-out_file (Path
) – Path to output file.
+out_file (Path
) – Path to output file.
- Return type:
--
+
-
-
-triples:
Dict
[str
, ndarray
[Any
, dtype
[int32
]]]
+triples: Dict
[str
, ndarray
[Any
, dtype
[int32
]]]
List of (h_ID, r_ID, t_ID) triples, for each part of the dataset;
{part: int32[n_triple, {h,r,t}]}
-
-type_offsets:
Optional
[Dict
[str
, int
]] = None
+type_offsets: Optional
[Dict
[str
, int
]] = None
If entities have types, IDs are assumed to be clustered by type;
{entity_type: int}
diff --git a/generated/besskge.embedding.init_KGE_normal.html b/generated/besskge.embedding.init_KGE_normal.html
index bc7a81a..5c7883d 100644
--- a/generated/besskge.embedding.init_KGE_normal.html
+++ b/generated/besskge.embedding.init_KGE_normal.html
@@ -108,13 +108,13 @@ besskge.embedding.init_KGE_normal
- Parameters:
-embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
-std (float
) – Standard deviation. Default: 1.0.
-divide_by_embedding_size (bool
) – Rescale standard deviation by 1/row_size. Default: True.
+embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
+std (float
) – Standard deviation. Default: 1.0.
+divide_by_embedding_size (bool
) – Rescale standard deviation by 1/row_size. Default: True.
- Return type:
--
+
-
- Returns:
Initialized tensor.
diff --git a/generated/besskge.embedding.init_KGE_uniform.html b/generated/besskge.embedding.init_KGE_uniform.html
index 146248d..beab19d 100644
--- a/generated/besskge.embedding.init_KGE_uniform.html
+++ b/generated/besskge.embedding.init_KGE_uniform.html
@@ -108,13 +108,13 @@ besskge.embedding.init_KGE_uniform
- Parameters:
-embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
-b (float
) – Positive boundary of distribution support. Default: 1.0.
-divide_by_embedding_size (bool
) – Rescale distribution support by 1/row_size. Default: True.
+embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
+b (float
) – Positive boundary of distribution support. Default: 1.0.
+divide_by_embedding_size (bool
) – Rescale distribution support by 1/row_size. Default: True.
- Return type:
--
+
-
- Returns:
Initialized tensor.
diff --git a/generated/besskge.embedding.init_uniform_norm.html b/generated/besskge.embedding.init_uniform_norm.html
index 9641e88..dbc927c 100644
--- a/generated/besskge.embedding.init_uniform_norm.html
+++ b/generated/besskge.embedding.init_uniform_norm.html
@@ -108,10 +108,10 @@ besskge.embedding.init_uniform_norm
- Parameters:
-embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
+embedding_table (Tensor
) – Tensor of embedding parameters to initialize.
- Return type:
--
+
-
- Returns:
Initialized tensor.
diff --git a/generated/besskge.embedding.initialize_entity_embedding.html b/generated/besskge.embedding.initialize_entity_embedding.html
index 945187b..2384db6 100644
--- a/generated/besskge.embedding.initialize_entity_embedding.html
+++ b/generated/besskge.embedding.initialize_entity_embedding.html
@@ -109,13 +109,13 @@ besskge.embedding.initialize_entity_embeddingParameters:
sharding (Sharding
) – Entity sharding.
-initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Embedding table or list of initializing functions. If providing
+
initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Embedding table or list of initializing functions. If providing
an embedding table, this can either be sharded
(shape: [n_shard, max_entity_per_shard, row_size])
or unsharded [shape: (n_entity, row_size]).
If providing list of initializers, this needs to be of same length
as row_size
.
-row_size (Optional
[List
[int
]]) – Number of parameters for each entity.
+
row_size (Optional
[List
[int
]]) – Number of parameters for each entity.
This needs to be a list, with the lengths of the different embedding tensors
to allocate for each entity. Each embedding tensor, once allocated, is
initialized with the corresponding entry of initializer
.
@@ -123,7 +123,7 @@
besskge.embedding.initialize_entity_embeddingReturn type:
--
+
-
- Returns:
shape: (n_shard, max_ent_per_shard, row_size)
diff --git a/generated/besskge.embedding.initialize_relation_embedding.html b/generated/besskge.embedding.initialize_relation_embedding.html
index 2ee3ff9..e2acd99 100644
--- a/generated/besskge.embedding.initialize_relation_embedding.html
+++ b/generated/besskge.embedding.initialize_relation_embedding.html
@@ -108,15 +108,15 @@
besskge.embedding.initialize_relation_embedding
- Parameters:
-n_relation_type (int
) – Number of relation types.
-inverse_relations (bool
) – If True, learn embeddings for inverse relations, in addition to direct ones.
+
n_relation_type (int
) – Number of relation types.
+inverse_relations (bool
) – If True, learn embeddings for inverse relations, in addition to direct ones.
Needs to be set to True when inverse triples are added to the dataset.
Given a relation with ID i, its inverse is the one with
ID i+n_relation_type.
-initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Embedding table or list of initializing functions.
+
initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Embedding table or list of initializing functions.
If providing list of initializers, this needs to be of same length
as row_size
.
-row_size (Optional
[List
[int
]]) – Number of parameters for each relation type.
+
row_size (Optional
[List
[int
]]) – Number of parameters for each relation type.
This needs to be a list, with the lengths of the different embedding tensors
to allocate for each relation. Each embedding tensor, once allocated, is
initialized with the corresponding entry of initializer
.
@@ -124,7 +124,7 @@
besskge.embedding.initialize_relation_embeddingReturn type:
--
+
-
- Returns:
Relation embedding table.
diff --git a/generated/besskge.embedding.refactor_embedding_sharding.html b/generated/besskge.embedding.refactor_embedding_sharding.html
index ae5688d..a61c25a 100644
--- a/generated/besskge.embedding.refactor_embedding_sharding.html
+++ b/generated/besskge.embedding.refactor_embedding_sharding.html
@@ -109,14 +109,14 @@ besskge.embedding.refactor_embedding_sharding
- Parameters:
-entity_embedding (Parameter
) – shape: (n_shard_old, max_ent_per_shard_old, row_size)
+
entity_embedding (Parameter
) – shape: (n_shard_old, max_ent_per_shard_old, row_size)
Entity embedding table sharded according to old_sharding.
old_sharding (Sharding
) – The current entity sharding.
new_sharding (Sharding
) – The new entity sharding.
- Return type:
--
+
-
- Returns:
shape: (n_shard_new, max_ent_per_shard_new, row_size)
diff --git a/generated/besskge.loss.BaseLossFunction.html b/generated/besskge.loss.BaseLossFunction.html
index c16a533..f9933f1 100644
--- a/generated/besskge.loss.BaseLossFunction.html
+++ b/generated/besskge.loss.BaseLossFunction.html
@@ -115,16 +115,16 @@
besskge.loss.BaseLossFunction
- Parameters:
-positive_score (Tensor
) – shape: (batch_size,)
+
positive_score (Tensor
) – shape: (batch_size,)
Scores of positive triples.
-negative_score (Tensor
) – shape: (batch_size, n_negative)
+
negative_score (Tensor
) – shape: (batch_size, n_negative)
Scores of negative triples.
-triple_weight (Tensor
) – shape: (batch_size,) or ()
+
triple_weight (Tensor
) – shape: (batch_size,) or ()
Weights of positive triples.
- Return type:
--
+
-
- Returns:
The batch loss.
@@ -138,11 +138,11 @@ besskge.loss.BaseLossFunction
- Parameters:
-negative_score (Tensor
) – : (batch_size, n_negative)
+
negative_score (Tensor
) – : (batch_size, n_negative)
Scores of negative samples.
- Return type:
--
+
-
- Returns:
shape: (batch_size, n_negative)
@@ -154,19 +154,19 @@
besskge.loss.BaseLossFunction
-
-loss_scale:
Tensor
+loss_scale: Tensor
Loss scaling factor, might be needed when using FP16 weights
-
-negative_adversarial_sampling:
bool
+negative_adversarial_sampling: bool
Use self-adversarial weighting of negative samples.
-
-negative_adversarial_scale:
Tensor
+negative_adversarial_scale: Tensor
Reciprocal temperature of self-adversarial weighting
diff --git a/generated/besskge.loss.LogSigmoidLoss.html b/generated/besskge.loss.LogSigmoidLoss.html
index 5979c17..a5b41b9 100644
--- a/generated/besskge.loss.LogSigmoidLoss.html
+++ b/generated/besskge.loss.LogSigmoidLoss.html
@@ -108,10 +108,10 @@ besskge.loss.LogSigmoidLoss
- Parameters:
-margin (float
) – The margin to be used in the loss computation.
-negative_adversarial_sampling (bool
) – see BaseLossFunction
-negative_adversarial_scale (float
) – see BaseLossFunction
-loss_scale (float
) – see BaseLossFunction
+margin (float
) – The margin to be used in the loss computation.
+negative_adversarial_sampling (bool
) – see BaseLossFunction
+negative_adversarial_scale (float
) – see BaseLossFunction
+loss_scale (float
) – see BaseLossFunction
@@ -122,16 +122,16 @@ besskge.loss.LogSigmoidLoss
- Parameters:
-positive_score (Tensor
) – shape: (batch_size,)
+
positive_score (Tensor
) – shape: (batch_size,)
Scores of positive triples.
-negative_score (Tensor
) – shape: (batch_size, n_negative)
+
negative_score (Tensor
) – shape: (batch_size, n_negative)
Scores of negative triples.
-triple_weight (Tensor
) – shape: (batch_size,) or ()
+
triple_weight (Tensor
) – shape: (batch_size,) or ()
Weights of positive triples.
- Return type:
--
+
-
- Returns:
The batch loss.
@@ -145,11 +145,11 @@ besskge.loss.LogSigmoidLoss
- Parameters:
-negative_score (Tensor
) – : (batch_size, n_negative)
+
negative_score (Tensor
) – : (batch_size, n_negative)
Scores of negative samples.
- Return type:
--
+
-
- Returns:
shape: (batch_size, n_negative)
@@ -161,19 +161,19 @@
besskge.loss.LogSigmoidLoss
-
-loss_scale:
Tensor
+loss_scale: Tensor
Loss scaling factor, might be needed when using FP16 weights
-
-negative_adversarial_sampling:
bool
+negative_adversarial_sampling: bool
Use self-adversarial weighting of negative samples.
-
-negative_adversarial_scale:
Tensor
+negative_adversarial_scale: Tensor
Reciprocal temperature of self-adversarial weighting
diff --git a/generated/besskge.loss.MarginBasedLossFunction.html b/generated/besskge.loss.MarginBasedLossFunction.html
index 711a137..5572a81 100644
--- a/generated/besskge.loss.MarginBasedLossFunction.html
+++ b/generated/besskge.loss.MarginBasedLossFunction.html
@@ -108,10 +108,10 @@ besskge.loss.MarginBasedLossFunction
- Parameters:
-margin (float
) – The margin to be used in the loss computation.
-negative_adversarial_sampling (bool
) – see BaseLossFunction
-negative_adversarial_scale (float
) – see BaseLossFunction
-loss_scale (float
) – see BaseLossFunction
+margin (float
) – The margin to be used in the loss computation.
+negative_adversarial_sampling (bool
) – see BaseLossFunction
+negative_adversarial_scale (float
) – see BaseLossFunction
+loss_scale (float
) – see BaseLossFunction
@@ -122,16 +122,16 @@ besskge.loss.MarginBasedLossFunction
- Parameters:
-positive_score (Tensor
) – shape: (batch_size,)
+
positive_score (Tensor
) – shape: (batch_size,)
Scores of positive triples.
-negative_score (Tensor
) – shape: (batch_size, n_negative)
+
negative_score (Tensor
) – shape: (batch_size, n_negative)
Scores of negative triples.
-triple_weight (Tensor
) – shape: (batch_size,) or ()
+
triple_weight (Tensor
) – shape: (batch_size,) or ()
Weights of positive triples.
- Return type:
--
+
-
- Returns:
The batch loss.
@@ -145,11 +145,11 @@ besskge.loss.MarginBasedLossFunction
- Parameters:
-negative_score (Tensor
) – : (batch_size, n_negative)
+
negative_score (Tensor
) – : (batch_size, n_negative)
Scores of negative samples.
- Return type:
--
+
-
- Returns:
shape: (batch_size, n_negative)
@@ -161,19 +161,19 @@
besskge.loss.MarginBasedLossFunction
-
-loss_scale:
Tensor
+loss_scale: Tensor
Loss scaling factor, might be needed when using FP16 weights
-
-negative_adversarial_sampling:
bool
+negative_adversarial_sampling: bool
Use self-adversarial weighting of negative samples.
-
-negative_adversarial_scale:
Tensor
+negative_adversarial_scale: Tensor
Reciprocal temperature of self-adversarial weighting
diff --git a/generated/besskge.loss.MarginRankingLoss.html b/generated/besskge.loss.MarginRankingLoss.html
index 984f57a..d5f8868 100644
--- a/generated/besskge.loss.MarginRankingLoss.html
+++ b/generated/besskge.loss.MarginRankingLoss.html
@@ -108,11 +108,11 @@ besskge.loss.MarginRankingLoss
- Parameters:
-margin (float
) – see MarginBasedLossFunction.__init__()
-negative_adversarial_sampling (bool
) – see BaseLossFunction
-negative_adversarial_scale (float
) – see BaseLossFunction
-loss_scale (float
) – see BaseLossFunction
-activation_function (str
) – The activation function in loss computation. Default: “relu”.
+margin (float
) – see MarginBasedLossFunction.__init__()
+negative_adversarial_sampling (bool
) – see BaseLossFunction
+negative_adversarial_scale (float
) – see BaseLossFunction
+loss_scale (float
) – see BaseLossFunction
+activation_function (str
) – The activation function in loss computation. Default: “relu”.
@@ -123,16 +123,16 @@ besskge.loss.MarginRankingLoss
- Parameters:
-positive_score (Tensor
) – shape: (batch_size,)
+
positive_score (Tensor
) – shape: (batch_size,)
Scores of positive triples.
-negative_score (Tensor
) – shape: (batch_size, n_negative)
+
negative_score (Tensor
) – shape: (batch_size, n_negative)
Scores of negative triples.
-triple_weight (Tensor
) – shape: (batch_size,) or ()
+
triple_weight (Tensor
) – shape: (batch_size,) or ()
Weights of positive triples.
- Return type:
--
+
-
- Returns:
The batch loss.
@@ -146,11 +146,11 @@ besskge.loss.MarginRankingLoss
- Parameters:
-negative_score (Tensor
) – : (batch_size, n_negative)
+
negative_score (Tensor
) – : (batch_size, n_negative)
Scores of negative samples.
- Return type:
--
+
-
- Returns:
shape: (batch_size, n_negative)
@@ -162,19 +162,19 @@
besskge.loss.MarginRankingLoss
-
-loss_scale:
Tensor
+loss_scale: Tensor
Loss scaling factor, might be needed when using FP16 weights
-
-negative_adversarial_sampling:
bool
+negative_adversarial_sampling: bool
Use self-adversarial weighting of negative samples.
-
-negative_adversarial_scale:
Tensor
+negative_adversarial_scale: Tensor
Reciprocal temperature of self-adversarial weighting
diff --git a/generated/besskge.loss.SampledSoftmaxCrossEntropyLoss.html b/generated/besskge.loss.SampledSoftmaxCrossEntropyLoss.html
index f523ef7..abbd947 100644
--- a/generated/besskge.loss.SampledSoftmaxCrossEntropyLoss.html
+++ b/generated/besskge.loss.SampledSoftmaxCrossEntropyLoss.html
@@ -109,8 +109,8 @@ besskge.loss.SampledSoftmaxCrossEntropyLoss
- Parameters:
-n_entity (int
) – The total number of entities in the knowledge graph.
-loss_scale (float
) – see BaseLossFunction
+n_entity (int
) – The total number of entities in the knowledge graph.
+loss_scale (float
) – see BaseLossFunction
@@ -121,16 +121,16 @@ besskge.loss.SampledSoftmaxCrossEntropyLoss
- Parameters:
-positive_score (Tensor
) – shape: (batch_size,)
+
positive_score (Tensor
) – shape: (batch_size,)
Scores of positive triples.
-negative_score (Tensor
) – shape: (batch_size, n_negative)
+
negative_score (Tensor
) – shape: (batch_size, n_negative)
Scores of negative triples.
-triple_weight (Tensor
) – shape: (batch_size,) or ()
+
triple_weight (Tensor
) – shape: (batch_size,) or ()
Weights of positive triples.
- Return type:
--
+
-
- Returns:
The batch loss.
@@ -144,11 +144,11 @@ besskge.loss.SampledSoftmaxCrossEntropyLoss
- Parameters:
-negative_score (Tensor
) – : (batch_size, n_negative)
+
negative_score (Tensor
) – : (batch_size, n_negative)
Scores of negative samples.
- Return type:
--
+
-
- Returns:
shape: (batch_size, n_negative)
@@ -160,19 +160,19 @@
besskge.loss.SampledSoftmaxCrossEntropyLoss
-
-loss_scale:
Tensor
+loss_scale: Tensor
Loss scaling factor, might be needed when using FP16 weights
-
-negative_adversarial_sampling:
bool
+negative_adversarial_sampling: bool
Use self-adversarial weighting of negative samples.
-
-negative_adversarial_scale:
Tensor
+negative_adversarial_scale: Tensor
Reciprocal temperature of self-adversarial weighting
diff --git a/generated/besskge.metric.Evaluation.html b/generated/besskge.metric.Evaluation.html
index 3da7b45..33b91d5 100644
--- a/generated/besskge.metric.Evaluation.html
+++ b/generated/besskge.metric.Evaluation.html
@@ -108,15 +108,15 @@ besskge.metric.Evaluation
- Parameters:
-metric_list (List
[str
]) – List of metrics to compute. Currently supports “mrr” and “hits@K”.
-mode (str
) – Mode used for metrics. Can be “optimistic”, “pessimistic”
+
metric_list (List
[str
]) – List of metrics to compute. Currently supports “mrr” and “hits@K”.
+mode (str
) – Mode used for metrics. Can be “optimistic”, “pessimistic”
or “average”. Default: “average”.
-worst_rank_infty (bool
) – If True, assign a prediction rank of infinity as the worst possible
+
worst_rank_infty (bool
) – If True, assign a prediction rank of infinity as the worst possible
rank. If False, assign a prediction rank of n_negative + 1 as the
worst possible rank. Default: False.
-reduction (str
) – Method to use to reduce metrics along the batch dimension.
+
reduction (str
) – Method to use to reduce metrics along the batch dimension.
Currently supports “none” (no reduction) and “sum”.
-return_ranks (bool
) – If True, returns prediction ranks alongside metrics.
+return_ranks (bool
) – If True, returns prediction ranks alongside metrics.
@@ -128,15 +128,15 @@ besskge.metric.Evaluation
- Parameters:
-
- Return type:
--
+
-
- Returns:
The dictionary of (reduced) batch metrics.
@@ -152,16 +152,16 @@ besskge.metric.Evaluation
- Parameters:
-ground_truth (Tensor
) – shape: (batch_size,)
+
ground_truth (Tensor
) – shape: (batch_size,)
Indices of ground truth entities for each query.
-candidate_indices (Tensor
) – shape: (batch_size, n_candidates)
+
candidate_indices (Tensor
) – shape: (batch_size, n_candidates)
Indices of top n_candidates predicted entities,
ordered by decreasing likelihood. The indices
on each row are assumed to be distinct.
- Return type:
--
+
-
- Returns:
The rank of the ground truth among the predictions.
@@ -178,14 +178,14 @@ besskge.metric.Evaluation
- Parameters:
-
- Return type:
--
+
-
- Returns:
The rank of the positive score among the ordered scores
@@ -203,14 +203,14 @@
besskge.metric.Evaluation
- Parameters:
-batch_rank (Tensor
) – shape: (batch_size,)
+
batch_rank (Tensor
) – shape: (batch_size,)
see Evaluation.dict_metrics_from_ranks()
.
-triple_mask (Optional
[Tensor
]) – shape: (batch_size,)
see Evaluation.dict_metrics_from_ranks()
.
- Return type:
--
+
-
- Returns:
shape: (1, n_metrics, batch_size)
diff --git a/generated/besskge.metric.HitsAtK.html b/generated/besskge.metric.HitsAtK.html
index 81b3257..fefbed1 100644
--- a/generated/besskge.metric.HitsAtK.html
+++ b/generated/besskge.metric.HitsAtK.html
@@ -108,7 +108,7 @@
besskge.metric.HitsAtK
diff --git a/generated/besskge.negative_sampler.PlaceholderNegativeSampler.html b/generated/besskge.negative_sampler.PlaceholderNegativeSampler.html
index e1b5ce1..0706d58 100644
--- a/generated/besskge.negative_sampler.PlaceholderNegativeSampler.html
+++ b/generated/besskge.negative_sampler.PlaceholderNegativeSampler.html
@@ -110,26 +110,26 @@ besskge.negative_sampler.PlaceholderNegativeSampler
- Parameters:
-corruption_scheme (str
) – see ShardedNegativeSampler
-seed (int
) – No effect.
+corruption_scheme (str
) – see ShardedNegativeSampler
+seed (int
) – No effect.
-
-flat_negative_format:
bool
+flat_negative_format: bool
Sample negatives per triple partition, instead of per triple
diff --git a/generated/besskge.negative_sampler.RandomShardedNegativeSampler.html b/generated/besskge.negative_sampler.RandomShardedNegativeSampler.html
index 82ebd5a..1de1dd6 100644
--- a/generated/besskge.negative_sampler.RandomShardedNegativeSampler.html
+++ b/generated/besskge.negative_sampler.RandomShardedNegativeSampler.html
@@ -108,17 +108,17 @@ besskge.negative_sampler.RandomShardedNegativeSampler
- Parameters:
-n_negative (int
) – Number of negative samples per shard-pair
+
n_negative (int
) – Number of negative samples per shard-pair
(if flat_negative_format
) or per triple.
sharding (Sharding
) – Sharding of entities.
-seed (int
) – Seed of RNG.
-corruption_scheme (str
) – “h”: corrupt head 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
+
local_sampling (bool
) – If True, sample negative entities only from the shard where the
triple is processed.
-flat_negative_format (bool
) – If True, sample n_negative
negative entities for each
+
flat_negative_format (bool
) – If True, sample n_negative
negative entities for each
shard-pair, instead of each triple. If True, requires use of
negative sample sharing. Default: False.
@@ -126,19 +126,19 @@ besskge.negative_sampler.RandomShardedNegativeSampler
-
-flat_negative_format:
bool
+flat_negative_format: bool
Sample negatives per triple partition, instead of per triple
diff --git a/generated/besskge.negative_sampler.ShardedNegativeSampler.html b/generated/besskge.negative_sampler.ShardedNegativeSampler.html
index 3e2398a..ee75865 100644
--- a/generated/besskge.negative_sampler.ShardedNegativeSampler.html
+++ b/generated/besskge.negative_sampler.ShardedNegativeSampler.html
@@ -106,19 +106,19 @@ besskge.negative_sampler.ShardedNegativeSampler
-
-corruption_scheme:
str
+corruption_scheme: str
Which entity to corrupt; “h”, “t”, “ht”
-
-flat_negative_format:
bool
+flat_negative_format: bool
Sample negatives per triple partition, instead of per triple
diff --git a/generated/besskge.negative_sampler.TripleBasedShardedNegativeSampler.html b/generated/besskge.negative_sampler.TripleBasedShardedNegativeSampler.html
index 4b80057..ebde14b 100644
--- a/generated/besskge.negative_sampler.TripleBasedShardedNegativeSampler.html
+++ b/generated/besskge.negative_sampler.TripleBasedShardedNegativeSampler.html
@@ -108,20 +108,20 @@ besskge.negative_sampler.TripleBasedShardedNegativeSampler
- Parameters:
-negative_heads (Optional
[ndarray
[Any
, dtype
[int32
]]]) – shape: (N, n_negative)
+
negative_heads (Optional
[ndarray
[Any
, dtype
[int32
]]]) – shape: (N, n_negative)
Global entity IDs of negative heads, specific
for each triple (N=n_triple) or for all of them (N=1).
-negative_tails (Optional
[ndarray
[Any
, dtype
[int32
]]]) – shape: (N, n_negative)
+
negative_tails (Optional
[ndarray
[Any
, dtype
[int32
]]]) – shape: (N, n_negative)
Global entity IDs of negative tails, specific
for each triple (N=n_triple) or for all of them (N=1).
sharding (Sharding
) – see RandomShardedNegativeSampler.__init__()
-corruption_scheme (str
) – see RandomShardedNegativeSampler.__init__()
-seed (int
) – see RandomShardedNegativeSampler.__init__()
-mask_on_gather (bool
) – If True, shape the negative mask to be applied on the device where
+
corruption_scheme (str
) – see RandomShardedNegativeSampler.__init__()
+seed (int
) – see RandomShardedNegativeSampler.__init__()
+mask_on_gather (bool
) – If True, shape the negative mask to be applied on the device where
negative entities are gathered, instead of the one where they
are scored. Set to True only when using
besskge.bess.TopKQueryBessKGE
. Default: False.
-return_sort_idx (bool
) – If True, return for each triple in the batch the sorting indices
+
return_sort_idx (bool
) – If True, return for each triple in the batch the sorting indices
to recover the same ordering of negatives as in
negative_heads
, negative_tails
. Default: False.
@@ -129,19 +129,19 @@ besskge.negative_sampler.TripleBasedShardedNegativeSampler
-
-corruption_scheme:
str
+corruption_scheme: str
Which entity to corrupt; “h”, “t”, “ht”
-
-flat_negative_format:
bool
+flat_negative_format: bool
Sample negatives per triple partition, instead of per triple
@@ -152,12 +152,12 @@ besskge.negative_sampler.TripleBasedShardedNegativeSampler
- Parameters:
-negatives (ndarray
[Any
, dtype
[int32
]]) – shape: (N, n_negative)
+
negatives (ndarray
[Any
, dtype
[int32
]]) – shape: (N, n_negative)
Negative entities, each row already sorted in shard order
(N = 1, n_triple).
-shard_counts (ndarray
[Any
, dtype
[int64
]]) – shape: (N, n_shard)
+
shard_counts (ndarray
[Any
, dtype
[int64
]]) – shape: (N, n_shard)
Number of negatives per shard.
-padded_shard_length (int
) – The size to which each shard list is to be padded.
+padded_shard_length (int
) – The size to which each shard list is to be padded.
- Return padded_negatives:
@@ -169,7 +169,7 @@ besskge.negative_sampler.TripleBasedShardedNegativeSamplerpadded_negatives.view(N,-1).
- Return type:
-Tuple
[ndarray
[Any
, dtype
[int32
]], ndarray
[Any
, dtype
[bool_
]]]
+Tuple
[ndarray
[Any
, dtype
[int32
]], ndarray
[Any
, dtype
[bool_
]]]
@@ -186,7 +186,7 @@ besskge.negative_sampler.TripleBasedShardedNegativeSampler
- Parameters:
-negatives (ndarray
[Any
, dtype
[int32
]]) – shape: (N, n_negatives)
+
negatives (ndarray
[Any
, dtype
[int32
]]) – shape: (N, n_negatives)
Negative entities to shard (N = 1, n_triple).
- Return shard_neg_counts:
@@ -198,7 +198,7 @@ besskge.negative_sampler.TripleBasedShardedNegativeSamplerReturn type:
-Tuple
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[int32
]]]
+Tuple
[ndarray
[Any
, dtype
[int64
]], ndarray
[Any
, dtype
[int32
]]]
diff --git a/generated/besskge.negative_sampler.TypeBasedShardedNegativeSampler.html b/generated/besskge.negative_sampler.TypeBasedShardedNegativeSampler.html
index c226711..9e4cdaa 100644
--- a/generated/besskge.negative_sampler.TypeBasedShardedNegativeSampler.html
+++ b/generated/besskge.negative_sampler.TypeBasedShardedNegativeSampler.html
@@ -108,31 +108,31 @@ besskge.negative_sampler.TypeBasedShardedNegativeSampler
- Parameters:
-triple_types (ndarray
[Any
, dtype
[int32
]]) – shape: (n_triple, 2)
+
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__()
+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
) – see RandomShardedNegativeSampler.__init__()
+local_sampling (bool
) – see RandomShardedNegativeSampler.__init__()
+seed (int
) – see RandomShardedNegativeSampler.__init__()
-
-flat_negative_format:
bool
+flat_negative_format: bool
Sample negatives per triple partition, instead of per triple
diff --git a/generated/besskge.scoring.BaseScoreFunction.html b/generated/besskge.scoring.BaseScoreFunction.html
index cae8c21..3f6d410 100644
--- a/generated/besskge.scoring.BaseScoreFunction.html
+++ b/generated/besskge.scoring.BaseScoreFunction.html
@@ -116,7 +116,7 @@ besskge.scoring.BaseScoreFunction
-
-entity_embedding:
Parameter
+entity_embedding: Parameter
Entity embedding table
@@ -126,13 +126,13 @@ besskge.scoring.BaseScoreFunctionBaseScoreFunction.score_triple()
- Return type:
--
+
-
- Parameters:
-
@@ -140,13 +140,13 @@ besskge.scoring.BaseScoreFunction
-
-negative_sample_sharing:
bool
+negative_sample_sharing: bool
Share negative entities to construct negative samples
@@ -157,16 +157,16 @@ besskge.scoring.BaseScoreFunction
- Parameters:
-head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
+
head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
Embeddings of head entities.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embedding of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_heads)
@@ -184,16 +184,16 @@
besskge.scoring.BaseScoreFunction
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
+
tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
Embedding of tail entities.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_tails)
@@ -211,16 +211,16 @@
besskge.scoring.BaseScoreFunction
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size,)
@@ -244,7 +244,7 @@
besskge.scoring.BaseScoreFunctionnew_sharding (Sharding
) – The new entity sharding.
- Return type:
--
+
-
diff --git a/generated/besskge.scoring.BoxE.html b/generated/besskge.scoring.BoxE.html
index 88982aa..28fb804 100644
--- a/generated/besskge.scoring.BoxE.html
+++ b/generated/besskge.scoring.BoxE.html
@@ -115,25 +115,25 @@ besskge.scoring.BoxE
- Parameters:
-negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
-scoring_norm (int
) – see DistanceBasedScoreFunction.__init__()
+negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
+scoring_norm (int
) – see DistanceBasedScoreFunction.__init__()
sharding (Sharding
) – Entity sharding.
-n_relation_type (int
) – Number of relation types in the knowledge graph.
-embedding_size (int
) – Size of final entity embeddings.
-entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
-relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization functions or table for relation embeddings.
+
n_relation_type (int
) – Number of relation types in the knowledge graph.
+embedding_size (int
) – Size of final entity embeddings.
+entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
+relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization functions or table for relation embeddings.
If not passing a table, two functions are needed: the initializer
for head/tail box centers and the initializer for
(scalar) head/tail box sizes.
-apply_tanh (bool
) – If True, bound relation box sizes and bumped entity
+
apply_tanh (bool
) – If True, bound relation box sizes and bumped entity
representations with tanh. Default: True.
-dist_func_per_dim (bool
) – If True, instead of selecting between the two BoxE distance
+
dist_func_per_dim (bool
) – If True, instead of selecting between the two BoxE distance
functions based on whether the bumped representation is inside
or outside the relation box, make the choice separately for
each dimension of the embedding space. Default: True.
-eps (float
) – Softening parameter for geometric normalization of box widths.
+
eps (float
) – Softening parameter for geometric normalization of box widths.
Default: 1e-6.
-inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
+inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
@@ -144,25 +144,25 @@ besskge.scoring.BoxE
- Parameters:
-bumped_ht (Tensor
) – shape: (batch_size, 2, emb_size)
+
bumped_ht (Tensor
) – shape: (batch_size, 2, emb_size)
or (batch_size, n_negative, 2, emb_size)
Bumped h/t entity embeddings (heads: bumped_ht[…,0,:],
tails: bumped_ht[…,1,:]).
-center_ht (Tensor
) – shape: (batch_size, 2, emb_size)
+
center_ht (Tensor
) – shape: (batch_size, 2, emb_size)
or (batch_size, 1, 2, emb_size)
Centers of h/t relation boxes
(heads: center_ht[…,0,:], tails: center_ht[…,1,:]).
-width_ht (Tensor
) – shape: (batch_size, 2, emb_size) or (batch_size, 1, 2, emb_size)
+
width_ht (Tensor
) – shape: (batch_size, 2, emb_size) or (batch_size, 1, 2, emb_size)
Widths of h/t relation boxes, before normalization
(heads: width_ht[…,0,:], tails: width_ht[…,1,:]).
-box_size (Tensor
) – shape: (batch_size, 2) or (batch_size, 1, 2)
+
box_size (Tensor
) – shape: (batch_size, 2) or (batch_size, 1, 2)
Parameter controlling the size of the (normalized)
h/t relation boxes
(heads: box_size[…,0], tails: box_size[…,1]).
- Return type:
--
+
-
- Returns:
shape: shape: (batch_size,) or (batch_size, n_negative)
@@ -180,14 +180,14 @@
besskge.scoring.BoxE
- Parameters:
-v1 (Tensor
) – shape: (batch_size, embedding_size)
+
v1 (Tensor
) – shape: (batch_size, embedding_size)
Batch queries.
-v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
+
v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
Negative embeddings to score against queries.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_neg) if
@@ -199,7 +199,7 @@
besskge.scoring.BoxE
-
-entity_embedding:
Parameter
+entity_embedding: Parameter
Entity embedding table
@@ -209,13 +209,13 @@ besskge.scoring.BoxEsee BaseScoreFunction.score_triple()
- Return type:
--
+
-
- Parameters:
-
@@ -223,7 +223,7 @@ besskge.scoring.BoxE
-
-negative_sample_sharing:
bool
+negative_sample_sharing: bool
Share negative entities to construct negative samples
@@ -233,11 +233,11 @@ besskge.scoring.BoxEp-norm reduction along embedding dimension.
- Parameters:
-v (Tensor
) – shape: (*, embedding_size)
+
v (Tensor
) – shape: (*, embedding_size)
The tensor to reduce.
- Return type:
--
+
-
- Returns:
shape: (*,)
@@ -248,7 +248,7 @@
besskge.scoring.BoxE
-
-relation_embedding:
Parameter
+relation_embedding: Parameter
Relation embedding table
@@ -259,16 +259,16 @@ besskge.scoring.BoxE
- Parameters:
-head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
+
head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
Embeddings of head entities.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embedding of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_heads)
@@ -286,16 +286,16 @@
besskge.scoring.BoxE
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
+
tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
Embedding of tail entities.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_tails)
@@ -313,16 +313,16 @@
besskge.scoring.BoxE
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size,)
@@ -346,7 +346,7 @@
besskge.scoring.BoxEnew_sharding (Sharding
) – The new entity sharding.
- Return type:
--
+
-
diff --git a/generated/besskge.scoring.ComplEx.html b/generated/besskge.scoring.ComplEx.html
index f6a95d5..a11d72e 100644
--- a/generated/besskge.scoring.ComplEx.html
+++ b/generated/besskge.scoring.ComplEx.html
@@ -115,13 +115,13 @@ besskge.scoring.ComplEx
- Parameters:
-negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
+negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
sharding (Sharding
) – Entity sharding.
-n_relation_type (int
) – Number of relation types in the knowledge graph.
-embedding_size (int
) – Complex size of entity and relation embeddings.
-entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
-relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for relation embeddings.
-inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
+n_relation_type (int
) – Number of relation types in the knowledge graph.
+embedding_size (int
) – Complex size of entity and relation embeddings.
+entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
+relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for relation embeddings.
+inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
@@ -134,14 +134,14 @@ besskge.scoring.ComplEx
- Parameters:
-v1 (Tensor
) – shape: (batch_size, embedding_size)
+
v1 (Tensor
) – shape: (batch_size, embedding_size)
Batch queries.
-v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
+
v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
Negative embeddings to score against queries.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_neg) if
@@ -153,7 +153,7 @@
besskge.scoring.ComplEx
-
-entity_embedding:
Parameter
+entity_embedding: Parameter
Entity embedding table
@@ -163,13 +163,13 @@ besskge.scoring.ComplExsee BaseScoreFunction.score_triple()
- Return type:
--
+
-
- Parameters:
-
@@ -177,7 +177,7 @@ besskge.scoring.ComplEx
-
-negative_sample_sharing:
bool
+negative_sample_sharing: bool
Share negative entities to construct negative samples
@@ -187,11 +187,11 @@ besskge.scoring.ComplExSum reduction along the embedding dimension.
- Parameters:
-v (Tensor
) – shape: (*, embedding_size)
+
v (Tensor
) – shape: (*, embedding_size)
The tensor to reduce.
- Return type:
--
+
-
- Returns:
shape: (*,)
@@ -202,7 +202,7 @@
besskge.scoring.ComplEx
-
-relation_embedding:
Parameter
+relation_embedding: Parameter
Relation embedding table
@@ -213,16 +213,16 @@ besskge.scoring.ComplEx
- Parameters:
-head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
+
head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
Embeddings of head entities.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embedding of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_heads)
@@ -240,16 +240,16 @@
besskge.scoring.ComplEx
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
+
tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
Embedding of tail entities.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_tails)
@@ -267,16 +267,16 @@
besskge.scoring.ComplEx
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size,)
@@ -300,7 +300,7 @@
besskge.scoring.ComplExnew_sharding (Sharding
) – The new entity sharding.
- Return type:
--
+
-
diff --git a/generated/besskge.scoring.DistMult.html b/generated/besskge.scoring.DistMult.html
index 24433df..79d9b42 100644
--- a/generated/besskge.scoring.DistMult.html
+++ b/generated/besskge.scoring.DistMult.html
@@ -115,13 +115,13 @@ besskge.scoring.DistMult
- Parameters:
-negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
+negative_sample_sharing (bool
) – see DistanceBasedScoreFunction.__init__()
sharding (Sharding
) – Entity sharding.
-n_relation_type (int
) – Number of relation types in the knowledge graph.
-embedding_size (int
) – Size of entity and relation embeddings.
-entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
-relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for relation embeddings.
-inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
+n_relation_type (int
) – Number of relation types in the knowledge graph.
+embedding_size (int
) – Size of entity and relation embeddings.
+entity_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for entity embeddings.
+relation_initializer (Union
[Tensor
, List
[Callable
[...
, Tensor
]]]) – Initialization function or table for relation embeddings.
+inverse_relations (bool
) – If True, learn embeddings for inverse relations. Default: False
@@ -134,14 +134,14 @@ besskge.scoring.DistMult
- Parameters:
-v1 (Tensor
) – shape: (batch_size, embedding_size)
+
v1 (Tensor
) – shape: (batch_size, embedding_size)
Batch queries.
-v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
+
v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
Negative embeddings to score against queries.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_neg) if
@@ -153,7 +153,7 @@
besskge.scoring.DistMult
-
-entity_embedding:
Parameter
+entity_embedding: Parameter
Entity embedding table
@@ -163,13 +163,13 @@ besskge.scoring.DistMultBaseScoreFunction.score_triple()
- Return type:
--
+
-
- Parameters:
-
@@ -177,7 +177,7 @@ besskge.scoring.DistMult
-
-negative_sample_sharing:
bool
+negative_sample_sharing: bool
Share negative entities to construct negative samples
@@ -187,11 +187,11 @@ besskge.scoring.DistMult
- Parameters:
-v (Tensor
) – shape: (*, embedding_size)
+
v (Tensor
) – shape: (*, embedding_size)
The tensor to reduce.
- Return type:
--
+
-
- Returns:
shape: (*,)
@@ -202,7 +202,7 @@
besskge.scoring.DistMult
-
-relation_embedding:
Parameter
+relation_embedding: Parameter
Relation embedding table
@@ -213,16 +213,16 @@ besskge.scoring.DistMult
- Parameters:
-head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
+
head_emb (Tensor
) – shape: (B, n_heads, embedding_size) with B = 1, batch_size
Embeddings of head entities.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embedding of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_heads)
@@ -240,16 +240,16 @@
besskge.scoring.DistMult
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
+
tail_emb (Tensor
) – shape: (B, n_tails, embedding_size) with B = 1, batch_size
Embedding of tail entities.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_tails)
@@ -267,16 +267,16 @@
besskge.scoring.DistMult
- Parameters:
-head_emb (Tensor
) – shape: (batch_size, embedding_size)
+
head_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of head entities in batch.
-relation_id (Tensor
) – shape: (batch_size,)
+
relation_id (Tensor
) – shape: (batch_size,)
IDs of relation types in batch.
-tail_emb (Tensor
) – shape: (batch_size, embedding_size)
+
tail_emb (Tensor
) – shape: (batch_size, embedding_size)
Embeddings of tail entities in batch.
- Return type:
--
+
-
- Returns:
shape: (batch_size,)
@@ -300,7 +300,7 @@
besskge.scoring.DistMultnew_sharding (Sharding
) – The new entity sharding.
- Return type:
--
+
-
diff --git a/generated/besskge.scoring.DistanceBasedScoreFunction.html b/generated/besskge.scoring.DistanceBasedScoreFunction.html
index ec249c3..99b3239 100644
--- a/generated/besskge.scoring.DistanceBasedScoreFunction.html
+++ b/generated/besskge.scoring.DistanceBasedScoreFunction.html
@@ -115,8 +115,8 @@ besskge.scoring.DistanceBasedScoreFunction
- Parameters:
-negative_sample_sharing (bool
) – see BaseScoreFunction
-scoring_norm (int
) – p for p-norm to use in distance computation.
+negative_sample_sharing (bool
) – see BaseScoreFunction
+scoring_norm (int
) – p for p-norm to use in distance computation.
@@ -129,14 +129,14 @@ besskge.scoring.DistanceBasedScoreFunction
- Parameters:
-v1 (Tensor
) – shape: (batch_size, embedding_size)
+
v1 (Tensor
) – shape: (batch_size, embedding_size)
Batch queries.
-v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
+
v2 (Tensor
) – shape: (B, n_neg, embedding_size) with B = 1, batch_size
Negative embeddings to score against queries.
- Return type:
--
+
-
- Returns:
shape: (batch_size, B * n_neg) if
@@ -148,7 +148,7 @@
besskge.scoring.DistanceBasedScoreFunction
-
-entity_embedding: