模型名称: LFM2.5-VL-450M (LiquidAI/LFM2.5-VL-450M)
模型链接: HuggingFace
模型描述: LFM2.5-VL-450M 是一个小型视觉语言模型(VLM),结合了 SigLIP2 NaFlex 视觉编码器(86M)和 LFM2.5 文本 backbone(350M),通过 MLP Projector(~13M)连接,总参数量约 449M。文本 backbone 采用混合 SSM+Attention 架构(LFM2),支持高效的序列建模。
模型架构: SigLIP2 NaFlex (Vision Encoder) + MLP Projector + LFM2.5-350M (Hybrid SSM+Attention Text Backbone)
参数规模: ~449M (Vision: 86M + Text: 350M + Projector: 13M)
输入规格:
<image> token 嵌入文本 prompt输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| vllm-ascend | >= 0.18.0 | 昇腾推理引擎 |
| transformers | >= 4.45.0 | HuggingFace Transformers(需支持 LFM2 模型) |
| Pillow | >= 9.0 | 图像处理 |
| sentencepiece | >= 0.1.99 | Tokenizer 依赖 |
| protobuf | >= 3.20.0 | 序列化依赖 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch_npu vllm-ascend transformers Pillow sentencepiece protobuf# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download LiquidAI/LFM2.5-VL-450M --local-dir /path/to/model_weights/方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
git clone https://ai.gitcode.com/hf_mirrors/LiquidAI/LFM2.5-VL-450M.git /path/to/model_weights/本模型需要两个运行时补丁才能在 vLLM-Ascend 上正常工作:
patch_mamba_config_fix.py):修复 LFM2 模型 SSM state 小于一个 attention block 时的 page size 对齐断言失败。block_dim 和 block_ff_dim 字段,使 vLLM 能正确读取模型配置。# 文本推理
python inference.py --model-path /path/to/model_weights/
# 指定 NPU 卡数
python inference.py --model-path /path/to/model_weights/ --tensor-parallel-size 1| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --tensor-parallel-size | int | 1 | NPU 卡数(当前仅支持单卡) |
| --max-model-len | int | 2048 | 最大序列长度 |
| --port | int | 8000 | API 服务端口 |
[Test 1] English Text Inference
Prompt: user: What is 2+2? Answer briefly.
assistant:
Output: 1.
Finish reason: stop
Tokens generated: 3
Status: SUCCESS[Test 2] Image (VLM) Inference
Prompt: user: <image>
What color is this image?
assistant:
Output: The image you're referring to is a solid, vibrant red. There's no
gradient or any other colors present in the image. It's a pure,
Finish reason: length
Tokens generated: 32
Status: SUCCESS注意: 由于模型参数量较小(450M),生成质量有限,可能存在重复或不完整的输出。这是小模型的预期行为,不代表适配失败。
运行命令:
python inference.py --model-path /tmp/adapt_liquidai_lfm2.5-vl-450m/model_weights/输出:
Output: 1.
Status: SUCCESS运行命令:
python inference.py --model-path /tmp/adapt_liquidai_lfm2.5-vl-450m/model_weights/输出:
Output: The image you're referring to is a solid, vibrant red. There's no
gradient or any other colors present in the image. It's a pure,
Status: SUCCESS


测试数据: 手工构造测试用例
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 文本推理 | ✅ 通过 | 英文简单问答正确 |
| 图像推理 | ✅ 通过 | 正确识别红色图像 |
| 模型加载 | ✅ 通过 | 0.88 GB 权重加载成功 |
| 冷启动耗时 | ~7s | 模型加载 + KV cache 初始化 |
tokenizer.chat_template,vLLM 不会自动读取 chat_template.json。