The models: CarMind R.E.V and E.V#

Both boards carry two on-board models. CarMind E.V is fixed and tested. CarMind R.E.V keeps learning in your car: the board updates part of the model from what your car reports while you drive. The inputs, outputs and files of each are in Model files, and the scores in Model results.

Choose your model#

CarMind E.V

CarMind R.E.V

Status

released in 2.4.0, the default in the 2.5.1 release

new in 2.5.0, improved in 2.5.1, the default on a new board with the firmware from main

Size on the chip

about 89 KB

about 66 KB

Parameters

38,679

19,815

Time per run on the ESP32-S3

about 3.5 ms in the car, 2.9 ms on the bench

about 2.9 ms in the car (median), 2.2 ms on the bench

Learns in your car

the model is fixed. The tank size and fill-up calibration learn with either model

its fuel estimate and an airflow constant that also gives the engine size, so its torque estimate learns your engine too. Plus the tank size and fill-up calibration, like E.V

Steady cruising with your foot on the gas

can be shown as braking

corrected in 2.5.1

Fill-up calibration

yes

yes

Best for

a fixed, tested model

older cars, roughly pre-2020, that have no fuel-rate PID and can lose the airflow (MAF) reading

On the ESP-Mosaico (OpenCarMind EdgeOS 2.1.0, as in 2.0.0 and mossREV 1.2.0)

included, switch in Settings > MODEL

included, the default on a new board

Animated, from CarMind E.V to CarMind R.E.V in seven steps: E.V with 38,679 parameters, 89 KB and 3.5 ms per run. Structured pruning removes whole channels, down to 19,815 parameters. Knowledge distillation, E.V teaching R.E.V. Quantised for the chip: 66 KB and 2.9 ms. Learns in your car: fuel R2 from 0.709 to 0.867 on 31 unseen cars with the airflow hidden. Explainable AI fix: cruising called right on my drives from 10.7 to 87.5 percent. Shrugs off bad data: with 1 percent bad labels fuel R2 stays 0.867, where 2.5.0 fell to 0.696

From E.V to R.E.V in seven steps, each with the number it moved. How each was measured is in the detailed README.

Many older cars do not report their fuel rate, so the board works it out from the airflow sensor. When that reading is missing, a fixed model can only offer its factory estimate. R.E.V learns your car while a fuel-rate or airflow reading is there and uses what it learned when it is not.

To switch, connect the board to the desktop app with its USB cable while the car is parked, open the Board page and pick the model under “On-board model”. The board keeps the choice after a restart, and what R.E.V learned stays on the SD card while E.V runs. More in What R.E.V learns.

Renders of what changes with R.E.V. Board page 5 with CarMind E.V and with CarMind R.E.V, which adds a Learning job. The desktop app's On-board model panel on the Board page and the CarMind R.E.V learning panel on the Fuel page

Renders, not photos, with example values. Left: page 5 with E.V. Middle: page 5 with R.E.V, which adds a third job, “Learning”. Right: the model selector on the app’s Board page and R.E.V’s learning status on its Fuel page.

What the models do#

Animated, CarMind E.V in four steps: five seconds of driving from 10 OBD signals cut into one-second bins, one shared trunk of 1-D convolutions, two heads (a manoeuvre class of stopped, braking, accelerating or cruising, and estimates of brake pressure, torque and fuel rate), and the answer for every OBD row on the road

Both models are small quantised 1-D convolutional networks run by ESP-DL[6]: 8-bit weights and 16-bit activations, which makes them small and fast enough for a microcontroller. With every OBD row the selected model classifies the last 5 seconds and estimates brake pressure, flywheel torque and fuel rate. They were trained on public data, the HCRL Driving Dataset[7] and the Vehicle Energy Dataset[8], plus drives from my own car. Scores on held-out drives and unseen cars are in the detailed README.

The model card puts every step from E.V to the final R.E.V in one table: size, speed, classifier and fuel-learner scores, before and after, with a key to each metric and where it was measured.

How the models are made#

How the models are made: drive data trains E.V with quantisation-aware training. R.E.V starts from E.V's design, is compressed by structured pruning to about half the parameters, fine-tuned with knowledge distillation with E.V as the teacher, quantised to int8 weights and tested on unseen cars

