BaseModelConfig¶
Base configuration class for all model architectures.
from mobius import BaseModelConfig, ArchitectureConfig
Class Hierarchy¶
BaseModelConfig
├── ArchitectureConfig # Decoder-only models
│ ├── CausalLMConfig # With additional causal LM fields
│ ├── Gemma2Config # Gemma-2 specific
│ ├── MambaConfig # SSM models
│ └── VisionLanguageConfig # Vision-language models
│ └── MllamaConfig
├── EncoderConfig # Encoder-only (BERT)
├── WhisperConfig # Whisper speech-to-text
├── Sam2Config # SAM2 segmentation
├── SegformerConfig # Segformer segmentation
├── DepthAnythingConfig # Depth estimation
└── YolosConfig # Object detection
BaseModelConfig Fields¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Vocabulary size. |
|
|
— |
Hidden dimension. |
|
|
— |
Feed-forward intermediate size. |
|
|
— |
Number of transformer layers. |
|
|
— |
Number of attention heads. |
|
|
— |
Number of KV heads (for GQA). |
|
|
— |
Dimension per attention head. |
|
|
|
Activation function ( |
|
|
— |
Padding token ID. |
|
|
|
Whether to tie input/output embeddings. |
|
|
|
Model weight dtype. |
ArchitectureConfig Additional Fields¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Maximum sequence length. |
|
|
|
RMSNorm epsilon. |
|
|
|
RoPE type ( |
|
|
|
RoPE base frequency. |
|
|
|
RoPE scaling configuration. |
|
|
|
Sliding window attention size. |
|
|
|
Number of MoE experts. |
|
|
|
Active experts per token. |
Usage¶
Configs are typically created automatically by build() from HuggingFace
configs. For manual construction:
from mobius import ArchitectureConfig
config = ArchitectureConfig(
vocab_size=32000,
hidden_size=4096,
intermediate_size=11008,
num_hidden_layers=32,
num_attention_heads=32,
num_key_value_heads=32,
max_position_embeddings=4096,
hidden_act="silu",
head_dim=128,
pad_token_id=0,
)
# Validate the config
config.validate()
Validation¶
config.validate() checks that critical fields like hidden_size,
num_attention_heads, and vocab_size have positive values and are
internally consistent (e.g. head_dim divides hidden_size).