circuits-llm
Safe HaskellNone
LanguageGHC2024

Circuit.LLM.GPT

Description

GPT-2 architecture using hmatrix for linear algebra.

Synopsis

Normalisation and activation

layerNorm :: Matrix Double -> Vector Double -> Vector Double -> Double -> Matrix Double Source #

Layer normalisation along the last axis.

gelu :: Matrix Double -> Matrix Double Source #

GELU activation (approximation).

Transformer block

data FeedForward Source #

Feed-forward network.

Full model

data GptConfig Source #

GPT-2 model configuration.

Constructors

GptConfig 

forward :: GptConfig -> Gpt -> [Int] -> Matrix Double Source #

Full forward pass.