LFM2.5-VL-450M 是 Liquid AI 的刷新版视觉语言模型,基于 LFM2.5-350M 语言骨干 + SigLIP2 NaFlex 86M 视觉编码器,支持 32K 上下文、512x512 原生分辨率、tiling 策略和可调 image token。支持指令跟随、多语言视觉理解、边界框预测和纯文本函数调用。权重 897MB (bfloat16),验证为 vision-language 路线。
本仓库适配到单卡 Ascend910B (npu:0),实测 bfloat16 可用,CPU/NPU 输出一致,NPU 加速 52x。
pip install -r requirements.txt
# requirements: torch, torch_npu, transformers>=5.1.0, accelerate, pillow, numpy, huggingface_hub, safetensors模型下载 (必须设 HF_ENDPOINT):
HF_ENDPOINT=https://hf-mirror.com python3 -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='LiquidAI/LFM2.5-VL-450M', local_dir='./model_cache/LiquidAI-LFM2.5-VL-450M', max_workers=1)"python inference.py
# 或指定设备
python inference.py --device npu:0
python inference.py --device cpu默认使用 npu:0 若可用,否则回退 CPU。参数: --mode validate (默认) | benchmark.
input: pixel_values [1,1024,768] mean -0.1248 std 0.2768, input_ids [1,276]
output: [1,308] new tokens 32
text: "The image displays a colorful, abstract pattern composed of various small squares. These squares are arranged in a grid-like formation, creating a visually striking composition. The colors"
logits [1,276,65536] mean -4.8545 max 20.375 min -57.75 has_nan False has_inf False
bbox prompt: [{"label": "square", "bbox": [0.0, 0.0, 1.0, 1.0]logits mean -4.8713 max 20.5 min -57.5
text 完全一致: "The image displays a colorful, abstract pattern composed..."
bbox 同为 [0.0,0.0,1.0,1.0]两者生成文本字符级一致,logits 数值误差均值差异 0.0168 (<0.5%).
| 指标 | CPU | NPU (bf16) | 差异 |
|---|---|---|---|
| logits mean | -4.8713 | -4.8545 | 0.0168 |
| logits max | 20.5 | 20.375 | 0.125 |
| logits min | -57.5 | -57.75 | 0.25 |
| 生成文本 | 完全一致 | 完全一致 | 0 |
| 是否 NaN/Inf | 否 | 否 | - |
| 视觉 embedding | CPU pixel mean -0.1248 | NPU 同 | 0 |
验证策略: 确定性贪心解码 + 前向 logits 统计 + 文本精确匹配。属单样本一致性验证,非全量数据集评测。
torch.npu.synchronize() 包围计时, 预热2次, 正式5次, bfloat16, batch 1, 512x512.
NPU (npu:0, bf16):
CPU (bf16):
模型 dtype: bfloat16, 输入 276 tokens, 输出 308 tokens, tile 512, max_image_tokens 256.

三图由 scripts/render_xterm_evidence.mjs --style raw 从真实日志渲染,含命令、退出码、SHA256.
Hardware: NPU, NPU, Ascend, Ascend910, vision-language, LFM2.5