Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::LlamaConfig Class Referenceexport

Network-level configuration for LLaMA-style transformer networks. More...

Inheritance diagram for Mila::Dnn::LlamaConfig:
Mila::Dnn::ComponentConfig

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ LlamaConfig()

Mila::Dnn::LlamaConfig::LlamaConfig ( dim_t embedding_dim,
dim_t num_layers )
inline

Construct a LLaMA network configuration.

Parameters
embedding_dimModel embedding dimension. Must be > 0.
num_layersNumber of transformer layers. Must be > 0.

Member Function Documentation

◆ fromMetadata()

void Mila::Dnn::LlamaConfig::fromMetadata ( const SerializationMetadata & meta)
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.

Parameters
metaMetadata to read configuration values from.

Implements Mila::Dnn::ComponentConfig.

◆ toMetadata()

SerializationMetadata Mila::Dnn::LlamaConfig::toMetadata ( ) const
inlineoverridevirtual

Convert configuration into a SerializationMetadata object.

Implementations should include any fields required to fully reconstruct the configuration via fromMetadata.

Returns
SerializationMetadata Metadata representation of the config.

Implements Mila::Dnn::ComponentConfig.

◆ toString()

std::string Mila::Dnn::LlamaConfig::toString ( ) const
inlineoverridevirtual

Produce a short, human-readable summary of the configuration.

Implementations should return a compact, single-line description suitable for logging and debugging.

Returns
std::string Human-readable summary of the configuration.

Implements Mila::Dnn::ComponentConfig.

◆ validate()

void Mila::Dnn::LlamaConfig::validate ( ) const
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.

Exceptions
std::invalid_argumentIf the configuration is invalid.

Implements Mila::Dnn::ComponentConfig.

◆ withMaxSequenceLength()

template<typename Self>
decltype(auto) Mila::Dnn::LlamaConfig::withMaxSequenceLength ( this Self && self,
dim_t max_seq_len )
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.

Template Parameters
SelfDeduced type of the builder ( supports both lvalue and rvalue chains ).
Parameters
max_seq_lenThe trained maximum sequence length. Must be > 0.
Exceptions
std::invalid_argumentif max_seq_len is zero or negative.

The documentation for this class was generated from the following file: