Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::ModelConfig Class Referenceabstractexport

Abstract base configuration for all deployable Mila models. More...

Public Member Functions

 ModelConfig (const ModelConfig &)=delete
dim_t getContextLength () const noexcept
ModelConfig & operator= (const ModelConfig &)=delete
virtual std::string toString () const =0
 Produce a human-readable summary of the model configuration.
template<typename Self>
Self & withContextLength (this Self &self, dim_t context_length)
 Set the maximum sequence length.

Protected Member Functions

 ModelConfig ()=default
 Default constructor for subclasses that set context_length via withContextLength().
 ModelConfig (dim_t context_length)
 Construct with required context_length.
std::string baseToString () const
 Produce the base fields portion of toString().

Protected Attributes

dim_t context_length_ { 0 }

Detailed Description

Abstract base configuration for all deployable Mila models.

Subclasses add architecture-specific deployment concerns (e.g. LlamaModelConfig adds nothing beyond what ModelConfig already owns – all Llama architectural parameters come from checkpoint metadata).

Non-copyable by design – model configs are constructed once and passed by const reference into fromPretrained().

Constructor & Destructor Documentation

◆ ModelConfig() [1/2]

Mila::Dnn::ModelConfig::ModelConfig ( dim_t context_length)
inlineexplicitprotected

Construct with required context_length.

Protected – construction is via concrete subclass only.

Parameters
context_lengthMaximum sequence length. Must be > 0.

◆ ModelConfig() [2/2]

Mila::Dnn::ModelConfig::ModelConfig ( )
protecteddefault

Default constructor for subclasses that set context_length via withContextLength().

context_length_ is initialised to zero. Subclasses or fromPretrained() must call withContextLength() before passing the config to build().

Member Function Documentation

◆ baseToString()

std::string Mila::Dnn::ModelConfig::baseToString ( ) const
inlineprotected

Produce the base fields portion of toString().

Subclasses call this and append their own fields.

◆ toString()

virtual std::string Mila::Dnn::ModelConfig::toString ( ) const
pure virtual

Produce a human-readable summary of the model configuration.

Implementations should include base fields by calling baseToString() and appending subclass-specific fields.

◆ withContextLength()

template<typename Self>
Self & Mila::Dnn::ModelConfig::withContextLength ( this Self & self,
dim_t context_length )
inline

Set the maximum sequence length.

Required. The model is built at this context length so that RoPE embeddings and KV cache buffers cover the full range.

Parameters
context_lengthMaximum sequence length in tokens.
Returns
Reference to the concrete config for chaining.

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