Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelMix ¶
type ChannelMix struct { nn.Module Key nn.Param `spago:"type:weights"` Value nn.Param `spago:"type:weights"` Receptance nn.Param `spago:"type:weights"` TimeMixK nn.Param `spago:"type:weights"` TimeMixR nn.Param `spago:"type:weights"` }
ChannelMix implements the channel mix module.
func NewChannelMix ¶
func NewChannelMix[T float.DType](c Config, _ int) *ChannelMix
func (*ChannelMix) ForwardSequence ¶
func (m *ChannelMix) ForwardSequence(x []ag.Node, state *LayerState) (rkv []ag.Node)
ForwardSequence performs the forward step for a sequence of nodes. The state is updated with the last node of the sequence.
func (*ChannelMix) ForwardSingle ¶
func (m *ChannelMix) ForwardSingle(x ag.Node, state *LayerState) (rkv ag.Node)
ForwardSingle performs the forward step for a single node.
type Layer ¶
type Layer struct { nn.Module LN0 *layernorm.Model LN1 *layernorm.Model LN2 *layernorm.Model ChanMix *ChannelMix TimeMix *TimeMix ID int }
Layer is a single block of the RWKV model.
func (*Layer) ForwardSequence ¶
func (*Layer) ForwardSingle ¶
type LayerState ¶
LayerState is the RWKV state for a single layer.
type Model ¶
Model implements the RWKV neural network.
func (*Model) ForwardSequence ¶
ForwardSequence performs the forward step for the entire sequence, just a bit more optimized. It is equivalent to calling ForwardSingle for each element of the sequence, for example:
var x ag.Node for _, e := range encoded { x, s = m.ForwardSingle(e, s) } return x, s
It returns the last computed state.
type State ¶
type State []*LayerState
type TimeMix ¶
type TimeMix struct { nn.Module Key nn.Param `spago:"type:weights"` Value nn.Param `spago:"type:weights"` Receptance nn.Param `spago:"type:weights"` Output nn.Param `spago:"type:weights"` TimeDecay nn.Param `spago:"type:weights"` TimeFirst nn.Param `spago:"type:weights"` TimeMixK nn.Param `spago:"type:weights"` TimeMixV nn.Param `spago:"type:weights"` TimeMixR nn.Param `spago:"type:weights"` Config Config }
TimeMix is a model that implements the TimeMix component.
func (*TimeMix) ForwardSequence ¶
ForwardSequence performs the forward step for a sequence of inputs. The state is updated at the end of the sequence.
func (*TimeMix) ForwardSingle ¶
ForwardSingle performs the forward step for a single input.