Contents

Close

ESEN

← Projects

SMEV

In development

A small language model that only translates sentences into exact orders, and a system built around it so that it never has to solve the hard part.

The whole technical video, 4 minutes long, looping and silent. Tap it to watch it here with sound, narrated by SMEV itself, in Spanish.

“Activate the alarm on the second tank when it reaches 5 bar.” Anyone who works at a water plant understands the sentence at once, and yet it carries a decision nobody has taken, because the alarm could go off when the pressure rises to 5, when it falls to 5 or for as long as it stays above it. A person asks, or works it out from the context, whereas a machine that guesses can get it right 9 times and wrong the tenth, which tends to be the one that matters.

The usual tool for understanding sentences like that today is a language model, a program that has read vast amounts of text and writes, piece by piece, the most likely continuation of whatever is in front of it. The large ones sit badly in a power grid, a water network or a railway line, because they need a permanent connection that inside a tunnel simply isn’t there and they send the data to someone else’s server when it cannot leave the site. The small ones, which fit on a laptop, have far less room to keep what they have read and share the factory defect of them all, which is that they don’t know when they don’t know, so when a fact is missing they write something that sounds right.

SMEV, the Sistema de Mando con Ejecución Verificada, or command system with verified execution, comes from moving the problem somewhere else. “The solution lies not so much in learning to solve the hard problems, but in making the hard problems easier to solve.” I lift everything hard off the small model and build a system around it in which it never has to solve it, because reliability comes from how little the model is left to decide.

With SMEV you give orders to a facility in plain words, spoken or typed, to log work reports, set alarms on sensors, look up data and operate equipment, and before doing anything it repeats what it is about to do. Inside, it is a translator, which turns a person’s sentence into an exact order for a machine and also passes the message from one piece of equipment into the format of another, while checking, calculating, deciding whether something is allowed and carrying it out are left to programs that make no mistakes and that anyone can inspect. The whole thing fits on a laptop and works offline, with a European, open model that takes up 1.5 GB.

A waiter who doesn’t cook

A waiter who has just started at a restaurant can’t cook or add up the bill, yet he understands what the customer asks for and writes it down properly on the order pad, and in a well run restaurant he needs nothing more, because the dishes come out of the kitchen and the bill comes from the till. He gets by with 3 habits that keep him from ever slipping, saying “we don’t have that” when someone asks for something off the menu, asking “rare or medium?” when the order isn’t clear and reading the order back before taking it to the kitchen.

In SMEV the menu is the facility’s catalogue, the kitchen and the till are the programs and the waiter is the language model, whose only job is to understand the sentence and write it as an order of one of 4 kinds, log, monitor, query or out of scope. The order read back has its own name on the railway, collation, which means repeating an order before carrying it out so that whoever gave it confirms it is the right one.

The division of roles comes from a measurement. Before building anything I took the small model apart, measuring its abilities one by one. It calculated badly, it got lost when chaining steps, to the point of answering 0 out of 40 questions that required linking 4 facts in a row, it chose worse the more tools it had in front of it and it hardly ever noticed that information was missing. The one thing it did well, and always in the same way, was turning a sentence into an order with its fields filled in, and SMEV is built on that ability and on that ability alone. It’s better for it to do fewer things and do them better than to do many things in a mediocre way.

The measurements used queries about a fictitious company and open models with 4,000 and 8,000 million parameters, the numbers that training adjusts and where everything the model knows is stored. Taking the calculation away from the model raised accuracy by between 42 and 67 points, and every tweak to the architecture squeezed a little more out of those untrained models, much like tuning a production car, where a 140 horsepower engine tuned well reaches 170 and never reaches 400 however much you work on it, so the leap had to come from training. A model with 600 million parameters, trained on the laptop for 62.5 minutes, got 99.6% of the queries right, while the untrained 8,000 million model stayed at 54.2% and gave figures with no support in the data up to 9 times out of 10.

An order always follows the same path, from the sentence to the order with its fields, then on to the checks against the catalogue and to the collation, which a program writes and the person confirms by tapping the screen, and only then is it carried out and entered in the log. The catalogue is a file that describes the facility, with its equipment, what each piece measures with its unit and range, the names used for each thing and the commands each piece of equipment accepts, so the model needs to know nothing about the facility and changing facility means changing the file. The demonstration facility never appeared in training, and on it the translator got 100% of the reports and 99.7% of the alarms right.

