hasktorch-gradually-typed-0.2.0.0: experimental project for hasktorch
Safe HaskellSafe-Inferred
LanguageHaskell2010

Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Synopsis

Documentation

data EncoderOnlyTransformerHasEmbedScaling Source #

Data type that is used to represent whether the encoder-only transformer model has a scaled embedding.

Instances

Instances details
Generic EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Show EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Eq EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Ord EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

HasStateDict EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

HasInitialize EncoderOnlyTransformerHasEmbedScaling generatorDevice EncoderOnlyTransformerHasEmbedScaling generatorDevice Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

type Rep EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

type Rep EncoderOnlyTransformerHasEmbedScaling = D1 ('MetaData "EncoderOnlyTransformerHasEmbedScaling" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "EncoderOnlyTransformerWithEmbedScaling" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EncoderOnlyTransformerWithoutEmbedScaling" 'PrefixI 'False) (U1 :: Type -> Type))
type ModelSpec EncoderOnlyTransformerHasEmbedScaling Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

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.

Constructors

GEncoderOnlyTransformer 

Fields

Instances

Instances details
Generic (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (GEncoderOnlyTransformer inputEmbedDim encoder encoderEmbedding encoderTypeEmbedding head) :: Type -> Type Source #

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 #

HasForward instance for encoder-only transformers with optional scaling and head.

   ┌───────┐    ┌───────────┐  ┌─────┐  ┌───────────────┐
   │ input │    │ inputType │  │ pos │  │ attentionMask │
   └───┬───┘    └─────┬─────┘  └──┬──┘  └──────┬────────┘
       │              │           │            │
       ▼              ▼           │            │
 eotEmbedding  eotTypeEmbedding   │            │
       ▼              ▼           │            │
(embedScaling)  (embedScaling)    │            │
       │              │           │            │
       └────►add◄─────┘           │            │
              │                   │            │
              ▼                   │            │
         eotEncoder◄──────────────┘◄───────────┘
              ▼
          (eotHead)
              │
              ▼
         ┌────────┐
         │ output │
         └────────┘
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

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 # 
Instance details

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 #

Equations

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.

Equations

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.

Equations

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.

Equations

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 parameters
  • device: 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 #

Constructors

GSimplifiedEncoderOnlyTransformer 

Fields

Instances

Instances details
Generic (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask) :: Type -> Type Source #

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

(==) :: 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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

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 # 
Instance details

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.

Constructors

EncoderOnlyTransformerInput 

Fields

Instances

Instances details
Generic (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (EncoderOnlyTransformerInput input inputType pos attentionMask) :: Type -> Type Source #

Methods

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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

showsPrec :: Int -> EncoderOnlyTransformerInput input inputType pos attentionMask -> ShowS Source #

show :: EncoderOnlyTransformerInput input inputType pos attentionMask -> String Source #

showList :: [EncoderOnlyTransformerInput input inputType pos attentionMask] -> ShowS Source #

(Eq input, Eq inputType, Eq pos, Eq attentionMask) => Eq (EncoderOnlyTransformerInput input inputType pos attentionMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

(==) :: 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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 #

HasForward instance for encoder-only transformers with optional scaling and head.

   ┌───────┐    ┌───────────┐  ┌─────┐  ┌───────────────┐
   │ input │    │ inputType │  │ pos │  │ attentionMask │
   └───┬───┘    └─────┬─────┘  └──┬──┘  └──────┬────────┘
       │              │           │            │
       ▼              ▼           │            │
 eotEmbedding  eotTypeEmbedding   │            │
       ▼              ▼           │            │
(embedScaling)  (embedScaling)    │            │
       │              │           │            │
       └────►add◄─────┘           │            │
              │                   │            │
              ▼                   │            │
         eotEncoder◄──────────────┘◄───────────┘
              ▼
          (eotHead)
              │
              ▼
         ┌────────┐
         │ output │
         └────────┘
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

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 #

Constructors

SimplifiedEncoderOnlyTransformerInput 

Fields

Instances

Instances details
Generic (SimplifiedEncoderOnlyTransformerInput input inputType) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (SimplifiedEncoderOnlyTransformerInput input inputType) :: Type -> Type Source #

(Show input, Show inputType) => Show (SimplifiedEncoderOnlyTransformerInput input inputType) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(Eq input, Eq inputType) => Eq (SimplifiedEncoderOnlyTransformerInput input inputType) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(Ord input, Ord inputType) => Ord (SimplifiedEncoderOnlyTransformerInput input inputType) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

forward :: MonadThrow m => GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> SimplifiedEncoderOnlyTransformerInput input inputType -> Generator generatorDevice -> m (SimplifiedEncoderOnlyTransformerOutput output paddingMask, Generator generatorOutputDevice) Source #

type Rep (SimplifiedEncoderOnlyTransformerInput input inputType) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

type Rep (SimplifiedEncoderOnlyTransformerInput input inputType) = D1 ('MetaData "SimplifiedEncoderOnlyTransformerInput" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "SimplifiedEncoderOnlyTransformerInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "seotInput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 input) :*: S1 ('MetaSel ('Just "seotInputType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 inputType)))

data EncoderOnlyTransformerOutput output where Source #

Output data type for use with an encoder-only transformer.

Constructors

EncoderOnlyTransformerOutput 

Fields

Instances

Instances details
Generic (EncoderOnlyTransformerOutput output) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (EncoderOnlyTransformerOutput output) :: Type -> Type Source #

Show output => Show (EncoderOnlyTransformerOutput output) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Eq output => Eq (EncoderOnlyTransformerOutput output) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Ord output => Ord (EncoderOnlyTransformerOutput output) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(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 #

HasForward instance for encoder-only transformers with optional scaling and head.

   ┌───────┐    ┌───────────┐  ┌─────┐  ┌───────────────┐
   │ input │    │ inputType │  │ pos │  │ attentionMask │
   └───┬───┘    └─────┬─────┘  └──┬──┘  └──────┬────────┘
       │              │           │            │
       ▼              ▼           │            │
 eotEmbedding  eotTypeEmbedding   │            │
       ▼              ▼           │            │
(embedScaling)  (embedScaling)    │            │
       │              │           │            │
       └────►add◄─────┘           │            │
              │                   │            │
              ▼                   │            │
         eotEncoder◄──────────────┘◄───────────┘
              ▼
          (eotHead)
              │
              ▼
         ┌────────┐
         │ output │
         └────────┘
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

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 # 
Instance details

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 #

Constructors

SimplifiedEncoderOnlyTransformerOutput 

Fields

Instances

Instances details
Generic (SimplifiedEncoderOnlyTransformerOutput output paddingMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Associated Types

type Rep (SimplifiedEncoderOnlyTransformerOutput output paddingMask) :: Type -> Type Source #

(Show output, Show paddingMask) => Show (SimplifiedEncoderOnlyTransformerOutput output paddingMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(Eq output, Eq paddingMask) => Eq (SimplifiedEncoderOnlyTransformerOutput output paddingMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(Ord output, Ord paddingMask) => Ord (SimplifiedEncoderOnlyTransformerOutput output paddingMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

(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 # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

Methods

forward :: MonadThrow m => GSimplifiedEncoderOnlyTransformer model mkPos mkPaddingMask mkAttentionMask -> SimplifiedEncoderOnlyTransformerInput input inputType -> Generator generatorDevice -> m (SimplifiedEncoderOnlyTransformerOutput output paddingMask, Generator generatorOutputDevice) Source #

type Rep (SimplifiedEncoderOnlyTransformerOutput output paddingMask) Source # 
Instance details

Defined in Torch.GraduallyTyped.NN.Transformer.GEncoderOnly

type Rep (SimplifiedEncoderOnlyTransformerOutput output paddingMask) = D1 ('MetaData "SimplifiedEncoderOnlyTransformerOutput" "Torch.GraduallyTyped.NN.Transformer.GEncoderOnly" "hasktorch-gradually-typed-0.2.0.0-1KV1aIPzzbp6JpSr37tC1K" 'False) (C1 ('MetaCons "SimplifiedEncoderOnlyTransformerOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "seotOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 output) :*: S1 ('MetaSel ('Just "sedtPaddingMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 paddingMask)))