File size: 11,490 Bytes
347abca
 
 
 
 
 
 
 
 
 
 
6a4ff03
347abca
c491ec5
 
a2390c7
 
 
347abca
566a5b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ed6c32
 
 
 
 
 
 
 
b261ce5
 
2ed6c32
 
 
db5ccd0
2ed6c32
 
 
 
 
 
 
467991c
 
 
 
1a398e2
 
 
 
c63723a
 
 
 
467991c
 
 
 
b2b0a94
 
347abca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a4ff03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e112dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a4ff03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e112dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a4ff03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e112dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a4ff03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347abca
 
 
 
 
 
42792c1
ed46dec
 
 
 
36c38cc
ed46dec
 
 
 
d510f78
7dd82d8
 
ed46dec
1527568
 
467991c
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
---
library_name: transformers
license: gemma
base_model: google/gemma-4-12B
pipeline_tag: text-classification
tags:
  - custom_code
  - gemma4
  - typed-decisions
---

# System One Model (using Gemma 4 12B)

Using encoder and decoder from `google/gemma-4-12B` with its 262k-token
language-model head replaced by a low dimentional vector
that outputs one logit per answer. The forward pass gives the 26 logits.
Questions (`noul`, `choice`, `score`) are answered by softmax
over the logits for each question.

## Benchmark on RTX 5090

Median latency is **34.1ms** for a warm single-question decision.

```
Warm single-question decisions (latency_bench, 55 calls):
    p50  34.1ms
    p95  35.0ms
    max  36.3ms

Prefix cache (8 endings):
    decisions changed:    0 of 8
    batched vs unbatched: 64.3ms vs 270ms

5-question request: 166ms
```

## Comparison: Strands Decider 2B and the hosted Jev API

Same 39 labelled cases (15 `noul`, 12 `choice`, 12 `score`) sent through
`/v1/systemone` schema to each system. Local models ran on an Apple
Silicon Mac (64 GB, MPS, bf16)

