Image-Text-to-Text
Transformers
Safetensors
MLX
lfm2_vl
liquid
lfm2
lfm2-vl
edge
lfm2.5-vl
lfm2.5
conversational
8-bit precision
Instructions to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit") 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("lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit") model = AutoModelForMultimodalLM.from_pretrained("lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit", 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]:])) - MLX
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit") config = load_config("lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit", "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/lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit
- SGLang
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit 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 "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit" \ --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": "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit", "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 "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit" \ --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": "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit", "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" } } ] } ] }' - Pi
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit
Run Hermes
hermes
- OpenClaw new
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit with Docker Model Runner:
docker model run hf.co/lmstudio-community/LFM2.5-VL-1.6B-MLX-8bit
| { | |
| "additional_special_tokens": null, | |
| "backend": "tokenizers", | |
| "bos_token": "<|startoftext|>", | |
| "clean_up_tokenization_spaces": true, | |
| "eos_token": "<|im_end|>", | |
| "extra_special_tokens": [], | |
| "image_end_token": "<|image_end|>", | |
| "image_start_token": "<|image_start|>", | |
| "image_thumbnail": "<|img_thumbnail|>", | |
| "image_token": "<image>", | |
| "is_local": true, | |
| "legacy": false, | |
| "model_max_length": 1000000000000000019884624838656, | |
| "model_specific_special_tokens": { | |
| "image_end_token": "<|image_end|>", | |
| "image_start_token": "<|image_start|>", | |
| "image_thumbnail": "<|img_thumbnail|>", | |
| "image_token": "<image>" | |
| }, | |
| "pad_token": "<|pad|>", | |
| "processor_class": "Lfm2VlProcessor", | |
| "return_token_type_ids": false, | |
| "sp_model_kwargs": {}, | |
| "spaces_between_special_tokens": false, | |
| "tokenizer_class": "TokenizersBackend", | |
| "use_default_system_prompt": false, | |
| "use_fast": true, | |
| "chat_template": "{{- bos_token -}}\n{%- set keep_past_thinking = keep_past_thinking | default(false) -%}\n{%- set ns = namespace(system_prompt=\"\") -%}\n{%- if messages[0][\"role\"] == \"system\" -%}\n {%- set ns.system_prompt = messages[0][\"content\"] -%}\n {%- set messages = messages[1:] -%}\n{%- endif -%}\n{%- if tools -%}\n {%- set ns.system_prompt = ns.system_prompt + (\"\\n\" if ns.system_prompt else \"\") + \"List of tools: [\" -%}\n {%- for tool in tools -%}\n {%- if tool is not string -%}\n {%- set tool = tool | tojson -%}\n {%- endif -%}\n {%- set ns.system_prompt = ns.system_prompt + tool -%}\n {%- if not loop.last -%}\n {%- set ns.system_prompt = ns.system_prompt + \", \" -%}\n {%- endif -%}\n {%- endfor -%}\n {%- set ns.system_prompt = ns.system_prompt + \"]\" -%}\n{%- endif -%}\n{%- if ns.system_prompt -%}\n {{- \"<|im_start|>system\\n\" + ns.system_prompt + \"<|im_end|>\\n\" -}}\n{%- endif -%}\n{%- set ns.last_assistant_index = -1 -%}\n{%- for message in messages -%}\n {%- if message[\"role\"] == \"assistant\" -%}\n {%- set ns.last_assistant_index = loop.index0 -%}\n {%- endif -%}\n{%- endfor -%}\n{%- for message in messages -%}\n {{- \"<|im_start|>\" + message[\"role\"] + \"\\n\" -}}\n {%- if message.get('tool_calls') %}\n {# \u2500\u2500\u2500\u2500\u2500 create a list to append tool calls to \u2500\u2500\u2500\u2500\u2500 #}\n {%- set tool_calls_ns = namespace(tool_calls=[])%}\n {%- for tool_call in message['tool_calls'] %}\n {%- set func_name = tool_call['function']['name'] %}\n {%- set func_args = tool_call['function']['arguments'] %}\n {# \u2500\u2500\u2500\u2500\u2500 create a list of func_arg strings to accumulate for each tool call \u2500\u2500\u2500\u2500\u2500 #}\n {%- set args_ns = namespace(arg_strings=[])%}\n {%- for arg_name, arg_value in func_args.items() %}\n {%- if arg_value is none %}\n {%- set formatted_arg_value = 'null' %}\n {%- elif arg_value is boolean %}\n {%- set formatted_arg_value = 'True' if arg_value else 'False' %}\n {%- elif arg_value is string %}\n {%- set formatted_arg_value = '\"' ~ arg_value ~ '\"' %}\n {%- elif arg_value is mapping or arg_value is iterable %}\n {%- set formatted_arg_value = arg_value | tojson %}\n {%- else %}\n {%- set formatted_arg_value = arg_value | string %}\n {%- endif %}\n {# \u2500\u2500\u2500\u2500\u2500 format each argument key,value pair \u2500\u2500\u2500\u2500\u2500 #}\n {%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name ~ '=' ~ formatted_arg_value] %}\n {%- endfor %}\n {# \u2500\u2500\u2500\u2500\u2500 append each formatted tool call \u2500\u2500\u2500\u2500\u2500 #}\n {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [(func_name + '(' + (args_ns.arg_strings | join(\", \")) + ')' )]%}\n {%- endfor %}\n {# \u2500\u2500\u2500\u2500\u2500 format the final tool calls \u2500\u2500\u2500\u2500\u2500 #}\n {{-'<|tool_call_start|>[' + (tool_calls_ns.tool_calls | join(\", \")) + ']<|tool_call_end|>'}}\n {%- endif %}\n {%- set content = message[\"content\"] -%}\n {%- if content is not string -%}\n {%- set ns.content = \"\" -%}\n {%- for item in content -%}\n {%- if item[\"type\"] == \"image\" -%}\n {%- set ns.content = ns.content + \"<image>\" -%}\n {%- elif item[\"type\"] == \"text\" -%}\n {%- set ns.content = ns.content + item[\"text\"] -%}\n {%- else -%}\n {%- set ns.content = ns.content + item | tojson -%}\n {%- endif -%}\n {%- endfor -%}\n {%- set content = ns.content -%}\n {%- endif -%}\n {%- if message[\"role\"] == \"assistant\" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}\n {%- if \"</think>\" in content -%}\n {%- set content = content.split(\"</think>\")[-1] | trim -%}\n {%- endif -%}\n {%- endif -%}\n {{- content + \"<|im_end|>\\n\" -}}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{- \"<|im_start|>assistant\\n\" -}}\n{%- endif -%}\n" | |
| } |