- deployment runtime choice (see Deployment runtimes),
- chat templates (see Chat Template),
- sampling configuration (see Sampling Configuration),
- tool-call parsing (see Tool Use), and
- LoRA module names (see Fine-tuning).
Model mapping
Pick the LFM in the same deployment class as your current model. Compare within class; benchmarking a 1.2B LFM against a 32B Qwen-family model does not tell you whether it fits your deployment.
See the Complete Model Library for the full catalog.
Deployment runtimes
Across runtimes, avoid carrying over hand-written Qwen, Llama, or Gemma prompt templates. Use the model-provided chat template, and configure thelfm2 tool-call parser in vLLM or SGLang when tool use is in scope.
For GPU inference, see Transformers, vLLM, or SGLang.
For edge and on-device inference, see llama.cpp, Ollama, LM Studio, MLX, ONNX, or the LEAP SDK.
Chat Template
LFMs use a ChatML-style format: Roles aresystem, user, assistant, and tool. Vision-language models use an <image> sentinel.
Migration notes:
- From Qwen: ChatML is familiar, but token details differ. Use
apply_chat_template; do not reuse literal Qwen strings. - From Llama: replace
<|begin_of_text|>and<|start_header_id|>prompt builders. - From Gemma: replace
<start_of_turn>builders. LFMs support a realsystemrole.
apply_chat_template guide for the full formatting workflow.
Sampling Configuration
Generation parameters are model-specific. Tune on your task instead of carrying over defaults from Qwen, Llama, or Gemma. See the Prompting Guide for recommended sampling configurations by model.Tool Use
LFMs natively emit a Pythonic tool-call list, not OpenAI-style JSON: If you swap an agent to an LFM and let a generic JSON parser run, tool calls can appear broken. The format is different. What to do:- Pass tools through
tokenizer.apply_chat_template(messages, tools=[...])or the serving runtime’s supported tool mechanism. - Parse the Pythonic call list between
<|tool_call_start|>and<|tool_call_end|>. - On vLLM or SGLang, configure the
lfm2tool-call parser instead of a generic JSON parser. - Return results as
toolrole messages, with JSON content if useful. - If you fine-tune for tool calling, train on the native Pythonic format and convert to any internal domain-specific language after parsing.
Fine-tuning
LFMs are standard Hugging Face causal LMs, so TRL and Unsloth-style pipelines carry over with two LFM-specific corrections. First, update LoRAtarget_modules. LFM2 and LFM2.5 use a conv-attention hybrid with different module names than Llama-family models:
model.print_trainable_parameters(). You should see millions of trainable parameters, and the LoRA module count should be in the expected range for your model size. If it is near zero, the module names are wrong.
Second, format training examples with the LFM chat template. Training data formatted with your previous model’s template creates a silent distribution mismatch.
Everything else transfers directly. Use LEAP Finetune, TRL, or Unsloth depending on your existing workflow.
See Fine-tuning Overview for the main fine-tuning workflow.