Jev can now see images. Can you build a similar model and run it on your laptop? Yes.
Fabio Severino
CTO & Founder
A decision model chooses between given answers and says how confident it is, instead of writing text. Here we explain 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 cannot be downloaded or run in-house, and TypeSafe describes 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 must 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 error-free version, verified 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, deliberate thinking (“system 2”). TypeSafe uses the same distinction for AI models: Jev is a System 1 model, which chooses instantly between given answers; chat models are System 2, because they reason by writing. What we find most interesting is that a System 1 can be obtained from a fairly small System 2 model, without any training. Below we reconstruct 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 between given answers and gives the probability of each | Writes the answer: text, reasoning, code |
| Type of question | Closed: the possible answers are listed in advance | Open: the answer can be anything |
| Model work | A single pass, no words generated | One pass for every word generated, from tens 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 | Must be read, interpreted and validated |
| Uncertainty | A number, which can be calibrated and compared with a threshold | Stated in words, if asked |
| Limits | Cannot answer outside the options and does not 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 it is asked to write |
The two types are not in competition. In an automated process, a System 2 model handles open tasks, such as summarizing a document or writing a reply; a System 1 model handles the many small decisions around them, such as 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 an extra sentence shows up. 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 add up to one. The code takes the highest, or compares it with a threshold before acting.
| LLM | Decision model | |
|---|---|---|
| What it produces | Text, one word after another | A probability for each option |
| Words generated | Tens or hundreds | None |
| Valid answer | Needs checking | Always, by construction |
| How confident it is | It says so in words, if you ask | It is a number, and it can be calibrated |
How we built it
1. Start from a method that works, without training
We did not 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 that we could compare results; and the questions we used to calibrate the probabilities. We wrote the code from scratch, with the help of an AI coding assistant, because Cygnet runs on NVIDIA GPUs and we wanted a MacBook. Cygnet works on text only: images, which were the goal of our work, are our addition (steps 4, 7 and 8).
The idea is simple. Before writing each word, a language model assigns a score to every possible word 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 at lower precision (4 bits), 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, summing to 1
p = softmax(scores)
2. Every letter exists twice
The model does not read letters but “tokens”, entries in a fixed dictionary. In Gemma 4’s dictionary the letter A appears twice, as two different entries, and the model can split A’s probability between them. If we read only one, we would underestimate A. We add them together, and to find them all we look for every dictionary entry that is spelled 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 numbers add up.
3. The first result was wrong, and the generated text did not 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 in the vocabulary at every position in the text, while we only needed the last one, where the answer goes. All it took was asking: 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.
When we moved to the 12B, correct answers dropped to 65 out of 120, almost all “A”. When asked to write normally, the model answered well, so the weights were fine; and the 8-bit version did even worse, so it was not the compression. The problem was in the way we were calling it.
Along with the text, the library returns a list indicating 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, each word could also see the following ones, and the computation at the last position came out skewed. The writing test did not catch it, because it used the library’s own function, which does not pass that parameter. Removing it took the 12B from 65 to 115 correct answers out of 120.
# before: all-ones mask 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 towards one letter shows up immediately. On the full benchmark our version answers 193 out of 231 questions 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 one piece at a time
With images, a similar error appeared. We built a control test: two photos, before and after a repair, to be compared. The model answered “worse” even when we swapped the two photos, so it was not comparing them. Gemma 4 splits each image into many pieces and looks at them all together, not one after the other like words. To do this it needs to know which pieces of the message are image. This information was being lost in the function we used to call the model, and the image was read like text, in sequence. Calling the model in two steps, as the library does when it generates text, gets the information 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 a way out
The first test on a real photo is the label of a bottle of laboratory methanol, 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 instead of the photo.

