HolE

class HolE(*, embedding_dim: int = 200, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, entity_constrainer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function clamp_norm>, entity_constrainer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, entity_representation_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, relation_representation_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]

Bases: ERModel[Tensor, Tensor, Tensor]

An implementation of HolE from [nickel2016].

This model represents both entities and relations as \(d\)-dimensional vectors stored in an Embedding matrix. The representations are then passed to the HolEInteraction function to obtain scores.

Note

The original paper describes modelling the probability as \(\sigma(f(h, r, t))\), however, since the margin ranking loss is used for all experiments, the implementation of the score function does not include the \(\sigma\).

Initialize the model.

Parameters:
  • embedding_dim (int) – the embedding dimension (for entities and relations)

  • entity_initializer (str | Callable[[Tensor], Tensor] | None) – the initializer for entity representations

  • entity_constrainer (str | Callable[[Tensor], Tensor] | None) – the constrainer for entity representations

  • entity_constrainer_kwargs (Mapping[str, Any] | None) – keyword-based parameters passed to the constrainer. If None, use entity_constrainer_default_kwargs

  • entity_representation_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters passed to the entity representation

  • relation_initializer (str | Callable[[Tensor], Tensor] | None) – the initializer for relation representations

  • relation_representation_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters passed to the entity representation

  • kwargs – additional keyword-based parameters passed to ERModel.__init__()

Attributes Summary

entity_constrainer_default_kwargs

The default settings for the entity constrainer

hpo_default

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

Attributes Documentation

entity_constrainer_default_kwargs = {'dim': -1, 'maxnorm': 1.0, 'p': 2}

The default settings for the entity constrainer

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