Skip to main content
This guide is for teams already running Qwen, Llama, or Gemma who want to evaluate Liquid Foundation Models (LFMs) as replacements. LFMs load and serve through the same frameworks you already use, so most migrations are a model ID and configuration change. The details that usually matter are: Use this alongside Use Case Evaluation for model selection and benchmarking methodology.

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 uses qwen3_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 real system role.
See Chat Template and Hugging Face’s 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 the qwen3_coder format:
LFM2 and LFM2.5 use the earlier tool-call format, typically a Pythonic call list:
Serving runtimes can parse these native formats into OpenAI-compatible tool_calls. A client that reads raw generated text must handle the format for its selected model. What to do:
  1. Pass tools through tokenizer.apply_chat_template(messages, tools=[...]) or the serving runtime’s supported tool mechanism.
  2. 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.
  3. On vLLM or SGLang, use qwen3_coder for LFM3 and lfm2 for LFM2/LFM2.5, with the other flags from the model’s quickstart.
  4. Return results as tool role messages, with JSON content if useful.
  5. If you fine-tune for tool calling, format the data with the selected model’s own chat template and native tool-call format.
See Tool Use for the full tool-calling workflow.

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 LoRA target_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:
Before a long run, call 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.
Last modified on November 16, 2026