Use AIUnderstand AIBuild with AI
Build with AI·Model deep dive·· 6 min read

Run LFM3-Omni-2B for Speech, Image and Video Questions

Liquid AI's 2.2B omni model takes text, images, video and audio in and answers in text or speech. Run ASR, TTS, image Q&A and tool calls with Transformers.

The code in this post comes from the model's docs and hasn't been run in our CI yet. If something breaks, let us know.

LFM3-Omni-2B is Liquid AI’s first omni-modal model in the LFM3 family: one model that understands text, images, video and audio, and answers in text and speech. The card says it is built for on-device use, replacing separate speech recognition, vision-language, text and text-to-speech models with a single one.

Key specs

Parameters 2.17B total
Inputs Text, images, video (with or without soundtrack), 16 kHz audio
Outputs Text, 24 kHz speech, or interleaved text and speech
Context length 32K tokens (input + output)
Video sampling 2 fps, 4 to 384 frames by default
Image size Native resolution, up to 2,048 tokens per image
Text languages English, Arabic, Chinese, French, German, Italian, Japanese, Korean, Portuguese, Spanish, Vietnamese, Thai, Indonesian, Hindi, Russian, Polish
Speech languages Arabic, Danish, German, Greek, British and American English, Finnish, French, Hebrew, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Spanish, Swedish, Turkish, Chinese
License LFM Open License v1.0 (license: other; read the LICENSE file in the repo)

It is a non-reasoning model: enable_thinking=True is not supported, and every assistant turn opens with an empty <think></think>.

The card lists two checkpoints: BF16 (Transformers, and SGLang for text output) and GGUF for llama.cpp, which includes a realtime speech server. This post uses the BF16 repo with Transformers.

Install

Terminal window
pip install "transformers>=5.20.2" torch torchvision torchcodec accelerate pillow librosa soundfile

Load the model

The checkpoint uses custom code, so trust_remote_code=True is required. The card says the codec implementation is in the repository and the processor loads its weights from audio_tokenizer/.

load.py
import torch
import soundfile as sf
from transformers import AutoModelForMultimodalLM, AutoProcessor
model_id = "LiquidAI/LFM3-Omni-2B"
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
model = AutoModelForMultimodalLM.from_pretrained(
model_id, dtype=dtype, device_map=device, trust_remote_code=True
).eval()
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
codec = processor.audio_tokenizer.to(device=device).eval()

The next examples reuse model, processor, codec and device from this script. Audio files are resampled to 16 kHz mono on load.

Transcribe speech

For transcription, use the system prompt Perform ASR in <language>. with the English name of the language.

asr.py
conversation = [
{"role": "system", "content": "Perform ASR in English."},
{"role": "user", "content": [{"type": "audio", "audio": "audio.wav"}]},
]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, generation_mode="text")
text = processor.decode(
outputs.sequences[0, inputs["input_ids"].shape[1]:outputs.sequence_lengths[0]],
skip_special_tokens=True,
)
print(text)

Ask a spoken question about an image

Put the image and the recording in the same user turn. The card suggests grounding the answer with a system prompt, and adding Respond with text. for a text reply.

spoken_vqa.py
conversation = [
{
"role": "system",
"content": "Answer questions about the provided image. Base every answer only on what can be seen. Respond with text.",
},
{
"role": "user",
"content": [
{"type": "image", "image": "photo.jpg"},
{"type": "audio", "audio": "question.wav"},
],
},
]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, generation_mode="text")
print(processor.decode(
outputs.sequences[0, inputs["input_ids"].shape[1]:outputs.sequence_lengths[0]],
skip_special_tokens=True,
))

For a plain text question, replace the audio item with {"type": "text", "text": "What is written on the sign?"}.

Video that it can see and hear

To let the model use a video’s soundtrack, use the system prompt below and pass two flags. load_audio_from_video=True reads the audio track from the file, and use_audio_in_video=True interleaves it with the frames. Without them, the model gets frames only.

video_audio.py
conversation = [
{"role": "system", "content": "Answer questions about the video using what you see and hear."},
{
"role": "user",
"content": [
{"type": "video", "video": "clip.mp4"},
{"type": "text", "text": "What happens here, and what can you hear?"},
],
},
]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
load_audio_from_video=True,
processor_kwargs={"use_audio_in_video": True},
).to(device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, generation_mode="text")
print(processor.decode(
outputs.sequences[0, inputs["input_ids"].shape[1]:outputs.sequence_lengths[0]],
skip_special_tokens=True,
))

For long videos, each frame adds vision tokens. In Transformers you can lower the frame rate per call with processor_kwargs={"fps": 1}, and set a frame limit when loading the processor with max_frames=128. The card says these settings do not change the soundtrack: the model always hears all of it.