Querying means counting, listing, seeing the latest entry, finding the equipment with no report, reading a sensor’s current value or asking for a piece of equipment’s status. Logging means dictating a report that starts with “apunta”, Spanish for “note down”, which is saved well formed and with the incident copied word for word, without going through the model. Monitoring means setting an alarm on a threshold, which a separate engine compares with the sensor readings and which can be cleared by voice or from the screen.

A 1.5 GB translator

Now we go down into the engine, part by part, and anyone who would rather stay on the surface can skip ahead to signal 4 knowing only that the translator takes up 1.5 GB, always gives the same answer to the same sentence and carries out nothing that has not cleared 4 barriers.

The translator is Salamandra 2B in its instruct version, the one tuned to follow instructions. The Barcelona Supercomputing Center trained it from scratch, it is published under the Apache 2.0 licence, which lets anyone use and modify it freely, and it learnt from some 12.9 trillion tokens, the pieces of words a model reads with, in 35 European languages. With about 2,000 million parameters it sits at the ceiling I set so that the system fits in the hand or on board a piece of equipment, and I chose it for its size and for sovereignty. European sovereignty and independence are the key. Against Qwen3 with 600 and 1,700 million parameters, it matched them in the system’s language, made up less and understood Catalan and Galician better, although it coped less well with free phrasing in Spanish.

Getting it to write orders in SMEV’s exact form takes fine tuning, a short round of training on top of what it already has, and tuning the whole model means moving its 2,000 million numbers and keeping in memory how each of them has to change, which does not fit on a laptop graphics card. That is why I used LoRA, short for low rank adaptation, in which the base model stays frozen and, next to each of its matrices, the tables of numbers it does its sums with, a correction is trained and added to its result. Low rank means that the correction is the product of 2 very narrow matrices, 16 columns wide here, so instead of retouching a table thousands of rows by thousands of columns, 2 thin strips are trained which, multiplied together, give a correction of the same size. The 9,600 examples came from 60 different facilities, so that it would learn the shape of an order without learning any facility by heart, and the tuning took about 3 and a half hours on a laptop graphics card with 6 GB.

Then comes quantisation, which means storing each of the model’s numbers with less precision so that it takes up less room. The numbers are split into small blocks, each block keeps its own scale and within it each number is rounded to one of 16 steps, the ones that fit in 4 bits, and with the Q4_K_M variant, which owes its Q4 to those 4 bits, the model comes down to 1.5 GB. Rounding always loses something, so I compared the compressed model with the original on 100 orders, and in all 100 they wrote exactly the same thing, letter for letter. It runs on Ollama, an open engine for local models, at temperature 0, and since at each step the model chooses among candidate pieces with their probabilities and the temperature sets how much risk it takes, at 0 it always picks the most likely one and gives the same answer every time to the same sentence.

To stop it writing something that looks like an order and isn’t, with a field that does not exist or a bracket left open, there is grammar constrained output. A grammar, in this sense, is a set of rules saying which strings of symbols make a valid order, and at each step of generation it crosses off the candidate list every piece that cannot continue one, so anything that doesn’t fit can never be written. In 8,181 test requests not a single answer came out that the system could not read.

A well written order can still be wrong, so before it runs it crosses 4 barriers and stops at the first one where it doesn’t add up. The first is evidence, a check taking less than a millisecond that requires every item in the order to be traceable to the words the person said, and whatever isn’t there is asked about instead of filled in. The second is the catalogue, which checks that the equipment exists, that the quantity is measured on that equipment and that the unit and the range fit, like the waiter checking the menu. The third is the rules, which make sure the order doesn’t clash with anything already in place and, when it comes to operating equipment, that whoever gives it has permission and that the moment is safe.

The fourth is the collation. The sentence the person sees is written by a program from what is about to be carried out, without the model touching that text, and the person confirms it by pressing “Correcto” or discards it with “Repita”, correct and repeat, the words used to collate orders on the railway. A program writes it because in a published study a system with a large model asked for confirmation and still stored the wrong rules, since what it showed was not what it was about to carry out.

The wrong orders that survive fall into a few classes of ambiguity, such as the direction of a relation, a “that’s all” at the end of a report, a negation that turns the sentence around or a time left on its own, and the system declares them and asks about them. For alarms I set a single threshold rule, under which an alarm goes off when the reading crosses the threshold, stays on while the reading is on the other side and clears itself when it comes back, so the tank at the start only needs a question when it is unclear which way the pressure is going. With that rule, on sentences the model had not seen, the questions per order fell from 0.78 to 0.41 with no new errors.

