kiwi.modules.common.scorer
Scorer
Score function for attention module.
MLPScorer
MultiLayerPerceptron Scorer with variable nb of layers and neurons.
kiwi.modules.common.scorer.
Bases: torch.nn.Module
torch.nn.Module
scaled – whether to scale scores by sqrt(hidden_size) as proposed by the “Attention is All You Need” paper.
scale
Denominator for scaling the scores.
hidden_size – max hidden size between query and keys.
sqrt(hidden_size) if scaled is True, 1 otherwise.
forward
Compute scores for each key of size n given the queries of size m.
The three dots (…) represent any other dimensions, such as the number of heads (useful if you use a multi head attention).
query – query matrix (bs, ..., target_len, m).
(bs, ..., target_len, m)
keys – keys matrix (bs, ..., source_len, n).
(bs, ..., source_len, n)
matrix representing scores between source words and target words (bs, ..., target_len, source_len)
(bs, ..., target_len, source_len)
Bases: kiwi.modules.common.scorer.Scorer
kiwi.modules.common.scorer.Scorer
kiwi.modules.common.scalar_mix
kiwi.modules.sentence_level_output