transformer_interaction
- transformer_interaction(h, r, t, transformer, position_embeddings, final)[source]
Evaluate the Transformer interaction function, as described in [galkin2020]..
\[\textit{score}(h, r, t) = \textit{Linear}(\textit{SumPooling}(\textit{Transformer}([h + pe[0]; r + pe[1]])))^T t\]- Parameters:
h (
FloatTensor
) – shape: (*batch_dims, dim) The head representations.r (
FloatTensor
) – shape: (*batch_dims, dim) The relation representations.t (
FloatTensor
) – shape: (*batch_dims, dim) The tail representations.transformer (
TransformerEncoder
) – the transformer encoderposition_embeddings (
FloatTensor
) – shape: (2, dim) the positional embeddings, one for head and one for relationfinal (
Module
) – the final (linear) transformation
- Return type:
FloatTensor
- Returns:
The scores.