Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeysValuesPairs ¶ added in v0.5.0
type KeysValuesPairs = []attention.KeysValuesPair
KeysValuesPairs contains the attention.KeysValuesPair for each attention head.
type Model ¶
type Model struct { nn.BaseModel Attention []*selfattention.Model OutputMerge *linear.Model NumOfHeads int // number of heads Dm int // input and output vectors dimension Dk int // hidden vectors dimension (Dm / NumOfHeads) }
Model contains the serializable parameters.
func (*Model) Forward ¶
Forward performs the forward step for each input node and returns the result.
func (*Model) ForwardWithPastKeysValues ¶ added in v0.5.0
func (m *Model) ForwardWithPastKeysValues(qkv attention.QKV, pastProjKeysValues KeysValuesPairs) Output
ForwardWithPastKeysValues performs the forward step for each input node and returns the result.
type Output ¶ added in v0.5.0
type Output struct { // Result of the multi-head attention. AttOutput []ag.Node // AttWeights attention scores. AttWeights [][]mat.Matrix // ProjKeysValues contains the attention.KeysValuesPair for each attention head. ProjKeysValues KeysValuesPairs }
Output aggregates the multiple output of the multi-head attentions, incl. attention scores and last projected keys and values for each head.
Click to show internal directories.
Click to hide internal directories.