Expand description
Model builder: constructs an Lfm2Model from a WeightsContext.
Loads Hugging Face safetensors checkpoints of two families into the same decoder structure, with optional LoRA adapters:
- Llama-style (
model_typellama/mistral, e.g. SmolLM2, TinyLlama): every block is RoPE grouped-query attention plus a SwiGLU MLP; weights namedself_attn.{q,k,v,o}_proj,mlp.{gate,up,down}_proj,input_layernorm,post_attention_layernormandmodel.norm. - LFM2 (
layer_typespresent): blocks are short convolutions or attention, namedoperator_norm,ffn_norm,feed_forward.w{1,2,3}, with the final norm stored asmodel.embedding_norm.
Base weights are frozen (Tensor::frozen) unless
Lfm2ModelBuilder::with_trainable_base is set, so LoRA training skips
their gradients.
Structs§
- Build
Error - Error returned when a checkpoint cannot be turned into a model.
- Lfm2
Model Builder - Builds an
Lfm2Modelfrom loaded weights. - LoRa
Config - Configuration for LoRA adapters
Enums§
- Architecture
- Weight-naming family of a checkpoint.
Functions§
- load_
lfm2_ model - Load the model in
model_path(config.jsonplus safetensors).