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

Torch.GraduallyTyped.NN.Transformer.Pegasus.Common

Synopsis

Documentation

type PegasusDType = 'Float Source #

Pegasus dType.

pegasusDType :: SDType PegasusDType Source #

Pegasus dType singleton.

type PegasusDataType = 'DataType PegasusDType Source #

Pegasus data type.

pegasusDataType :: SDataType PegasusDataType Source #

Pegasus data type singleton.

pegasusDropoutP :: Double Source #

Pegasus dropout rate. 'dropout_rate = 0.1'

type PegasusPosEncDim = 'Dim ('Name "*") ('Size 512) Source #

Pegasus positional encoding dimension.

pegasusPosEncDim :: SDim PegasusPosEncDim Source #

Pegasus positional encoding dimension singleton.

pegasusEps :: Double Source #

Pegasus layer-norm epsilon.

pegasusMaxPositionEmbeddings :: Int Source #

Pegasus maximum number of position embeddings. 'max_position_embeddings = 512'

pegasusPadTokenId :: Int Source #

Pegasus padding token id. 'pad_token_id = 0'

pegasusBOSTokenId :: Int Source #

Pegasus begin-of-sentence token id. 'bos_token_id = 0'

pegasusEOSTokenId :: Int Source #

Pegasus end-of-sentence token id. 'eos_token_id = 0'

pegasusAttentionMaskBias :: Double Source #

Pegasus attention mask bias

type family PegasusModelF (transformerHead :: TransformerHead) (numLayers :: Nat) (gradient :: Gradient RequiresGradient) (device :: Device (DeviceType Nat)) (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)) (vocabDim :: Dim (Name Symbol) (Size Nat)) (hasDropout :: HasDropout) :: Type where ... Source #

Specifies the Pegasus model.

Equations

PegasusModelF transformerHead numLayers gradient device headDim headEmbedDim embedDim inputEmbedDim ffnDim vocabDim hasDropout = GSimplifiedEncoderDecoderTransformer (GEncoderDecoderTransformerF 'Pegasus transformerHead numLayers numLayers gradient device PegasusDataType headDim headEmbedDim embedDim inputEmbedDim ffnDim PegasusPosEncDim vocabDim hasDropout) MkAbsPos MkAbsPos MkTransformerPaddingMask (MkTransformerAttentionMask PegasusDataType) (MkTransformerCrossAttentionMask PegasusDataType) (MkTransformerDecoderAttentionMask PegasusDataType) 

pegasusModelSpec :: forall transformerHead numLayers gradient device headDim headEmbedDim embedDim inputEmbedDim ffnDim vocabDim hasDropout. (SingI headDim, SingI headEmbedDim, SingI embedDim, SingI inputEmbedDim, SingI ffnDim, SingI vocabDim) => STransformerHead transformerHead -> SNat numLayers -> SGradient gradient -> SDevice device -> SHasDropout hasDropout -> ModelSpec (PegasusModelF transformerHead numLayers gradient device headDim headEmbedDim embedDim inputEmbedDim ffnDim vocabDim hasDropout) Source #

Specifies the parameters of a Pegasus model.

  • transformerHead: the head of the Pegasus model.
  • numLayers: the number of layers in the Pegasus model.
  • gradient: whether to compute the gradient of the Pegasus model.
  • device: the computational device on which the Pegasus model parameters are to be allocated.

mkPegasusInput :: forall batchDim seqDim device m output. (MonadThrow m, SGetDim batchDim, SGetDim seqDim, Catch ('Shape '['Dim ('Name "*") 'UncheckedSize, 'Dim ('Name "*") 'UncheckedSize] <+> 'Shape '[batchDim, seqDim]), output ~ Tensor ('Gradient 'WithoutGradient) ('Layout 'Dense) device ('DataType 'Int64) ('Shape '[batchDim, seqDim])) => SDim batchDim -> SDim seqDim -> SDevice device -> [[Int]] -> m output Source #