| Rule | Answer | Calibrated | Raw |
|---|---|---|---|
| 1. Flammables in the flammables cabinet, toxics in the toxics cabinet, everything else on the shelf | flammables cabinet | 0.58 | 0.92 |
| 2. Anything with the skull goes in the toxics cabinet, even if flammable | toxics cabinet | 0.45 | 0.90 |
| 3. Same as 2, with a blank sheet instead 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 for the blank sheet. Under rule 1 the product is both flammable and toxic, and the model leaves 0.30 to the toxics cabinet.
The answers are correct, but the “raw” column shows a flaw: the model claims to be very confident in all three cases, and almost certain when faced with the blank sheet. With numbers like these, a threshold cannot tell confident cases from uncertain ones. The usual fix is called “temperature”: a single number that softens all the probabilities, chosen on questions whose answers are already known. The right value is not 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 correct 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 fix, the gap between stated confidence and actual results was almost twice as large.
# 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 that is needed. The probabilities only hold relative to the options offered: if you ask “cat, dog or horse?” and the photo shows an airplane, 100% still ends up among the three animals. That is why every question can include the human_review option, “ask a person”. With the blank sheet, that is the one chosen; without it, the model would have pointed to a cabinet. This test also gave us a rule of method: every test must be repeated with the blank sheet, because if the answer does not change without the image, it is being suggested by the descriptions of the options.
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 were useful, and we discarded one.
- Weights pinned in memory. With the Mac’s memory under pressure, the system was moving 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 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 on, the time drops from 2.5 to half a second, with the same probabilities.
- Fewer tokens for the image: discarded. Gemma 4 can describe an image with fewer tokens. With 140 instead of 280 the decision was 35% faster, but in the before/after comparison confidence dropped from 0.994 to 0.651; with 70 the answer became wrong.
7. Where the images end up 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 an option can be defined with an example image instead of words.
This is where the problem came up, and it had nothing to do with the model. The chat template of the MLX version of Gemma, the code that lays out the message, moved all the images to the beginning and joined the text parts with a space: “Image 1: previous inspection” ended up far from its photo. The answers remained 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 belongs; 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 box, the bounding box around an object[3]. A box is four numbers and our model does not 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 in which column the object starts, in which it ends, in which row it starts and in which it ends. Then we crop the area found plus one cell on each side, enlarge it and repeat. First of all we ask whether the object is there: Jev’s box does not include a “not found” answer.
The first version took the cell boundary as the edge, and the boxes always came out a little too wide: the real edge can be anywhere within the cell, so it is better to take its center. With this fix the box found overlaps the true one by 67% on average (it was 63%), on eight test images where the position was known. Questions on the same grid share the image and use the cache from step 6. It is enough to crop an area or check that an object is where it is expected to be; it does not replace models specialized in finding objects.
9. Connecting it to the Rational AI decision API
The Rational AI platform already has a decision API in the same format as Jev, System One: a state, any images, and a series of questions of the choice, yes/no or score type. A compatible model is registered as a connector and goes through the same controls as the other models: governance, call log, token counting. Our server was missing two things. 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, checking 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 was reading it as empty.
The result, inside Rational AI
To try it out we created a Knowledge, “Decisions on photos”, 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.


| Photo | Which sign? | Visibility | Where? |
|---|---|---|---|
| Give way | give way 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 does not recognize the no entry sign, answers “none” to the position question as well, and at the same time rates the sign as “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 reduces the image to about 270 tokens, and at that scale the sign becomes a few dots. For cases like this, TypeSafe’s documentation suggests cropping and asking again on a portion of the image[2]; that is the next step.

The limits
On a laptop, a decision on an image takes about 2 seconds, half a second for subsequent questions: it is a bit slow. On inexpensive machines with NVIDIA GPUs, such as a DGX Spark or the servers in our cloud, times drop drastically, to 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 answers 10 fewer hard questions correctly out of 231 than the full model. Small details in large photos get missed, as the no entry sign shows, and the results on images come from only a few photos. Finally, Gemma’s license prohibits automated decisions in areas that affect people’s rights[7]: in those cases a person decides, and human_review is there to hand them the case.
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 tested 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 includes 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: anyone building 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. Starting today, the same API also accepts images, with the decision model described in this article.
- Runs on your own machines, even without internet: the data stays with you.
- Same governance and cost controls as the other models.
- Starting 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 by Google DeepMind; the 4-bit version is by mlx-community. Neither is involved in this work.


