cookbook · vertical · embedded-sensor-classifier
Recipe · vertical

Sensor stream in, labeled events out — on a Cortex-M.

A local .kolm file that takes a 1-second window of multi-axis IMU + audio + vibration and returns a labeled event ("bearing_fault", "normal", "belt_slip", "impact"). Sub-50MB artifact deploys to STM32H7 / Coral micro / Jetson Nano. Trained on 12,000 labeled windows from your own equipment fleet.

base modeltinyllama-1.1b-int8 + dsp-frontend
gold windows12,000 (8.4k train / 3.6k eval)
k-score floor0.85
artifact size42 MB (int8)
compile time~38 min
spec sourceclosed-vocab + asymmetric cost

What this recipe does

The classic embedded ML problem is the cost-asymmetric one: a missed bearing fault is a $40,000 truck breakdown, a false alarm is a five-minute walk to the bay. This recipe optimizes for the asymmetric cost from the gate: false negatives weighted 25× false positives in the K-score loss, with a confidence threshold the user controls per-deployment.

The artifact ships at 42MB int8-quantized — fits in 64MB flash on a Cortex-M7 with the DSP front-end pre-baked. The signed receipt walks identically on the device and on the cloud — a field tech can confirm the deployed model is the one QA signed off on.

The spec

{
  "output_kind": "json",
  "schema": {
    "required": ["label", "confidence"],
    "properties": {
      "label": { "enum": ["normal", "bearing_fault", "belt_slip", "impact", "unknown"] },
      "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
      "top_features": { "type": "array", "items": {"type":"string"}, "maxItems": 3 }
    }
  },
  "verifier": {
    "closed_vocab_label": true,
    "false_negative_cost": 25,
    "false_positive_cost": 1,
    "calibration_target_brier_score": 0.08,
    "max_artifact_bytes": 50000000
  }
}

Compile

kolm compile "vibration+IMU+audio classifier for Cortex-M7" \
  --base tinyllama-1.1b-int8 \
  --frontend dsp-mfcc-stft \
  --pairs ./windows/*.parquet \
  --target-arch cortex-m7 \
  --max-bytes 50000000 \
  --asymmetric-loss false-neg=25 \
  --k-floor 0.85 \
  --output embedded-sensor.kolm

ok wrote embedded-sensor.kolm
   k_score=0.89  signature=hmac-sha256
   artifact 42.0 MB int8

K-score gate

K-score 0.89 held-out 3,600 windows · bearing_fault recall 99.2% (only 4 missed) · overall precision 96% · Brier 0.071 (target 0.08) · 42 MB artifact

Run-time profile

STM32H7 (480MHz)
38ms
Coral micro
11ms
Jetson Nano
6ms
Mac mini
4ms

Deploy

// firmware loop — fire on every 1s window:
window_t w = sensor_capture_1s();
kolm_result_t r = kolm_run(&artifact_embedded_sensor, &w);
if (r.label == BEARING_FAULT && r.confidence > 0.7) {
  led_set(LED_RED);
  modbus_write(REG_FAULT, 1);
  flash_log_event(&r);
}

The signed receipt of the artifact is logged with each event. When QA pulls the device for inspection, the fault history is provably from the signed-off model.