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
Run-time profile
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.