class InductiveNodePiece(*, triples_factory, inference_factory, num_tokens=2, embedding_dim=64, relation_representations_kwargs=None, interaction=<class 'pykeen.nn.modules.DistMultInteraction'>, aggregation=None, validation_factory=None, test_factory=None, **kwargs)[source]

Bases: InductiveERModel

A wrapper which combines an interaction function with NodePiece entity representations from [galkin2021].

This model uses the pykeen.nn.NodePieceRepresentation instead of a typical pykeen.nn.Embedding to more efficiently store representations.

Initialize the model.

  • triples_factory (CoreTriplesFactory) – the triples factory of training triples. Must have create_inverse_triples set to True.

  • inference_factory (CoreTriplesFactory) – the triples factory of inference triples. Must have create_inverse_triples set to True.

  • validation_factory (Optional[CoreTriplesFactory]) – the triples factory of validation triples. Must have create_inverse_triples set to True.

  • test_factory (Optional[CoreTriplesFactory]) – the triples factory of testing triples. Must have create_inverse_triples set to True.

  • num_tokens (int) – the number of relations to use to represent each entity, cf. pykeen.nn.NodePieceRepresentation.

  • embedding_dim (int) – the embedding dimension. Only used if embedding_specification is not given.

  • relation_representations_kwargs (Optional[Mapping[str, Any]]) – the relation representation parameters

  • interaction (Union[str, Interaction, Type[Interaction], None]) – the interaction module, or a hint for it.

  • aggregation (Union[str, Callable[[Tensor, int], Tensor], None]) –

    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 ERModel.__init__()


ValueError – if the triples factory does not create inverse triples

Attributes Summary


The default strategy for optimizing the model's hyper-parameters

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}}

The default strategy for optimizing the model’s hyper-parameters