1. Model Architecture Overview
Mirror AI is a Sequence-to-Sequence (Seq2Seq) Transformer that uses a Pre-Layer Normalization (Pre-LN) design, which stabilizes training compared to classic Post-LN Transformers. It also employs SwiGLU activation in place of standard feed-forward networks.
2. Detailed Hyperparameters
Vocabulary Size (vocab_size): 16,000 (driven by the custom SentencePiece tokenizer). Model Dimension (d_model): 256 (the size of token embeddings and hidden states throughout the network). Attention Heads (nhead): 8 (dividing the 256-dimensional space into 8 parallel attention heads of size 32 each). Encoder Layers (num_encoder_layers): 4 Pre-LN encoder layers. Decoder Layers (num_decoder_layers): 4 Pre-LN decoder layers. Feed-Forward Dimension (d_ff): 1024 (the internal projection layer inside the SwiGLU block). Dropout Rate: 0.1 (applied to self-attention outputs, cross-attention, and SwiGLU layers during training). Positional Encoding: Sinusoidal absolute positional encodings.
3. Key Architectural Features
Pre-LN Structure: Normalization (nn.LayerNorm) is applied directly to the inputs of each sub-layer (attention and feed-forward) before adding residual connections. This prevents vanishing/exploding gradients. SwiGLU Feed-Forward Blocks: Instead of the standard ReLU or GELU MLPs, your model uses SwiGLU (Swish Gated Linear Unit) layers defined as: $$\text{SwiGLU}(x) = (\text{SiLU}(xW_1) \otimes xW_2)W_3$$ This is a modern feed-forward structure commonly used in state-of-the-art models like LLaMA and Mistral because it captures non-linear features much better.
Inference Examples:
BIDIRECTIONAL MODEL EVALUATION SUITE:
[Tumbuka -> English]
Source: Muli makola?
Output: are you afraid?
[English -> Tumbuka]
Source: How are you today?
Output: Kasi mwahuno wuli?
[Tumbuka -> English]
Source: Mu mutendeko Chiuta wakalenga kuchanya na charu cha pasi.
Output: In the beginning God created the heavens and the earth.
[English -> Tumbuka]
Source: In the beginning God created the heaven and the earth.
Output: Mu mutendeko Chiuta wakalenga mtambo na charu cha pasi.
[Tumbuka -> English]
Source: Zina lako ndiwe njani?
Output: What is your name?
[English -> Tumbuka]
Source: What is your name?
Output: Zina lako ndiwe njani?