- class NodePiece(*, triples_factory, num_tokens=2, tokenizers=None, tokenizers_kwargs=None, embedding_dim=64, interaction=<class 'pykeen.nn.modules.DistMultInteraction'>, aggregation=None, entity_initializer=None, entity_normalizer=None, entity_constrainer=None, entity_regularizer=None, relation_initializer=None, relation_normalizer=None, relation_constrainer=None, relation_regularizer=None, **kwargs)¶
A wrapper which combines an interaction function with NodePiece entity representations from [galkin2021].
This model uses the
pykeen.nn.NodePieceRepresentationinstead of a typical
pykeen.nn.representation.Embeddingto more efficiently store representations.
Initialize the model.
CoreTriplesFactory) – the triples factory. Must have create_inverse_triples set to True.
int) – the embedding dimension. Only used if embedding_specification is not given.
aggregation of multiple token representations to a single entity representation. By default, this uses
torch.mean(). If a string is provided, the module assumes that this refers to a top-level torch function, e.g. “mean” for
torch.mean(), or “sum” for func:torch.sum. An aggregation can also have trainable parameters, .e.g.,
MLP(mean(MLP(tokens)))(cf. DeepSets from [zaheer2017]). In this case, the module has to be created outside of this component.
Moreover, we support providing “mlp” as a shortcut to use the MLP aggregation version from [galkin2021].
We could also have aggregations which result in differently shapes output, e.g. a concatenation of all token embeddings resulting in shape
(num_tokens * d,). In this case, shape must be provided.
The aggregation takes two arguments: the (batched) tensor of token representations, in shape
(*, num_tokens, *dt), and the index along which to aggregate.
kwargs – additional keyword-based arguments passed to
ValueError – if the triples factory does not create inverse triples
The default strategy for optimizing the model's hyper-parameters