marcodsn commited on
Commit
a790235
·
verified ·
1 Parent(s): e158f82

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LFM Open License v1.0
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
8
+
9
+ "Licensor" shall mean Liquid AI, Inc.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+
13
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
14
+
15
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+
17
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
18
+
19
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
20
+
21
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
22
+
23
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
24
+
25
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
26
+
27
+ "Commercial Use" shall mean any use of the Work for direct or indirect commercial advantage or monetary compensation.
28
+
29
+ "Qualified Non-Profit Organization" shall mean a Legal Entity that is organized and operated exclusively for religious, charitable, scientific, testing for public safety, literary, or educational purposes, and which is exempt from federal income tax under Section 501(c)(3) of the United States Internal Revenue Code of 1986, as amended, or any equivalent non-profit or charitable organization in a foreign jurisdiction.
30
+
31
+ "Non-Commercial or Research Purposes" shall mean purposes that do not involve any use of the Work or a Derivative Work for Commercial Use.
32
+
33
+ "Threshold" shall mean annual revenue of 10 million United States dollars ($10,000,000) or more.
34
+
35
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
36
+
37
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
38
+
39
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Commercial Use Limitation.
52
+
53
+ (a) The rights granted under this License for Commercial Use are conditioned upon You or Your Legal Entity not exceeding the Threshold.
54
+
55
+ (b) Any Commercial Use of the Work or a Derivative Work by a Legal Entity that exceeds the Threshold is not licensed under this Agreement.
56
+
57
+ (c) The Threshold shall not apply to a Qualified Non-Profit Organization's use of the Work or a Derivative Work for Non-Commercial or Research Purposes.
58
+
59
+ 6. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
60
+
61
+ 7. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except for the reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
62
+
63
+ 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
64
+
65
+ 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
68
+
69
+ 11. Termination. This License will terminate automatically and immediately if You fail to comply with any of its terms and conditions. Upon termination, You must cease all use of the Work and any Derivative Works and delete all copies in Your possession.
70
+
71
+ END OF TERMS AND CONDITIONS
NOTICE ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ alpha-sys-1-3B-260920: the weights of LiquidAI/LFM2.5-VL-3B with a LoRA (rank 32, every linear
2
+ layer of the language model and the projector) trained on seven public environments and merged in.
3
+ The vision tower is unchanged. Training configuration in run.json. Changed file: model.safetensors.
4
+ Base model licensed under the LFM Open License v1.0 (LICENSE), whose terms apply to this derivative.
README.md ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: lfm1.0
4
+ license_link: LICENSE
5
+ base_model:
6
+ - LiquidAI/LFM2.5-VL-3B
7
+ base_model_relation: finetune
8
+ pipeline_tag: image-text-to-text
9
+ library_name: transformers
10
+ language:
11
+ - en
12
+ tags:
13
+ - calibration
14
+ - classification
15
+ - system-one
16
+ - jev-compatible
17
+ datasets:
18
+ - allenai/ai2_arc
19
+ - allenai/sciq
20
+ - allenai/openbookqa
21
+ - tau/commonsense_qa
22
+ - uoft-cs/cifar10
23
+ - mteb/stsbenchmark-sts
24
+ ---
25
+
26
+ <div align="center">
27
+ <img
28
+ src="https://huggingface.co/buckets/nullsilver/main/resolve/nullsilver-banner-light-1.png"
29
+ alt="alpha-sys-1 banner"
30
+ style="width: 100%; max-width: 100%; height: auto; display: inline-block; margin-bottom: 0.5em; margin-top: 0.5em;"
31
+ />
32
+ <div style="display: flex; justify-content: center; gap: 0.5em; margin-bottom: 1em;">
33
+ <a href="https://github.com/nullsilver-labs/alpha-sys-1/blob/main/docs/USAGE.md"><strong>docs</strong></a> •
34
+ <a href="https://nullsilver.com"><strong>nullsilver.com</strong></a>
35
+ </div>
36
+ </div>
37
+
38
+ # alpha-sys-1-3B
39
+
40
+ alpha-sys-1 is a multimodal, Jev-compatible **System One model**. It takes a state, which
41
+ may contain text, an image, or both, together with a question that has a fixed set of
42
+ answers, and returns a probability distribution over those answers in one forward pass. It
43
+ generates no text.
44
+
45
+ The model is trained for calibrated probabilities: across a large group of similar
46
+ examples where it assigns an answer a probability near 80%, that answer should be correct
47
+ in roughly 80% of cases. Calibration degrades when the input differs substantially from
48
+ the training data, so check the probabilities on data from the intended application.
49
+
50
+ | | |
51
+ |---|---|
52
+ | Base | [LiquidAI/LFM2.5-VL-3B](https://huggingface.co/LiquidAI/LFM2.5-VL-3B) |
53
+ | Tuning | LoRA rank 32, lr 1e-4, merged into the base weights |
54
+ | Checkpoint | `alpha-sys-1-260920`, revision `260920`, seed 1 of 3 |
55
+ | Input | text, one image, or both; English |
56
+ | Output | probabilities over the answer space |
57
+ | Sizes | [450M](https://huggingface.co/nullsilver/alpha-sys-1-450M) · [1.6B](https://huggingface.co/nullsilver/alpha-sys-1-1.6B) · [3B](https://huggingface.co/nullsilver/alpha-sys-1-3B) |
58
+
59
+ ## Question types
60
+
61
+ Questions follow TypeSafe's System One format: a request contains one `state` and any
62
+ number of `questions`, so a question written for Jev runs here as is. `images` is an extra
63
+ field for multimodal inputs.
64
+
65
+ | type | answer space | returns |
66
+ |---|---|---|
67
+ | `choice` | named options, up to 26 | `probabilities` over the options, `choice` (argmax) |
68
+ | `noul` | a statement | `noul`, P(true) |
69
+ | `score` | ordered levels, lowest first | `probabilities` over the levels, `score` (expected level index) |
70
+
71
+ The answer is read from the next-token logits for the answer labels (`A`, `B`, … or
72
+ `No`/`Yes`), renormalised over the valid labels. Each question is answered independently:
73
+ one question's answer is never context for another.
74
+
75
+ > [!NOTE]
76
+ > `confidence` is `1 - H(p)/log(n)`, computed from the distribution. It is not a separate
77
+ > prediction.
78
+
79
+ > [!TIP]
80
+ > A `noul` probability near 0.5 means the model is uncertain.
81
+
82
+ ## Usage
83
+
84
+ `alpha_sys_1.py` in this repository renders questions the way the model was trained on
85
+ them, batches the questions on one state, and returns answers in the System One shape.
86
+
87
+ ```python
88
+ from huggingface_hub import hf_hub_download
89
+ import importlib.util, sys
90
+ spec = importlib.util.spec_from_file_location("alpha_sys_1", hf_hub_download("nullsilver/alpha-sys-1-3B", "alpha_sys_1.py", revision="260920"))
91
+ alpha_sys_1 = importlib.util.module_from_spec(spec); spec.loader.exec_module(alpha_sys_1)
92
+
93
+ m = alpha_sys_1.SystemOne("nullsilver/alpha-sys-1-3B", revision="260920")
94
+ m.system_one({
95
+ "state": {"subject": "Duplicate charge on invoice #4411",
96
+ "body": "We were billed twice for March. Refund the duplicate today or we cancel our plan."},
97
+ "questions": {
98
+ "department": {"type": "choice", "instructions": "Which department should handle this email?",
99
+ "criteria": {"billing": "invoices, payments, refunds", "technical": "bugs, outages",
100
+ "sales": "pricing, new contracts", "other": "everything else"}},
101
+ "urgency": {"type": "score", "instructions": "How urgent is this request?",
102
+ "criteria": ["not urgent", "soon", "critical deadline or blocking issue"]},
103
+ "churn_risk": {"type": "noul", "instructions": "The user threatens to cancel or leave."}}})
104
+ # {"department": {"choice": "billing", "probabilities": {"billing": 1.00, "technical": 0.00, "sales": 0.00, "other": 0.00}, "confidence": 0.98},
105
+ # "urgency": {"score": 1.14, "probabilities": [0.21, 0.45, 0.34], ...},
106
+ # "churn_risk": {"noul": 0.64}}
107
+ ```
108
+
109
+ Email triage is not one of the training environments; the output above is what this
110
+ checkpoint returns on it, not a tuned result.
111
+
112
+ Without the client, use this prompt format. A different format gives less reliable
113
+ probabilities.
114
+
115
+ ```python
116
+ import string, torch
117
+ from transformers import AutoModelForImageTextToText, AutoProcessor
118
+
119
+ repo, rev = "nullsilver/alpha-sys-1-3B", "260920"
120
+ processor = AutoProcessor.from_pretrained(repo, revision=rev)
121
+ processor.tokenizer.padding_side = "left"
122
+ model = AutoModelForImageTextToText.from_pretrained(
123
+ repo, revision=rev, dtype=torch.bfloat16, device_map="auto").eval()
124
+
125
+ def render(state, q):
126
+ parts = [state] if state else []
127
+ if q["type"] == "noul":
128
+ c = q.get("criteria") or {}
129
+ clar = "".join(f"\n{lab} means: {c[k]}" for lab, k in (("Yes", "true"), ("No", "false")) if c.get(k))
130
+ parts.append(f"Statement: {q['instructions']}{clar}\nIs the statement true? Answer with Yes or No only.")
131
+ return "\n\n".join(parts), ["No", "Yes"]
132
+ crit = q["criteria"]
133
+ items = list(crit.items()) if isinstance(crit, dict) else [(o, None) for o in crit]
134
+ labels = list(string.ascii_uppercase[:len(items)])
135
+ lines = [f"{lab}. {o}" + (f": {d}" if d else "") for lab, (o, d) in zip(labels, items)]
136
+ parts.append(q["instructions"] + "\n" + "\n".join(lines) + "\nAnswer with the letter only.")
137
+ return "\n\n".join(parts), labels
138
+
139
+ @torch.inference_mode()
140
+ def ask(q, state="", image=None):
141
+ text, labels = render(state, q)
142
+ content = ([{"type": "image", "image": image}] if image is not None else []) + [{"type": "text", "text": text}]
143
+ inputs = processor.apply_chat_template(
144
+ [[{"role": "user", "content": content}]], add_generation_prompt=True, tokenize=True,
145
+ return_dict=True, processor_kwargs={"return_tensors": "pt"}).to(model.device)
146
+ logits = model(**inputs, logits_to_keep=1).logits[0, -1].float()
147
+ ids = [processor.tokenizer.encode(lab, add_special_tokens=False)[0] for lab in labels]
148
+ return torch.softmax(logits[ids], -1).tolist()
149
+
150
+ p = ask({"type": "noul", "instructions": "The message conveys urgency"},
151
+ state="Our API integration started returning 500 errors an hour before launch.")
152
+ urgent = p[1] # P(Yes)
153
+ ```
154
+
155
+ > [!NOTE]
156
+ > - A dict `state` is rendered one field per line, as `key: value`.
157
+ > - Training images smaller than 256 px were upscaled to 256 px.
158
+ > - For several questions on one state, batch them with `padding_side="left"`.
159
+ > - In bfloat16, probabilities move by up to a few hundredths with batch composition and
160
+ > padding.
161
+
162
+ ## Training
163
+
164
+ Training uses cross-entropy between the model's distribution and a target `y_soft`. The
165
+ target is one-hot when a dataset provides one answer, and the annotator distribution when
166
+ several annotations are available. Options are shuffled on every draw, the vision tower is
167
+ frozen, and environments are sampled in proportion to the square root of their size.
168
+
169
+ | environment | modality | type | label |
170
+ |---|---|---|---|
171
+ | mcq (ARC-Easy, SciQ, OpenBookQA, CommonsenseQA) | text | choice | one-hot |
172
+ | ChaosNLI (100-annotator items) | text | choice | annotator distribution |
173
+ | CivilComments-WILDS | text | noul | annotator share |
174
+ | STS-B | text | score | annotator mean |
175
+ | Folktables (ACS income, California 2014) | tabular as text | noul | outcome |
176
+ | CIFAR-10 | image | choice | one-hot |
177
+ | Camelyon17-WILDS | image | noul | outcome |
178
+
179
+ Three random seeds were trained. The released checkpoint is the seed with the lowest mean
180
+ development loss across environments.
181
+
182
+ ## Evaluation
183
+
184
+ Each test split was read once per checkpoint. Reported intervals are 95% clustered
185
+ bootstrap intervals, clustered on the relevant dataset group: question, comment, hospital,
186
+ or state-year.
187
+
188
+ > [!IMPORTANT]
189
+ > Compare models on NLL and Brier score. ECE is reported alongside them and is misleading
190
+ > on its own: a model that always predicts the base rate can have a low ECE.
191
+
192
+ The tables carry two reference points. The **base rate** is the constant predictor: it
193
+ answers every question with the label frequencies of the training split (for example
194
+ "toxic" 14% of the time on CivilComments, whatever the comment says), or uniformly when
195
+ the options are shuffled. Any model should beat it. **Base + T** is the untuned
196
+ LFM2.5-VL-3B, read the same way as the tuned model, with its label logits divided by
197
+ one scalar temperature chosen to minimise NLL on the environment's development split.
198
+
199
+ **Trained environments.**
200
+
201
+ | environment | NLL | NLL, base + T | Brier | ECE | AUROC | acc |
202
+ |---|---|---|---|---|---|---|
203
+ | mcq | **0.289** | 0.386 | 0.152 | 0.008 | 0.905 | 0.894 |
204
+ | ChaosNLI | **0.735** | 0.795 | 0.133 | 0.049 | 0.717 | 0.729 |
205
+ | CivilComments | **0.319** | 0.423 | 0.040 | 0.067 | 0.913 | 0.945 |
206
+ | STS-B | **0.961** | 1.576 | 0.270 | 0.033 | 0.652 | 0.611 |
207
+ | Folktables | **0.441** | 0.610 | 0.289 | 0.014 | 0.761 | 0.787 |
208
+ | CIFAR-10 (+C) | **0.197** | 0.261 | 0.092 | 0.018 | 0.951 | 0.938 |
209
+ | Camelyon17 | **0.193** | 0.686 | 0.093 | 0.030 | 0.871 | 0.942 |
210
+
211
+ > [!NOTE]
212
+ > ChaosNLI, CivilComments and STS-B have soft labels from multiple annotations, so
213
+ > top-label ECE does not fully measure calibration. On these, use NLL and KL divergence to
214
+ > the annotator distribution.
215
+
216
+ **Unseen tasks.** Not in training.
217
+
218
+ | task | type | NLL | NLL, base + T | base rate |
219
+ |---|---|---|---|---|
220
+ | BoolQ | noul | 0.405 | **0.393** | 0.665 |
221
+ | Yelp review stars | score | 0.973 | **0.961** | 1.609 |
222
+
223
+ **Distribution shift.** CIFAR-10-C.
224
+
225
+ | | clean | sev. 1 | 2 | 3 | 4 | 5 |
226
+ |---|---|---|---|---|---|---|
227
+ | accuracy | 0.984 | 0.967 | 0.949 | 0.936 | 0.915 | 0.873 |
228
+ | mean confidence | 0.986 | 0.973 | 0.962 | 0.952 | 0.936 | 0.910 |
229
+
230
+ **Other System One models.** NLL on the text environments, same test splits, same
231
+ readout. The other alpha-sys-1 sizes on the table are their released seeds. `Qwen3.8-27B` is the open 27B
232
+ generalist, read at its first answer token with reasoning off, plus a dev-fitted
233
+ temperature.
234
+
235
+ | environment | alpha-sys-1-450M | alpha-sys-1-1.6B | alpha-sys-1-3B (this) | Qwen3.8-27B + T | base rate |
236
+ |---|---|---|---|---|---|
237
+ | mcq | 0.727 | 0.427 | 0.289 | **0.159** | 1.439 |
238
+ | ChaosNLI | 0.902 | 0.784 | 0.735 | **0.706** | 0.938 |
239
+ | CivilComments | 0.324 | 0.323 | **0.319** | 0.473 | 0.425 |
240
+ | STS-B | 1.107 | 1.033 | **0.961** | 1.347 | 1.727 |
241
+ | Folktables | **0.436** | 0.448 | 0.441 | 0.472 | 0.683 |
242
+ | BoolQ (unseen) | 0.661 | 0.479 | 0.405 | **0.316** | 0.665 |
243
+ | Yelp review stars (unseen) | 1.467 | 1.110 | 0.973 | **0.858** | 1.609 |
244
+
245
+ Per-hospital, per-state-year and per-identity-group tables, the three-seed gate tables and
246
+ the full comparison against other System One models (hosted and open) are in the
247
+ [repository](https://github.com/nullsilver-labs/alpha-sys-1) under `runs/`.
248
+
249
+ ## Limitations
250
+
251
+ > [!WARNING]
252
+ > On a task that differs substantially from the training environments, do not assume this
253
+ > model stays calibrated; measure it against the base model's calibration. In
254
+ > leave-one-domain-out tests at 1.6B, a model tuned on the other environments beat the
255
+ > untuned base with a transferred temperature on one held-out environment out of three,
256
+ > and on the two unseen tasks above the trained-on-all checkpoints match the base model and do not beat it.
257
+ > With a few hundred labelled examples from your own task, fit a temperature on them:
258
+ > divide the label logits by one scalar chosen to minimise NLL on those examples
259
+ > (`alpha_sys_1.fit_temperature`), then pass it as `SystemOne(..., temperature=T)`.
260
+
261
+ - When the model does not know an answer, its distribution is close to uniform.
262
+ - Under strong distribution shift, such as CIFAR-10-C at severity 5, confidence remains
263
+ higher than accuracy.
264
+ - Reversing the option order changes the top answer on a few percent of MCQ items, mostly
265
+ among low-confidence examples.
266
+ - The answer space is capped at 26 options.
267
+ - Fine-tuning used English data only and at most one image per question.
268
+
269
+ ## Related work
270
+
271
+ The interface follows TypeSafe's Jev (a hosted System One model, the `state` / `questions`
272
+ request shape). Reading an answer distribution from the label-token logits of one forward
273
+ pass is the readout of Kadavath et al. (2022, *Language Models (Mostly) Know What They
274
+ Know*) and of the LLM-as-a-Verifier line of work, which scores rubric levels from the
275
+ logits of letter tokens. That calibration improves with size, and that a temperature
276
+ fitted on one domain transfers badly to another, is Jiang et al. (2021, *How Can We Know
277
+ When Language Models Know?*). Training on a proper scoring rule against annotator
278
+ distributions is why a fixed answer space and calibration are non-conflicting (Kalai and
279
+ Vempala, 2024, *Calibrated Language Models Must Hallucinate*). Base models: Liquid AI's
280
+ LFM2.5-VL.
281
+
282
+ ## License
283
+
284
+ This model is derived from LiquidAI/LFM2.5-VL-3B and is released under the [LFM Open License
285
+ v1.0](LICENSE).
286
+
287
+ ## Citation
288
+
289
+ ```bibtex
290
+ @misc{alphasys1,
291
+ title = {alpha-sys-1: a small calibrated System One model},
292
+ author = {Nullsilver},
293
+ year = {2026},
294
+ url = {https://huggingface.co/collections/nullsilver/alpha-sys-1}
295
+ }
296
+ ```
alpha_sys_1.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """alpha-sys-1 inference client: one file, no dependency on this repository, shipped in the
2
+ Hugging Face repos as `alpha_sys_1.py`. It renders questions exactly as the model was trained
3
+ on them and reads the answer distribution from one forward pass.
4
+
5
+ from alpha_sys_1 import SystemOne
6
+ m = SystemOne("nullsilver/alpha-sys-1-1.6B")
7
+ m.ask({"type": "choice", "instructions": "Which team should handle this?",
8
+ "criteria": {"billing": "payments, refunds", "technical": "bugs, outages", "sales": "pricing"}},
9
+ state="Our API started returning 500 errors this morning.")
10
+ # -> {"choice": "technical", "probabilities": {...}, "confidence": 0.71}
11
+
12
+ m.system_one({"state": ..., "images": [...], "questions": {"q1": {...}, "q2": {...}}})
13
+ # -> {"model": ..., "answers": {"q1": {...}, "q2": {...}}} (TypeSafe's System One shape)
14
+
15
+ Question types: choice (criteria = {option: description or None} or a list of options, up to
16
+ 26), noul (a statement; criteria = {"true": ..., "false": ...} optional), score (criteria = the
17
+ levels, lowest first; the score is the expected level index). Images: a PIL image, a path, or
18
+ a data URL; small images are upscaled to 256 px as in training.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import base64
24
+ import io
25
+ import math
26
+ import string
27
+ from typing import Any
28
+
29
+ import torch
30
+ from PIL import Image
31
+ from transformers import AutoModelForImageTextToText, AutoProcessor
32
+
33
+ IMAGE_SIDE = 256
34
+
35
+
36
+ def render_state(state: Any) -> str:
37
+ if state is None:
38
+ return ""
39
+ if isinstance(state, str):
40
+ return state
41
+ if isinstance(state, dict):
42
+ return "\n".join(f"{k}: {v}" for k, v in state.items())
43
+ return str(state)
44
+
45
+
46
+ def render(state: Any, q: dict) -> tuple[str, list[str], list[str]]:
47
+ """-> (user text, label tokens in listed order, answer-space keys in the same order)."""
48
+ parts = [s for s in [render_state(state)] if s]
49
+ t = q["type"]
50
+ if t == "noul":
51
+ c = q.get("criteria") or {}
52
+ clar = "".join(f"\n{lab} means: {c[k]}" for lab, k in (("Yes", "true"), ("No", "false")) if c.get(k))
53
+ parts.append(f"Statement: {q['instructions']}{clar}\nIs the statement true? Answer with Yes or No only.")
54
+ return "\n\n".join(parts), ["No", "Yes"], ["no", "yes"]
55
+ crit = q["criteria"]
56
+ if t == "choice":
57
+ items = list(crit.items()) if isinstance(crit, dict) else [(o, None) for o in crit]
58
+ keys = [k for k, _ in items]
59
+ else:
60
+ items, keys = [(lvl, None) for lvl in crit], [str(i) for i in range(len(crit))]
61
+ if len(items) > 26:
62
+ raise ValueError("at most 26 options or levels per question")
63
+ labels = list(string.ascii_uppercase[: len(items)])
64
+ lines = [f"{lab}. {o}" + (f": {d}" if d else "") for lab, (o, d) in zip(labels, items)]
65
+ parts.append(f"{q['instructions']}\n" + "\n".join(lines) + "\nAnswer with the letter only.")
66
+ return "\n\n".join(parts), labels, keys
67
+
68
+
69
+ def load_image(im: Any) -> Image.Image:
70
+ if isinstance(im, Image.Image):
71
+ img = im
72
+ elif isinstance(im, str) and im.startswith("data:"):
73
+ img = Image.open(io.BytesIO(base64.b64decode(im.split(",", 1)[1])))
74
+ else:
75
+ img = Image.open(im)
76
+ img = img.convert("RGB")
77
+ if max(img.size) < IMAGE_SIDE:
78
+ img = img.resize((IMAGE_SIDE, IMAGE_SIDE), Image.BICUBIC)
79
+ return img
80
+
81
+
82
+ def confidence(p: list[float]) -> float:
83
+ n = len(p)
84
+ if n < 2:
85
+ return 1.0
86
+ h = -sum(x * math.log(x) for x in p if x > 0)
87
+ return round(max(0.0, 1 - h / math.log(n)), 4)
88
+
89
+
90
+ class SystemOne:
91
+ def __init__(self, repo: str, revision: str | None = None, device: str | None = None, dtype=torch.bfloat16, temperature: float = 1.0):
92
+ """temperature: the label logits are divided by it (1.0 = the model as released; see fit_temperature)."""
93
+ self.repo, self.revision, self.temperature = repo, revision, temperature
94
+ self.processor = AutoProcessor.from_pretrained(repo, revision=revision)
95
+ self.processor.tokenizer.padding_side = "left"
96
+ self.model = AutoModelForImageTextToText.from_pretrained(repo, revision=revision, dtype=dtype)
97
+ self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
98
+ self.model.to(self.device).eval()
99
+ self._ids: dict[str, int] = {}
100
+
101
+ def _label_id(self, label: str) -> int:
102
+ if label not in self._ids:
103
+ ids = self.processor.tokenizer.encode(label, add_special_tokens=False)
104
+ assert len(ids) == 1, label
105
+ self._ids[label] = ids[0]
106
+ return self._ids[label]
107
+
108
+ @torch.inference_mode()
109
+ def distributions(self, items: list[tuple[Any, dict, list | None]]) -> list[list[float]]:
110
+ """items: (state, question, images or None) -> probabilities in the answer-space order."""
111
+ msgs, labels_per = [], []
112
+ for state, q, images in items:
113
+ text, labels, _ = render(state, q)
114
+ content = [{"type": "image", "image": load_image(im)} for im in (images or [])] + [{"type": "text", "text": text}]
115
+ msgs.append([{"role": "user", "content": content}])
116
+ labels_per.append(labels)
117
+ inputs = self.processor.apply_chat_template(
118
+ msgs, add_generation_prompt=True, tokenize=True, return_dict=True,
119
+ processor_kwargs={"return_tensors": "pt", "padding": True}).to(self.device)
120
+ logits = self.model(**inputs, logits_to_keep=1).logits[:, -1].float()
121
+ out = []
122
+ for i, labels in enumerate(labels_per):
123
+ ids = torch.tensor([self._label_id(lab) for lab in labels], device=logits.device)
124
+ out.append(torch.softmax(logits[i, ids] / self.temperature, -1).tolist())
125
+ return out
126
+
127
+ def answer(self, q: dict, p: list[float]) -> dict:
128
+ _, _, keys = render(None, q)
129
+ if q["type"] == "choice":
130
+ return {"type": "choice", "choice": keys[max(range(len(p)), key=p.__getitem__)],
131
+ "probabilities": dict(zip(keys, p)), "confidence": confidence(p)}
132
+ if q["type"] == "noul":
133
+ return {"type": "noul", "noul": p[1]}
134
+ return {"type": "score", "score": sum(i * x for i, x in enumerate(p)),
135
+ "legend": dict(zip(keys, q["criteria"])), "probabilities": p, "confidence": confidence(p)}
136
+
137
+ def ask(self, q: dict, state: Any = None, images: list | None = None) -> dict:
138
+ return self.answer(q, self.distributions([(state, q, images)])[0])
139
+
140
+ def system_one(self, request: dict, batch: int = 16) -> dict:
141
+ """A request in TypeSafe's System One shape: {state, images?, questions: {id: q}}."""
142
+ state, images = request.get("state"), request.get("images")
143
+ ids = list(request["questions"])
144
+ answers = {}
145
+ for s in range(0, len(ids), batch):
146
+ chunk = ids[s : s + batch]
147
+ ps = self.distributions([(state, request["questions"][i], images) for i in chunk])
148
+ for i, p in zip(chunk, ps):
149
+ answers[i] = self.answer(request["questions"][i], p)
150
+ return {"model": self.repo + (f"@{self.revision}" if self.revision else ""), "answers": answers}
151
+
152
+
153
+ def fit_temperature(model: SystemOne, examples: list[tuple[Any, dict, list | None, int]], batch: int = 16) -> float:
154
+ """One scalar that minimises NLL on labelled examples (state, question, images, index of the
155
+ true answer in the answer space: option position, 0/1 for noul, level index for score).
156
+ A few hundred examples are enough. Use it as SystemOne(..., temperature=T)."""
157
+ old, model.temperature = model.temperature, 1.0
158
+ try:
159
+ probs, truth = [], []
160
+ for s in range(0, len(examples), batch):
161
+ chunk = examples[s : s + batch]
162
+ probs += model.distributions([(st, q, im) for st, q, im, _ in chunk])
163
+ truth += [t for _, _, _, t in chunk]
164
+ finally:
165
+ model.temperature = old
166
+ logs = [[math.log(max(x, 1e-12)) for x in p] for p in probs]
167
+
168
+ def nll(t: float) -> float:
169
+ total = 0.0
170
+ for lp, y in zip(logs, truth):
171
+ z = [v / t for v in lp]
172
+ m = max(z)
173
+ total -= z[y] - (m + math.log(sum(math.exp(v - m) for v in z)))
174
+ return total / len(logs)
175
+
176
+ lo, hi = math.log(0.05), math.log(20.0) # golden-section search on log T
177
+ g = (math.sqrt(5) - 1) / 2
178
+ a, b = hi - g * (hi - lo), lo + g * (hi - lo)
179
+ fa, fb = nll(math.exp(a)), nll(math.exp(b))
180
+ for _ in range(60):
181
+ if fa < fb:
182
+ hi, b, fb = b, a, fa
183
+ a = hi - g * (hi - lo)
184
+ fa = nll(math.exp(a))
185
+ else:
186
+ lo, a, fa = a, b, fb
187
+ b = lo + g * (hi - lo)
188
+ fb = nll(math.exp(b))
189
+ return round(math.exp((lo + hi) / 2), 3)
chat_template.jinja ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- set preserve_thinking = preserve_thinking | default(false) -%}
3
+
4
+ {%- macro format_arg_value(arg_value) -%}
5
+ {%- if arg_value is string -%}
6
+ {{- "'" + (arg_value | replace("\\", "\\\\") | replace("'", "\\'") | replace("\n", "\\n") | replace("\r", "\\r")) + "'" -}}
7
+ {%- elif arg_value is mapping or arg_value is iterable -%}
8
+ {{- arg_value | tojson -}}
9
+ {%- else -%}
10
+ {{- arg_value | string -}}
11
+ {%- endif -%}
12
+ {%- endmacro -%}
13
+
14
+ {%- macro parse_content(content) -%}
15
+ {%- if content is string -%}
16
+ {{- content -}}
17
+ {%- elif content is mapping -%}
18
+ {{- content | tojson -}}
19
+ {%- elif content is iterable -%}
20
+ {%- set _ns = namespace(result="") -%}
21
+ {%- for item in content -%}
22
+ {%- if item is string -%}
23
+ {%- set _ns.result = _ns.result + item -%}
24
+ {%- elif item is mapping and item.get("type") == "image" -%}
25
+ {%- set _ns.result = _ns.result + "<image>" -%}
26
+ {%- elif item is mapping and item.get("type") == "text" -%}
27
+ {%- set _ns.result = _ns.result + ((item.get("text") or "") | string) -%}
28
+ {%- else -%}
29
+ {%- set _ns.result = _ns.result + (item | tojson) -%}
30
+ {%- endif -%}
31
+ {%- endfor -%}
32
+ {{- _ns.result -}}
33
+ {%- endif -%}
34
+ {%- endmacro -%}
35
+
36
+ {%- macro render_tool_calls(tool_calls) -%}
37
+ {%- set tool_calls_ns = namespace(tool_calls=[]) -%}
38
+ {%- for tool_call in tool_calls -%}
39
+ {%- set func = tool_call["function"] if "function" in tool_call else tool_call -%}
40
+ {%- set func_name = func["name"] -%}
41
+ {%- set func_args = func.get("arguments") -%}
42
+ {%- set args_ns = namespace(arg_strings=[]) -%}
43
+ {%- if func_args is mapping -%}
44
+ {%- for arg_name, arg_value in func_args.items() -%}
45
+ {%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name + "=" + format_arg_value(arg_value)] -%}
46
+ {%- endfor -%}
47
+ {%- elif func_args is string and (func_args | trim) not in ["", "{}", "null"] -%}
48
+ {{- raise_exception("Tool call arguments must be a mapping, got a JSON-encoded string: parse arguments with json.loads() before applying the chat template") -}}
49
+ {%- endif -%}
50
+ {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
51
+ {%- endfor -%}
52
+ {{- "<|tool_call_start|>[" + (tool_calls_ns.tool_calls | join(", ")) + "]<|tool_call_end|>" -}}
53
+ {%- endmacro -%}
54
+
55
+ {%- set ns = namespace(system_prompt="", last_user_index=-1) -%}
56
+ {%- if messages and messages[0]["role"] == "system" -%}
57
+ {%- if messages[0].get("content") -%}
58
+ {%- set ns.system_prompt = parse_content(messages[0]["content"]) -%}
59
+ {%- endif -%}
60
+ {%- set messages = messages[1:] -%}
61
+ {%- endif -%}
62
+ {%- if tools -%}
63
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
64
+ {%- for tool in tools -%}
65
+ {%- if tool is not string -%}
66
+ {%- set tool = tool | tojson -%}
67
+ {%- endif -%}
68
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
69
+ {%- if not loop.last -%}
70
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
71
+ {%- endif -%}
72
+ {%- endfor -%}
73
+ {%- set ns.system_prompt = ns.system_prompt + "]" -%}
74
+ {%- endif -%}
75
+ {%- if ns.system_prompt -%}
76
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
77
+ {%- endif -%}
78
+ {%- for message in messages -%}
79
+ {%- if message["role"] == "user" -%}
80
+ {%- set ns.last_user_index = loop.index0 -%}
81
+ {%- endif -%}
82
+ {%- endfor -%}
83
+ {%- for message in messages -%}
84
+ {{- "<|im_start|>" + message.role + "\n" -}}
85
+ {%- if message.role == "assistant" -%}
86
+ {%- generation -%}
87
+ {%- set keep_thinking = preserve_thinking or loop.index0 > ns.last_user_index -%}
88
+ {%- set thinking = message.thinking or message.reasoning or message.reasoning_content -%}
89
+ {%- set thinking = thinking if thinking is string else "" -%}
90
+ {%- if thinking and keep_thinking -%}
91
+ {{- "<think>" + thinking + "</think>" -}}
92
+ {%- endif -%}
93
+ {%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
94
+ {%- set _has_cfm = false -%}
95
+ {%- set content = "" -%}
96
+ {%- if message.get("content") -%}
97
+ {%- set content = parse_content(message.content) -%}
98
+ {%- endif -%}
99
+ {%- if not keep_thinking and "</think>" in content -%}
100
+ {%- set content = content.split("</think>")[-1] | trim -%}
101
+ {%- endif -%}
102
+ {%- if content.endswith(_cfm_tag) -%}
103
+ {%- set _has_cfm = true -%}
104
+ {%- set _trunc_len = (content | length) - (_cfm_tag | length) -%}
105
+ {%- set content = content[:_trunc_len] -%}
106
+ {%- endif -%}
107
+ {{- content -}}
108
+ {%- if message.tool_calls -%}
109
+ {{- render_tool_calls(message.tool_calls) -}}
110
+ {%- endif -%}
111
+ {%- if _has_cfm -%}
112
+ {{- _cfm_tag -}}
113
+ {%- endif -%}
114
+ {{- "<|im_end|>\n" -}}
115
+ {%- endgeneration -%}
116
+ {%- else %}
117
+ {%- if message.get("content") -%}
118
+ {{- parse_content(message["content"]) -}}
119
+ {%- endif -%}
120
+ {{- "<|im_end|>\n" -}}
121
+ {%- endif %}
122
+ {%- endfor -%}
123
+ {%- if add_generation_prompt -%}
124
+ {{- "<|im_start|>assistant\n" -}}
125
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Lfm2VlForConditionalGeneration"
4
+ ],
5
+ "auto_map": {},
6
+ "bos_token_id": 124894,
7
+ "do_image_splitting": true,
8
+ "do_resize": true,
9
+ "downsample_factor": 2,
10
+ "dtype": "bfloat16",
11
+ "encoder_patch_size": 16,
12
+ "eos_token_id": 124900,
13
+ "freeze_language_model": false,
14
+ "freeze_multi_modal_projector": false,
15
+ "freeze_vision_tower": false,
16
+ "image_token_id": 124907,
17
+ "keep_trainable_parameters_fp32": true,
18
+ "language_model_lr_multiplier": 1.0,
19
+ "lfm2_attention_backend": "flash_varlen",
20
+ "lfm2_attention_fusion": "fused_linear",
21
+ "lfm2_flash_varlen_blhd_fastpath": false,
22
+ "lfm2_frozen_input_grad_only_linear": true,
23
+ "lfm2_mlp_fusion": "triton_swiglu",
24
+ "lfm2_rmsnorm_fusion": "none",
25
+ "lfm2_short_conv_frozen_recompute_in_proj": 0,
26
+ "lfm2_torch_compile_clone_outputs": false,
27
+ "lfm2_torch_compile_disable_cudagraphs": true,
28
+ "lfm2_torch_compile_dynamic": true,
29
+ "lfm2_torch_compile_fullgraph": false,
30
+ "lfm2_torch_compile_layers": "none",
31
+ "lfm2_torch_compile_mlp": false,
32
+ "lfm2_torch_compile_mode": "reduce-overhead",
33
+ "lfm2_vl_direct_image_merge_by_shape": true,
34
+ "lfm2_vl_forward_dtype": "bf16",
35
+ "lfm2_vl_frozen_vision_chunk_size": 2048,
36
+ "lfm2_vl_grouped_image_projector": true,
37
+ "lfm2_vl_grouped_vision_by_patch_count": false,
38
+ "lfm2_vl_grouped_vision_by_shape": true,
39
+ "lfm2_vl_inplace_image_merge": true,
40
+ "lfm2_vl_siglip_packed_vision": true,
41
+ "lfm2_vl_torch_compile_vision_encoder": true,
42
+ "lfm2_vl_torch_compile_vision_encoder_mode": "whole",
43
+ "lm_head_loss_mask_only": true,
44
+ "max_image_tokens": 256,
45
+ "max_num_patches": 1024,
46
+ "max_pixels_tolerance": 2.0,
47
+ "max_tiles": 10,
48
+ "min_image_tokens": 64,
49
+ "min_tiles": 2,
50
+ "model_type": "lfm2_vl",
51
+ "pad_token_id": 124893,
52
+ "projector_bias": true,
53
+ "projector_hidden_act": "gelu",
54
+ "projector_hidden_size": 2048,
55
+ "projector_lr_multiplier": 1.0,
56
+ "projector_use_layernorm": false,
57
+ "siglip2_layernorm_fusion": "liger",
58
+ "text_config": {
59
+ "architectures": [
60
+ "Lfm2ForCausalLM"
61
+ ],
62
+ "block__name_mlp": "parallel_mlp_merged",
63
+ "block_auto_adjust_ff_dim": false,
64
+ "block_dim": 2048,
65
+ "block_ffn_dim_multiplier": 1.0,
66
+ "block_ffn_te_autocast": false,
67
+ "block_ffn_use_quantized_params": false,
68
+ "block_mlp_init_scale": 1.0,
69
+ "block_multiple_of": 256,
70
+ "block_norm_eps": 1e-05,
71
+ "block_out_init_scale": 1.0,
72
+ "block_use_swiglu": true,
73
+ "block_use_xavier_init": true,
74
+ "bos_token_id": 124894,
75
+ "conv_L_cache": 3,
76
+ "conv_bias": false,
77
+ "conv_dim": 2048,
78
+ "conv_use_xavier_init": true,
79
+ "dtype": "bfloat16",
80
+ "eos_token_id": 124900,
81
+ "full_attn_idxs": null,
82
+ "hidden_size": 2048,
83
+ "initializer_range": 0.02,
84
+ "intermediate_size": 10752,
85
+ "layer_types": [
86
+ "conv",
87
+ "conv",
88
+ "full_attention",
89
+ "conv",
90
+ "conv",
91
+ "full_attention",
92
+ "conv",
93
+ "conv",
94
+ "conv",
95
+ "full_attention",
96
+ "conv",
97
+ "conv",
98
+ "conv",
99
+ "full_attention",
100
+ "conv",
101
+ "conv",
102
+ "conv",
103
+ "full_attention",
104
+ "conv",
105
+ "conv",
106
+ "conv",
107
+ "full_attention",
108
+ "conv",
109
+ "conv",
110
+ "full_attention",
111
+ "conv",
112
+ "conv",
113
+ "full_attention",
114
+ "conv",
115
+ "conv"
116
+ ],
117
+ "lfm2_attention_backend": "flash_varlen",
118
+ "lfm2_flash_varlen_blhd_fastpath": false,
119
+ "lfm2_frozen_input_grad_only_linear": true,
120
+ "max_position_embeddings": 32768,
121
+ "mm_config_image_embedder": {
122
+ "activation_checkpointing_layer_stride": 0,
123
+ "attn_implementation": "sdpa",
124
+ "cuda_sync_points": [],
125
+ "downsample": 2,
126
+ "encoder_load_balance": false,
127
+ "hidden_dim": 2048,
128
+ "hidden_state_index": -1,
129
+ "layer_norm": false,
130
+ "max_batch_size": 1024,
131
+ "pretrained_model_name_or_path": "google/siglip2-so400m-patch16-naflex",
132
+ "set_activation_checkpointing": false,
133
+ "use_image_special_tokens": true,
134
+ "use_pooling_head": false,
135
+ "use_slice_special_tokens": false,
136
+ "use_torch_pixel_unshuffle": false
137
+ },
138
+ "model_type": "lfm2",
139
+ "norm_eps": 1e-05,
140
+ "num_attention_heads": 32,
141
+ "num_heads": 32,
142
+ "num_hidden_layers": 30,
143
+ "num_key_value_heads": 8,
144
+ "output_softcap": 0.0,
145
+ "pad_token_id": 124893,
146
+ "rope_parameters": {
147
+ "rope_theta": 1000000.0,
148
+ "rope_type": "default"
149
+ },
150
+ "tie_word_embeddings": true,
151
+ "use_cache": true,
152
+ "use_pos_enc": true,
153
+ "vocab_size": 128000
154
+ },
155
+ "tie_word_embeddings": true,
156
+ "tile_size": 512,
157
+ "transformers_version": "5.17.0",
158
+ "use_image_special_tokens": true,
159
+ "use_thumbnail": true,
160
+ "vision_config": {
161
+ "attention_dropout": 0.0,
162
+ "dtype": "bfloat16",
163
+ "hidden_act": "gelu_pytorch_tanh",
164
+ "hidden_size": 1152,
165
+ "intermediate_size": 4304,
166
+ "layer_norm_eps": 1e-06,
167
+ "model_type": "siglip2_vision_model",
168
+ "num_attention_heads": 16,
169
+ "num_channels": 3,
170
+ "num_hidden_layers": 27,
171
+ "num_patches": 256,
172
+ "patch_size": 16,
173
+ "vision_use_head": false
174
+ },
175
+ "vision_tower_lr_multiplier": 1.0
176
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 124894,
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 124900
7
+ ],
8
+ "output_attentions": false,
9
+ "output_hidden_states": false,
10
+ "pad_token_id": 124893,
11
+ "repetition_penalty": 1.0,
12
+ "temperature": 0.2,
13
+ "top_k": 50,
14
+ "transformers_version": "5.17.0",
15
+ "use_cache": true
16
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c7ad3e0d933292a620338ba03fd83eb22ce6ced705f45f547a5845eaa0fba78
3
+ size 6247065504
processor_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "data_format": "channels_first",
4
+ "do_image_splitting": true,
5
+ "do_normalize": true,
6
+ "do_pad": true,
7
+ "do_rescale": true,
8
+ "do_resize": true,
9
+ "downsample_factor": 2,
10
+ "encoder_patch_size": 16,
11
+ "image_mean": [
12
+ 0.5,
13
+ 0.5,
14
+ 0.5
15
+ ],
16
+ "image_processor_type": "Lfm2VlImageProcessor",
17
+ "image_std": [
18
+ 0.5,
19
+ 0.5,
20
+ 0.5
21
+ ],
22
+ "max_image_tokens": 256,
23
+ "max_num_patches": 1024,
24
+ "max_pixels_tolerance": 2.0,
25
+ "max_tiles": 10,
26
+ "min_image_tokens": 64,
27
+ "min_tiles": 2,
28
+ "resample": 3,
29
+ "rescale_factor": 0.00392156862745098,
30
+ "return_row_col_info": true,
31
+ "size": {
32
+ "height": 512,
33
+ "width": 512
34
+ },
35
+ "tile_size": 512,
36
+ "use_thumbnail": true
37
+ },
38
+ "processor_class": "Lfm2VlProcessor"
39
+ }
run.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "envs": [
3
+ "mcq",
4
+ "chaosnli",
5
+ "cifar10",
6
+ "civilcomments",
7
+ "stsb",
8
+ "folktables",
9
+ "camelyon17"
10
+ ],
11
+ "model": "LiquidAI/LFM2.5-VL-3B",
12
+ "name": "mix7-3B-s1",
13
+ "phase": "p2",
14
+ "seed": 1,
15
+ "lr": 0.0001,
16
+ "batch": 32,
17
+ "lora_rank": 32,
18
+ "micro": 4,
19
+ "steps": 10500,
20
+ "warmup": 50,
21
+ "eval_every": 300,
22
+ "dev_cap": 1500,
23
+ "soft_upsample": 10,
24
+ "env_sampling": "sqrt",
25
+ "device": "cuda:0",
26
+ "best_dev_ce": 0.4266407826892831,
27
+ "best_step": 3600
28
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8096ecb9f54599d756c8de728a598a340bc1e43c0deb77ddd62456c38349fcee
3
+ size 17905750
tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|startoftext|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|im_end|>",
6
+ "is_local": false,
7
+ "legacy": false,
8
+ "local_files_only": false,
9
+ "max_length": null,
10
+ "model_max_length": 1000000000000000019884624838656,
11
+ "pad_to_multiple_of": null,
12
+ "pad_token": "<|pad|>",
13
+ "pad_token_type_id": 0,
14
+ "padding_side": "left",
15
+ "processor_class": "Lfm2VlProcessor",
16
+ "tokenizer_class": "TokenizersBackend",
17
+ "use_default_system_prompt": false
18
+ }