Image-Text-to-Text
Transformers
Safetensors
lfm3_vl
feature-extraction
liquid
lfm3
edge
decision
classification
extraction
calibration
system-one
multimodal
decision-model
custom_code
conversational
Instructions to use LiquidAI/d1-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/d1-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="LiquidAI/d1-2B", 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("LiquidAI/d1-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LiquidAI/d1-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LiquidAI/d1-2B" # 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/d1-2B", "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/d1-2B
- SGLang
How to use LiquidAI/d1-2B 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/d1-2B" \ --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/d1-2B", "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/d1-2B" \ --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/d1-2B", "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/d1-2B with Docker Model Runner:
docker model run hf.co/LiquidAI/d1-2B
Download native_lfm3_vl.py from LiquidAI/d1-2B: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/LiquidAI/d1-2B/resolve/main/native_lfm3_vl.py
- Command line
-
hf download hf://LiquidAI/d1-2B/native_lfm3_vl.py
-
curl -L -o native_lfm3_vl.py https://huggingface.co/LiquidAI/d1-2B/resolve/main/native_lfm3_vl.py
1.39 kB
| """LFM3-VL's transformers classes (`native_lfm3`): its config, vision tower, picture and video processors.""" | |
| from __future__ import annotations | |
| from .native_lfm3 import Lfm3Model # noqa: F401 (registered: the VL builds its text model by config) | |
| try: | |
| from transformers import Lfm3VlConfig, Lfm3VlForConditionalGeneration, Lfm3VlProcessor | |
| except ImportError: | |
| from transformers import AutoConfig, AutoImageProcessor, AutoModel, AutoProcessor, AutoVideoProcessor | |
| from .configuration_lfm3_vl import Lfm3VlConfig, Lfm3VlVisionConfig | |
| from .image_processing_lfm3_vl import Lfm3VlImageProcessor | |
| from .modeling_lfm3_vl import Lfm3VlForConditionalGeneration, Lfm3VlVisionModel | |
| from .processing_lfm3_vl import Lfm3VlProcessor | |
| from .video_processing_lfm3_vl import Lfm3VlVideoProcessor | |
| for config in (Lfm3VlConfig, Lfm3VlVisionConfig): | |
| AutoConfig.register(config.model_type, config, exist_ok=True) | |
| AutoModel.register(Lfm3VlVisionConfig, Lfm3VlVisionModel, exist_ok=True) # the tower, built by config | |
| AutoImageProcessor.register(Lfm3VlConfig, fast_image_processor_class=Lfm3VlImageProcessor, exist_ok=True) | |
| AutoVideoProcessor.register(Lfm3VlConfig, Lfm3VlVideoProcessor, exist_ok=True) | |
| AutoProcessor.register(Lfm3VlConfig, Lfm3VlProcessor, exist_ok=True) | |
| __all__ = ["Lfm3VlConfig", "Lfm3VlForConditionalGeneration", "Lfm3VlProcessor"] | |