---
library_name: transformers
license: other
license_name: lfm1.0
license_link: LICENSE
language:
- ar
- zh
- en
- fr
- de
- hi
- id
- it
- ja
- ko
- pl
- pt
- ru
- es
- th
- vi
pipeline_tag: image-text-to-text
tags:
- liquid
- lfm2.5
- edge
- heretic
- uncensored
- decensored
- abliterated
base_model:
- LiquidAI/LFM2.5-VL-3B
---
This is an **LFM2.5-VL-3B** fine-tune, produced through P-E-W's [Heretic](https://github.com/p-e-w/heretic) (v1.4.0) abliteration engine with [Self-Organizing Maps & Magnitude-Preserving Orthogonal Ablation](https://github.com/p-e-w/heretic/pull/196) enabled.
---
# LFM2.5-VL-3B
LFM2.5-VL-3B is a multimodal variant of LFM2.5, a family of hybrid models designed for **on-device deployment**. It builds on LFM2-VL-3B with further mid- and post-training. LFM2.5-VL-3B can process both text and images, and uses the LFM2.5-2.6B language model as its backbone, combined with a SigLIP2 NaFlex vision encoder.
* **Better grounding**: Improved grounding and object detection with natural language queries.
* **Better OCR**: Full page OCR with layout annotation. See [layout annotation format](#layout-annotation-format) for more information.
* **Efficient inference**: 228 tok/s on an Apple M5 Max and 116 tok/s on an AMD Ryzen AI Max+ 395, in under 3.3 GB of memory.
Find more information about LFM2.5-VL-3B in our [release post](https://www.liquid.ai/blog/lfm2-5-vl-3b).

> [!NOTE]
> 💻 **Demos**: Try LFM2.5-VL-3B's vision understanding capabilities in a Hugging Face space without any setup:
> **[Vision-capable chat in your browser](https://huggingface.co/spaces/LiquidAI/LFM2.5-VL-3B-WebGPU)**: allows you to upload images or use the webcam to capture stills and let the model interact with them.
## Model Details
| Model | Description |
|-------|-------------|
| **[LFM2.5‑VL‑3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B)** | Original checkpoint in native format. Best for fine-tuning and inference with HF Transformers, vLLM and SGLang |
| **[LFM2.5‑VL‑3B‑GGUF](https://huggingface.co/LiquidAI/LFM2.5-VL-3B-GGUF)** | Quantized GGUF exports of the original checkpoint. Best for CPU inference with reduced memory usage with llama.cpp |
| **[LFM2.5‑VL‑3B‑ONNX](https://huggingface.co/LiquidAI/LFM2.5-VL-3B-ONNX)** | Quantized ONNX exports for cross-platform deployment. Enables hardware-accelerated inference across diverse environments (cloud, edge, mobile). See the [demo](https://huggingface.co/spaces/LiquidAI/LFM2.5-VL-3B-WebGPU). |
| **[LFM2.5-VL-3B-MLX](https://huggingface.co/LiquidAI/LFM2.5-VL-3B-MLX-8bit)** | Quantized MLX exports for Apple Silicon. Optimized for fast inference on Mac devices using the [mlx-vlm](https://github.com/Blaizzy/mlx-vlm) framework. |
- **LM Backbone**: LFM2.5-2.6B
- **Vision encoder**: SigLIP2 NaFlex shape‑optimized 400M
- **Vocabulary size:** 128,000
- **Context length**: 32,768 tokens
- **Languages**: English, Arabic, Chinese, French, German, Italian, Japanese, Korean, Portuguese, Spanish, Vietnamese, Thai, Indonesian, Hindi, Russian, Polish
- **Native resolution processing**: Uses SigLIP2's NaFlex; large images are split into non-overlapping 512×512 patches and a resized whole-image thumbnail.
- **Generation parameters**:
- text: `temperature=0.2`, `top_k=50`, `repetition_penalty=1.0`
- vision: Use the `processor_config.json` file.
We recommend using it for single-turn, high-throughput, low-latency tasks; for example, for near-realtime object detection in automotive applications, batch processing scanned documents with OCR with layout information for turning PDFs into searchable text, or for on-device translation of menus and road signs into your native language.
It is not recommended for long-context, reasoning-intensive tasks, such as visual web design, or answering highly technical questions about blueprints.
### Chat Template
LFM2.5 uses a ChatML-like format. See the [Chat Template documentation](https://docs.liquid.ai/lfm/key-concepts/chat-template#vision-models) for details. Example:
```
<|startoftext|><|im_start|>system
You are a helpful assistant trained by Liquid AI.<|im_end|>
<|im_start|>user
What species is in this picture?<|im_end|>
<|im_start|>assistant
```
You can use [`tokenizer.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#using-applychattemplate) to format your messages automatically.
> [!TIP]
> **Note**: The `apply_chat_template()` method automatically inserts the `` tag for each image in your message. Do not include `` in your message content.
## Inference
LFM2.5-VL is supported by many inference frameworks. See the [Inference documentation](https://docs.liquid.ai/lfm/inference/transformers) for the full list.
| Name | Description | Docs | Notebook |
|------|-------------|------|----------|
| [Transformers](https://github.com/huggingface/transformers) | Simple inference with direct access to model internals. | Link| |
| [vLLM](https://github.com/vllm-project/vllm) | High-throughput production deployments with GPU. | Link | |
| [SGLang](https://github.com/sgl-project/sglang) | High-throughput production deployments with GPU. | Link | |
| [llama.cpp](https://github.com/ggml-org/llama.cpp) | Cross-platform inference with CPU offloading. | Link | |
### Quick start
Quick start with Transformers (compatible with `transformers>=5.0.0`):
You will need `torch`, `transformers`, and `torchvision`.
```python
import torch
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "LiquidAI/LFM2.5-VL-3B"
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16)
processor = AutoProcessor.from_pretrained(model_id)
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://placecats.com/300/200"},
{"type": "text", "text": "Describe this image."},
],
}
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
output_ids = model.generate(
**inputs,
do_sample=True,
temperature=0.2,
top_k=50,
repetition_penalty=1.0,
max_new_tokens=256,
)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])
```
### Tool Use
LFM2.5-VL-3B supports function calling in four steps:
1. **Function definition**: Provide the list of tools as a JSON object in the system prompt, or use [`tokenizer.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_extras#passing-tools) with `tools=...`.
2. **Function call**: By default, LFM2.5 writes Pythonic function calls (a Python list between `<|tool_call_start|>` and `<|tool_call_end|>` special tokens), as the assistant answer.
3. **Function execution**: Execute the call and return the result with the `tool` role.
4. **Final answer**: LFM2.5 interprets the tool output and returns a plain-text answer addressing the original prompt.
See the [Tool Use documentation](https://docs.liquid.ai/lfm/key-concepts/tool-use) for the full guide. Example:
```
<|startoftext|><|im_start|>system
List of tools: [{"name": "get_candidate_status", "description": "Retrieves the current status of a candidate in the recruitment process", "parameters": {"type": "object", "properties": {"candidate_id": {"type": "string", "description": "Unique identifier for the candidate"}}, "required": ["candidate_id"]}}]<|im_end|>
<|im_start|>user
What is the current status of candidate ID 12345?<|im_end|>
<|im_start|>assistant
<|tool_call_start|>[get_candidate_status(candidate_id="12345")]<|tool_call_end|>Checking the current status of candidate ID 12345.<|im_end|>
<|im_start|>tool
[{"candidate_id": "12345", "status": "Interview Scheduled", "position": "Clinical Research Associate", "date": "2023-11-20"}]<|im_end|>
<|im_start|>assistant
The candidate with ID 12345 is currently in the "Interview Scheduled" stage for the position of Clinical Research Associate, with an interview date set for 2023-11-20.<|im_end|>
```
### Layout Annotation Format
LFM2.5-VL-3B can do OCR with layout annotation. The layout annotation is a list of regions, each with a label, bounding box, and content. The format is:
```text
image_index=