Expand description
Model Architecture Language (MAL) for Hermes LLM
A composable DSL for defining LLM model architectures using pest parser.
§Example MAL - Simple (flat) style
model tiny {
vocab_size: 32000
hidden_size: 128
num_layers: 4
num_heads: 4
intermediate_size: 512
}§Example MAL - Composable style
# Define attention mechanism
attention gqa {
num_heads: 32
num_kv_heads: 8
head_dim: 128
position_encoding: rope { theta: 10000.0 }
}
# Define FFN
ffn swiglu_mlp {
hidden_dim: 14336
activation: swiglu
bias: false
}
# Define transformer block
block llama_block {
attention: gqa
ffn: swiglu_mlp
norm: rmsnorm { eps: 1e-5 }
norm_position: pre
}
# Define model using the block
model llama_7b {
vocab_size: 32000
max_seq_len: 4096
hidden_size: 4096
block: llama_block
num_layers: 32
}Structs§
- Attention
Def - Attention mechanism definition
- Block
Def - Transformer block definition
- Embeddings
Config - Embeddings configuration
- FfnDef
- Feed-forward network definition
- MalFile
- Complete parsed MAL file with all definitions
- MalParser
- Model
Def - Parsed model definition from MAL
- Norm
Config - Normalization configuration
- Output
Config - Output head configuration
- SsmDef
- Selective state-space (Mamba) mixer definition
Enums§
- Activation
- Activation function
- Norm
Position - Normalization position in block
- Norm
Type - Normalization type
- Position
Encoding - Position encoding type
- Rule
Functions§
- get_
builtin_ model - Get a well-known model definition by name
- get_
wellknown_ mal - Get the raw MAL content for a well-known model
- list_
wellknown_ models - List all well-known model names (auto-discovered from embedded files)
- parse_
mal - Parse MAL from a string (returns first model found)
- parse_
mal_ file - Parse MAL from a file
- parse_
mal_ full - Parse complete MAL file with all definitions