E.V is trained so that the version on the chip scores like the one on a computer. R.E.V starts from E.V’s design, is pruned to about half the parameters, and learns from E.V as its teacher on a wider set of public drives. The training code and data stay in a private repository. The shipped files are in ml/onboard and ml/onboard/rev, and docs/MODEL.md lists their inputs and outputs.

What R.E.V learns#

How CarMind R.E.V keeps learning in the car. The frozen network gives 64 features. Manoeuvre class and brake pressure are fixed, engine torque is a physics estimate sized from the airflow constant, and the fuel rate's read-out is refit on the board and goes live only if it is better on held-back rows. An airflow constant is learned from load and rpm, fill-ups give one calibration factor, and the tank size is learned from the fuel level

The network itself never changes in the car, which protects it from forgetting what it learned in training[9]. Small parts on top of it learn, each only from something the car gives it to check against.

Output

In the car

Learns from

Fuel rate

learns

the car’s own fuel rate, or fuel worked out from the airflow sensor

Airflow constant (also the engine size)

learns

airflow, engine load and rpm while the airflow sensor works

Fill-up calibration, both models

learns

the litres you pump, entered in the app

Fuel tank size, both models

learns

the fuel used against the drop in the fuel level

Engine torque

learns, through the engine size

the energy in the fuel minus friction, using the engine size R.E.V learns. Planned: a learned torque read-out on cars that report torque (see Limitations)

Manoeuvre class

fixed

nothing yet: the car gives no label for it

Brake pressure

fixed

nothing: no car reports it

How R.E.V learns on the board#

Animated, R.E.V's fuel learner in five steps: the network stays frozen and only the 65-weight fuel read-out learns, every label passes a gate that drops implausible ones, unusual labels count less and old drives fade, a refit every 30 windows goes live only if it wins on the last 150, and the learned estimate follows the true fuel rate better than the factory one

The last layer, which turns the network’s features into a fuel rate, is refit from your car’s own readings. A refit goes live only if it beats the current one on recent driving, and the board goes back to the factory version if learning ever makes things worse. Since 2.5.1 the learner ignores implausible readings and gives less weight to unusual ones[10], so a faulty sensor cannot spoil what it learned. When the car reports neither fuel rate nor airflow, the board uses whichever estimate has been most accurate on your car so far and shows it in amber. What R.E.V learned is saved to the SD card while you drive.

Looking inside R.E.V with explainable AI#

On R.E.V’s first drives in my car, the screen said “braking” while I held a steady speed with my foot on the gas. E.V does the same. I opened up R.E.V with explainable-AI methods, Grad-CAM[11] and a probe on its internal features, and found that the network’s features already told cruising from braking. Only the last layer that picks the class had it wrong. Correcting that one layer fixed it, and everything R.E.V had already learned in the car stayed valid.

R.E.V's 64-value embedding of my drives drawn with PCA, with the first and the corrected classifier head side by side. Accelerating, braking and foot-on-gas cruising sit in their own regions. The first head gets most of the cruising region wrong, and the corrected head gets few windows wrong

Each dot is a 5-second window of my driving, placed by what the network sees. The points are the same on both sides. Only the layer that reads them changed. The Grad-CAM maps and the scores are in the detailed README.

How R.E.V got better, step by step#

  1. 2.5.0. R.E.V ships: half of E.V’s size, and it learns your car’s fuel use, airflow and tank in the car.

  2. First drives. The learners worked, and the classifier called steady cruising “braking”.

  3. Explainable AI showed the error was in the classifier’s last layer, not in what the network sees.

  4. A corrected last layer fixed it without touching what R.E.V had learned.

  5. Fault tests showed that a few bad sensor readings could stop the fuel learner.

  6. A fuel learner that shrugs off bad readings, checked on public cars and against two published meta-learning methods. It came out ahead, so it ships in 2.5.1.

The numbers for each step are in the detailed README.

Edge learning: R.E.V picks what to learn#

Edge learning, in preparation. Every second R.E.V scores a window and the board computes its margin, the gap between the two highest class probabilities, and holds the window in a small buffer. About 5 s later a physics judge gives a verdict or stays undecided. When it decided, the board learns from the window if the margin is under a threshold or the board was wrong, with a ridge refit of the class read-out behind a holdout gate. When it did not decide, the board keeps the lowest-margin windows, at most 40 per drive and 5 s apart, on the SD card for a label sheet. The threshold adjusts itself to a learn budget, and a drift alarm raises the budget

