The problem we kept running into
A model of two to four billion parameters, running on a laptop or a phone, can explain photosynthesis clearly. The trouble starts when we ask it for something with a shape.
When we asked for a quiz as a web page, the model spent hundreds of tokens on markup, broke the layout, and gave us a different design on every reply. When we asked for JSON instead, a single missing quotation mark destroyed the whole block. After reading a page of sources, the model often answered in the language of the sources and not in the language the person had written in. It placed the correct answer at option B far more often than chance would allow. And quite often it described the flashcards it was about to make, when what we wanted was the flashcards.
These are not faults we can remove by asking more politely. They come with a small model, and a small model is what fits on the devices our users own. We therefore stopped asking the model to do the whole job.
The idea
We divide the work according to what each side does well, and we mediate in both directions.
The model is asked only for meaning, in the smallest description of the content that we can design. Kalon owns everything else: checking, correcting, shuffling, grading, drawing, animating and remembering. Every action the person takes is then encoded back into a short and precise message that the model can act on.
That is where the name comes from. The encoding runs in two directions, from the model to the app and from the person back to the model, and the app sits in the middle as the mediator. We call it the Bi-directional Encoding and Mediation Architecture, or BEMA.
Where it started
BEMA began inside Kalon, and it grew from a single lesson.
In July 2026 we taught Kalon to draw charts natively. The model wrote a small block of data, and Kalon drew the chart itself. This worked far better than asking the model to draw anything, and the pattern stayed with us. In November we rebuilt study cards and quizzes on the same pattern, wrote the design down under the name BEMA, and then carried it to mind maps and slide decks. Econuva, our climate and sustainability learning app, came after that and reuses the approach. We describe what Econuva added near the end of this report.
The sections that follow take the six parts of BEMA in turn, as they exist in Kalon.
Part 1: a compact format, one item per line
The model writes a fenced block, such as a quiz block or a slides block, and puts one small JSON object on each line. The keys are short. A quiz question, for example, carries its type, the question, the options, the index of the correct answer and one sentence explaining why.
Two properties of this format matter to us.
The first is that damage stays local. If a reply is cut short, we lose one item and keep the rest of the set. In a single large JSON document, the same accident loses everything.
The second is that the format streams. Each item can appear on screen as soon as its line is complete. While a deck is being written, the reader sees the newest finished slide, fully drawn, with a quiet note that the next slide is on its way. The reader never sees raw JSON.
The format is also economical. By our estimate, a quiz question in this form costs about 100 tokens, where the same question written as HTML costs about 1,000. We have not yet measured this difference formally, and we return to that point below.
Part 2: mediation, line by line
Every item passes through checks before anyone sees it. We follow one rule here: we are lenient where nothing can go wrong, and strict where a learner could be misled.
Where we are lenient. A model does not always use the names we asked for. We accept keys in any letter case and long names in place of short ones. For slides we accept about forty alternative names for the fields. An answer may arrive as an index counted from zero, an index counted from one, a letter, or the text of the option itself, and we resolve all of these to a single form. Where an index could be read either way, we look at which option the explanation names. If that does not settle the matter, we drop the item.
Where we are strict. A multiple-choice question must have three or four options, and they must be distinct. The answer must be one of them. We reject "all of the above". A question may run to 300 characters, an option to 160 and an explanation to 400. An item that fails these rules is dropped. We never guess at what the model meant when a learner's understanding depends on it.
Where the app does what the model does badly. Small models favour one answer position, so Kalon shuffles the options itself. The shuffle is seeded on the question, which keeps the order the same when the person reopens the chat. Grading happens locally and at once, and duplicate questions are removed.
How a slide is repaired. Slides give us more room to reshape than to reject. If a list of steps has fewer than two items, we draw it as bullets. A slide with six to ten points becomes two slides. A timeline in which one entry lacks its date becomes a list of steps. A figure longer than eight characters is not a headline number, so we turn it into an ordinary point. A deck is capped at 20 slides, and an identical slide that follows its twin is removed.
What happens when nothing survives. If no item passes, we do not show a broken card. The reader sees the reply as ordinary text.
Part 3: fixed templates, drawn by the app
Once the data has passed, it goes into templates that Kalon draws natively, in the same way every time. A study set uses the index card, the quiz card and the score card. The look, the motion, the accessibility and the children's styling are our responsibility, so a small model spends none of its tokens on design.
Slide decks show this division most clearly. The model chooses only the kind of each slide, from thirteen kinds: a title, bullets, a grid, steps, a timeline, an agenda, two columns, a table, a quote, a section break, a number, a set of statistics and a closing slide. The model is never told that layouts exist.
Kalon chooses the rest. It has 26 layout variants and 13 themes, of which ten are fully designed and two are made for children. A planner picks a variant for each slide from the shape of its content, and it follows rules that a designer would follow. A variant is not used on two slides in a row. A section slide is followed by a calm one. A loud slide does not appear near another loud slide. If the person chooses a layout, that choice wins. The plan for a slide depends only on the slides before it, which means the deck does not rearrange itself while it is still being written.
Kalon also chooses the icons. There are 48, and when the model names none, Kalon picks one from the words of the item. No icon repeats within a slide.
Making the text fit
Every slot has a limit. A heading may hold 70 characters and a point 110. A slide may hold five points, speaker notes may run to 600 characters, and a headline figure to eight.
A slide is drawn on a fixed canvas of 1280 by 720 points. For each block of text, Kalon measures the text at the largest type size and steps down until it fits. Body text has three sizes to try, and a title in a designed theme has five. We set the character limits so that the smallest size always fits, and a self-test confirms this by measuring real text in English, German and Hindi.
We never send a sentence back to the model because it is too long. Fitting is the app's job, because the app can measure.
Changing the look costs nothing
Because the words and the design are separate, changing the theme of a finished deck needs no model call. The theme is swapped, the plan is computed again from the same data, and the deck is redrawn. The strip that offers the themes shows the first slide of the person's own deck in each one.
A deck can be presented from the chat, with a presenter view that shows the current slide, the next slide, the notes and a timer. It can be exported as a PDF in which the text remains text, or as a Markdown outline.
Part 4: reading the request before the model does
The first three parts handle what the model writes. The second direction begins before the model has written anything.
Kalon reads the person's message itself. If the message asks for a deck, a quiz, flashcards or a mind map, Kalon adds a short instruction to that one turn. The instruction gives the format, says how many items to write, and tells the model to write them now and not to ask first. It is attached only to the turn that needs it, so it does not sit in every conversation and take up room in the model's limited context. Kalon recognises a request for a deck in eight languages.
Kalon also settles the language. It identifies the language of the person's message on the device, and when the turn carries sources or instructions it tells the model plainly, for example "Reply in English." We found that the looser phrase "the user's language" is misread by small models once they have read a page of sources. For the same reason, when a turn includes sources from the web or from a document, Kalon repeats the person's question after them.
The same reading adjusts the request for the reader. For a child, the instruction asks for fewer slides, headings of at most five simple words, and an ending that poses a question or an activity.
Part 5: the return channel
A quiz is not finished when it has been drawn. The person answers it, and what they do should reach the model.
In BEMA, the person's actions are encoded back as plain and exact text. When someone taps Go over my answers, Kalon sends the model a list of the questions that were missed, with the option that was chosen and the option that was correct. When someone taps Explain this on a flashcard, the message carries the front and the back of that card. On a mind map, Ask about this names the branch and the branch above it.
As a result, the model never has to infer the state of the screen. It is told what happened in a form it can use.
Part 6: memory of the interaction
Progress is stored with the chat. Kalon keeps the attempts, the cards sorted as known or to be seen again, and the live position in each set, so that closing the app and opening it later returns the person to where they stopped.
A question answered wrongly is asked once more, three questions later. Mastery of a topic is computed from the last ten answers, with recent answers weighted more heavily. We also try to be honest in how we report it. With fewer than five answers, Kalon says "Just started" and makes no further claim.
For decks, Kalon remembers the theme, any layouts the person chose and the slide they were on.
What we carried into Econuva
Econuva teaches climate and sustainability, and it needed the same abilities for a different kind of work, namely whole courses that a learner can ask the model to draft. It talks to Kalon over Kalon's local API on the same machine. We reused BEMA there and extended it in four ways.
The model is told what went wrong. When a drafted lesson fails its checks, Econuva returns the model's own reply together with the reasons and asks for the lesson again. Each step is allowed three attempts in all. If a lesson is still incomplete after that, we keep the best attempt and fill a missing level from the nearest level the model did write.
Sources come from a fixed list. The model is given eleven sources by identifier, title and publisher, and it is asked to cite identifiers only. It is never shown a web address and is told never to write one. Any citation outside the list is dropped.
A key figure must come from the lesson. A large number on a slide persuades easily and is easy to invent, so Econuva does not ask the model for one. It looks in the lesson's own text for a number with a unit, and it builds a key-figure slide only when it finds one.
Nothing trimmed is lost. Econuva has fifteen layouts and thirty designs, and it writes PowerPoint files directly. When text is cut to fit a slide, the full text goes into the speaker notes of that slide.
Econuva also fills fifteen country slots in the lessons we ship, such as the capital or the national weather service, from a pack of facts for each of 195 countries. No model is involved in that step. Where a fact can come from a file, we do not ask a model for it.
What is tested, and what we have not measured
The parts in Kalon are covered by self-tests that run before every commit to the Mac app. They check several things. The format we show the model can be read back by our own parser. The lenient readings all resolve to the same result. The limits split, clip and cap as described. A half-written line is left out while a reply is streaming. Text fits at the smallest type size in three languages. The planner gives the same plan every time and obeys its rules. A separate render test draws every fitting layout in every theme and checks that the text has a contrast of at least 3 to 1 against the ground beneath it.
We have not yet measured BEMA against the alternative, and we want to be clear about that. Our plan is to compare replies with and without BEMA on Gemma 4 at two and four billion parameters and on Qwen 3.5 at four billion. We will measure the share of items that are valid and can be drawn, the bias in the position of the correct answer before and after the shuffle, the tokens and the time to the first drawn item against asking for HTML, the rate of replies in the wrong language with and without the explicit language line, and how often the model talks about the task when it should be doing it. Until those results exist, the figures in this report are limits and counts from our code, and the token comparison in Part 1 is an estimate.
Limitations we accept for now
- Slides have no return channel yet. Quizzes, flashcards and mind maps send the person's actions back to the model. A deck does not.
- Deck text cannot be edited in place. A person can change the theme and the layout of a slide, but they cannot yet change its words or the order of the slides.
- Review is not spaced. Cards are sorted into known and to be seen again, and a missed question returns once. We do not yet schedule review over days.
- Decks export as PDF and as an outline. Kalon does not yet write these decks as PowerPoint files, although Econuva does.
- Study progress is not yet in backups.
- The phone asks for less than the Mac. On iPhone and iPad, Kalon asks for decks and mind maps. It can draw a quiz or a set of flashcards, but it does not yet ask the model for them.
- Nothing checks that a sentence is true. BEMA can keep a model from inventing an answer option, a source or a headline figure. It cannot tell whether an explanation the model wrote is correct.
How BEMA relates to other approaches
Several existing techniques address parts of this problem. JSON modes and structured outputs constrain the shape of a reply. Grammar-constrained decoding, which Kalon already uses for tool calls, constrains it token by token. Function calling gives the model a schema to fill. Generative interfaces let the model choose components.
BEMA differs from these in where it places the effort. It does not try to make the model's output perfect. It assumes that the output will be imperfect and arranges matters so that the imperfection is cheap: the data arrives one line at a time, each item is judged on its own, the app owns the grading and the fairness, the request and the language are settled before the model begins, and what the person does comes back in a form the model can use.
Why this suits the edge
Every product that runs a model on the device meets the same question sooner or later. The model is capable, private and free to run, but it is unreliable about form.
One answer is to wait for a larger model, which needs a larger machine. The other is to ask the small model only for what it does well, and to build the remainder as ordinary software: a precise request going in, a careful reader coming out, and templates that are the same every time. We chose the second answer because it runs on the machine that is already in the room.
Status
BEMA is in the Kalon we ship. Charts, quizzes, flashcards, mind maps and slide decks all use it on the Mac, and decks and mind maps use it on iPhone and iPad. Econuva uses it for drafted courses, tutor decks, flashcards and quizzes. The measurements described above are the next piece of work, and we will publish them when we have them.