Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data EncoderOnlyTransformerHasEmbedScaling
- data GEncoderOnlyTransformer (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (encoder :: Type) (encoderEmbedding :: Type) (encoderTypeEmbedding :: Type) (head :: Type) where
- GEncoderOnlyTransformer :: forall inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head. {..} -> GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head
- type family GEncoderOnlyTransformerF (style :: TransformerStyle) (transformerHead :: TransformerHead) (numLayers :: Nat) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (headDim :: Dim (Name Symbol) (Size Nat)) (headEmbedDim :: Dim (Name Symbol) (Size Nat)) (embedDim :: Dim (Name Symbol) (Size Nat)) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (ffnDim :: Dim (Name Symbol) (Size Nat)) (posEncDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) (typeVocabDim :: Dim (Name Symbol) (Size Nat)) (hasDropout :: HasDropout) :: Type where ...
- type family EOTEmbeddingF (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 EOTTypeEmbeddingF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (typeVocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- type family EOTHeadF (style :: TransformerStyle) (transformerHead :: TransformerHead) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ...
- encoderOnlyTransformerSpec :: forall style transformerHead numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim vocabDim typeVocabDim hasDropout. STransformerStyle style -> STransformerHead transformerHead -> SNat numLayers -> SGradient gradient -> SDevice device -> SDataType dataType -> SDim headDim -> SDim headEmbedDim -> SDim embedDim -> SDim inputEmbedDim -> SDim ffnDim -> SDim posEncDim -> SDim vocabDim -> SDim typeVocabDim -> SHasDropout hasDropout -> Double -> Double -> ModelSpec (GEncoderOnlyTransformerF style transformerHead numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim vocabDim typeVocabDim hasDropout)
- data GSimplifiedEncoderOnlyTransformer (model :: Type) (mkPos :: Type) (mkPaddingMask :: Type) (mkAttentionMask :: Type) where
- GSimplifiedEncoderOnlyTransformer :: forall model mkPos mkPaddingMask mkAttentionMask. {..} -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask
- data EncoderOnlyTransformerInput input inputType pos attentionMask where
- EncoderOnlyTransformerInput :: forall input inputType pos attentionMask. {..} -> EncoderOnlyTransformerInput input inputType pos attentionMask
- data SimplifiedEncoderOnlyTransformerInput input inputType where
- SimplifiedEncoderOnlyTransformerInput :: forall input inputType. {..} -> SimplifiedEncoderOnlyTransformerInput input inputType
- data EncoderOnlyTransformerOutput output where
- EncoderOnlyTransformerOutput :: forall output. {..} -> EncoderOnlyTransformerOutput output
- data SimplifiedEncoderOnlyTransformerOutput output paddingMask where
- SimplifiedEncoderOnlyTransformerOutput :: forall output paddingMask. {..} -> SimplifiedEncoderOnlyTransformerOutput output paddingMask
Documentation
data EncoderOnlyTransformerHasEmbedScaling Source #
Data type that is used to represent whether the encoder-only transformer model has a scaled embedding.
Instances
data GEncoderOnlyTransformer (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (encoder :: Type) (encoderEmbedding :: Type) (encoderTypeEmbedding :: Type) (head :: Type) where Source #
Generic encoder-only transformer model. This is a transformer model that only encodes the input, e.g. BERT.
inputEmbedDim
: the dimension of the input embedding.encoder
: a transformer encoder.encoderEmbedding
: an embedding layer for the input.encoderTypeEmbedding
: an embedding layer for the type of the input.head
: a head layer for the output.
GEncoderOnlyTransformer | |
|
Instances
Generic (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) :: Type -> Type Source # from :: GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) x Source # to :: Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) x -> GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head Source # | |
(Show encoder, Show encoderEmbedding, Show encoderTypeEmbedding, Show head) => Show (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly showsPrec :: Int -> GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> ShowS Source # show :: GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> String Source # showList :: [GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head] -> ShowS Source # | |
(HasStateDict encoder, HasStateDict encoderEmbedding, HasStateDict encoderTypeEmbedding, HasStateDict head) => HasStateDict (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly fromStateDict :: (MonadIO m, MonadThrow m, MonadState StateDict m) => ModelSpec (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) -> StateDictKey -> m (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # toStateDict :: (MonadThrow m, MonadState StateDict m) => StateDictKey -> GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> m () Source # | |
(HasInitialize encoder generatorDevice encoder' generatorDevice0, HasInitialize encoderEmbedding generatorDevice0 encoderEmbedding' generatorDevice1, HasInitialize encoderTypeEmbedding generatorDevice1 encoderTypeEmbedding' generatorDevice2, HasInitialize head generatorDevice2 head' generatorOutputDevice) => HasInitialize (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) generatorDevice (GEncoderOnlyTransformer inputEmbedDim encoder' encoderEmbedding' encoderTypeEmbedding' head') generatorOutputDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly initialize :: MonadThrow m => ModelSpec (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) -> Generator generatorDevice -> m (GEncoderOnlyTransformer inputEmbedDim encoder' encoderEmbedding' encoderTypeEmbedding' head', Generator generatorOutputDevice) Source # | |
(HasForward encoderEmbedding input generatorDevice embeddingOutput embeddingGeneratorOutputDevice, embeddingOutput ~ Tensor gradient' layout' device' dataType' shape', HasForward encoderTypeEmbedding inputType embeddingGeneratorOutputDevice typeEmbeddingOutput typeEmbeddingGeneratorOutputDevice, typeEmbeddingOutput ~ Tensor gradient'' layout'' device'' dataType'' shape'', HasForward encoder (Tensor (gradient' <|> gradient'') (layout' <+> layout'') (device' <+> device'') (dataType' <+> dataType'') (BroadcastShapesF shape' shape''), pos, attentionMask) typeEmbeddingGeneratorOutputDevice encoderOutput encoderGeneratorOutputDevice, Catch (BroadcastShapesF shape' shape''), HasForward head encoderOutput encoderGeneratorOutputDevice headOutput generatorOutputDevice) => HasForward (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) (EncoderOnlyTransformerInput input inputType pos attentionMask) generatorDevice (EncoderOnlyTransformerOutput headOutput) generatorOutputDevice Source # |
┌───────┐ ┌───────────┐ ┌─────┐ ┌───────────────┐ │ input │ │ inputType │ │ pos │ │ attentionMask │ └───┬───┘ └─────┬─────┘ └──┬──┘ └──────┬────────┘ │ │ │ │ ▼ ▼ │ │ eotEmbedding eotTypeEmbedding │ │ ▼ ▼ │ │ (embedScaling) (embedScaling) │ │ │ │ │ │ └────►add◄─────┘ │ │ │ │ │ ▼ │ │ eotEncoder◄──────────────┘◄───────────┘ ▼ (eotHead) │ ▼ ┌────────┐ │ output │ └────────┘ |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly forward :: MonadThrow m => GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Generator generatorDevice -> m (EncoderOnlyTransformerOutput headOutput, Generator generatorOutputDevice) Source # | |
type Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) = D1 ('MetaData "GEncoderOnlyTransformer" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "GEncoderOnlyTransformer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "eotInputEmbedDim") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SDim inputEmbedDim)) :*: (S1 ('MetaSel ('Just "eotEncoder") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 encoder) :*: S1 ('MetaSel ('Just "eotEmbedding") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 encoderEmbedding))) :*: (S1 ('MetaSel ('Just "eotTypeEmbedding") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 encoderTypeEmbedding) :*: (S1 ('MetaSel ('Just "eotHead") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 head) :*: S1 ('MetaSel ('Just "eotEmbedScaling") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EncoderOnlyTransformerHasEmbedScaling))))) | |
type ModelSpec (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type ModelSpec (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) = GEncoderOnlyTransformer inputEmbedDim (ModelSpec encoder) (ModelSpec encoderEmbedding) (ModelSpec encoderTypeEmbedding) (ModelSpec head) |
type family GEncoderOnlyTransformerF (style :: TransformerStyle) (transformerHead :: TransformerHead) (numLayers :: Nat) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (headDim :: Dim (Name Symbol) (Size Nat)) (headEmbedDim :: Dim (Name Symbol) (Size Nat)) (embedDim :: Dim (Name Symbol) (Size Nat)) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (ffnDim :: Dim (Name Symbol) (Size Nat)) (posEncDim :: Dim (Name Symbol) (Size Nat)) (vocabDim :: Dim (Name Symbol) (Size Nat)) (typeVocabDim :: Dim (Name Symbol) (Size Nat)) (hasDropout :: HasDropout) :: Type where ... Source #
GEncoderOnlyTransformerF style transformerHead numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim vocabDim typeVocabDim hasDropout = GEncoderOnlyTransformer inputEmbedDim (NamedModel (TransformerEncoderF style numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim hasDropout)) (EOTEmbeddingF style gradient device dataType inputEmbedDim vocabDim) (EOTTypeEmbeddingF style gradient device dataType inputEmbedDim typeVocabDim) (EOTHeadF style transformerHead gradient device dataType inputEmbedDim vocabDim) |
type family EOTEmbeddingF (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 embedding layer of the encoder-only transformer model.
EOTEmbeddingF _ gradient device dataType inputEmbedDim vocabDim = NamedModel (Embedding gradient ('Layout 'Dense) device dataType vocabDim inputEmbedDim 'Nothing) |
type family EOTTypeEmbeddingF (style :: TransformerStyle) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (dataType :: DataType DType) (inputEmbedDim :: Dim (Name Symbol) (Size Nat)) (typeVocabDim :: Dim (Name Symbol) (Size Nat)) :: Type where ... Source #
Specifies the type embedding layer of the encoder-only transformer model.
EOTTypeEmbeddingF 'BERT gradient device dataType inputEmbedDim typeVocabDim = NamedModel (Embedding gradient ('Layout 'Dense) device dataType typeVocabDim inputEmbedDim 'Nothing) | |
EOTTypeEmbeddingF 'RoBERTa gradient device dataType inputEmbedDim typeVocabDim = EOTTypeEmbeddingF 'BERT gradient device dataType inputEmbedDim typeVocabDim |
type family EOTHeadF (style :: TransformerStyle) (transformerHead :: TransformerHead) (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 head layer of the encoder-only transformer model.
EOTHeadF _ 'WithoutHead _ _ _ _ _ = () | |
EOTHeadF style 'WithLMHead gradient device dataType inputEmbedDim vocabDim = NamedModel (GLMHeadF style gradient device dataType inputEmbedDim vocabDim) |
encoderOnlyTransformerSpec :: forall style transformerHead numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim vocabDim typeVocabDim hasDropout. STransformerStyle style -> STransformerHead transformerHead -> SNat numLayers -> SGradient gradient -> SDevice device -> SDataType dataType -> SDim headDim -> SDim headEmbedDim -> SDim embedDim -> SDim inputEmbedDim -> SDim ffnDim -> SDim posEncDim -> SDim vocabDim -> SDim typeVocabDim -> SHasDropout hasDropout -> Double -> Double -> ModelSpec (GEncoderOnlyTransformerF style transformerHead numLayers gradient device dataType headDim headEmbedDim embedDim inputEmbedDim ffnDim posEncDim vocabDim typeVocabDim hasDropout) Source #
Specifies the parameters of an encoder-only transformer model.
style
: the style of the encoder-only transformer model, e.g.SBERT
,SRoBERTa
, etc.transformerHead
: the head of the encoder-only transformer model.numLayers
: the number of layers of the encoder-only transformer model.gradient
: whether to compute the gradient of the model parametersdevice
: the computational device on which the model is allocated.dataType
: the data type of the model parameters.headDim
: the dimension of all transformer heads in the encoder-only transformer model.headEmbedDim
: the dimension of the transformer head embeddings.embedDim
: the dimension of the transformer embeddings.inputEmbedDim
: the dimension of the input embeddings.ffnDim
: the dimension of the feed-forward network.posEncDim
: the dimension of the positional embeddings.vocabDim
: the dimension of the vocabulary.typeVocabDim
: the dimension of the type vocabulary.dropoutP
: the dropout rate.eps
: the epsilon value for numerical stability of the layer normalization.
data GSimplifiedEncoderOnlyTransformer (model :: Type) (mkPos :: Type) (mkPaddingMask :: Type) (mkAttentionMask :: Type) where Source #
GSimplifiedEncoderOnlyTransformer | |
|
Instances
Generic (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) :: Type -> Type Source # from :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) x Source # to :: Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) x -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask Source # | |
(Show model, Show mkPos, Show mkPaddingMask, Show mkAttentionMask) => Show (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly showsPrec :: Int -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> ShowS Source # show :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> String Source # showList :: [GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask] -> ShowS Source # | |
(Eq model, Eq mkPos, Eq mkPaddingMask, Eq mkAttentionMask) => Eq (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly (==) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # (/=) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # | |
(Ord model, Ord mkPos, Ord mkPaddingMask, Ord mkAttentionMask) => Ord (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly compare :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Ordering Source # (<) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # (<=) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # (>) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # (>=) :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> Bool Source # max :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask Source # min :: GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask Source # | |
(HasStateDict model, HasStateDict mkPos, HasStateDict mkPaddingMask, HasStateDict mkAttentionMask) => HasStateDict (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly fromStateDict :: (MonadIO m, MonadThrow m, MonadState StateDict m) => ModelSpec (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) -> StateDictKey -> m (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # toStateDict :: (MonadThrow m, MonadState StateDict m) => StateDictKey -> GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> m () Source # | |
(HasInitialize model generatorDevice model' generatorDevice0, HasInitialize mkPos generatorDevice0 mkPos' generatorDevice1, HasInitialize mkPaddingMask generatorDevice1 mkPaddingMask' generatorDevice2, HasInitialize mkAttentionMask generatorDevice2 mkAttentionMask' generatorOutputDevice) => HasInitialize (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) generatorDevice (GSimplifiedEncoderOnlyTransformer model' mkPos' mkPaddingMask' mkAttentionMask') generatorOutputDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly initialize :: MonadThrow m => ModelSpec (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) -> Generator generatorDevice -> m (GSimplifiedEncoderOnlyTransformer model' mkPos' mkPaddingMask' mkAttentionMask', Generator generatorOutputDevice) Source # | |
(HasForward mkPaddingMask input generatorDevice paddingMask generatorDevice, HasForward mkAttentionMask paddingMask generatorDevice attentionMask generatorDevice, HasForward mkPos input generatorDevice pos generatorDevice, HasForward model (EncoderOnlyTransformerInput input inputType pos attentionMask) generatorDevice (EncoderOnlyTransformerOutput output) generatorOutputDevice) => HasForward (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) (SimplifiedEncoderOnlyTransformerInput input inputType) generatorDevice (SimplifiedEncoderOnlyTransformerOutput output paddingMask) generatorOutputDevice Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly forward :: MonadThrow m => GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> SimplifiedEncoderOnlyTransformerInput input inputType -> Generator generatorDevice -> m (SimplifiedEncoderOnlyTransformerOutput output paddingMask, Generator generatorOutputDevice) Source # | |
type Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) = D1 ('MetaData "GSimplifiedEncoderOnlyTransformer" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "GSimplifiedEncoderOnlyTransformer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "seotModel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 model) :*: S1 ('MetaSel ('Just "seotMkPos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 mkPos)) :*: (S1 ('MetaSel ('Just "seotMkPaddingMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 mkPaddingMask) :*: S1 ('MetaSel ('Just "seotMkAttentionMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 mkAttentionMask)))) | |
type ModelSpec (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type ModelSpec (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) = GSimplifiedEncoderOnlyTransformer (ModelSpec model) (ModelSpec mkPos) (ModelSpec mkPaddingMask) (ModelSpec mkAttentionMask) |
data EncoderOnlyTransformerInput input inputType pos attentionMask where Source #
Input data type for use with an encoder-only transformer.
EncoderOnlyTransformerInput | |
|
Instances
Generic (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly from :: EncoderOnlyTransformerInput input inputType pos attentionMask -> Rep (EncoderOnlyTransformerInput input inputType pos attentionMask) x Source # to :: Rep (EncoderOnlyTransformerInput input inputType pos attentionMask) x -> EncoderOnlyTransformerInput input inputType pos attentionMask Source # | |
(Show input, Show inputType, Show pos, Show attentionMask) => Show (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # | |
(Eq input, Eq inputType, Eq pos, Eq attentionMask) => Eq (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly (==) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # (/=) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # | |
(Ord input, Ord inputType, Ord pos, Ord attentionMask) => Ord (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly compare :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Ordering Source # (<) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # (<=) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # (>) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # (>=) :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Bool Source # max :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask Source # min :: EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask -> EncoderOnlyTransformerInput input inputType pos attentionMask Source # | |
(HasForward encoderEmbedding input generatorDevice embeddingOutput embeddingGeneratorOutputDevice, embeddingOutput ~ Tensor gradient' layout' device' dataType' shape', HasForward encoderTypeEmbedding inputType embeddingGeneratorOutputDevice typeEmbeddingOutput typeEmbeddingGeneratorOutputDevice, typeEmbeddingOutput ~ Tensor gradient'' layout'' device'' dataType'' shape'', HasForward encoder (Tensor (gradient' <|> gradient'') (layout' <+> layout'') (device' <+> device'') (dataType' <+> dataType'') (BroadcastShapesF shape' shape''), pos, attentionMask) typeEmbeddingGeneratorOutputDevice encoderOutput encoderGeneratorOutputDevice, Catch (BroadcastShapesF shape' shape''), HasForward head encoderOutput encoderGeneratorOutputDevice headOutput generatorOutputDevice) => HasForward (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) (EncoderOnlyTransformerInput input inputType pos attentionMask) generatorDevice (EncoderOnlyTransformerOutput headOutput) generatorOutputDevice Source # |
┌───────┐ ┌───────────┐ ┌─────┐ ┌───────────────┐ │ input │ │ inputType │ │ pos │ │ attentionMask │ └───┬───┘ └─────┬─────┘ └──┬──┘ └──────┬────────┘ │ │ │ │ ▼ ▼ │ │ eotEmbedding eotTypeEmbedding │ │ ▼ ▼ │ │ (embedScaling) (embedScaling) │ │ │ │ │ │ └────►add◄─────┘ │ │ │ │ │ ▼ │ │ eotEncoder◄──────────────┘◄───────────┘ ▼ (eotHead) │ ▼ ┌────────┐ │ output │ └────────┘ |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly forward :: MonadThrow m => GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Generator generatorDevice -> m (EncoderOnlyTransformerOutput headOutput, Generator generatorOutputDevice) Source # | |
type Rep (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (EncoderOnlyTransformerInput input inputType pos attentionMask) = D1 ('MetaData "EncoderOnlyTransformerInput" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "EncoderOnlyTransformerInput" 'PrefixI 'True) ((S1 ('MetaSel ('Just "eotInput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 input) :*: S1 ('MetaSel ('Just "eotInputType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 inputType)) :*: (S1 ('MetaSel ('Just "eotPos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 pos) :*: S1 ('MetaSel ('Just "eotAttentionMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 attentionMask)))) |
data SimplifiedEncoderOnlyTransformerInput input inputType where Source #
SimplifiedEncoderOnlyTransformerInput | |
|
Instances
data EncoderOnlyTransformerOutput output where Source #
Output data type for use with an encoder-only transformer.
EncoderOnlyTransformerOutput | |
|
Instances
Generic (EncoderOnlyTransformerOutput output) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly from :: EncoderOnlyTransformerOutput output -> Rep (EncoderOnlyTransformerOutput output) x Source # to :: Rep (EncoderOnlyTransformerOutput output) x -> EncoderOnlyTransformerOutput output Source # | |
Show output => Show (EncoderOnlyTransformerOutput output) Source # | |
Eq output => Eq (EncoderOnlyTransformerOutput output) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly (==) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # (/=) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # | |
Ord output => Ord (EncoderOnlyTransformerOutput output) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly compare :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Ordering Source # (<) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # (<=) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # (>) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # (>=) :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> Bool Source # max :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output Source # min :: EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output -> EncoderOnlyTransformerOutput output Source # | |
(HasForward encoderEmbedding input generatorDevice embeddingOutput embeddingGeneratorOutputDevice, embeddingOutput ~ Tensor gradient' layout' device' dataType' shape', HasForward encoderTypeEmbedding inputType embeddingGeneratorOutputDevice typeEmbeddingOutput typeEmbeddingGeneratorOutputDevice, typeEmbeddingOutput ~ Tensor gradient'' layout'' device'' dataType'' shape'', HasForward encoder (Tensor (gradient' <|> gradient'') (layout' <+> layout'') (device' <+> device'') (dataType' <+> dataType'') (BroadcastShapesF shape' shape''), pos, attentionMask) typeEmbeddingGeneratorOutputDevice encoderOutput encoderGeneratorOutputDevice, Catch (BroadcastShapesF shape' shape''), HasForward head encoderOutput encoderGeneratorOutputDevice headOutput generatorOutputDevice) => HasForward (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) (EncoderOnlyTransformerInput input inputType pos attentionMask) generatorDevice (EncoderOnlyTransformerOutput headOutput) generatorOutputDevice Source # |
┌───────┐ ┌───────────┐ ┌─────┐ ┌───────────────┐ │ input │ │ inputType │ │ pos │ │ attentionMask │ └───┬───┘ └─────┬─────┘ └──┬──┘ └──────┬────────┘ │ │ │ │ ▼ ▼ │ │ eotEmbedding eotTypeEmbedding │ │ ▼ ▼ │ │ (embedScaling) (embedScaling) │ │ │ │ │ │ └────►add◄─────┘ │ │ │ │ │ ▼ │ │ eotEncoder◄──────────────┘◄───────────┘ ▼ (eotHead) │ ▼ ┌────────┐ │ output │ └────────┘ |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly forward :: MonadThrow m => GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head -> EncoderOnlyTransformerInput input inputType pos attentionMask -> Generator generatorDevice -> m (EncoderOnlyTransformerOutput headOutput, Generator generatorOutputDevice) Source # | |
type Rep (EncoderOnlyTransformerOutput output) Source # | |
Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly type Rep (EncoderOnlyTransformerOutput output) = D1 ('MetaData "EncoderOnlyTransformerOutput" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "EncoderOnlyTransformerOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "eotOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 output))) |
data SimplifiedEncoderOnlyTransformerOutput output paddingMask where Source #
SimplifiedEncoderOnlyTransformerOutput | |
|