R.E.V’s classifier does not learn in the car yet. Edge learning is how I plan to change that, and I am preparing it now. It is active learning that runs on the board itself: the board decides which windows are worth learning from, and which few are worth your time later. Nobody in the car labels anything, and no computer takes part while you drive.

The phrase “edge learning” already exists as a broad term for training models on edge devices[15]. Here I use it as the name for one specific method, four rules built for a microcontroller whose teacher is free, late and sometimes silent.

The teacher is a physics judge. About 5 seconds after a window, what the speed, throttle and rpm did next usually shows whether the car was stopped, braking, accelerating or cruising. Sometimes it cannot tell, and the window stays undecided. ESP-DL runs the network but does not train it[6], so the learning happens in the class read-out, refit by least squares in C, the way the fuel read-out learns today.

The four rules:

  1. Score every window by its margin, m = p₁ − p₂, the gap between the two highest class probabilities. A small gap means R.E.V is torn between two answers, most often braking and cruising. Margin is a standard active-learning score[16], and the board already logs the probabilities in every .ml.csv line.

  2. Keep the learn rate on budget with a threshold that moves itself, \(\tau \leftarrow \tau + \eta\,(b - \mathbf{1}[m < \tau])\). Here b is the share of windows to learn from, η is a small step, and the indicator 1[m < τ] is 1 when a window’s margin is under the threshold. If the board learns too often, the indicator is 1 more than b of the time and τ shrinks. If it learns too rarely, τ grows. It settles where a share b of the margins fall below it. This is Robbins–Monro stochastic approximation[17] with a constant step, so τ keeps following the margins as the car or the driving changes. Žliobaitė et al. move an uncertainty threshold after every decision in a similar way for drifting data streams[18], with a multiplicative step and no target rate. The rule stores two numbers.

  3. Learn from a window when its margin is under τ, or when the judge’s verdict shows the board was wrong. The update is a ridge refit of the class read-out, with a holdout gate and one saved state per car, like the fuel learner.

  4. Keep undecided windows by margin. These are the only windows where a label costs anything, because a person has to give it. The board will write up to 40 per drive to the SD card, at least 5 s apart because windows overlap, and the desktop tools turn them into a label sheet.

To test the rules before writing them for the board, I copied the board’s read-out learner into Python and streamed seven drives from a second car, one R.E.V never trained on, in the order they were driven. It started from the shipped R.E.V. Each window was scored first and learned from afterwards, so no window graded a model that had already seen it.

Rule, at a 10 % learn budget

Judged windows learned

Macro recall over the stream

No learning

0 %

0.857

Learn every judged window (stopped ones 1 in 10, as on the board)

56 %

0.954

Random, 5 seeds

5.8 %

0.935 ± 0.008

Margin only

5.5 %

0.944

Margin or mistake (edge learning)

5.7 %

0.953

Margin or mistake matched learning from every judged window while learning from about a tenth as many, so the board runs the solver about ten times less often. Two cautions. This is one stream of seven drives with one run of each margin rule, so the gap to random is about two standard deviations. That is a good sign, not a settled result. And a read-out adapted to the new car scored lower on other cars’ validation windows, KIA from 0.778 to 0.728 and my car from 0.969 to 0.935. One saved state per car is there so that this adaptation never reaches another car’s read-out.

Three ideas of mine failed, and each was meant to be the new part:

  • Posterior flip probability. A ridge read-out is a Bayesian linear model, so I computed in closed form the chance that a read-out drawn from its posterior would change the board’s answer. At ranking the board’s real mistakes it scored an AUROC of 0.874, against 0.942 for plain margin. The mistakes here were systematic, such as a throttle that reads high at idle, not windows the read-out was unsure about.

  • A loss predictor after Yoo and Kweon[19], trained on the board by the judge’s late verdicts. AUROC 0.908, still below margin.

  • Learning only from high-loss windows, which are mostly the board’s mistakes. At a 5 % budget it reached 0.927 against 0.943 for margin. A learner that sees mostly its own errors gets a skewed sample, the sampling bias Dasgupta describes for active learning[20].

Status: the rules run in simulation only. The board code, the buffer in PSRAM and the drift alarm are not written, and none of this is in the firmware on main.