BF16 · Transformers / SGLang
使用 Transformers 运行下方 Python 示例。官方模型卡也列出 SGLang,可用于提供文本回答服务。
| 项目 | 规格 |
|---|---|
| 总参数量 | 2.17B |
| 上下文窗口 | 32K token,输入与输出共享 |
| 输入 | 文本、图像、视频与音频(16 kHz) |
| 输出 | 文本、语音(24 kHz),或交错的文本与语音 |
| 默认视频采样 | 每秒 2 帧;每段视频 4–384 帧 |
| 语言支持 | 16 种文本语言、19 种语音语言或地区变体,包括中文和英文 |
| 许可证 | LFM Open License v1.0 |
这是非推理模型,不生成图像或视频,不支持 enable_thinking=True。参数量较小不代表固定的最低内存要求,也不保证所有设备都能实时运行。
将图像与语音问题一起输入,要求模型以文本或语音回答。
结合画面动作与声音事件进行问答。读取视频音轨需要教程中的显式配置。
将录音转成文本或进行语音翻译。请使用自己的语言、口音与噪声样本验证准确率。
请求语音回答,或交错的文本与音频输出。应用仍需处理录音、播放与对话流程。
从官方仓库下载,并按运行框架选择权重。支持某种权重格式,不代表运行工具已支持全部四种输入模态。
使用 Transformers 运行下方 Python 示例。官方模型卡也列出 SGLang,可用于提供文本回答服务。
选择量化权重进行本地 CPU/GPU 推理。所需模型文件和支持功能请以 Liquid AI 的 llama.cpp 文档为准。
模型权重采用 LFM Open License v1.0。商业使用存在条件,使用或分发前请阅读官方许可证全文。
示例改编自官方模型卡,供本地使用,本站尚未执行这些推理示例。请使用独立 Python 环境;本页面不运行模型。
python -m pip install "transformers>=5.20.2" torch torchvision torchcodec accelerate pillow librosa soundfile
import torch
from transformers import AutoModelForMultimodalLM, AutoProcessor
checkpoint = "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(
checkpoint, dtype=dtype, device_map=device, trust_remote_code=True
).eval()
processor = AutoProcessor.from_pretrained(checkpoint, trust_remote_code=True)
messages = [{"role": "user", "content": [
{"type": "image", "image": "photo.jpg"},
{"type": "text", "text": "Describe only what is visible in this image."},
]}]
inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt",
).to(device)
with torch.no_grad():
result = model.generate(**inputs, max_new_tokens=256, generation_mode="text")
start = inputs["input_ids"].shape[1]
end = result.sequence_lengths[0]
print(processor.decode(result.sequences[0, start:end], skip_special_tokens=True))python image_qa.py
将 photo.jpg 放在脚本旁,然后运行 python image_qa.py。首次运行会下载权重。有 CUDA 时使用 GPU,否则使用 CPU float32,速度可能较慢且内存占用更高。trust_remote_code=True 会加载官方仓库的自定义实现,运行前请阅读相关代码。安装或媒体解码出错时,请查阅链接中的运行框架文档。
# Reuse model, processor and device from the image example.
messages = [{"role": "user", "content": [
{"type": "video", "video": "clip.mp4"},
{"type": "text", "text": "Describe the visible events and audible sounds."},
]}]
inputs = processor.apply_chat_template(
messages, 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():
result = model.generate(**inputs, max_new_tokens=256, generation_mode="text")
start = inputs["input_ids"].shape[1]
end = result.sequence_lengths[0]
print(processor.decode(result.sequences[0, start:end], skip_special_tokens=True))复用图像示例的导入及模型加载代码,用此代码块替换对话与生成部分,并准备含音轨的 clip.mp4。必须同时设置 load_audio_from_video=True 与 use_audio_in_video=True,否则仅传入视频帧。较长媒体会消耗更多上下文和内存。
以下为开发方公布的结果,并非独立实测。表格选取模型卡中的三项任务,三项均为越高越好(↑)。核验日期:2026-10-30。
| 基准 ↑ | LFM3-Omni-2B | Qwen2.5-Omni-3B | Qwen2.5-Omni-7B | Gemma 4 E2B | Gemma 4 E4B | Phi-4 multimodal |
|---|---|---|---|---|---|---|
| Daily-Omni ↑ | 70.09 | 58.81 | 61.32 | 50.63 | 54.14 | 48.87 |
| WorldSense ↑ | 47.10 | 44.99 | 45.37 | 38.11 | 43.51 | 42.37 |
| OmniBench (overall) ↑ | 46.32 | 47.11 | 49.65 | 16.81 | 20.67 | 38.97 |
在所列六款模型中,LFM3-Omni 的 Daily-Omni 与 WorldSense 音视频任务得分领先;但在图像与音频任务 OmniBench 总分上,其 46.32 低于 Qwen2.5-Omni-3B 的 47.11 和 7B 的 49.65。它值得作为轻量音视频助手的候选模型测试,不能据此判断其在所有任务中领先。
“3B”“7B”“E2B”“E4B”是模型名称,不能直接视为可横向比较的总参数量。这些分数不衡量延迟、内存或你的应用准确率。选型前应在目标硬件上使用代表性媒体进行验证。
规格、示例与分数可能更新,最新信息请以这些官方来源为准。