Jev now sees images. Can you build a similar model and run it on your laptop? Yes.
About 19 minutes to read
In brief. A decision model chooses among given answers and says how sure it is, instead of writing text. Here we walk through, step by step, how we built one that also works on images, on a laptop, privately: the choices, the mistakes and how we found them. The code is on our GitHub.
On October 14, TypeSafe released Jev 1.14[1]. Jev is a decision model: you give it a context and a closed list of answers, and it returns a probability for each one. With 1.14 the context can contain images: in the description of the situation, in the question and even among the possible answers[2]. It is a cloud service: the model can’t be downloaded or run in house, and TypeSafe labels the image support as experimental[8][9].
Our first experiment, at the end of September, started from a question: can you build a model like Jev that also works on images, starting from an open model? With two constraints: it has to run on our machines or the customer’s, even without internet, and the data must not leave them. The first tests said yes. The first working prototype took about half an hour; the first version without errors, checked on a public benchmark, about two hours. The release of Jev with images, a few days ago, gave us further confirmation, and we are taking the opportunity to share how we built it.
Psychology distinguishes between fast, intuitive thinking (“System 1”) and slow, reasoned thinking (“System 2”). TypeSafe uses the same distinction for AI models: Jev is a System 1 model, which chooses in an instant among given answers; chat models are System 2, because they reason by writing. What strikes us as most interesting is that a System 1 can be obtained from a small System 2 model, with no training at all. Below we rebuild the steps from the repository history: the choices, the mistakes and how we found them, with the essential code and the measurements before and after each change.
Deep dive: System 1 and System 2 models
| System 1 | System 2 | |
|---|---|---|
| What it does | Chooses among given answers and gives the probability of each | Writes the answer: text, reasoning, code |
| Type of question | Closed: the possible answers are listed beforehand | Open: the answer can be anything |
| Model work | A single pass, no words generated | One pass for every word generated, from dozens to thousands |
| Time and cost | Depend only on the length of the input | Grow with the length of the answer |
| Answer | Always one of the options, in the expected format | Has to be read, interpreted and validated |
| Uncertainty | A number, which can be calibrated and compared to a threshold | Stated in words, if requested |
| Limits | Doesn’t answer outside the options and doesn’t explain its choice | Slower and more expensive; the answer format can vary |
| Examples | Jev, the model in this article | Chat models, including Gemma 4 when you let it write |
The two types don’t compete. In an automated process a System 2 model is for open tasks, like summarizing a document or writing a reply; a System 1 model is for the many small decisions around them, like choosing who to forward a request to or whether a person is needed. In this article the same model does both: Gemma 4 is a System 2 model when it writes, and becomes a System 1 when we read its probabilities instead of letting it write.
What a decision model is
An LLM answers by writing. If you ask it whether an invoice should be paid, it produces a paragraph; if you ask for JSON, it usually produces JSON, and the code that uses it has to read it, validate it and handle the times when an extra sentence comes along. A decision model instead receives the possible answers together with the question, for example “pay”, “send to the CFO”, “reject”, and returns three numbers that sum to one. The code takes the highest one or compares it to a threshold before acting.
| LLM | Decision model | |
|---|---|---|
| What it produces | Text, one word after another | A probability for each option |
| Words generated | Dozens or hundreds | None |
| Valid answer | To be checked | Always, by construction |
| How sure it is | Says so in words, if you ask | It’s a number, and it can be calibrated |
How we built it
1. Start from a method that works, without training
We didn’t train a model. The method comes from Cygnet[5], which had applied it to Gemma 4 on text, starting from an idea by NInfer[4]. From Cygnet we took two things: the prompt, word for word, so we could compare results; and the questions on which we calibrated the probabilities. We wrote the code from scratch, with the help of an AI programming assistant, because Cygnet runs on NVIDIA GPUs and we wanted a MacBook. Cygnet works only on text: the images, which were the goal of our work, we added ourselves (steps 4, 7 and 8).
The idea is simple. Before writing each word, a language model assigns a score to all possible words and then picks one. If the options are called A, B and C and we ask it to answer with a letter, we just read those scores for the three letters and stop there: a single pass of the model, no words written. On the MacBook Pro M1 Max with 32 GB we use MLX, Apple’s library for its chips, with a reduced version of Gemma 4: the model’s numbers are stored with lower precision (4 bit), and it takes up 6.8 GB instead of 24.
# next-token scores, whole vocabulary
logits = model(prompt)[-1]
scores = [logsumexp(logits[ids]) for ids in letter_ids[:n_options]]
# one probability per option, sums to 1
p = softmax(scores)
2. Every letter exists twice
The model doesn’t read letters but “tokens”, entries in a fixed dictionary. In Gemma 4’s dictionary the A appears twice, as two different entries, and the model can split the probability of A between the two. If we read only one, we would underestimate A. We add them up, and to find them all we search the dictionary for every entry that is written exactly “A”.
def label_token_ids(tokenizer):
ids = {letter: [] for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
for token_id in range(len(tokenizer)):
text = tokenizer.decode([token_id])
if text in ids:
# on Gemma 4: two ids per letter
ids[text].append(token_id)
return list(ids.values())
An automated test checks that the math is right.
3. The first result was wrong, and the generated text didn’t show it
The first run on the JevBench benchmark[6] was slow: long questions took tens of seconds. The model was computing scores for all 262,000 tokens of the vocabulary at every position in the text, when we only needed the last one, the position of the answer. We just had to ask for that: an option in mlx-vlm, the library we use to run Gemma 4 with MLX (logits_to_keep=1), limits the computation to that position.
Moving to the 12B, correct answers dropped to 65 out of 120, almost all “A”. When we let it write normally, the model answered well, so the weights were sound; and the 8-bit version did even worse, so it wasn’t the compression. The problem was in the way we were calling it.
Along with the text, the library returns a list that indicates which parts of the request are real and which are padding; we were passing it to the model in the parameter that instead determines what each word can look at. A language model is trained to read in order, looking only at the preceding words. With our mistake every word could also see the following ones, and the computation for the last position came out skewed. The writing test didn’t notice, because it used the library’s own function, which doesn’t pass that parameter. Once we removed it, the 12B went from 65 to 115 correct answers out of 120.
# before: mask of all 1s from the preprocessor, which replaces the causal one
out = model(input_ids, pixel_values, mask=inputs["attention_mask"])
# after: no explicit mask, the model builds the causal one
out = model(input_ids, pixel_values, logits_to_keep=1)
This is where the check we run after every change comes from: 120 questions in two minutes, with a histogram of the letters chosen. A model that writes well can still decide badly, and a skew toward one letter shows up right away. On the full benchmark our version answers 193 questions out of 231 correctly, Cygnet with the full model 203; in 210 cases out of 231 they give the same answer, and the differences are almost all among the hard questions.
4. Images read a piece at a time
With images a similar mistake appeared. We built a control test: two photos, before and after a repair, to compare. The model answered “worse” even when we swapped the two photos, so it wasn’t comparing them. Gemma 4 splits each image into many pieces and looks at them all together, not one after another like words. To do that it needs to know which parts of the message are image. That information was being lost in the function we used to call the model, and the image was read as text, in sequence. By calling the model in two steps, as the library does when it generates text, the information gets through. After the fix the comparison follows the photos: “improved” 0.995 one way, “worse” 1.0 the other.
emb = model.get_input_embeddings(input_ids, pixel_values, **extra)
out = model.language_model(None, inputs_embeds=emb.inputs_embeds,
per_layer_inputs=emb.per_layer_inputs,
# image pieces together
mm_token_type_ids=extra["mm_token_type_ids"],
logits_to_keep=1)
5. Calibrate, and leave an exit
The first test on a real photo is the label of a laboratory methanol bottle, with three pictograms: flame, skull and health hazard. The question is “which cabinet does it go in?”, with different company rules and, as a control, with a blank sheet in place of the photo.
Photo: Mfomich, CC0, via Wikimedia Commons.
| Rule | Answer | Calibrated | Raw |
|---|---|---|---|
| 1. Flammables in the flammables cabinet, toxics in the toxics cabinet, the rest on the shelf | flammables cabinet | 0.58 | 0.92 |
| 2. With the skull it goes in the toxics cabinet, even if flammable | toxics cabinet | 0.45 | 0.90 |
| 3. Same as 2, with a blank sheet in place of the photo | human_review | 0.73 | 1.00 |
The answers follow the rule and the image. The raw probabilities are always high, between 0.90 and 1.00, even in front of the blank sheet. With rule 1 the product is both flammable and toxic, and the model leaves 0.30 to the toxics cabinet.
The answers are right, but the “raw” column shows a flaw: the model declares itself very sure in all three cases, and almost certain in front of the blank sheet. With numbers like these a threshold can’t tell the sure cases from the uncertain ones. The usual fix is called “temperature”: a single number that softens all the probabilities, chosen on questions whose answer is already known. The right value isn’t known in advance, and we found it by trial: we tried 46 values, from 0.5 to 5, on 241 questions prepared by Cygnet, different from the ones we measure on, and kept the one that gave the most probability to the right answers. It came out at 3.7. The effect: when the calibrated model says 0.8, it is right roughly 8 times out of 10. Before the correction the gap between stated confidence and actual results was almost double.
# T from 0.5 to 5.0
grid = [0.5 + 0.1 * i for i in range(46)]
T = min(grid, key=lambda t: mean(-log(softmax(s / t)[gold]) for s, gold in held_out))
The third row of the table shows the second thing you need. Probabilities only hold relative to the options offered: if you ask “cat, dog or horse?” and the photo shows an airplane, 100% still lands on the three animals. That is why every question can include the human_review option, “ask a person”. With the blank sheet that is the choice; without it, the model would have named a cabinet. A rule of method comes from this test too: repeat every test with the blank sheet, because if the answer doesn’t change without the image, the option descriptions are suggesting it.
6. Speed on a laptop
A decision on an image took between 2 and 4 seconds. Before changing anything we measured where the time goes: preparing the prompt and the image about 30 milliseconds, reading the scores 1 millisecond, the rest is the model’s computation on the GPU, about 170 tokens per second for the 12B on this chip. Rewriting the code in a faster language would have changed nothing. Two changes helped, and one we discarded.
- Weights pinned in memory. With the Mac’s memory under pressure, the system moved part of the weights to disk between one decision and the next, and the same decision went from 2.2 to 11 seconds in the same process. By asking MLX to keep the weights in memory for the whole life of the server, the time stays between 2.2 and 2.8 seconds.
- Reusing the shared work. Several questions about the same photo repeat the same parts: instructions, image, context. The model processes that part once, we keep the result (the so-called KV cache) and for each new question it processes only the question. We check that the model reads exactly the same text with or without this reuse. From the second question the time drops from 2.5 to half a second, with the same probabilities.
- Fewer tokens for the image: discarded. Gemma 4 lets you describe an image with fewer tokens. With 140 instead of 280 the decision was 35% faster, but in the before/after comparison confidence fell from 0.994 to 0.651; with 70 the answer became wrong.
7. Where images go in the prompt
To put images in the question and among the answers we followed Jev’s scheme[2]: each image is attached once with a name, and the name can be written anywhere in the request, for example as the description of an option. The server replaces each name with a placeholder and passes the images to the model in the same order. This way you can define an option with an example image instead of in words.
The problem showed up here, and it didn’t come from the model. The chat template of the MLX version of Gemma, the code that lays out the message, moved all the images to the start and joined the text parts with a space: “Image 1: previous inspection” ended up far from its photo. The answers stayed plausible, but a before/after comparison with the “ask a person” option always chose that one. Now we build the message ourselves as a single text part, with the image placeholder exactly where it’s needed; text-only prompts stay identical byte for byte, and the same comparison answers “improved” 0.999 and “worse” 1.0.
8. A bounding box made of closed questions
Jev 1.14 also introduces the box, the rectangle around an object[3]. A box is four numbers and our model doesn’t write numbers, so we derived it from multiple-choice questions. We draw an 8 × 8 grid around the image, with numbered columns and lettered rows in a white margin, and ask which column the object starts in, which it ends in, which row it starts in and which it ends in. Then we crop the zone found plus one cell on each side, enlarge it and repeat. First of all we ask whether the object is there at all: Jev’s box has no “not found” answer.
What the model sees: the photo with the grid, the enlarged area with a new grid, and the final box. Nine questions, 12 seconds; presence of the sign 0.96. Photo: Mx. Granger, CC0, via Wikimedia Commons; grids and box added by us.
The first version took the cell boundary as the edge, and the boxes always came out a bit wide: the real edge can be anywhere in the cell, so it’s better to take its center. With this fix the box found overlaps the true one by 67% on average (it was 63%), over eight test images where the position was known. The questions on the same grid share the image and use the cache from step 6. It’s enough to crop an area or check that an object is where you expect it; it doesn’t replace models specialized in finding objects.
9. Connecting it to Rational AI’s decision API
The Rational AI platform already has a decision API in the same format as Jev, the System One: a state, optional images and a series of questions of type choice, yes/no or score. A compatible model is registered as a connector and goes through the same controls as the other models: governance, call log, token count. Two things were missing from our server. The first was the full format: our endpoint only knew the single-question variant used by the benchmark, and we extended it to multiple questions, images and different types, verifying that on the benchmark’s 231 questions the text read by the model stayed identical. The second came up on the first real call: the platform forwards the request body in chunks (Transfer-Encoding: chunked), without declaring its length, and the server read it as empty.
The result, inside Rational AI
To try it we created a Knowledge, “Photo decisions”, with real photos of labels and signs and a custom view that sends the chosen photo and three questions to the decision API. The following screenshots come from there.
Three questions in one request: toxics cabinet (0.64), flame pictogram present (0.95), high hazard (0.84). 9 seconds, 1,244 input tokens, no words generated. Screenshot of the Rational AI Control Room. Photo: Mfomich, CC0, Wikimedia Commons.
Options defined by images: the official sign icons. Yield 0.97, clear visibility 0.88, position in the center 0.87. Screenshot of the Rational AI Control Room. Photo: Mx. Granger, CC0. Icons: F l a n k e r (stop, CC BY-SA 3.0; no entry, public domain), Mediatus (yield, CC0). Via Wikimedia Commons.
| Photo | Which sign? | Visibility | Where? |
|---|---|---|---|
| Yield | yield 0.97 | clear 0.88 | center 0.87 |
| No entry | none 0.80 | clear 0.70 | none 0.64 |
| No sign | none 0.97 | absent 0.88 | none 0.96 |
On the narrow street the model gets it wrong. It doesn’t recognize the no-entry sign, answers “none” to the position question as well, and meanwhile judges the sign “clear”: the three answers are not consistent with each other. The photo is 1280 × 3556 pixels and the sign takes up a small part of it; the model shrinks the image to about 270 tokens, and at that scale the sign becomes a few dots. TypeSafe’s documentation suggests, for these cases, cropping and asking again on a portion of the image[2]; that is the next step.
The case where it fails: small sign in a very tall photo. Screenshot of the Rational AI Control Room. Photo: International Driving Authority, CC BY-SA 4.0, Wikimedia Commons.
The limits
On a laptop a decision on an image takes about 2 seconds, half a second for the following questions: for some uses it is still slow. On inexpensive machines with NVIDIA GPUs, like a DGX Spark or our cloud’s servers, times drop dramatically, in the order of tens or hundreds of milliseconds. For example, Cygnet’s benchmarks report under 70 milliseconds on datacenter NVIDIA GPUs[5]. The 4-bit version gets 10 fewer hard questions right out of 231 than the full model. Small details in large photos slip by, as the no-entry sign shows, and the image results come from a few photos. Finally, Gemma’s license prohibits automated decisions in areas that touch people’s rights[7]: in those cases a person decides, and human_review is there to hand the case over.
Try it
The code is on our GitHub, under the Apache-2.0 license. It contains no weights: on first launch it downloads Gemma 4 from Hugging Face, about 7 GB. You need a Mac with Apple Silicon; we tried it on an M1 Max with 32 GB.
git clone https://github.com/Rational-AI/rational-decision-model && cd rational-decision-model
uv sync
uv run python -m rmdm.server
curl -s localhost:8009/v1/decisions -d @examples/12-assets-and-several-decisions.json
The repository also has the two-minute check from step 3 (scripts/quick_eval.py) and the calibration script from step 5 (scripts/calibrate.py).
Decisions on images, inside Rational AI
Rational AI has supported the decision API in Jev’s format since September: whoever builds applications on the platform can already ask a compatible model for decisions with probabilities, with the same governance and cost controls as the other models. As of today the same API also accepts images, with the decision model described in this article.
- It runs on your machines, even without internet: the data doesn’t leave.
- Same governance and cost controls as the other models.
- As of today the decision API also accepts images.
Sources
- TypeSafe AI, Jev 1.14, October 14, 2026.
- TypeSafe AI, documentation: Images.
- TypeSafe AI, documentation: Box.
- NInfer, github.com/igorls/ninfer.
- Cygnet, github.com/blockbrain-ai/cygnet-recipe.
- JevBench, github.com/fstandhartinger/jevbench.
- Google, Gemma Prohibited Use Policy.
- Zeli, TypeSafe ships Jev 1.14.0 with a ‘danger zone’ for experimental features.
- Ecosistema Startup, Jev 1.14: TypeSafe abre imágenes y contexto largo.
Gemma 4 is from Google DeepMind; the 4-bit version is from mlx-community. Neither is involved in this work.









