PairRE

class PairRE(embedding_dim: int = 200, p: int = 1, power_norm: bool = False, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function uniform_>, entity_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, entity_normalizer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function normalize>, entity_normalizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function uniform_>, relation_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]

Bases: ERModel[Tensor, tuple[Tensor, Tensor], Tensor]

An implementation of PairRE from [chao2020].

This model represents entities as \(d\)-dimensional vectors, and relations by a pair of \(d\)-dimensional vectors, all stored in an Embedding matrix. Moreover, it enforces unit length for the entity embeddings.

The representations are then passed to the PairREInteraction function to obtain scores.

Initialize the model.

Parameters:

Attributes Summary

default_entity_normalizer_kwargs

The default entity normalizer parameters The entity representations are normalized to L2 unit length cf.

hpo_default

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

loss_default_kwargs

The default parameters for the default loss function class

Attributes Documentation

default_entity_normalizer_kwargs: ClassVar[Mapping[str, Any]] = {'dim': -1, 'p': 2}

The default entity normalizer parameters The entity representations are normalized to L2 unit length cf. https://github.com/alipay/KnowledgeGraphEmbeddingsViaPairedRelationVectors_PairRE/blob/0a95bcd54759207984c670af92ceefa19dd248ad/biokg/model.py#L232-L240 # noqa: E501

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

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

loss_default_kwargs: ClassVar[Mapping[str, Any] | None] = {'adversarial_temperature': 1.0, 'margin': 12.0, 'reduction': 'mean'}

The default parameters for the default loss function class