- 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
Start with LFM3 for general text, vision, audio, or omni workloads. Compare models within your deployment’s memory, latency, and quality constraints. Smaller and specialized older models remain useful when they fit those constraints better.
For image-to-JSON extraction, also evaluate the specialized LFM2.5-VL-Extract models.
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 a runtime build that supports your checkpoint. For tool use, LFM3 usesqwen3_coder parsing in vLLM and SGLang; LFM2 and LFM2.5 use lfm2. Follow the selected model’s quickstart for the full launch configuration.
For GPU inference, see Transformers, vLLM, SGLang, or zml/llmd.
For edge and on-device inference, see llama.cpp, Ollama, Atomic Chat, LM Studio, MLX, or ONNX. To embed a model in a mobile or desktop app, see Build with llama.cpp.
Chat Template
LFMs use a ChatML-style format, with generation-specific tokens and reasoning behavior. LFM3 templates normally open a thinking-model assistant turn with<think>; use the tokenizer or processor to format the prompt.
Roles are system, user, assistant, and tool. Image and video markers differ by model generation; let the processor insert them.
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
LFM3 emits XML tool calls, using a superset of theqwen3_coder format:
tool_calls. A client that reads raw generated text must handle the format for its selected model.
What to do:
- Pass tools through
tokenizer.apply_chat_template(messages, tools=[...])or the serving runtime’s supported tool mechanism. - Prefer the serving runtime’s structured
tool_calls. If you parse raw text, handle LFM3 XML or the older<|tool_call_start|>/<|tool_call_end|>format as appropriate. - On vLLM or SGLang, use
qwen3_coderfor LFM3 andlfm2for LFM2/LFM2.5, with the other flags from the model’s quickstart. - Return results as
toolrole messages, with JSON content if useful. - If you fine-tune for tool calling, format the data with the selected model’s own chat template and native tool-call format.
Fine-tuning
Use a training workflow that supports your model architecture. The LFM3-1.7B model card documents a TRL path. Check framework support before reusing an older training recipe. First, choose LoRAtarget_modules for the selected model. Inspect model.named_modules() or use its training recipe; module names differ across LFM generations. The following example applies to LFM2 and LFM2.5 only:
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.
Use Liquid Finetune, TRL, Unsloth, or Halo according to the selected model and the framework’s documented support.
See Fine-tuning Overview for the main fine-tuning workflow.