ankke commited on
Commit
0269745
·
verified ·
1 Parent(s): 5c24786

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +161 -193
README.md CHANGED
@@ -1,199 +1,167 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
  library_name: transformers
3
+ license: other
4
+ license_name: lfm1.0
5
+ license_link: LICENSE
6
+ language:
7
+ - en
8
+ pipeline_tag: image-text-to-text
9
+ tags:
10
+ - liquid
11
+ - lfm2
12
+ - lfm2-vl
13
+ - edge
14
  ---
15
 
16
+ <center>
17
+ <div style="text-align: center;">
18
+ <img
19
+ src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/7_6D7rWrLxp2hb6OHSV1p.png"
20
+ alt="Liquid AI"
21
+ style="width: 100%; max-width: 66%; height: auto; display: inline-block; margin-bottom: 0.5em; margin-top: 0.5em;"
22
+ />
23
+ </div>
24
+ </center>
25
+
26
+ # LFM2‑VL
27
+
28
+ LFM2‑VL is [Liquid AI](https://www.liquid.ai/)'s first series of multimodal models, designed to process text and images with variable resolutions.
29
+ Built on the [LFM2](https://huggingface.co/collections/LiquidAI/lfm2-686d721927015b2ad73eaa38) backbone, it is optimized for low-latency and edge AI applications.
30
+
31
+ We're releasing the weights of two post-trained checkpoints with [450M](https://huggingface.co/LiquidAI/LFM2-VL-450M) (for highly constrained devices) and [1.6B](https://huggingface.co/LiquidAI/LFM2-VL-1.6B) (more capable yet still lightweight) parameters.
32
+
33
+ * **2× faster inference speed** on GPUs compared to existing VLMs while maintaining competitive accuracy
34
+ * **Flexible architecture** with user-tunable speed-quality tradeoffs at inference time
35
+ * **Native resolution processing** up to 512×512 with intelligent patch-based handling for larger images, avoiding upscaling and distortion
36
+
37
+ Find more about our vision-language model in the [LFM2-VL post](http://www.liquid.ai/blog/lfm2-vl-hyperefficient-vision-language-models) and its language backbone in the [LFM2 blog post](https://www.liquid.ai/blog/liquid-foundation-models-v2-our-second-series-of-generative-ai-models).
38
+
39
+ ## 📄 Model details
40
+
41
+ Due to their small size, **we recommend fine-tuning LFM2-VL models on narrow use cases** to maximize performance.
42
+ They were trained for instruction following and lightweight agentic flows.
43
+ Not intended for safety‑critical decisions.
44
+
45
+ | Property | [**LFM2-VL-450M**](https://huggingface.co/LiquidAI/LFM2-VL-450M) | [**LFM2-VL-1.6B**](https://huggingface.co/LiquidAI/LFM2-VL-1.6B) |
46
+ |---|---:|---:|
47
+ | **Parameters (LM only)** | 350M | 1.2B |
48
+ | **Vision encoder** | SigLIP2 NaFlex base (86M) | SigLIP2 NaFlex shape‑optimized (400M) |
49
+ | **Backbone layers** | hybrid conv+attention | hybrid conv+attention |
50
+ | **Context (text)** | 32,768 tokens | 32,768 tokens |
51
+ | **Image tokens** | dynamic, user‑tunable | dynamic, user‑tunable |
52
+ | **Vocab size** | 65,536 | 65,536 |
53
+ | **Precision** | bfloat16 | bfloat16 |
54
+ | **License** | LFM Open License v1.0 | LFM Open License v1.0 |
55
+
56
+ **Supported languages:** English
57
+
58
+ **Generation parameters**: We recommend the following parameters:
59
+ - Text: `temperature=0.1`, `min_p=0.15`, `repetition_penalty=1.05`
60
+ - Vision: `min_image_tokens=64` `max_image_tokens=256`, `do_image_splitting=True`
61
+
62
+ **Chat template**: LFM2-VL uses a ChatML-like chat template as follows:
63
+
64
+ ```
65
+ <|startoftext|><|im_start|>system
66
+ You are a helpful multimodal assistant by Liquid AI.<|im_end|>
67
+ <|im_start|>user
68
+ <image>Describe this image.<|im_end|>
69
+ <|im_start|>assistant
70
+ This image shows a Caenorhabditis elegans (C. elegans) nematode.<|im_end|>
71
+ ```
72
+
73
+ Images are referenced with a sentinel (`<image>`), which is automatically replaced with the image tokens by the processor.
74
+
75
+ You can apply it using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers.
76
+
77
+ **Architecture**
78
+ - **Hybrid backbone**: Language model tower (LFM2-1.2B or LFM2-350M) paired with SigLIP2 NaFlex vision encoders (400M shape-optimized or 86M base variant)
79
+ - **Native resolution processing**: Handles images up to 512×512 pixels without upscaling and preserves non-standard aspect ratios without distortion
80
+ - **Tiling strategy**: Splits large images into non-overlapping 512×512 patches and includes thumbnail encoding for global context (in 1.6B model)
81
+ - **Efficient token mapping**: 2-layer MLP connector with pixel unshuffle reduces image tokens (e.g., 256×384 image → 96 tokens, 1000×3000 → 1,020 tokens)
82
+ - **Inference-time flexibility**: User-tunable maximum image tokens and patch count for speed/quality tradeoff without retraining
83
+
84
+ **Training approach**
85
+ - Builds on the LFM2 base model with joint mid-training that fuses vision and language capabilities using a gradually adjusted text-to-image ratio
86
+ - Applies joint SFT with emphasis on image understanding and vision tasks
87
+ - Leverages large-scale open-source datasets combined with in-house synthetic vision data, selected for balanced task coverage
88
+ - Follows a progressive training strategy: base model → joint mid-training → supervised fine-tuning
89
+
90
+ ## 🏃 How to run LFM2-VL
91
+
92
+ You can run LFM2-VL with Hugging Face [`transformers`](https://github.com/huggingface/transformers) v4.55 or more recent as follows:
93
+
94
+ ```bash
95
+ pip install -U transformers pillow
96
+ ```
97
+
98
+ Here is an example of how to generate an answer with transformers in Python:
99
+
100
+ ```python
101
+ from transformers import AutoProcessor, AutoModelForImageTextToText
102
+ from transformers.image_utils import load_image
103
+
104
+ # Load model and processor
105
+ model_id = "LiquidAI/LFM2-VL-1.6B"
106
+ model = AutoModelForImageTextToText.from_pretrained(
107
+ model_id,
108
+ device_map="auto",
109
+ torch_dtype="bfloat16",
110
+ trust_remote_code=True
111
+ )
112
+ processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
113
+
114
+ # Load image and create conversation
115
+ url = "https://www.ilankelman.org/stopsigns/australia.jpg"
116
+ image = load_image(url)
117
+ conversation = [
118
+ {
119
+ "role": "user",
120
+ "content": [
121
+ {"type": "image", "image": image},
122
+ {"type": "text", "text": "What is in this image?"},
123
+ ],
124
+ },
125
+ ]
126
 
127
+ # Generate Answer
128
+ inputs = processor.apply_chat_template(
129
+ conversation,
130
+ add_generation_prompt=True,
131
+ return_tensors="pt",
132
+ return_dict=True,
133
+ tokenize=True,
134
+ ).to(model.device)
135
+ outputs = model.generate(**inputs, max_new_tokens=64)
136
+ processor.batch_decode(outputs, skip_special_tokens=True)[0]
137
+
138
+ # This image depicts a vibrant street scene in what appears to be a Chinatown or similar cultural area. The focal point is a large red stop sign with white lettering, mounted on a pole.
139
+ ```
140
+
141
+ You can directly run and test the model with this [Colab notebook](https://colab.research.google.com/drive/11EMJhcVB6OTEuv--OePyGK86k-38WU3q?usp=sharing).
142
+
143
+
144
+ ## 🔧 How to fine-tune
145
+
146
+ We recommend fine-tuning LFM2-VL models on your use cases to maximize performance.
147
+
148
+ | Notebook | Description | Link |
149
+ |-----------|----------------------------------------------------------------------|------|
150
+ | SFT (TRL) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using TRL. | <a href="https://colab.research.google.com/drive/1csXCLwJx7wI7aruudBp6ZIcnqfv8EMYN?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |
151
+
152
+
153
+ ## 📈 Performance
154
 
155
+ | Model | RealWorldQA | MM-IFEval | InfoVQA (Val) | OCRBench | BLINK | MMStar | MMMU (Val) | MathVista | SEEDBench_IMG | MMVet | MME | MMLU |
156
+ |-------------------|-------------|-----------|---------------|----------|-------|--------|------------|-----------|---------------|-------|----------|-------|
157
+ | InternVL3-2B | 65.10 | 38.49 | 66.10 | 831.00 | 53.10 | 61.10 | 48.70 | 57.60 | 75.00 | 67.00 | 2186.40 | 64.80 |
158
+ | InternVL3-1B | 57.00 | 31.14 | 54.94 | 798.00 | 43.00 | 52.30 | 43.20 | 46.90 | 71.20 | 58.70 | 1912.40 | 49.80 |
159
+ | SmolVLM2-2.2B | 57.50 | 19.42 | 37.75 | 725.00 | 42.30 | 46.00 | 41.60 | 51.50 | 71.30 | 34.90 | 1792.50 | - |
160
+ | LFM2-VL-1.6B | 65.23 | 37.66 | 58.68 | 742.00 | 44.40 | 49.53 | 38.44 | 51.10 | 71.97 | 48.07 | 1753.04 | 50.99 |
161
+ | SmolVLM2-500M | 49.90 | 11.27 | 24.64 | 609.00 | 40.70 | 38.20 | 34.10 | 37.50 | 62.20 | 29.90 | 1448.30 | - |
162
+ | LFM2-VL-440M | 52.29 | 26.18 | 46.51 | 655.00 | 41.98 | 40.87 | 33.11 | 44.70 | 63.50 | 33.76 | 1239.06 | 40.16 |
163
+
164
+
165
+ ## 📬 Contact
166
+
167
+ If you are interested in custom solutions with edge deployment, please contact [our sales team](https://www.liquid.ai/contact).