Image-Text-to-Text
Transformers
Safetensors
lfm2_vl
liquid
lfm2
lfm2-vl
edge
lfm2.5-vl
lfm2.5
conversational
Instructions to use LiquidAI/LFM2.5-VL-1.6B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/LFM2.5-VL-1.6B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2.5-VL-1.6B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("LiquidAI/LFM2.5-VL-1.6B") model = AutoModelForMultimodalLM.from_pretrained("LiquidAI/LFM2.5-VL-1.6B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LiquidAI/LFM2.5-VL-1.6B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LiquidAI/LFM2.5-VL-1.6B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2.5-VL-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/LiquidAI/LFM2.5-VL-1.6B
- SGLang
How to use LiquidAI/LFM2.5-VL-1.6B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "LiquidAI/LFM2.5-VL-1.6B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2.5-VL-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "LiquidAI/LFM2.5-VL-1.6B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2.5-VL-1.6B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use LiquidAI/LFM2.5-VL-1.6B with Docker Model Runner:
docker model run hf.co/LiquidAI/LFM2.5-VL-1.6B
Upload folder using huggingface_hub
Browse files- README.md +202 -0
- chat_template.jinja +55 -0
- config.json +97 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- processor_config.json +39 -0
- tokenizer.json +0 -0
- tokenizer_config.json +27 -0
README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: other
|
| 4 |
+
license_name: lfm1.0
|
| 5 |
+
license_link: LICENSE
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
- ja
|
| 9 |
+
- ko
|
| 10 |
+
- fr
|
| 11 |
+
- es
|
| 12 |
+
- de
|
| 13 |
+
- ar
|
| 14 |
+
- zh
|
| 15 |
+
pipeline_tag: image-text-to-text
|
| 16 |
+
tags:
|
| 17 |
+
- liquid
|
| 18 |
+
- lfm2
|
| 19 |
+
- lfm2-vl
|
| 20 |
+
- edge
|
| 21 |
+
- lfm2.5-vl
|
| 22 |
+
- lfm2.5
|
| 23 |
+
base_model: LiquidAI/LFM2.5-1.2B-Base
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
<center>
|
| 27 |
+
<div style="text-align: center;">
|
| 28 |
+
<img
|
| 29 |
+
src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/2b08LKpev0DNEk6DlnWkY.png"
|
| 30 |
+
alt="Liquid AI"
|
| 31 |
+
style="width: 100%; max-width: 100%; height: auto; display: inline-block; margin-bottom: 0.5em; margin-top: 0.5em;"
|
| 32 |
+
/>
|
| 33 |
+
</div>
|
| 34 |
+
<div style="display: flex; justify-content: center; gap: 0.5em;">
|
| 35 |
+
<a href="https://playground.liquid.ai/chat">
|
| 36 |
+
<a href="https://playground.liquid.ai/"><strong>Try LFM</strong></a> • <a href="https://docs.liquid.ai/lfm"><strong>Documentation</strong></a> • <a href="https://leap.liquid.ai/"><strong>LEAP</strong></a></a>
|
| 37 |
+
</div>
|
| 38 |
+
</center>
|
| 39 |
+
|
| 40 |
+
# LFM2.5‑VL-1.6B
|
| 41 |
+
|
| 42 |
+
LFM2.5‑VL-1.6B is [Liquid AI](https://www.liquid.ai/)'s refreshed version of the first vision-language model, [LFM2-VL-1.6B](https://huggingface.co/LiquidAI/LFM2-VL-1.6B), built on an updated backbone [LFM2.5-1.2B-Base](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Base) and tuned for stronger real-world performance.
|
| 43 |
+
|
| 44 |
+
* **Enhanced instruction following** on vision and language tasks.
|
| 45 |
+
* **Improved multilingual vision understanding** in Arabic, Chinese, French, German, Japanese, Korean, and Spanish.
|
| 46 |
+
* **Robust understanding of visual content** with improved results on multi-image inputs, high-resolution images, and OCR.
|
| 47 |
+
|
| 48 |
+
Find more about LFM2.5 family of models in our [blog post](https://www.liquid.ai/blog/introducing-lfm2-5-the-next-generation-of-on-device-ai).
|
| 49 |
+
|
| 50 |
+
## 📄 Model details
|
| 51 |
+
|
| 52 |
+
LFM2.5-VL-1.6B is a general-purpose vision-language model with the following features:
|
| 53 |
+
|
| 54 |
+
- **LM Backbone**: LFM2.5-1.2B-Base
|
| 55 |
+
- **Vision encoder**: SigLIP2 NaFlex shape‑optimized 400M
|
| 56 |
+
- **Context length**: 32,768 tokens
|
| 57 |
+
- **Vocabulary size**: 65,536
|
| 58 |
+
- **Languages**: English, Arabic, Chinese, French, German, Japanese, Korean, and Spanish
|
| 59 |
+
- **Native resolution processing**: handles images up to 512*512 pixels without upscaling and preserves non-standard aspect ratios without distortion
|
| 60 |
+
- **Tiling strategy**: splits large images into non-overlapping 512×512 patches and includes thumbnail encoding for global context
|
| 61 |
+
- **Inference-time flexibility**: user-tunable maximum image tokens and tile count for speed/quality tradeoff without retraining
|
| 62 |
+
- **Generation parameters**:
|
| 63 |
+
- text: `temperature=0.1`, `min_p=0.15`, `repetition_penalty=1.05`
|
| 64 |
+
- vision: `min_image_tokens=64` `max_image_tokens=256`, `do_image_splitting=True`
|
| 65 |
+
|
| 66 |
+
We recommend using it for general vision-language workloads, OCR or document comprehension. It’s not well-suited for knowledge-intensive tasks.
|
| 67 |
+
|
| 68 |
+
### Chat Template
|
| 69 |
+
|
| 70 |
+
LFM2.5-VL uses a ChatML-like format. See the [Chat Template documentation](https://docs.liquid.ai/lfm/getting-started/vision#chat-template) for details.
|
| 71 |
+
|
| 72 |
+
```
|
| 73 |
+
<|startoftext|><|im_start|>system
|
| 74 |
+
You are a helpful multimodal assistant by Liquid AI.<|im_end|>
|
| 75 |
+
<|im_start|>user
|
| 76 |
+
<image>Describe this image.<|im_end|>
|
| 77 |
+
<|im_start|>assistant
|
| 78 |
+
This image shows a Caenorhabditis elegans (C. elegans) nematode.<|im_end|>
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
You can use [`processor.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating_multimodal) to format your messages automatically.
|
| 82 |
+
|
| 83 |
+
## 🏃 Inference
|
| 84 |
+
|
| 85 |
+
You can run LFM2.5-VL-1.6B with Hugging Face [`transformers`](https://github.com/huggingface/transformers):
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
pip install git+https://github.com/huggingface/transformers.git@3c2517727ce28a30f5044e01663ee204deb1cdbe pillow
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 93 |
+
from transformers.image_utils import load_image
|
| 94 |
+
|
| 95 |
+
# Load model and processor
|
| 96 |
+
model_id = "LiquidAI/LFM2.5-VL-1.6B"
|
| 97 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 98 |
+
model_id,
|
| 99 |
+
device_map="auto",
|
| 100 |
+
dtype="bfloat16"
|
| 101 |
+
)
|
| 102 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 103 |
+
|
| 104 |
+
# Load image and create conversation
|
| 105 |
+
url = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
| 106 |
+
image = load_image(url)
|
| 107 |
+
conversation = [
|
| 108 |
+
{
|
| 109 |
+
"role": "user",
|
| 110 |
+
"content": [
|
| 111 |
+
{"type": "image", "image": image},
|
| 112 |
+
{"type": "text", "text": "What is in this image?"},
|
| 113 |
+
],
|
| 114 |
+
},
|
| 115 |
+
]
|
| 116 |
+
|
| 117 |
+
# Generate Answer
|
| 118 |
+
inputs = processor.apply_chat_template(
|
| 119 |
+
conversation,
|
| 120 |
+
add_generation_prompt=True,
|
| 121 |
+
return_tensors="pt",
|
| 122 |
+
return_dict=True,
|
| 123 |
+
tokenize=True,
|
| 124 |
+
).to(model.device)
|
| 125 |
+
outputs = model.generate(**inputs, max_new_tokens=64)
|
| 126 |
+
processor.batch_decode(outputs, skip_special_tokens=True)[0]
|
| 127 |
+
|
| 128 |
+
# This image showcases the iconic Statue of Liberty standing majestically on Liberty Island in New York Harbor. The statue is positioned on a small island surrounded by calm blue waters, with the New York City skyline visible in the background.
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### Tool Use
|
| 132 |
+
|
| 133 |
+
LFM2.5 supports function calling for text only input by applying the chat template with the tokenizer. See the [Tool Use documentation](https://docs.liquid.ai/lfm/key-concepts/tool-use) for the full guide.
|
| 134 |
+
|
| 135 |
+
```python
|
| 136 |
+
tools = [{
|
| 137 |
+
"name": "get_weather",
|
| 138 |
+
"description": "Get current weather for a location",
|
| 139 |
+
"parameters": {
|
| 140 |
+
"type": "object",
|
| 141 |
+
"properties": {"location": {"type": "string"}},
|
| 142 |
+
"required": ["location"]
|
| 143 |
+
}
|
| 144 |
+
}]
|
| 145 |
+
|
| 146 |
+
messages = [{"role": "user", "content": "What's the weather in Paris?"}]
|
| 147 |
+
|
| 148 |
+
# Apply chat template with tools
|
| 149 |
+
inputs = processor.tokenizer.apply_chat_template(
|
| 150 |
+
messages,
|
| 151 |
+
tools=tools,
|
| 152 |
+
add_generation_prompt=True,
|
| 153 |
+
return_tensors="pt",
|
| 154 |
+
return_dict=True,
|
| 155 |
+
)
|
| 156 |
+
input_ids = inputs["input_ids"].to(model.device)
|
| 157 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
| 158 |
+
response = processor.tokenizer.decode(outputs[0, input_ids.shape[1]:], skip_special_tokens=False)
|
| 159 |
+
|
| 160 |
+
# <|tool_call_start|>[get_weather(location="Paris")]<|tool_call_end|>I am retrieving the current weather for Paris.<|im_end|>
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
| Name | Description | Docs | Notebook |
|
| 164 |
+
|------|-------------|------|----------|
|
| 165 |
+
| [Transformers](https://github.com/huggingface/transformers) | Simple inference with direct access to model internals. | <a href="https://docs.liquid.ai/lfm/inference/transformers#vision-models">Link</a>| <a href="https://colab.research.google.com/drive/1WVQpf4XrHgHFkP0FnlZfx2nK8PugvQNZ?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |
|
| 166 |
+
| [vLLM](https://github.com/vllm-project/vllm) | High-throughput production deployments with GPU. | coming soon | coming soon |
|
| 167 |
+
| [llama.cpp](https://github.com/ggml-org/llama.cpp) | Cross-platform inference with CPU offloading. | <a href="https://docs.liquid.ai/lfm/inference/llama-cpp#vision-models">Link</a> | <a href="https://colab.research.google.com/drive/10gOUd8TvhWvofdaZvGBP9MBAxY41DG0i?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |
|
| 168 |
+
|
| 169 |
+
## 🔧 Fine-tuning
|
| 170 |
+
|
| 171 |
+
We recommend fine-tuning LFM2.5-VL-1.6B model on your use cases to maximize performance.
|
| 172 |
+
|
| 173 |
+
| Notebook | Description | Link |
|
| 174 |
+
|-----------|----------------------------------------------------------------------|------|
|
| 175 |
+
| SFT (TRL) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using TRL. | <a href="https://colab.research.google.com/drive/10530_jt_Joa5zH2wgYlyXosypq1R7PIz?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
## 📊 Performance
|
| 179 |
+
|
| 180 |
+
| Model | MMStar | MM-IFEval | BLINK | InfoVQA (Val) | OCRBench (v2) | RealWorldQA | MMMU (Val) | MMMB (avg) | Multilingual MMBench (avg) |
|
| 181 |
+
|--------------------|--------|-----------|-------|---------------|---------------|-------------|------------|------------|----------------------------|
|
| 182 |
+
| **LFM2.5-VL-1.6B** | 50.67 | 52.29 | 48.82 | 62.71 | 41.44 | 64.84 | 40.56 | 76.96 | 65.90 |
|
| 183 |
+
| LFM2-VL-1.6B | 49.87 | 46.35 | 44.50 | 58.35 | 35.11 | 65.75 | 39.67 | 72.13 | 60.57 |
|
| 184 |
+
| InternVL3.5-1B | 50.27 | 36.17 | 44.19 | 60.99 | 33.53 | 57.12 | 41.89 | 68.93 | 58.32 |
|
| 185 |
+
| FastVLM-1.5B | 53.13 | 24.99 | 43.29 | 23.92 | 26.61 | 61.56 | 38.78 | 64.84 | 50.89 |
|
| 186 |
+
|
| 187 |
+
All vision benchmark scores are obtained using [VLMEvalKit](https://github.com/open-compass/VLMEvalKit). Multilingual scores are based on the average of benchmarks translated by GPT-4.1-mini from English to Arabic, Chinese, French, German, Japanese, Korean, and Spanish.
|
| 188 |
+
|
| 189 |
+
## 📬 Contact
|
| 190 |
+
|
| 191 |
+
If you are interested in custom solutions with edge deployment, please contact [our sales team](https://www.liquid.ai/contact).
|
| 192 |
+
|
| 193 |
+
## Citation
|
| 194 |
+
|
| 195 |
+
```
|
| 196 |
+
@article{liquidai2025lfm2,
|
| 197 |
+
title={LFM2 Technical Report},
|
| 198 |
+
author={Liquid AI},
|
| 199 |
+
journal={arXiv preprint arXiv:2511.23404},
|
| 200 |
+
year={2025}
|
| 201 |
+
}
|
| 202 |
+
```
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token -}}
|
| 2 |
+
{%- set keep_past_thinking = keep_past_thinking | default(false) -%}
|
| 3 |
+
{%- set ns = namespace(system_prompt="") -%}
|
| 4 |
+
{%- if messages[0]["role"] == "system" -%}
|
| 5 |
+
{%- set ns.system_prompt = messages[0]["content"] -%}
|
| 6 |
+
{%- set messages = messages[1:] -%}
|
| 7 |
+
{%- endif -%}
|
| 8 |
+
{%- if tools -%}
|
| 9 |
+
{%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
|
| 10 |
+
{%- for tool in tools -%}
|
| 11 |
+
{%- if tool is not string -%}
|
| 12 |
+
{%- set tool = tool | tojson -%}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- set ns.system_prompt = ns.system_prompt + tool -%}
|
| 15 |
+
{%- if not loop.last -%}
|
| 16 |
+
{%- set ns.system_prompt = ns.system_prompt + ", " -%}
|
| 17 |
+
{%- endif -%}
|
| 18 |
+
{%- endfor -%}
|
| 19 |
+
{%- set ns.system_prompt = ns.system_prompt + "]" -%}
|
| 20 |
+
{%- endif -%}
|
| 21 |
+
{%- if ns.system_prompt -%}
|
| 22 |
+
{{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
|
| 23 |
+
{%- endif -%}
|
| 24 |
+
{%- set ns.last_assistant_index = -1 -%}
|
| 25 |
+
{%- for message in messages -%}
|
| 26 |
+
{%- if message["role"] == "assistant" -%}
|
| 27 |
+
{%- set ns.last_assistant_index = loop.index0 -%}
|
| 28 |
+
{%- endif -%}
|
| 29 |
+
{%- endfor -%}
|
| 30 |
+
{%- for message in messages -%}
|
| 31 |
+
{{- "<|im_start|>" + message["role"] + "\n" -}}
|
| 32 |
+
{%- set content = message["content"] -%}
|
| 33 |
+
{%- if content is not string -%}
|
| 34 |
+
{%- set ns.content = "" -%}
|
| 35 |
+
{%- for item in content -%}
|
| 36 |
+
{%- if item["type"] == "image" -%}
|
| 37 |
+
{%- set ns.content = ns.content + "<image>" -%}
|
| 38 |
+
{%- elif item["type"] == "text" -%}
|
| 39 |
+
{%- set ns.content = ns.content + item["text"] -%}
|
| 40 |
+
{%- else -%}
|
| 41 |
+
{%- set ns.content = ns.content + item | tojson -%}
|
| 42 |
+
{%- endif -%}
|
| 43 |
+
{%- endfor -%}
|
| 44 |
+
{%- set content = ns.content -%}
|
| 45 |
+
{%- endif -%}
|
| 46 |
+
{%- if message["role"] == "assistant" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}
|
| 47 |
+
{%- if "</think>" in content -%}
|
| 48 |
+
{%- set content = content.split("</think>")[-1] | trim -%}
|
| 49 |
+
{%- endif -%}
|
| 50 |
+
{%- endif -%}
|
| 51 |
+
{{- content + "<|im_end|>\n" -}}
|
| 52 |
+
{%- endfor -%}
|
| 53 |
+
{%- if add_generation_prompt -%}
|
| 54 |
+
{{- "<|im_start|>assistant\n" -}}
|
| 55 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Lfm2VlForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"do_image_splitting": true,
|
| 6 |
+
"downsample_factor": 2,
|
| 7 |
+
"dtype": "bfloat16",
|
| 8 |
+
"encoder_patch_size": 16,
|
| 9 |
+
"image_token_id": 396,
|
| 10 |
+
"max_image_tokens": 256,
|
| 11 |
+
"max_pixels_tolerance": 2.0,
|
| 12 |
+
"max_tiles": 10,
|
| 13 |
+
"min_image_tokens": 64,
|
| 14 |
+
"min_tiles": 2,
|
| 15 |
+
"model_type": "lfm2_vl",
|
| 16 |
+
"projector_bias": true,
|
| 17 |
+
"projector_hidden_act": "gelu",
|
| 18 |
+
"projector_hidden_size": 2048,
|
| 19 |
+
"projector_use_layernorm": false,
|
| 20 |
+
"text_config": {
|
| 21 |
+
"_name_or_path": "LiquidAI/LFM2-1.2B",
|
| 22 |
+
"architectures": [
|
| 23 |
+
"Lfm2ForCausalLM"
|
| 24 |
+
],
|
| 25 |
+
"block_auto_adjust_ff_dim": true,
|
| 26 |
+
"block_dim": 2048,
|
| 27 |
+
"block_ff_dim": 12288,
|
| 28 |
+
"block_ffn_dim_multiplier": 1.0,
|
| 29 |
+
"block_mlp_init_scale": 1.0,
|
| 30 |
+
"block_multiple_of": 256,
|
| 31 |
+
"block_norm_eps": 1e-05,
|
| 32 |
+
"block_out_init_scale": 1.0,
|
| 33 |
+
"block_use_swiglu": true,
|
| 34 |
+
"block_use_xavier_init": true,
|
| 35 |
+
"conv_L_cache": 3,
|
| 36 |
+
"conv_bias": false,
|
| 37 |
+
"conv_dim": 2048,
|
| 38 |
+
"conv_dim_out": 2048,
|
| 39 |
+
"conv_use_xavier_init": true,
|
| 40 |
+
"dtype": "bfloat16",
|
| 41 |
+
"eos_token_id": 7,
|
| 42 |
+
"hidden_size": 2048,
|
| 43 |
+
"initializer_range": 0.02,
|
| 44 |
+
"intermediate_size": 12288,
|
| 45 |
+
"layer_types": [
|
| 46 |
+
"conv",
|
| 47 |
+
"conv",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"conv",
|
| 50 |
+
"conv",
|
| 51 |
+
"full_attention",
|
| 52 |
+
"conv",
|
| 53 |
+
"conv",
|
| 54 |
+
"full_attention",
|
| 55 |
+
"conv",
|
| 56 |
+
"full_attention",
|
| 57 |
+
"conv",
|
| 58 |
+
"full_attention",
|
| 59 |
+
"conv",
|
| 60 |
+
"full_attention",
|
| 61 |
+
"conv"
|
| 62 |
+
],
|
| 63 |
+
"max_position_embeddings": 128000,
|
| 64 |
+
"model_type": "lfm2",
|
| 65 |
+
"norm_eps": 1e-05,
|
| 66 |
+
"num_attention_heads": 32,
|
| 67 |
+
"num_heads": 32,
|
| 68 |
+
"num_hidden_layers": 16,
|
| 69 |
+
"num_key_value_heads": 8,
|
| 70 |
+
"rope_parameters": {
|
| 71 |
+
"rope_theta": 1000000.0,
|
| 72 |
+
"rope_type": "default"
|
| 73 |
+
},
|
| 74 |
+
"use_cache": true,
|
| 75 |
+
"use_pos_enc": true,
|
| 76 |
+
"vocab_size": 65536
|
| 77 |
+
},
|
| 78 |
+
"tile_size": 512,
|
| 79 |
+
"transformers_version": "5.0.0.dev0",
|
| 80 |
+
"use_image_special_tokens": true,
|
| 81 |
+
"use_thumbnail": true,
|
| 82 |
+
"vision_config": {
|
| 83 |
+
"attention_dropout": 0.0,
|
| 84 |
+
"dtype": "bfloat16",
|
| 85 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 86 |
+
"hidden_size": 1152,
|
| 87 |
+
"intermediate_size": 4304,
|
| 88 |
+
"layer_norm_eps": 1e-06,
|
| 89 |
+
"model_type": "siglip2_vision_model",
|
| 90 |
+
"num_attention_heads": 16,
|
| 91 |
+
"num_channels": 3,
|
| 92 |
+
"num_hidden_layers": 27,
|
| 93 |
+
"num_patches": 256,
|
| 94 |
+
"patch_size": 16,
|
| 95 |
+
"vision_use_head": false
|
| 96 |
+
}
|
| 97 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 7,
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "5.0.0.dev0"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7fc7458e4382fc6e558cfdda45857fbf9ab5b40a8bf199c9cd073003b14ac26d
|
| 3 |
+
size 3193334216
|
processor_config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"do_image_splitting": true,
|
| 5 |
+
"do_normalize": true,
|
| 6 |
+
"do_pad": true,
|
| 7 |
+
"do_rescale": true,
|
| 8 |
+
"do_resize": true,
|
| 9 |
+
"downsample_factor": 2,
|
| 10 |
+
"encoder_patch_size": 16,
|
| 11 |
+
"image_mean": [
|
| 12 |
+
0.5,
|
| 13 |
+
0.5,
|
| 14 |
+
0.5
|
| 15 |
+
],
|
| 16 |
+
"image_processor_type": "Lfm2VlImageProcessorFast",
|
| 17 |
+
"image_std": [
|
| 18 |
+
0.5,
|
| 19 |
+
0.5,
|
| 20 |
+
0.5
|
| 21 |
+
],
|
| 22 |
+
"max_image_tokens": 256,
|
| 23 |
+
"max_num_patches": 1024,
|
| 24 |
+
"max_pixels_tolerance": 2.0,
|
| 25 |
+
"max_tiles": 10,
|
| 26 |
+
"min_image_tokens": 64,
|
| 27 |
+
"min_tiles": 2,
|
| 28 |
+
"resample": 2,
|
| 29 |
+
"rescale_factor": 0.00392156862745098,
|
| 30 |
+
"return_row_col_info": true,
|
| 31 |
+
"size": {
|
| 32 |
+
"height": 512,
|
| 33 |
+
"width": 512
|
| 34 |
+
},
|
| 35 |
+
"tile_size": 512,
|
| 36 |
+
"use_thumbnail": true
|
| 37 |
+
},
|
| 38 |
+
"processor_class": "Lfm2VlProcessor"
|
| 39 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|startoftext|>",
|
| 4 |
+
"clean_up_tokenization_spaces": true,
|
| 5 |
+
"eos_token": "<|im_end|>",
|
| 6 |
+
"image_end_token": "<|image_end|>",
|
| 7 |
+
"image_start_token": "<|image_start|>",
|
| 8 |
+
"image_thumbnail": "<|img_thumbnail|>",
|
| 9 |
+
"image_token": "<image>",
|
| 10 |
+
"is_local": true,
|
| 11 |
+
"legacy": false,
|
| 12 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 13 |
+
"model_specific_special_tokens": {
|
| 14 |
+
"image_end_token": "<|image_end|>",
|
| 15 |
+
"image_start_token": "<|image_start|>",
|
| 16 |
+
"image_thumbnail": "<|img_thumbnail|>",
|
| 17 |
+
"image_token": "<image>"
|
| 18 |
+
},
|
| 19 |
+
"pad_token": "<|pad|>",
|
| 20 |
+
"processor_class": "Lfm2VlProcessor",
|
| 21 |
+
"return_token_type_ids": false,
|
| 22 |
+
"sp_model_kwargs": {},
|
| 23 |
+
"spaces_between_special_tokens": false,
|
| 24 |
+
"tokenizer_class": "TokenizersBackend",
|
| 25 |
+
"use_default_system_prompt": false,
|
| 26 |
+
"use_fast": true
|
| 27 |
+
}
|