If someone asks how many welds have been inspected and the data holds 212, SMEV answers “at least 212 welds inspected; reports from one crew for the last 3 weeks have yet to be loaded”. That is called completeness, knowing whether the data in front of you is all there, and every answer arrives with a label, complete, incomplete or unknown, which a rule in the system turns into words. With complete data it gives the exact figure, and with incomplete data it says “at least” when counting, adding up values that cannot be negative and finding the maximum, because with what is missing those results can only grow, whereas an average could move either way and then it says it doesn’t know. Underneath lies a simple mathematical idea, that if 2 different situations leave the same data in view no algorithm can be right about both, so an observed count is a floor below which the real number cannot lie. The rule lives outside the model because, with the label in front of it, the model still gave exact figures with no basis between 58 and 79% of the time, and applied by the system it stays at 0% by construction. The guarantee, mind you, is only as good as the label.

Close signal 4

The names of the equipment in a new field are learnt from a few examples, and the way people ask, with all its turns of phrase, is far harder, to the point that the untrained 8,000 million model got 82.3% right with terse wording and 32.7% with a colloquial one. So SMEV behaves like a television remote, which doesn’t try to understand every way of asking for more volume and has a button with a picture on it that anyone learns in a moment, and it leads the person towards a language of its own that is short and clear.

To operate equipment I measured 3 ways of understanding orders given in free language. Teaching the model a fifth output, the one for giving orders, made the other 4 kinds of order worse, and the 2 versions of a program placed after the model turned into orders sentences that merely talked about an action without asking for it. All 3 measurements pointed to the shape of the sentence, and the answer lay in how someone who gives orders speaks. “When you give an order, you don’t say ‘to close’ or ‘to open’. You say ‘close’ or ‘open’ because you are giving an order.” SMEV trains the model and also trains the person in what can be said, the same as when a new program comes out or you have to read the instruction manual for an appliance.

Giving orders became a set of fixed form commands read by a program, without going through the model. There are 13 generic commands, the same in any facility, Abre and Cierra (open and close), Arranca and Para (start and stop), Enciende and Apaga (switch on and off), Sube and Baja (raise and lower), Bloquea and Desbloquea (lock and unlock), Activa and Desactiva (enable and disable), and Rearma (reset), always in the imperative and at the start of the sentence, with no synonyms, like the buttons on the remote, and each facility declares which commands each piece of equipment accepts and what they mean there. If someone tries to give an order with a “could you close signal 4?”, nothing is operated and the system shows how it is said, “To give an order, say Close signal 4”. After that come the person’s permission and the safety of the moment, and if there is a risk it is not done, whoever asks, and to go back the opposite command is given. With this design, and without touching the model, it read all 954 commands in the test correctly and turned none of the 1,852 sentences that were not commands into an order.

For sentences that match nothing known there is the guide, which recognises the catalogue words, offers options, completes the order step by step and shows the model sentence. Rewriting the sentence with another model was ruled out once measured, because one with 4,000 million parameters changed the meaning of 1 in every 3 rewritten sentences.

SMEV’s voice is 136 recorded prompts that work for any facility, and it is silent by default. It isn’t a conversation, just a guide. The synthetic voice from the same centre that made Salamandra sounded robotic, and a closed set of sentences can be recorded once and in good quality. To listen, the phone’s dictation turns speech into text, and the system’s name is recognised by how it sounds, requiring the sound “sme” so that similar words, such as the Spanish “ese” or “eso es”, don’t wake it.

Everything is run from a web app served by the laptop itself, with the phone as the remote over a local network that never reaches the internet, and in it a line split into 4 sections shows which barriers the order has cleared. A large screen shows a 3D model of a fictitious 20 km stretch of railway, with a station, points, signals, a viaduct and a tunnel, built by reading the catalogue. When an alarm goes off the camera moves to the equipment that set it off, and the train obeys the signals and the points.

All the tests are sentences generated by program on fictitious facilities, written before the training material and with the success criteria fixed before measuring, and since 2 training runs with the same recipe can differ by up to 8.5 points on some figure, no decision is taken on a single one. With everything in place, the translator takes 0.66 seconds per order on the laptop’s graphics card. It got 99.2% of the queries right with wording it had not seen, without giving a single exact figure when it lacked the data, and with free phrasing it logs and monitors correctly from start to finish around 67% of the time, while the rest is settled by asking or guiding. SMEV was trained in Spanish alone and understands alarms in Catalan and Galician at 99.7%, and Basque, without training, it does not understand.

Fig. 1Console with 4 gates

Drag to turn it.

The translator writes the order and the order crosses 4 gates, evidence, catalogue, rules and read-back, and one that does not add up stays at its gate and goes back to the person as a question.

Links