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

Torch.GraduallyTyped.NN.Transformer.BART.Common

Synopsis

Documentation

type BARTDType = 'Float Source #

BART dType.

bartDType :: SDType BARTDType Source #

BART dType singleton.

type BARTDataType = 'DataType BARTDType Source #

BART data type.

bartDataType :: SDataType BARTDataType Source #

BART data type singleton.

bartDropoutP :: Double Source #

BART dropout rate. 'dropout_rate = 0.1'

type BARTPosEncDim = 'Dim ('Name "*") ('Size 1026) Source #

BART positional encoding dimension.

bartPosEncDim :: SDim BARTPosEncDim Source #

BART positional encoding dimension singleton.

bartEps :: Double Source #

BART layer-norm epsilon.

bartMaxPositionEmbeddings :: Int Source #

BART maximum number of position embeddings. 'max_position_embeddings = 1024'

bartPadTokenId :: Int Source #

BART padding token id. 'pad_token_id = 1'

bartBOSTokenId :: Int Source #

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

bartEOSTokenId :: Int Source #

BART end-of-sentence token id. 'eos_token_id = 2'

bartAttentionMaskBias :: Double Source #

BART attention mask bias

type family BARTModelF (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 BART model.

Equations

BARTModelF transformerHead numLayers gradient device headDim headEmbedDim embedDim inputEmbedDim ffnDim vocabDim hasDropout = GSimplifiedEncoderDecoderTransformer (GEncoderDecoderTransformerF 'BART transformerHead numLayers numLayers gradient device BARTDataType headDim headEmbedDim embedDim inputEmbedDim ffnDim BARTPosEncDim vocabDim hasDropout) MkAbsPos MkAbsPos MkTransformerPaddingMask (MkTransformerAttentionMask BARTDataType) (MkTransformerCrossAttentionMask BARTDataType) (MkTransformerDecoderAttentionMask BARTDataType) 

bartModelSpec :: 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 (BARTModelF transformerHead numLayers gradient device headDim headEmbedDim embedDim inputEmbedDim ffnDim vocabDim hasDropout) Source #

Specifies the parameters of a BART model.

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

mkBARTInput :: 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 #