Generate speech

For text-to-speech, use the system prompt Perform TTS in <language> using a <gender> voice. with a female or male voice and one of the listed speech languages. Pass generation_mode="audio" and decode the audio codes with the codec.

tts.py
conversation = [
{"role": "system", "content": "Perform TTS in American English using a female voice."},
{"role": "user", "content": "The quick brown fox jumps over the lazy dog"},
]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
generation_mode="audio",
audio_temperature=0.4,
audio_repetition_penalty=1.2,
)
waveform = codec.decode(
outputs.audio_codes[:1, :, :outputs.audio_lengths[0]]
).audio_values[0] # 24 kHz
sf.write("tts.wav", waveform.squeeze(0).float().cpu().numpy(), 24_000)

For voice chat with text and speech replies, the card uses the system prompt Respond with interleaved text and audio. and generation_mode="interleaved", with the same two audio sampling settings.

Tool calls from spoken requests

Pass function schemas with tools= to apply_chat_template(). The model writes calls in a <tool_call> format; your code parses and runs them, appends the results as a tool message, and generates again. This is the card’s example, using a made-up set_volume function.

tools.py
import json
import re
tools = [{
"type": "function",
"function": {
"name": "set_volume",
"description": "Set the device speaker volume.",
"parameters": {
"type": "object",
"properties": {
"volume": {"type": "integer", "description": "Volume from 0 to 100."}
},
"required": ["volume"],
},
},
}]
functions = {"set_volume": lambda volume: {"volume": volume}} # your implementations
CALL_RE = re.compile(r"<tool_call>\s*<function=([^>\n]+)>(.*?)</function>\s*</tool_call>", re.DOTALL)
PARAM_RE = re.compile(r"<parameter=([^>\n]+)>\n?(.*?)\n?</parameter>", re.DOTALL)
def parse_tool_calls(text):
calls = []
for name, body in CALL_RE.findall(text):
arguments = {}
for key, value in PARAM_RE.findall(body):
try:
arguments[key] = json.loads(value)
except json.JSONDecodeError:
arguments[key] = value # plain string
calls.append({"type": "function", "function": {"name": name, "arguments": arguments}})
return calls
def respond(conversation):
inputs = processor.apply_chat_template(
conversation,
tools=tools,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, generation_mode="text")
return processor.decode(
outputs.sequences[0, inputs["input_ids"].shape[1]:outputs.sequence_lengths[0]],
skip_special_tokens=True,
)
conversation = [
{"role": "user", "content": [{"type": "audio", "audio": "question.wav"}]},
]
text = respond(conversation)
while calls := parse_tool_calls(text):
results = [functions[c["function"]["name"]](**c["function"]["arguments"]) for c in calls]
conversation += [
{"role": "assistant", "tool_calls": calls},
{"role": "tool", "content": json.dumps(results)},
]
text = respond(conversation)
print(text)

Benchmarks from the card

The card compares the model with Qwen2.5-Omni 3B and 7B, Gemma 4 E2B and E4B, and Phi-4 multimodal. On video-plus-audio benchmarks it reports Daily-Omni 70.09 (the next best listed is Qwen2.5-Omni 7B at 61.32), WorldSense 47.10 and AV-SpeakerBench 46.79. Results on image-plus-audio and spoken visual QA are mixed: for example, Qwen2.5-Omni 7B scores higher on OmniBench overall (49.65 vs 46.32), RealWorldQA (69.93 vs 64.68) and MMStar (57.27 vs 51.79). Treat these as the vendor’s own numbers.

Gotchas

  • Custom code. You must pass trust_remote_code=True. Review the repository code before running it somewhere sensitive.
  • Sampling settings differ by output. Greedy decoding works well for text. For speech or interleaved output, the card recommends audio_temperature=0.4 and audio_repetition_penalty=1.2.
  • Output type is steered by the system prompt. By default the model usually matches the input modality. Add Respond in text. or the interleaved-audio instruction to force a choice, or pass generation_mode.
  • Video costs context. Frames add tokens, and total context is 32K. Lower fps or max_frames for long clips.
  • llama.cpp ignores your frame settings. The card says it always uses 2 fps and 4 to 384 frames, and --video-fps has no effect.
  • Translation. The card says translation to or from English generally works best.
  • License. It is license: other, the LFM Open License v1.0. Read it before commercial use.

When to pick it

Pick it if you want one small model that handles a voice-in, text-or-voice-out assistant, transcription, image questions and video with sound, especially on-device. Its reported video-plus-audio numbers are its strongest results.

Skip it if you need reasoning mode, since the card says it is non-reasoning, or if your task is plain text, where a text-only model is simpler. If you need the best image-only scores, check the card’s vision tables against the models you are considering.

Related