Class LlamaTransformerBlock

java.lang.Object
io.github.kirstenali.deepj.layers.transformer.blocks.LlamaTransformerBlock
All Implemented Interfaces:
Layer, Trainable

public final class LlamaTransformerBlock extends Object
Pre-LN transformer block with Llama-style full-head attention:
   x = x + RoPE-Attn( RMSNorm(x) )
   x = x + SwiGLU(    RMSNorm(x) )
 

Composes RMSNorm1D, RoPEMultiHeadSelfAttention, and SwiGLULayer.

  • Constructor Details

    • LlamaTransformerBlock

      public LlamaTransformerBlock(int dModel, int nHeads, int dFF, int maxSeqLen, Random rnd)
      Parameters:
      dModel - model dimension
      nHeads - attention heads (must divide dModel)
      dFF - SwiGLU intermediate dimension (typically ≈ 8/3 × dModel)
      maxSeqLen - maximum sequence length for the RoPE table
      rnd - random source for weight initialisation
  • Method Details