Image-Text-to-Text
MLX
Safetensors
lfm3_vl
liquid
lfm3
edge
decision
classification
calibration
system-one
multimodal
vision
conversational
custom_code
4-bit precision
Instructions to use LiquidAI/d1-2B-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use LiquidAI/d1-2B-MLX-4bit 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("LiquidAI/d1-2B-MLX-4bit") config = load_config("LiquidAI/d1-2B-MLX-4bit") # 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
- Pi
How to use LiquidAI/d1-2B-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "LiquidAI/d1-2B-MLX-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "LiquidAI/d1-2B-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use LiquidAI/d1-2B-MLX-4bit 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 "LiquidAI/d1-2B-MLX-4bit"
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 LiquidAI/d1-2B-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use LiquidAI/d1-2B-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "LiquidAI/d1-2B-MLX-4bit"
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 "LiquidAI/d1-2B-MLX-4bit" \ --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"
File size: 5,928 Bytes
6c4e058 0789edc 03fcc18 6c4e058 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | ---
library_name: mlx
license: other
license_name: lfm1.0
license_link: LICENSE
pipeline_tag: image-text-to-text
tags:
- liquid
- lfm3
- edge
- decision
- classification
- calibration
- system-one
- multimodal
- vision
- mlx
language:
- en
- ar
- zh
- fr
- de
- it
- ja
- ko
- pt
- es
- vi
- th
- id
- hi
- ru
- pl
base_model: LiquidAI/d1-2B
base_model_relation: quantized
---
<div align="center">
<img
src="https://huggingface.co/LiquidAI/LFM3-1.7B/resolve/main/assets/liquid-ai-banner.webp"
alt="Liquid AI"
style="width: 100%; max-width: 100%; height: auto; display: block; margin: 0;"
/>
<div align="center" style="display: flex; justify-content: center; align-items: center; gap: 1.25em; margin: 8px 0 1.7rem; padding: 0; line-height: 1.3;">
<a href="https://console.liquid.ai/dashboard" style="display: inline-flex; align-items: center; gap: 6px;"><img src="https://huggingface.co/LiquidAI/LFM3-1.7B/resolve/main/assets/icons/api.svg" width="16" height="16" alt="" aria-hidden="true" style="display: block; flex: 0 0 16px; width: 16px; height: 16px; margin: 0;" /><strong>API</strong></a>
<a href="https://playground.liquid.ai/" style="display: inline-flex; align-items: center; gap: 6px;"><img src="https://huggingface.co/LiquidAI/LFM3-1.7B/resolve/main/assets/icons/try.svg" width="16" height="16" alt="" aria-hidden="true" style="display: block; flex: 0 0 16px; width: 16px; height: 16px; margin: 0;" /><strong>Try</strong></a>
<a href="https://docs.liquid.ai/lfm/getting-started/welcome" style="display: inline-flex; align-items: center; gap: 6px;"><img src="https://huggingface.co/LiquidAI/LFM3-1.7B/resolve/main/assets/icons/docs.svg" width="16" height="16" alt="" aria-hidden="true" style="display: block; flex: 0 0 16px; width: 16px; height: 16px; margin: 0;" /><strong>Docs</strong></a>
<a href="https://www.liquid.ai/blog/lfm3" style="display: inline-flex; align-items: center; gap: 6px;"><img src="https://huggingface.co/LiquidAI/LFM3-1.7B/resolve/main/assets/icons/blog.svg" width="16" height="16" alt="" aria-hidden="true" style="display: block; flex: 0 0 16px; width: 16px; height: 16px; margin: 0;" /><strong>Blog</strong></a>
</div>
</div>
# d1-2B-MLX-4bit
4-bit MLX version of [d1-2B](https://huggingface.co/LiquidAI/d1-2B) for Apple Silicon. The weights take 1.35 GB.
d1-2B is a decision model for text, pictures, and video. It answers named, typed questions over a state with calibrated probabilities in one forward pass, without generating tokens.
The language model uses 4-bit affine quantization with groups of 64. The vision tower, projector and norms stay in FP16. Against the original checkpoint run in float32, it changed 3 of 52 test answers and moved probabilities by up to 0.25. Prefer [FP16](https://huggingface.co/LiquidAI/d1-2B-MLX-fp16) or [8-bit](https://huggingface.co/LiquidAI/d1-2B-MLX-8bit) where calibration matters.
Find architecture and usage details in the [original model card](https://huggingface.co/LiquidAI/d1-2B).
## Use with MLX-VLM
<hr style="margin: -0.7em 0 1.2em 0; border: 0; border-top: 1px solid rgba(127, 127, 127, 0.3);" />
Requires [MLX-VLM](https://github.com/Blaizzy/mlx-vlm) 0.7.11 or later:
```bash
pip install -U "mlx-vlm>=0.7.11"
```
d1-2B answers questions without generating text, so chat apps and `mlx_vlm.generate` cannot run it. Use `model.system_one` or the `decide` command below.
```python
from mlx_vlm import load
from mlx_vlm.utils import load_image
model, processor = load("LiquidAI/d1-2B-MLX-4bit")
# Text: several named questions over one state, answered in one pass
ticket = "I was charged twice and my parcel never arrived. Please refund one charge."
out = model.system_one(ticket, {
"refund": {"type": "noul", "instructions": "Is the customer asking for a refund?"},
"team": {"type": "choice", "instructions": "Which team should handle this?",
"criteria": {"billing": "Charges, refunds, invoices",
"shipping": "Delivery and parcels",
"technical": "App or site faults"}},
"topics": {"type": "choice", "multiple": True,
"instructions": "Which topics does the message raise?",
"criteria": {"billing": "Payments and charges",
"delivery": "Shipping and parcels",
"login": "Signing in to the account"}},
"urgency": {"type": "score", "instructions": "How urgent is this ticket?",
"criteria": ["low", "medium", "high"]},
})
a = out["answers"]
print(round(a["refund"]["noul"], 2), a["team"]["choice"], a["topics"]["choices"],
a["urgency"]["legend"][str(int(a["urgency"]["score"]))])
# 1.0 billing ['billing', 'delivery'] medium
print(out["usage"])
# {'input_tokens': 189, 'output_tokens': 0}
# Picture: the photo is the whole state
image = load_image("http://images.cocodataset.org/val2017/000000039769.jpg")
out = model.system_one(None, {
"cats": {"type": "number", "instructions": "How many cats are there?", "range": [0, 10], "step": 1},
"remote": {"type": "box", "instructions": "Where is the remote control on the left?"},
}, media=[image])
a = out["answers"]
print(a["cats"]["number"], {k: round(v, 2) for k, v in a["remote"]["box"].items()})
# 2.0 {'top': 0.16, 'bottom': 0.24, 'left': 0.06, 'right': 0.28}
```
`model.system_one` returns `{"answers": {name: answer}, "usage": {...}}`, and `model.system_one_batch` takes several requests. The original model card describes every question type and answer field.
From the command line, the answers print as JSON:
```bash
python -m mlx_vlm decide --model LiquidAI/d1-2B-MLX-4bit \
--state "I was charged twice this month. Please refund one of the charges." \
--questions '{"refund": {"type": "noul", "instructions": "Is the customer asking for a refund?"}}'
```
More options in the [MLX guide](https://docs.liquid.ai/deployment/on-device/mlx).
|