Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data LMHeadHasScaling
- data GLMHead (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (dense :: Type) (activation :: Type) (layerNorm :: Type) (decoder :: Type) (bias :: Type) where
- data GBias (bias :: Type) where
- type family GLMHeadF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- type family LMHeadDenseF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- type family LMHeadActivationF (style :: TransformerStyle) :: Type where ...
- type family LMHeadLayerNormF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- type family LMHeadDecoderF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- type family LMHeadBiasF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- lmHeadSpec :: forall style gradient device dataType inputEmbedDim vocabDim. STransformerStyle style -> SGradient gradient -> SDevice device -> SDataType dataType -> SDim inputEmbedDim -> SDim vocabDim -> Double -> ModelSpec (GLMHeadF style gradient device dataType inputEmbedDim vocabDim)
- type family LMHeadOutputF (style :: TransformerStyle) (decoderOutput :: Type) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
Documentation
data LMHeadHasScaling Source #
A data type that represents whether or not the language modelling head has a scaled decoder output.
Instances
data GLMHead (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (dense :: Type) (activation :: Type) (layerNorm :: Type) (decoder :: Type) (bias :: Type) where Source #
Generic language modelling head for transformer encoders and decoders.
inputEmbedDim
is the dimension of the input embedding.dense
is a dense layer.activation
is an activation function.layerNorm
is a layer normalization layer.decoder
is a decoder layer.bias
is a bias layer.
GLMHead | |
|
Instances
Generic (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead from :: GLMHead inputEmbedDim dense activation layerNorm decoder bias -> Rep (GLMHead inputEmbedDim dense activation layerNorm decoder bias) x Source # to :: Rep (GLMHead inputEmbedDim dense activation layerNorm decoder bias) x -> GLMHead inputEmbedDim dense activation layerNorm decoder bias Source # | |
(Show dense, Show activation, Show layerNorm, Show decoder, Show bias) => Show (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead | |
(HasStateDict dense, HasStateDict activation, HasStateDict layerNorm, HasStateDict decoder, HasStateDict bias) => HasStateDict (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead fromStateDict :: (MonadIO m, MonadThrow m, MonadState StateDict m) => ModelSpec (GLMHead inputEmbedDim dense activation layerNorm decoder bias) -> StateDictKey -> m (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # toStateDict :: (MonadThrow m, MonadState StateDict m) => StateDictKey -> GLMHead inputEmbedDim dense activation layerNorm decoder bias -> m () Source # | |
(HasInitialize dense generatorDevice dense' generatorDevice0, HasInitialize activation generatorDevice0 activation' generatorDevice1, HasInitialize layerNorm generatorDevice1 layerNorm' generatorDevice2, HasInitialize decoder generatorDevice2 decoder' generatorDevice3, HasInitialize bias generatorDevice3 bias' generatorOutputDevice) => HasInitialize (GLMHead inputEmbedDim dense activation layerNorm decoder bias) generatorDevice (GLMHead inputEmbedDim dense' activation' layerNorm' decoder' bias') generatorOutputDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead initialize :: MonadThrow m => ModelSpec (GLMHead inputEmbedDim dense activation layerNorm decoder bias) -> Generator generatorDevice -> m (GLMHead inputEmbedDim dense' activation' layerNorm' decoder' bias', Generator generatorOutputDevice) Source # | |
(HasForward dense (Tensor gradient layout device dataType shape) generatorDevice tensor0 generatorDevice0, HasForward activation tensor0 generatorDevice0 tensor1 generatorDevice1, HasForward layerNorm tensor1 generatorDevice1 tensor2 generatorDevice2, HasForward decoder tensor2 generatorDevice2 (Tensor gradient3 layout3 device3 dataType3 shape3) generatorDevice3, HasForward bias (Tensor gradient3 layout3 device3 dataType3 shape3) generatorDevice3 output generatorOutputDevice) => HasForward (GLMHead inputEmbedDim dense activation layerNorm decoder bias) (Tensor gradient layout device dataType shape) generatorDevice output generatorOutputDevice Source # |
┌───────┐ │ input │ └───┬───┘ │ ▼ (lmHeadDense) ▼ (lmHeadActivation) ▼ (lmHeadLayerNorm) ▼ lmHeadDecoder ▼ (scaling) ▼ (lmHeadBias) │ ▼ ┌───────────────┐ │ decoderOutput │ └───────────────┘ |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead | |
type Rep (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead type Rep (GLMHead inputEmbedDim dense activation layerNorm decoder bias) = D1 ('MetaData "GLMHead" "Torch.GraduallyTyped.NN.Transformer.GLMHead" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "GLMHead" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lmHeadInputEmbedDim") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SDim inputEmbedDim)) :*: (S1 ('MetaSel ('Just "lmHeadDense") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 dense) :*: S1 ('MetaSel ('Just "lmHeadActivation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 activation))) :*: ((S1 ('MetaSel ('Just "lmHeadLayerNorm") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 layerNorm) :*: S1 ('MetaSel ('Just "lmHeadDecoder") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 decoder)) :*: (S1 ('MetaSel ('Just "lmHeadBias") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 bias) :*: S1 ('MetaSel ('Just "lmHeadHasScaling") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LMHeadHasScaling))))) | |
type ModelSpec (GLMHead inputEmbedDim dense activation layerNorm decoder bias) Source # | |
data GBias (bias :: Type) where Source #
Generic data type for biasing the language model head.
Instances
Generic (GBias bias) Source # | |
Show bias => Show (GBias bias) Source # | |
Eq bias => Eq (GBias bias) Source # | |
Ord bias => Ord (GBias bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead compare :: GBias bias -> GBias bias -> Ordering Source # (<) :: GBias bias -> GBias bias -> Bool Source # (<=) :: GBias bias -> GBias bias -> Bool Source # (>) :: GBias bias -> GBias bias -> Bool Source # (>=) :: GBias bias -> GBias bias -> Bool Source # | |
HasStateDict bias => HasStateDict (GBias bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead fromStateDict :: (MonadIO m, MonadThrow m, MonadState StateDict m) => ModelSpec (GBias bias) -> StateDictKey -> m (GBias bias) Source # toStateDict :: (MonadThrow m, MonadState StateDict m) => StateDictKey -> GBias bias -> m () Source # | |
HasInitialize (GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape))) generatorDevice (GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape))) generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead initialize :: MonadThrow m => ModelSpec (GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape))) -> Generator generatorDevice -> m (GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape)), Generator generatorDevice) Source # | |
HasInitialize (GBias (Tensor biasGradient biasLayout biasDevice biasDataType biasShape)) generatorDevice (GBias (Tensor biasGradient biasLayout biasDevice biasDataType biasShape)) generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead | |
HasInitialize (GBias ()) generatorDevice (GBias ()) generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead initialize :: MonadThrow m => ModelSpec (GBias ()) -> Generator generatorDevice -> m (GBias (), Generator generatorDevice) Source # | |
(shape' ~ BroadcastShapesF shape biasShape, Catch shape', output ~ Tensor (gradient <|> biasGradient) (layout <+> biasLayout) (device <+> biasDevice) (dataType <+> biasDataType) shape') => HasForward (GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape))) (Tensor gradient layout device dataType shape) generatorDevice output generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead forward :: MonadThrow m => GBias (NamedModel (Tensor biasGradient biasLayout biasDevice biasDataType biasShape)) -> Tensor gradient layout device dataType shape -> Generator generatorDevice -> m (output, Generator generatorDevice) Source # | |
(shape' ~ BroadcastShapesF shape biasShape, Catch shape', output ~ Tensor (gradient <|> biasGradient) (layout <+> biasLayout) (device <+> biasDevice) (dataType <+> biasDataType) shape') => HasForward (GBias (Tensor biasGradient biasLayout biasDevice biasDataType biasShape)) (Tensor gradient layout device dataType shape) generatorDevice output generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead | |
HasForward (GBias ()) (Tensor gradient layout device dataType shape) generatorDevice (Tensor gradient layout device dataType shape) generatorDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead | |
type Rep (GBias bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead type Rep (GBias bias) = D1 ('MetaData "GBias" "Torch.GraduallyTyped.NN.Transformer.GLMHead" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "GBias" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 bias))) | |
type ModelSpec (GBias bias) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GLMHead |
type family GLMHeadF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
GLMHeadF style gradient device dataType inputEmbedDim vocabDim = GLMHead inputEmbedDim (LMHeadDenseF style gradient device dataType inputEmbedDim) (LMHeadActivationF style) (LMHeadLayerNormF style gradient device dataType inputEmbedDim) (LMHeadDecoderF style gradient device dataType inputEmbedDim vocabDim) (LMHeadBiasF style gradient device dataType vocabDim) |
type family LMHeadDenseF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
Specifies the dense layer of the language model head.
LMHeadDenseF 'T5 _ _ _ _ = () | |
LMHeadDenseF 'ByT5 gradient device dataType inputEmbedDim = LMHeadDenseF 'T5 gradient device dataType inputEmbedDim | |
LMHeadDenseF 'BART _ _ _ _ = () | |
LMHeadDenseF 'MBART gradient device dataType inputEmbedDim = LMHeadDenseF 'BART gradient device dataType inputEmbedDim | |
LMHeadDenseF 'Pegasus gradient device dataType inputEmbedDim = LMHeadDenseF 'BART gradient device dataType inputEmbedDim | |
LMHeadDenseF 'BERT gradient device dataType inputEmbedDim = NamedModel (GLinearF 'WithBias gradient device dataType inputEmbedDim inputEmbedDim) | |
LMHeadDenseF 'RoBERTa gradient device dataType inputEmbedDim = LMHeadDenseF 'BERT gradient device dataType inputEmbedDim |
type family LMHeadActivationF (style :: TransformerStyle) :: Type where ... Source #
Specifies the activation function of the language model head.
type family LMHeadLayerNormF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
Specifies the layer normalization layer of the language model head.
LMHeadLayerNormF 'T5 _ _ _ _ = () | |
LMHeadLayerNormF 'ByT5 gradient device dataType inputEmbedDim = LMHeadLayerNormF 'T5 gradient device dataType inputEmbedDim | |
LMHeadLayerNormF 'BART _ _ _ _ = () | |
LMHeadLayerNormF 'MBART gradient device dataType inputEmbedDim = LMHeadLayerNormF 'BART gradient device dataType inputEmbedDim | |
LMHeadLayerNormF 'Pegasus gradient device dataType inputEmbedDim = LMHeadLayerNormF 'BART gradient device dataType inputEmbedDim | |
LMHeadLayerNormF 'BERT gradient device dataType inputEmbedDim = NamedModel (LayerNorm 'WithBias gradient device dataType ('Shape '[inputEmbedDim])) | |
LMHeadLayerNormF 'RoBERTa gradient device dataType inputEmbedDim = LMHeadLayerNormF 'BERT gradient device dataType inputEmbedDim |
type family LMHeadDecoderF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
Specifies the decoder layer of the language model head.
LMHeadDecoderF 'T5 gradient device dataType inputEmbedDim vocabDim = NamedModel (GLinearF 'WithoutBias gradient device dataType inputEmbedDim vocabDim) | |
LMHeadDecoderF 'ByT5 gradient device dataType inputEmbedDim vocabDim = LMHeadDecoderF 'T5 gradient device dataType inputEmbedDim vocabDim | |
LMHeadDecoderF 'BART gradient device dataType inputEmbedDim vocabDim = NamedModel (GLinearF 'WithoutBias gradient device dataType inputEmbedDim vocabDim) | |
LMHeadDecoderF 'MBART gradient device dataType inputEmbedDim vocabDim = LMHeadDecoderF 'BART gradient device dataType inputEmbedDim vocabDim | |
LMHeadDecoderF 'Pegasus gradient device dataType inputEmbedDim vocabDim = LMHeadDecoderF 'BART gradient device dataType inputEmbedDim vocabDim | |
LMHeadDecoderF 'BERT gradient device dataType inputEmbedDim vocabDim = NamedModel (GLinearF 'WithBias gradient device dataType inputEmbedDim vocabDim) | |
LMHeadDecoderF 'RoBERTa gradient device dataType inputEmbedDim vocabDim = LMHeadDecoderF 'BERT gradient device dataType inputEmbedDim vocabDim |
type family LMHeadBiasF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
Specifies the bias layer of the language model head.
LMHeadBiasF 'T5 _ _ _ _ = GBias () | |
LMHeadBiasF 'ByT5 gradient device dataType vocabDim = LMHeadBiasF 'T5 gradient device dataType vocabDim | |
LMHeadBiasF 'BART gradient device dataType vocabDim = GBias (NamedModel (Tensor gradient ('Layout 'Dense) device dataType ('Shape '['Dim ('Name "*") ('Size 1), vocabDim]))) | |
LMHeadBiasF 'MBART gradient device dataType vocabDim = LMHeadBiasF 'BART gradient device dataType vocabDim | |
LMHeadBiasF 'Pegasus gradient device dataType vocabDim = LMHeadBiasF 'BART gradient device dataType vocabDim | |
LMHeadBiasF 'BERT _ _ _ _ = GBias () | |
LMHeadBiasF 'RoBERTa gradient device dataType vocabDim = LMHeadBiasF 'BERT gradient device dataType vocabDim |
lmHeadSpec :: forall style gradient device dataType inputEmbedDim vocabDim. STransformerStyle style -> SGradient gradient -> SDevice device -> SDataType dataType -> SDim inputEmbedDim -> SDim vocabDim -> Double -> ModelSpec (GLMHeadF style gradient device dataType inputEmbedDim vocabDim) Source #
Specifies the parameters of the language model head.
type family LMHeadOutputF (style :: TransformerStyle) (decoderOutput :: Type) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
LMHeadOutputF 'T5 decoderOutput _ _ _ _ = decoderOutput | |
LMHeadOutputF 'ByT5 decoderOutput gradient device dataType vocabDim = LMHeadOutputF 'T5 decoderOutput gradient device dataType vocabDim | |
LMHeadOutputF 'BART (Tensor gradient' layout' device' dataType' shape') gradient device dataType vocabDim = Tensor (gradient' <|> gradient) (layout' <+> 'Layout 'Dense) (device' <+> device) (dataType' <+> dataType) (BroadcastShapesF shape' ('Shape '['Dim ('Name "*") ('Size 1), vocabDim])) | |
LMHeadOutputF 'MBART decoderOutput gradient device dataType vocabDim = LMHeadOutputF 'BART decoderOutput gradient device dataType vocabDim | |
LMHeadOutputF 'Pegasus decoderOutput gradient device dataType vocabDim = LMHeadOutputF 'BART decoderOutput gradient device dataType vocabDim | |
LMHeadOutputF 'RoBERTa decoderOutput _ _ _ _ = decoderOutput | |
LMHeadOutputF 'BERT decoderOutput _ _ _ _ = decoderOutput |