HolE

class HolE(*, embedding_dim=200, entity_initializer=<function xavier_uniform_>, entity_constrainer=<function clamp_norm>, entity_constrainer_kwargs=None, entity_representation_kwargs=None, relation_initializer=<function xavier_uniform_>, relation_representation_kwargs=None, **kwargs)[source]

Bases: ERModel

An implementation of HolE [nickel2016].

Holographic embeddings (HolE) make use of the circular correlation operator to compute interactions between latent features of entities and relations:

\[f(h,r,t) = \sigma(\textbf{r}^{T}(\textbf{h} \star \textbf{t}))\]

where the circular correlation \(\star: \mathbb{R}^d \times \mathbb{R}^d \rightarrow \mathbb{R}^d\) is defined as:

\[[\textbf{a} \star \textbf{b}]_i = \sum_{k=0}^{d-1} \textbf{a}_{k} * \textbf{b}_{(i+k)\ mod \ d}\]

By using the correlation operator each component \([\textbf{h} \star \textbf{t}]_i\) represents a sum over a fixed partition over pairwise interactions. This enables the model to put semantic similar interactions into the same partition and share weights through \(\textbf{r}\). Similarly irrelevant interactions of features could also be placed into the same partition which could be assigned a small weight in \(\textbf{r}\).

Initialize the model.

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

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

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

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

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

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

  • relation_representation_kwargs (Optional[Mapping[str, Any]]) – 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