|
Mila
Deep Neural Network Library
|
Network-level configuration for LLaMA-style transformer networks. More...
Public Member Functions | |
| LlamaConfig (dim_t embedding_dim, dim_t num_layers) | |
| Construct a LLaMA network configuration. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| dim_t | getHiddenDimension () const noexcept |
| dim_t | getMaxSequenceLength () const noexcept |
| dim_t | getModelDim () const noexcept |
| dim_t | getNumHeads () const noexcept |
| dim_t | getNumKVHeads () const noexcept |
| dim_t | getNumLayers () const noexcept |
| float | getRMSNormEpsilon () const noexcept |
| float | getRoPEScalingFactor () const noexcept |
| float | getRoPETheta () const noexcept |
| dim_t | getVocabSize () const noexcept |
| SerializationMetadata | toMetadata () const override |
| Convert configuration into a SerializationMetadata object. | |
| std::string | toString () const override |
| Produce a short, human-readable summary of the configuration. | |
| bool | useBias () const noexcept |
| void | validate () const override |
| Validate configuration parameters. | |
| template<typename Self> | |
| decltype(auto) | withBias (this Self &&self, bool use_bias) |
| template<typename Self> | |
| decltype(auto) | withHiddenDimension (this Self &&self, dim_t hidden_dim) |
| template<typename Self> | |
| decltype(auto) | withMaxSequenceLength (this Self &&self, dim_t max_seq_len) |
| Sets the trained maximum sequence length for this model. | |
| template<typename Self> | |
| decltype(auto) | withNumHeads (this Self &&self, dim_t num_heads) |
| template<typename Self> | |
| decltype(auto) | withNumKVHeads (this Self &&self, dim_t num_kv_heads) |
| template<typename Self> | |
| decltype(auto) | withRoPEScalingFactor (this Self &&self, float scale_factor) |
| template<typename Self> | |
| decltype(auto) | withRoPETheta (this Self &&self, float theta) |
| template<typename Self> | |
| decltype(auto) | withVocabularyLength (this Self &&self, dim_t vocab_size) |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
Network-level configuration for LLaMA-style transformer networks.
Exposes only the settings needed at network scope: vocabulary, number of layers, embedding dimension, and max sequence length.
Construct a LLaMA network configuration.
| embedding_dim | Model embedding dimension. Must be > 0. |
| num_layers | Number of transformer layers. Must be > 0. |
|
inlineoverridevirtual |
Populate configuration from provided metadata.
Implementations should read available keys and leave missing keys at their current/default values to preserve forward/backward compatibility.
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Convert configuration into a SerializationMetadata object.
Implementations should include any fields required to fully reconstruct the configuration via fromMetadata.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Produce a short, human-readable summary of the configuration.
Implementations should return a compact, single-line description suitable for logging and debugging.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Validate configuration parameters.
Called by callers to ensure the configuration represents a valid, constructible component. Implementations must throw std::invalid_argument (or a derived exception) when validation fails.
| std::invalid_argument | If the configuration is invalid. |
Implements Mila::Dnn::ComponentConfig.
|
inline |
Sets the trained maximum sequence length for this model.
This value is sourced from the pretrained model metadata and represents the architectural ceiling on context length – the furthest position for which RoPE embeddings were trained.
This is not a deployment parameter. The runtime context length is a deployment decision carried by BuildContext, and must not exceed this value. LlamaModel::fromPretrained() enforces that invariant.
| Self | Deduced type of the builder ( supports both lvalue and rvalue chains ). |
| max_seq_len | The trained maximum sequence length. Must be > 0. |
| std::invalid_argument | if max_seq_len is zero or negative. |