Instructions to use LiquidAI/LFM2.5-VL-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/LFM2.5-VL-3B 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-3B", trust_remote_code=True) 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-3B", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("LiquidAI/LFM2.5-VL-3B", trust_remote_code=True, 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-3B 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-3B" # 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-3B", "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-3B
- SGLang
How to use LiquidAI/LFM2.5-VL-3B 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-3B" \ --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-3B", "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-3B" \ --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-3B", "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-3B with Docker Model Runner:
docker model run hf.co/LiquidAI/LFM2.5-VL-3B
| { | |
| "architectures": [ | |
| "Lfm2VlForConditionalGeneration" | |
| ], | |
| "auto_map": {}, | |
| "bos_token_id": 124894, | |
| "do_image_splitting": true, | |
| "do_resize": true, | |
| "downsample_factor": 2, | |
| "dtype": "bfloat16", | |
| "encoder_patch_size": 16, | |
| "eos_token_id": 124900, | |
| "freeze_language_model": false, | |
| "freeze_multi_modal_projector": false, | |
| "freeze_vision_tower": false, | |
| "image_token_id": 124907, | |
| "keep_trainable_parameters_fp32": true, | |
| "language_model_lr_multiplier": 1.0, | |
| "lfm2_attention_backend": "flash_varlen", | |
| "lfm2_attention_fusion": "fused_linear", | |
| "lfm2_flash_varlen_blhd_fastpath": false, | |
| "lfm2_frozen_input_grad_only_linear": true, | |
| "lfm2_mlp_fusion": "triton_swiglu", | |
| "lfm2_rmsnorm_fusion": "none", | |
| "lfm2_short_conv_frozen_recompute_in_proj": 0, | |
| "lfm2_torch_compile_clone_outputs": false, | |
| "lfm2_torch_compile_disable_cudagraphs": true, | |
| "lfm2_torch_compile_dynamic": true, | |
| "lfm2_torch_compile_fullgraph": false, | |
| "lfm2_torch_compile_layers": "none", | |
| "lfm2_torch_compile_mlp": false, | |
| "lfm2_torch_compile_mode": "reduce-overhead", | |
| "lfm2_vl_direct_image_merge_by_shape": true, | |
| "lfm2_vl_forward_dtype": "bf16", | |
| "lfm2_vl_frozen_vision_chunk_size": 2048, | |
| "lfm2_vl_grouped_image_projector": true, | |
| "lfm2_vl_grouped_vision_by_patch_count": false, | |
| "lfm2_vl_grouped_vision_by_shape": true, | |
| "lfm2_vl_inplace_image_merge": true, | |
| "lfm2_vl_siglip_packed_vision": true, | |
| "lfm2_vl_torch_compile_vision_encoder": true, | |
| "lfm2_vl_torch_compile_vision_encoder_mode": "whole", | |
| "lm_head_loss_mask_only": true, | |
| "max_image_tokens": 256, | |
| "max_num_patches": 1024, | |
| "max_pixels_tolerance": 2.0, | |
| "max_tiles": 10, | |
| "min_image_tokens": 64, | |
| "min_tiles": 1, | |
| "model_type": "lfm2_vl", | |
| "pad_token_id": 124893, | |
| "projector_bias": true, | |
| "projector_hidden_act": "gelu", | |
| "projector_hidden_size": 2048, | |
| "projector_lr_multiplier": 1.0, | |
| "projector_use_layernorm": false, | |
| "siglip2_layernorm_fusion": "liger", | |
| "text_config": { | |
| "block__name_mlp": "parallel_mlp_merged", | |
| "block_auto_adjust_ff_dim": false, | |
| "block_dim": 2048, | |
| "block_ffn_dim_multiplier": 1.0, | |
| "block_ffn_te_autocast": false, | |
| "block_ffn_use_quantized_params": false, | |
| "block_mlp_init_scale": 1.0, | |
| "block_multiple_of": 256, | |
| "block_norm_eps": 1e-05, | |
| "block_out_init_scale": 1.0, | |
| "block_use_swiglu": true, | |
| "block_use_xavier_init": true, | |
| "bos_token_id": 124894, | |
| "conv_L_cache": 3, | |
| "conv_bias": false, | |
| "conv_dim": 2048, | |
| "conv_use_xavier_init": true, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 124900, | |
| "full_attn_idxs": null, | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 10752, | |
| "layer_types": [ | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv", | |
| "full_attention", | |
| "conv", | |
| "conv" | |
| ], | |
| "lfm2_attention_backend": "flash_varlen", | |
| "lfm2_flash_varlen_blhd_fastpath": false, | |
| "lfm2_frozen_input_grad_only_linear": true, | |
| "max_position_embeddings": 128000, | |
| "mm_config_image_embedder": { | |
| "activation_checkpointing_layer_stride": 0, | |
| "attn_implementation": "sdpa", | |
| "cuda_sync_points": [], | |
| "downsample": 2, | |
| "encoder_load_balance": false, | |
| "hidden_dim": 2048, | |
| "hidden_state_index": -1, | |
| "layer_norm": false, | |
| "max_batch_size": 1024, | |
| "pretrained_model_name_or_path": "google/siglip2-so400m-patch16-naflex", | |
| "set_activation_checkpointing": false, | |
| "use_image_special_tokens": true, | |
| "use_pooling_head": false, | |
| "use_slice_special_tokens": false, | |
| "use_torch_pixel_unshuffle": false | |
| }, | |
| "model_type": "lfm2", | |
| "norm_eps": 1e-05, | |
| "num_attention_heads": 32, | |
| "num_heads": 32, | |
| "num_hidden_layers": 30, | |
| "num_key_value_heads": 8, | |
| "output_softcap": 0.0, | |
| "pad_token_id": 124893, | |
| "rope_parameters": { | |
| "rope_theta": 1000000.0, | |
| "rope_type": "default" | |
| }, | |
| "tie_word_embeddings": true, | |
| "use_cache": true, | |
| "use_pos_enc": true, | |
| "vocab_size": 128000, | |
| "architectures": [ | |
| "Lfm2ForCausalLM" | |
| ], | |
| "tie_embedding": true | |
| }, | |
| "tie_word_embeddings": true, | |
| "tile_size": 512, | |
| "transformers_version": "5.8.1", | |
| "use_image_special_tokens": true, | |
| "use_thumbnail": true, | |
| "vision_config": { | |
| "attention_dropout": 0.0, | |
| "dtype": "bfloat16", | |
| "hidden_act": "gelu_pytorch_tanh", | |
| "hidden_size": 1152, | |
| "intermediate_size": 4304, | |
| "layer_norm_eps": 1e-06, | |
| "model_type": "siglip2_vision_model", | |
| "num_attention_heads": 16, | |
| "num_channels": 3, | |
| "num_hidden_layers": 27, | |
| "num_patches": 256, | |
| "patch_size": 16, | |
| "vision_use_head": false | |
| }, | |
| "vision_tower_lr_multiplier": 1.0 | |
| } | |