{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
module Torch.GraduallyTyped.NN.Transformer.BERT.BaseUncased where
import Data.Singletons (SingI (sing))
import GHC.TypeLits (Nat)
import Torch.GraduallyTyped.Device (Device, DeviceType, SDevice)
import Torch.GraduallyTyped.NN.Class (ModelSpec)
import Torch.GraduallyTyped.NN.Transformer.BERT.Common (BERTModelF, bertModelSpec)
import Torch.GraduallyTyped.NN.Transformer.Type (STransformerHead, TransformerHead)
import Torch.GraduallyTyped.NN.Type (HasDropout, SHasDropout)
import Torch.GraduallyTyped.Prelude.TypeLits (SNat)
import Torch.GraduallyTyped.RequiresGradient (Gradient, RequiresGradient, SGradient)
import Torch.GraduallyTyped.Shape.Type (Dim (..), Name (..), SDim, Size (..))
type BERTBaseUncasedNumLayers = 12
bertBaseUncasedNumLayers :: SNat BERTBaseUncasedNumLayers
bertBaseUncasedNumLayers :: SNat BERTBaseUncasedNumLayers
bertBaseUncasedNumLayers = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedHeadDim = 'Dim ('Name "*") ('Size 12)
bertBaseUncasedHeadDim :: SDim BERTBaseUncasedHeadDim
bertBaseUncasedHeadDim :: SDim BERTBaseUncasedHeadDim
bertBaseUncasedHeadDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedHeadEmbedDim = 'Dim ('Name "*") ('Size 64)
bertBaseUncasedHeadEmbedDim :: SDim BERTBaseUncasedHeadEmbedDim
bertBaseUncasedHeadEmbedDim :: SDim BERTBaseUncasedHeadEmbedDim
bertBaseUncasedHeadEmbedDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedEmbedDim = 'Dim ('Name "*") ('Size 768)
bertBaseUncasedEmbedDim :: SDim BERTBaseUncasedEmbedDim
bertBaseUncasedEmbedDim :: SDim BERTBaseUncasedInputEmbedDim
bertBaseUncasedEmbedDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedInputEmbedDim = 'Dim ('Name "*") ('Size 768)
bertBaseUncasedInputEmbedDim :: SDim BERTBaseUncasedInputEmbedDim
bertBaseUncasedInputEmbedDim :: SDim BERTBaseUncasedInputEmbedDim
bertBaseUncasedInputEmbedDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedFFNDim = 'Dim ('Name "*") ('Size 3072)
bertBaseUncasedFFNDim :: SDim BERTBaseUncasedFFNDim
bertBaseUncasedFFNDim :: SDim BERTBaseUncasedFFNDim
bertBaseUncasedFFNDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedVocabDim = 'Dim ('Name "*") ('Size 30522)
bertBaseUncasedVocabDim :: SDim BERTBaseUncasedVocabDim
bertBaseUncasedVocabDim :: SDim BERTBaseUncasedVocabDim
bertBaseUncasedVocabDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncasedTypeVocabDim = 'Dim ('Name "*") ('Size 2)
bertBaseUncasedTypeVocabDim :: SDim BERTBaseUncasedTypeVocabDim
bertBaseUncasedTypeVocabDim :: SDim BERTBaseUncasedTypeVocabDim
bertBaseUncasedTypeVocabDim = forall {k} (a :: k). SingI a => Sing a
sing
type BERTBaseUncased
(transformerHead :: TransformerHead)
(gradient :: Gradient RequiresGradient)
(device :: Device (DeviceType Nat))
(hasDropout :: HasDropout) =
BERTModelF transformerHead BERTBaseUncasedNumLayers gradient device BERTBaseUncasedHeadDim BERTBaseUncasedHeadEmbedDim BERTBaseUncasedEmbedDim BERTBaseUncasedInputEmbedDim BERTBaseUncasedFFNDim BERTBaseUncasedVocabDim BERTBaseUncasedTypeVocabDim hasDropout
bertBaseUnchasedSpec ::
STransformerHead transformerHead ->
SGradient gradient ->
SDevice device ->
SHasDropout hasDropout ->
ModelSpec (BERTBaseUncased transformerHead gradient device hasDropout)
bertBaseUnchasedSpec :: forall (transformerHead :: TransformerHead)
(gradient :: Gradient RequiresGradient)
(device :: Device (DeviceType Natural)) (hasDropout :: HasDropout).
STransformerHead transformerHead
-> SGradient gradient
-> SDevice device
-> SHasDropout hasDropout
-> ModelSpec
(BERTBaseUncased transformerHead gradient device hasDropout)
bertBaseUnchasedSpec STransformerHead transformerHead
transformerHead = forall (transformerHead :: TransformerHead) (numLayers :: Natural)
(gradient :: Gradient RequiresGradient)
(device :: Device (DeviceType Natural))
(headDim :: Dim (Name Symbol) (Size Natural))
(headEmbedDim :: Dim (Name Symbol) (Size Natural))
(embedDim :: Dim (Name Symbol) (Size Natural))
(inputEmbedDim :: Dim (Name Symbol) (Size Natural))
(ffnDim :: Dim (Name Symbol) (Size Natural))
(vocabDim :: Dim (Name Symbol) (Size Natural))
(typeVocabDim :: Dim (Name Symbol) (Size Natural))
(hasDropout :: HasDropout).
(SingI headDim, SingI headEmbedDim, SingI embedDim,
SingI inputEmbedDim, SingI ffnDim, SingI vocabDim,
SingI typeVocabDim) =>
STransformerHead transformerHead
-> SNat numLayers
-> SGradient gradient
-> SDevice device
-> SHasDropout hasDropout
-> ModelSpec
(BERTModelF
transformerHead
numLayers
gradient
device
headDim
headEmbedDim
embedDim
inputEmbedDim
ffnDim
vocabDim
typeVocabDim
hasDropout)
bertModelSpec STransformerHead transformerHead
transformerHead SNat BERTBaseUncasedNumLayers
bertBaseUncasedNumLayers