Use d1-3b's code: D1Model in modeling_d1.py

#1
README.md CHANGED
@@ -3,23 +3,6 @@ library_name: transformers
3
  license: other
4
  license_name: lfm1.0
5
  license_link: LICENSE
6
- language:
7
- - ar
8
- - zh
9
- - en
10
- - fr
11
- - de
12
- - hi
13
- - id
14
- - it
15
- - ja
16
- - ko
17
- - pl
18
- - pt
19
- - ru
20
- - es
21
- - th
22
- - vi
23
  pipeline_tag: image-text-to-text
24
  base_model: LiquidAI/LFM2.5-VL-3B
25
  tags:
@@ -31,7 +14,6 @@ tags:
31
  - calibration
32
  - system-one
33
  - multimodal
34
- - decision-model
35
  ---
36
 
37
  <div align="center">
@@ -43,44 +25,41 @@ tags:
43
  <div style="display: flex; justify-content: center; gap: 0.5em; margin-bottom: 1em;">
44
  <a href="https://playground.liquid.ai/"><strong>Try LFM</strong></a> •
45
  <a href="https://docs.liquid.ai/lfm/getting-started/welcome"><strong>Docs</strong></a> •
 
46
  <a href="https://discord.com/invite/liquid-ai"><strong>Discord</strong></a>
47
  </div>
48
  </div>
49
 
50
  # d1-3B
51
 
52
- d1-3B is a 3B parameter **decision model** built on [LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B).
53
- You give it a state (text, JSON, images, or a mix) and a set of questions. It returns calibrated,
54
- typed answers in **one forward pass with zero output tokens**.
 
55
 
56
- - **Best decision model under 10B on the Decision Index 0.2.1**: 48.57, ahead of every 4B and 9B model
57
- and of Decider 35B-A3B (47.11).
58
- - **Multimodal**: images and text in the same state. It scores 74.1 on 11 public image benchmarks
59
  (LFM2.5-VL-3B: 73.9).
60
  - **Fast**: 8 ms a decision on an NVIDIA RTX 4090, 9 ms on an AMD MI325X, 30 ms on an Apple M5 Pro.
61
 