| metric | this model (Gemma 4 12B, local) | [Strands Decider 2B v19](https://strandsagents.com/blog/introducing-strands-decider/) (local) | [TypeSafe Jev API](https://docs.typesafe.ai/introduction/quickstart) (hosted) |
|---|---|---|---|
| Mario | 5/5 | 5/5 | 5/5 |
| Tetris | 40/40 | 40/40 | 40/40 |
| `noul` accuracy | 15/15 | 15/15 | 15/15 |
| `noul` Brier (lower is better) | 0.000003 | 0.0338 | 0.00035 |
| `choice` accuracy | 11/12 | 12/12 | 12/12 |
| `score` accuracy | 11/12 | 5/12 | 12/12 |
| `score` mean error (levels) | 0.09 | 0.48 | 0.004 |
| 1-question p50 latency | 117 ms | 96 ms | 144 ms |
| 3-question p50 latency | 332 ms | 121 ms | 164 ms |
| Size | ~24 GB | ~2B params | n/a |

Test suite: 141 passed. Small hand-written sample

## Doom played by the model.

<video controls width="640" src="https://huggingface.co/stephenlb/system-one-model/resolve/main/typesafe-replica-doom-game-only.mp4"></video>

## Tetris played by the model.

<video controls width="640" src="https://huggingface.co/stephenlb/system-one-model/resolve/main/tetris.mp4"></video>

## Super Mario Bros. World 1-1 played by the model.

<video controls width="640" src="https://huggingface.co/stephenlb/system-one-model/resolve/main/mario-world-1.mp4"></video>

## Flappy Bird played by the model.

<video controls width="640" src="https://huggingface.co/stephenlb/system-one-model/resolve/main/jev-system-one-replica-flappy-bird.mp4"></video>

## Model API

Requires `transformers>=5.17`. The repo ships custom code, so pass
`trust_remote_code=True`.

```python
from transformers import AutoModelForMultimodalLM, AutoTokenizer

repo = "stephenlb/system-one-model"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForMultimodalLM.from_pretrained(
    repo, trust_remote_code=True, dtype="bfloat16", device_map="auto"
)

result = model.system_one(
    tokenizer,
    state="I was charged twice for order A-104.",
    questions={
        "refund": {"type": "noul", "instructions": "Does the text request a refund?"},
        "team": {
            "type": "choice",
            "instructions": "Which team should handle this?",
            "criteria": {"billing": "Charges", "returns": "Refunds"},
        },
    },
)
print(result["answers"])
```

## Pipeline API

```python
from transformers import pipeline

pipe = pipeline("system-one", model=repo, trust_remote_code=True, dtype="bfloat16", device_map="auto")
print(pipe({"state": "I was charged twice.", "questions": {...}}))
```

## Output

```json
{"answers": {
  "refund": {"type": "noul", "noul": 0.93},
  "team": {"type": "choice", "choice": "billing",
           "probabilities": {"billing": 0.97, "returns": 0.03}, "confidence": 0.8},
  "urgency": {"type": "score", "score": 3.1, "legend": {"0": "..."},
              "probabilities": {"0": 0.0, "1": 0.1}, "confidence": 0.5}}}
```

`noul` is the probability of yes. `choice` returns the top label with
probabilities per option. `score` returns the expected level over an ordered
`criteria` list. Pass `temperature=` (default 0.7) to sharpen or soften.

## Examples

Outputs below are real results from this model (pipeline defaults, temperature 0.7).

### `noul`: yes/no probability

`noul` is the probability the answer is yes. Ask several yes/no questions about
one text in a single call.

```python
pipe({
    "state": "Please cancel my subscription and refund this month's charge.",
    "questions": {
        "refund": {"type": "noul", "instructions": "Does the text request a refund?"},
        "cancel": {"type": "noul", "instructions": "Does the text ask to cancel a subscription?"},
        "sports": {"type": "noul", "instructions": "Does the text talk about sports?"},
    },
})["answers"]
# {"refund": {"type": "noul", "noul": 0.9996},
#  "cancel": {"type": "noul", "noul": 0.9998},
#  "sports": {"type": "noul", "noul": 0.0023}}
```

Optional `criteria` overrides the yes/no wording: `{"true": "...", "false": "..."}`.

Another text, different questions: tone and content checks.

```python
pipe({
    "state": "Thanks so much for the quick help, the new dashboard looks great!",
    "questions": {
        "polite": {"type": "noul", "instructions": "Is the text polite?"},
        "complaint": {"type": "noul", "instructions": "Does the text contain a complaint?"},
        "question": {"type": "noul", "instructions": "Does the text ask a question?"},
    },
})["answers"]
# {"polite":    {"type": "noul", "noul": 0.9991},
#  "complaint": {"type": "noul", "noul": 0.0009},
#  "question":  {"type": "noul", "noul": 0.0080}}
```

### `choice`: pick one option

`criteria` maps each option label to a description. You get the top label,
a probability for every option, and a `confidence` (1.0 means all mass on one
option, 0.0 means uniform). Up to 26 options.

```python
pipe({
    "state": "My package says delivered but nothing arrived at my door.",
    "questions": {
        "team": {
            "type": "choice",
            "instructions": "Which team should handle this?",
            "criteria": {
                "billing": "Charges, invoices, payment problems",
                "shipping": "Delivery status, delays, lost packages",
                "returns": "Exchanges, refunds, wrong or damaged items",
            },
        },
    },
})["answers"]
# {"team": {"type": "choice", "choice": "shipping",
#           "probabilities": {"shipping": 0.9977, "returns": 0.0016, "billing": 0.0007},
#           "confidence": 0.984}}
```

Intent classification with four options:

```python
pipe({
    "state": "Can you add a dark mode to the mobile app? My eyes hurt at night.",
    "questions": {
        "intent": {
            "type": "choice",
            "instructions": "What is the intent of the message?",
            "criteria": {
                "bug_report": "Something is broken or not working as expected",
                "feature_request": "Asks for new functionality or an improvement",
                "praise": "Compliments or thanks",
                "question": "Asks how to do something",
            },
        },
    },
})["answers"]
# {"intent": {"type": "choice", "choice": "feature_request",
#             "probabilities": {"feature_request": 0.9781, "bug_report": 0.0094,
#                               "question": 0.0079, "praise": 0.0046},
#             "confidence": 0.907}}
```

### `score`: ordered scale

`criteria` is an ordered list of levels (lowest first, 2 to 26 levels). `score`
is the expected level `sum(i * p_i)`, so 1.94 below means mostly level 2 with a
little level 1. `legend` maps each level to its description.

```python
pipe({
    "state": "The checkout page crashes every time I press Pay and I can't buy anything.",
    "questions": {
        "severity": {
            "type": "score",
            "instructions": "How severe is the reported issue?",
            "criteria": [
                "Cosmetic; no impact to functionality",
                "Broken or degraded feature, but workaround exists",
                "Blocking issue; no workaround exists",
            ],
        },
    },
})["answers"]["severity"]
# {"type": "score", "score": 1.942,
#  "legend": {"0": "Cosmetic; ...", "1": "Broken or degraded ...", "2": "Blocking issue; ..."},
#  "probabilities": {"0": 0.0018, "1": 0.0542, "2": 0.9440}, "confidence": 0.796}
```

A five-point scale on mixed feedback. The distribution is spread out, so
`score` lands between levels and `confidence` is low:

```python
pipe({
    "state": "The delivery was two days late, the box was dented, but the product itself works fine.",
    "questions": {
        "satisfaction": {
            "type": "score",
            "instructions": "How satisfied is the customer overall?",
            "criteria": ["Very dissatisfied", "Dissatisfied", "Neutral", "Satisfied", "Very satisfied"],
        },
    },
})["answers"]["satisfaction"]
# {"type": "score", "score": 1.408,
#  "legend": {"0": "Very dissatisfied", "1": "Dissatisfied", "2": "Neutral",
#             "3": "Satisfied", "4": "Very satisfied"},
#  "probabilities": {"0": 0.1144, "1": 0.5705, "2": 0.1635, "3": 0.0957, "4": 0.0560},
#  "confidence": 0.223}
```

### Mixing types in one call

All questions in a call see the same `state` and run in one batched forward
pass. `state` may also be a dict or list; it is serialized to JSON.

```python
pipe({
    "state": {"customer": "A-104", "message": "The checkout page crashes when I press Pay."},
    "questions": {
        "urgent": {"type": "noul", "instructions": "Does the text express urgency?"},
        "sentiment": {
            "type": "choice",
            "instructions": "What is the sentiment of the text?",
            "criteria": {
                "positive": "Happy or satisfied",
                "neutral": "Factual, no strong emotion",
                "negative": "Unhappy or frustrated",
            },
        },
        "severity": {
            "type": "score",
            "instructions": "How severe is the reported issue?",
            "criteria": ["Cosmetic", "Degraded, workaround exists", "Blocking"],
        },
    },
}, temperature=0.5, include_letter_logits=True)
```

`temperature` below 0.7 sharpens the probabilities; above it, softens them. It
never changes which option wins. `include_letter_logits=True` adds the raw A-Z
logits per question under `letter_logits`.

## Raw logits

```python
enc = tokenizer(prompts, return_tensors="pt", padding=True)  # padding_side="left"
logits = model.letter_logits(enc.input_ids, enc.attention_mask)  # [batch, 26]
```

# Blocks.ai

We needed an open weight model that offered the capabilities of Jev System One Model.
Most common AI Agents require decisions making.
The System One model approach is a great new way to do this.
[Blocks.ai](https://blocks.ai) is the secure network for the Internet of Agents (IoA).
Whether connecting agents to users in your organization or making
your agents available for public use,
Blocks.ai makes your agents securely discoverable and callable
by everyone who needs them most.
[We Rebuilt Jev's API on an Open Model and Used It to Play Doom](https://blocks.ai/blog/jev-open-model-doom).
TypeSafe AI's Jev turns unstructured input into typed decisions and probabilities.
We rebuilt the API with an open model, reached 113ms median latency on an M4 Mac, and used it to play Doom.

# Github Source System One Model

https://github.com/stephenlb/system-one-model