62
- Find more information about open d1 in our [blog post](https://www.liquid.ai/blog/open-d1).
63
-
64
- ![image](https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/r2H7UlZ_m48SYAhZWIHiu.png)
65
-
66
- > [!NOTE]
67
- > 💻 **Demos**: Try d1-3B in a Hugging Face space without any setup:
68
- > [**Open d1 Arcade**](https://huggingface.co/spaces/LiquidAI/system-one-arcade): Collection of 10 demos using d1-3B
69
 
 
70
 
71
  ## 🗒️ Model Details
72
 
73
  | Model | Parameters | Description |
74
  |---|---|---|
75
  | [LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B) | 3.1B | General-purpose vision-language model (base) |
76
- | **[d1-3B](https://huggingface.co/LiquidAI/d1-3B)** | 3.1B | Post-trained for single-pass, calibrated decisions |
77
-
78
- d1-3B is a multimodal decision model with the following features:
79
 
80
  - **Total parameters**: 3.12B
 
81
  - **Vision encoder**: SigLIP2 NaFlex shape-optimized 400M
82
  - **Context length**: 32,768 tokens
83
  - **Vocabulary size**: 128,000
 
84
 
85
  We recommend d1-3B wherever a pipeline needs a yes/no, a pick from named options, or a rating:
86
  routing and triage, moderation, intent and topic classification, extraction checks, reranking, LLM-as-a-judge
@@ -97,47 +76,36 @@ pip install "transformers>=5.14" torch torchvision pillow
97
  The model ships its own code, so load it with `trust_remote_code=True`:
98
 
99
  ```python
 
 
 
100
  import torch
 
101
  from transformers import AutoModel
102
- from transformers.image_utils import load_image
103
 
104
  device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
105
- dtype = torch.float32 if device == "cpu" else torch.bfloat16
106
- model = AutoModel.from_pretrained("LiquidAI/d1-3B", trust_remote_code=True, dtype=dtype).to(device)
107
 
108
- # Text: several named questions over one state, answered in one pass
109
  questions = {
110
- "refund": {
111
- "type": "noul",
112
- "instructions": "Is the customer asking for a refund?",
113
- },
114
- "team": {
115
- "type": "choice",
116
- "instructions": "Which team should handle this?",
117
- "criteria": {
118
- "billing": "Charges, refunds, invoices",
119
- "technical": "App or site faults",
120
- "fraud": "Suspected unauthorised use",
121
- },
122
- },
123
- "urgency": {
124
- "type": "score",
125
- "instructions": "How urgent is this?",
126
- "criteria": ["Can wait", "Today", "Blocking the customer now"],
127
- },
128
  }
129
  print(model.system_one("I was charged twice this month, please refund one of them.", questions))
130
 
131
- # Image: the photo is the whole state
132
- image = load_image("http://images.cocodataset.org/val2017/000000039769.jpg") # two cats on a sofa
133
- cats = {
134
- "type": "choice",
135
- "instructions": "How many cats are there?",
136
- "criteria": {"one": "One", "two": "Two", "more": "Three or more"},
137
- }
138
- print(model.system_one(None, {"cats": cats}, images=[image]))
139
 
140
- # Batch: many requests, packed together with no padding
141
  tickets = ["Where is my parcel? It was due Monday.", "The app crashes when I open settings."]
142
  print(model.system_one_batch([(t, {"team": questions["team"]}) for t in tickets]))
143
  ```
@@ -163,32 +131,16 @@ Each call returns `{"answers": {name: answer}, "usage": {"input_tokens": n, "out
163
 
164
  ## ⚡ Speed
165
 
166
- Warm calls, one request at a time: a single question, three questions over one state, a 3.4k-token
167
- state and a 384 px image. The last column is throughput with 64 states packed into one pass.
168
-
169
- ### Edge Inference
170
-
171
- We measure latency on an Apple M5 Pro and, in collaboration with NVIDIA, on an NVIDIA Jetson AGX Thor,
172
- a Jetson AGX Orin 64 GB and a Jetson Orin Nano.
173
 
174
  | | one question | 3 questions, one pass | 3.4k-token state | 384 px image | 64 states, packed |
175
  |---|---:|---:|---:|---:|---:|
176
- | Apple M5 Pro (`mps`) | 30 ms | 41 ms | 640 ms | 62 ms | 78 / s |
177
- | NVIDIA Jetson AGX Thor | 16 ms | 20 ms | 220 ms | 35 ms | 262 / s |
178
- | NVIDIA Jetson AGX Orin 64 GB | 26 ms | 35 ms | 560 ms | 83 ms | 110 / s |
179
- | NVIDIA Jetson Orin Nano | 50 ms | 73 ms | 1640 ms | 202 ms | 38 / s |
180
-
181
- ### GPU Inference
182
 
183
- We measure latency on an NVIDIA RTX 4090 and an AMD MI325X, in bf16, median of 20 runs.
184
-
185
- | | one question | 3 questions, one pass | 3.4k-token state | 384 px image | 64 states, packed |
186
- |---|---:|---:|---:|---:|---:|
187
- | NVIDIA RTX 4090 | 8 ms | 21 ms | 102 ms | 17 ms | 475 / s |
188
- | AMD MI325X | 9 ms | 14 ms | 44 ms | 18 ms | 1,106 / s |
189
-
190
- On NVIDIA GPUs, `model.compile(mode="reduce-overhead")` runs single questions as CUDA graphs (the RTX 4090
191
- row uses it). Without it, a single question takes 16 ms. The first call with a new shape pays for kernel
192
  selection or compilation, so warm up the shapes you serve.
193
 
194
  ## 📊 Performance
@@ -197,12 +149,15 @@ All results are on public benchmarks.
197
 
198
  ### Decision Index 0.2.1
199
 
200
- We scored d1-3B with the official scorer (not a leaderboard submission). All other rows come from the public leaderboard v0.2.1.
 
 
 
201
 
202
  | Model | Size | Decision Index | Knowledge | Language | Retrieval | Tools | Arts |
203
  |---|---:|---:|---:|---:|---:|---:|---:|
204
  | Winnow-12B | 12B | 50.02 | 33.8 | 56.0 | 54.0 | 71.0 | 30.0 |
205
- | **d1-3B** | **3B** | **48.57** | 23.8 | 56.4 | 52.8 | **74.5** | **36.3** |
206
  | Decider 35B-A3B | 36B | 47.11 | 31.8 | 55.5 | 54.7 | 56.5 | 32.6 |
207
  | JPT-9B | 9.7B | 46.89 | 31.7 | 56.7 | 44.6 | 67.0 | 28.6 |
208
  | Decision 1.0 Lux | 9.7B | 43.49 | 30.9 | 48.0 | 50.0 | 57.2 | 26.4 |
@@ -214,22 +169,23 @@ We scored d1-3B with the official scorer (not a leaderboard submission). All oth
214
 
215
  ### Benchmarks as decisions
216
 
217
- Besides the Decision Index, we added a few other internal evaluations based on public benchmarks.
 
218
 
219
  | Benchmark | d1-3B | Decider 4B | Decider 2B |
220
  |---|---:|---:|---:|
221
- | SQuAD 2.0 | **85.3** | 76.0 | 67.7 |
222
- | Civil Comments | 93.0 | 92.8 | **93.6** |
223
- | MASSIVE intent | 87.3 | **88.3** | 81.1 |
224
- | HelpSteer2 | 36.7 | **42.0** | 32.0 |
225
- | PubMedQA | **66.0** | 63.3 | 65.7 |
226
- | BoolQ | 86.7 | **89.0** | 87.3 |
227
- | XNLI | 85.0 | **88.6** | 85.0 |
228
- | PAWS-X | **76.9** | 69.8 | 59.5 |
229
- | **Mean** | **77.1** | 76.2 | 71.5 |
230
-
231
- d1-3B also scores 71.8 on [DecisionBench](https://huggingface.co/datasets/Hanno-Labs/decision-bench) (eng v1,
232
- all 23,900 rows) and 69.3 on [Fast Decisions](https://huggingface.co/datasets/fastino/fast-decisions)
233
  (dev split).
234
 
235
  ### Vision
@@ -239,22 +195,29 @@ compared with the base model:
239
 
240
  | Benchmark | d1-3B | LFM2.5-VL-3B |
241
  |---|---:|---:|
242
- | AI2D | 79.9 | 80.9 |
243
- | BLINK | 59.2 | 58.7 |
244
- | CV-Bench | 82.1 | 87.6 |
245
- | HallusionBench | 65.3 | 65.0 |
246
- | MMBench | 84.9 | 84.3 |
247
- | MME | 82.1 | 82.4 |
248
- | MMStar | 59.9 | 61.2 |
249
- | MMVP | 77.0 | 73.7 |
250
  | POPE | 88.5 | 90.1 |
251
- | VisualWebBench | 71.4 | 78.3 |
252
- | VL-RewardBench | 65.0 | 50.9 |
253
- | **Mean** | **74.1** | 73.9 |
254
- | [ImajevBench](https://huggingface.co/datasets/mohit67890/imajev-bench) (dev and calibration, 253 rows) | 64.0 | 66.8 |
255
 
256
  With the images removed, the same questions score 45.1, so the answers come from the images.
257
 
 
 
 
 
 
 
 
258
  ## 📬 Contact
259
 
260
  - Got questions or want to connect? [Join our Discord community](https://discord.com/invite/liquid-ai)
@@ -262,16 +225,6 @@ With the images removed, the same questions score 45.1, so the answers come from
262
 
263
  ## Citation
264
 
265
- ```bibtex
266
- @article{liquidAI2026opend1,
267
- author = {Liquid AI},
268
- title = {Open d1: Edge decision models for text, vision, and audio},
269
- journal = {Liquid AI Blog},
270
- year = {2026},
271
- note = {https://www.liquid.ai/blog/d1-open},
272
- }
273
- ```
274
-
275
  ```bibtex
276
  @article{liquidai2025lfm2,
277
  title = {LFM2 Technical Report},
 
3
  license: other
4
  license_name: lfm1.0
5
  license_link: LICENSE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  pipeline_tag: image-text-to-text
7
  base_model: LiquidAI/LFM2.5-VL-3B
8
  tags:
 
14
  - calibration
15
  - system-one
16
  - multimodal
 
17
  ---
18
 
19
  <div align="center">
 
25
  <div style="display: flex; justify-content: center; gap: 0.5em; margin-bottom: 1em;">
26
  <a href="https://playground.liquid.ai/"><strong>Try LFM</strong></a> •
27
  <a href="https://docs.liquid.ai/lfm/getting-started/welcome"><strong>Docs</strong></a> •
28
+ <a href="https://leap.liquid.ai/"><strong>LEAP</strong></a> •
29
  <a href="https://discord.com/invite/liquid-ai"><strong>Discord</strong></a>
30
  </div>
31
  </div>
32
 
33
  # d1-3B
34
 
35
+ d1-3B is a 3B **decision model** built on [LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B).
36
+ You give it a state (text, JSON, images, or a mix) and a set of named questions. It returns calibrated,
37
+ typed answers in **one forward pass with zero output tokens**: every answer is read directly from the
38
+ model's distribution over the options, with no generation and no parsing.
39
 
40
+ - **Best decision model under 10B**: 47.12 on the Decision Index 0.2.1. That is ahead of every 4B and 9B
41
+ model on the public leaderboard and level with Decider 35B-A3B (47.11).
42
+ - **Multimodal**: images and text in the same state. It scores 73.7 on 11 public image benchmarks
43
  (LFM2.5-VL-3B: 73.9).
44
  - **Fast**: 8 ms a decision on an NVIDIA RTX 4090, 9 ms on an AMD MI325X, 30 ms on an Apple M5 Pro.
45
 
46
+ <video src="https://huggingface.co/LiquidAI/d1-3b-RC/resolve/main/assets/d1-3b-smash.mp4" controls width="100%"></video>
 
 
 
 
 
 
47
 
48
+ ![Decision Index against model size](assets/di_pareto.png)
49
 
50
  ## 🗒️ Model Details
51
 
52
  | Model | Parameters | Description |
53
  |---|---|---|
54
  | [LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B) | 3.1B | General-purpose vision-language model (base) |
55
+ | **[d1-3B](https://huggingface.co/LiquidAI/d1-3b-RC)** | 3.1B | Post-trained for single-pass, calibrated decisions |
 
 
56
 
57
  - **Total parameters**: 3.12B
58
+ - **LM backbone**: LFM2.5-2.6B, 30 layers (22 double-gated short convolution blocks + 8 GQA)
59
  - **Vision encoder**: SigLIP2 NaFlex shape-optimized 400M
60
  - **Context length**: 32,768 tokens
61
  - **Vocabulary size**: 128,000
62
+ - **Output**: no generated tokens. Each answer is a probability distribution over the question's options.
63
 
64
  We recommend d1-3B wherever a pipeline needs a yes/no, a pick from named options, or a rating:
65
  routing and triage, moderation, intent and topic classification, extraction checks, reranking, LLM-as-a-judge
 
76
  The model ships its own code, so load it with `trust_remote_code=True`:
77
 
78
  ```python
79
+ import io
80
+ import urllib.request
81
+
82
  import torch
83
+ from PIL import Image
84
  from transformers import AutoModel
 
85
 
86
  device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
87
+ model = AutoModel.from_pretrained("LiquidAI/d1-3b-RC", trust_remote_code=True,
88
+ dtype=torch.float32 if device == "cpu" else torch.bfloat16).to(device)
89
 
90
+ # Several named questions over one text state, answered in one pass
91
  questions = {
92
+ "refund": {"type": "noul", "instructions": "Is the customer asking for a refund?"},
93
+ "team": {"type": "choice", "instructions": "Which team should handle this?",
94
+ "criteria": {"billing": "Charges, refunds, invoices", "technical": "App or site faults",
95
+ "fraud": "Suspected unauthorised use"}},
96
+ "urgency": {"type": "score", "instructions": "How urgent is this?",
97
+ "criteria": ["Can wait", "Today", "Blocking the customer now"]},
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
  print(model.system_one("I was charged twice this month, please refund one of them.", questions))
100
 
101
+ # An image as the whole state
102
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg" # two cats on a sofa
103
+ photo = Image.open(io.BytesIO(urllib.request.urlopen(url).read()))
104
+ print(model.system_one(None, {"cats": {"type": "choice", "instructions": "How many cats are there?",
105
+ "criteria": {"one": "One", "two": "Two", "more": "Three or more"}}},
106
+ images=[photo]))
 
 
107
 
108
+ # Many requests, packed together with no padding
109
  tickets = ["Where is my parcel? It was due Monday.", "The app crashes when I open settings."]
110
  print(model.system_one_batch([(t, {"team": questions["team"]}) for t in tickets]))
111
  ```
 
131
 
132
  ## ⚡ Speed
133
 
134
+ Warm calls in bf16, median of 20 runs:
 
 
 
 
 
 
135
 
136
  | | one question | 3 questions, one pass | 3.4k-token state | 384 px image | 64 states, packed |
137
  |---|---:|---:|---:|---:|---:|
138
+ | NVIDIA RTX 4090 | **8.0 ms** | 21 ms | 102 ms | 17 ms | 475 / s |
139
+ | AMD MI325X | 9.2 ms | 14 ms | 44 ms | 18 ms | 1,106 / s |
140
+ | Apple M5 Pro (`mps`) | 30 ms | 41 ms | 0.64 s | 62 ms | 78 / s |
 
 
 
141
 
142
+ On NVIDIA GPUs, `model.compile(mode="reduce-overhead")` runs single questions as CUDA graphs. The RTX 4090
143
+ row uses it; without it a single question takes 16 ms. The first call with a new shape pays for kernel
 
 
 
 
 
 
 
144
  selection or compilation, so warm up the shapes you serve.
145
 
146
  ## 📊 Performance
 
149
 
150
  ### Decision Index 0.2.1
151
 
152
+ The [Decision Index](https://huggingface.co/spaces/multimodalart/jev-decision-index) casts 38 public
153
+ benchmarks as 120,226 typed decisions, scored as chance-corrected skill. We scored d1-3B with the official
154
+ scorer; it is not a leaderboard submission. All other rows come from the public leaderboard
155
+ (snapshot 2026-09-28). Sizes are served parameters.
156
 
157
  | Model | Size | Decision Index | Knowledge | Language | Retrieval | Tools | Arts |
158
  |---|---:|---:|---:|---:|---:|---:|---:|
159
  | Winnow-12B | 12B | 50.02 | 33.8 | 56.0 | 54.0 | 71.0 | 30.0 |
160
+ | **d1-3B** | **3B** | **47.12** | 27.8 | 53.5 | 52.2 | 66.7 | **34.6** |
161
  | Decider 35B-A3B | 36B | 47.11 | 31.8 | 55.5 | 54.7 | 56.5 | 32.6 |
162
  | JPT-9B | 9.7B | 46.89 | 31.7 | 56.7 | 44.6 | 67.0 | 28.6 |
163
  | Decision 1.0 Lux | 9.7B | 43.49 | 30.9 | 48.0 | 50.0 | 57.2 | 26.4 |
 
169
 
170
  ### Benchmarks as decisions
171
 
172
+ Evaluation splits are cast as typed decisions, with the same rows for every model. These scores follow the
173
+ decision protocol, not each benchmark's own.
174
 
175
  | Benchmark | d1-3B | Decider 4B | Decider 2B |
176
  |---|---:|---:|---:|
177
+ | SQuAD 2.0 | **83.3** | 76.0 | 67.7 |
178
+ | Civil Comments | 93.3 | 92.8 | **93.6** |
179
+ | MASSIVE intent | 86.9 | **88.3** | 81.1 |
180
+ | HelpSteer2 | 38.0 | **42.0** | 32.0 |
181
+ | PubMedQA | **68.3** | 63.3 | 65.7 |
182
+ | BoolQ | 86.3 | **89.0** | 87.3 |
183
+ | XNLI | 85.6 | **88.6** | 85.0 |
184
+ | PAWS-X | **76.4** | 69.8 | 59.5 |
185
+ | **Mean** | **77.3** | 76.2 | 71.5 |
186
+
187
+ d1-3B also scores 69.5 on [DecisionBench](https://huggingface.co/datasets/Hanno-Labs/decision-bench) (eng v1,
188
+ all 23,900 rows) and 68.8 on [Fast Decisions](https://huggingface.co/datasets/fastino/fast-decisions)
189
  (dev split).
190
 
191
  ### Vision
 
195
 
196
  | Benchmark | d1-3B | LFM2.5-VL-3B |
197
  |---|---:|---:|
198
+ | AI2D | 80.1 | 80.9 |
199
+ | BLINK | 58.2 | 58.7 |
200
+ | CV-Bench | 82.7 | 87.6 |
201
+ | HallusionBench | 63.8 | 65.0 |
202
+ | MMBench | 84.3 | 84.3 |
203
+ | MME | 81.7 | 82.4 |
204
+ | MMStar | 59.4 | 61.2 |
205
+ | MMVP | 76.3 | 73.7 |
206
  | POPE | 88.5 | 90.1 |
207
+ | VisualWebBench | 71.6 | 78.3 |
208
+ | VL-RewardBench | 63.6 | 50.9 |
209
+ | **Mean** | **73.7** | 73.9 |
210
+ | [ImajevBench](https://huggingface.co/datasets/mohit67890/imajev-bench) (dev and calibration, 253 rows) | 66.8 | 66.8 |
211
 
212
  With the images removed, the same questions score 45.1, so the answers come from the images.
213
 
214
+ ## ⚠️ Limitations
215
+
216
+ - **Knowledge-heavy questions**: larger models stay ahead on hard knowledge (for example MMLU-Pro and GPQA).
217
+ - **Thresholds**: calibrate any threshold on data from your own deployment before gating on it.
218
+ - **No text output**: d1-3B answers questions over fixed options. Use [LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B)
219
+ for open-ended generation.
220
+
221
  ## 📬 Contact
222
 
223
  - Got questions or want to connect? [Join our Discord community](https://discord.com/invite/liquid-ai)
 
225
 
226
  ## Citation
227
 
 
 
 
 
 
 
 
 
 
 
228
  ```bibtex
229
  @article{liquidai2025lfm2,
230
  title = {LFM2 Technical Report},
assets/d1-3b-smash.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08f69b1a67bf32cd18fad32b5872519b580be9e94bafbe26a13d5cf0aaa49c1f
3
+ size 53062187
assets/di_pareto.png ADDED

Git LFS Details

  • SHA256: 62e7f5907b765063a710291d273f33d622d9bcff3efc74f3343d4dbdb469d73f
  • Pointer size: 131 Bytes
  • Size of remote file: 146 kB
assets/ood_tasks.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b491dfa851157e12ba2bee33a394c9565408247cf0004e493730622c62878e42
3
+ size 8931625
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:50e03317847caf6df9a9aee27ed40f20554a86a21e60d1d47ba41a422b546c0c
3
  size 6247065504
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:042be2b86f2140cf7e696d9d26c0dd8d2f0f8f943b783eb9ffa34903b41c98bb
3
  size 6247065504